MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
ExpandableRowVector Class Reference

#include <JacSubMatrix.h>

Collaboration diagram for ExpandableRowVector:

Classes

struct  ExpandableRowElement
 

Public Member Functions

 ExpandableRowVector (void)
 
 ExpandableRowVector (const integer n)
 
virtual ~ExpandableRowVector (void)
 
void ReDim (const integer n)
 
integer GetDim (void) const
 
void Zero (void)
 
void Reset (void)
 
void Link (const integer i, const ExpandableRowVector *const xp, const integer rhs_block=1)
 
void SetIdx (integer i, integer iidx)
 
void Set (doublereal xx, integer i, integer iidx)
 
void Set (Vec3 xx, integer i, integer iidx)
 
doublerealoperator() (integer i)
 
const doublerealoperator() (integer i) const
 
void Set (doublereal xx, integer i)
 
void Set (Vec3 xx, integer i)
 
void Add (doublereal xx, integer i)
 
void Sub (doublereal xx, integer i)
 
void Add (SubVectorHandler &WorkVec, const doublereal c=1.) const
 
void Sub (SubVectorHandler &WorkVec, const doublereal c=1.) const
 
void Add (FullSubMatrixHandler &WM, const integer eq, const doublereal c=1.) const
 
void Add (FullSubMatrixHandler &WM, const std::vector< integer > &eq, const std::vector< doublereal > &cc, const doublereal c=1.) const
 
void Sub (FullSubMatrixHandler &WM, const integer eq, const doublereal c=1.) const
 
void Sub (FullSubMatrixHandler &WM, const std::vector< integer > &eq, const std::vector< doublereal > &cc, const doublereal c=1.) const
 
std::ostream & Write (std::ostream &out, const char *sFill="") const
 

Private Attributes

std::vector< ExpandableRowElementv
 

Detailed Description

Definition at line 42 of file JacSubMatrix.h.

Constructor & Destructor Documentation

ExpandableRowVector::ExpandableRowVector ( void  )

Definition at line 45 of file JacSubMatrix.cc.

45 {};
ExpandableRowVector::ExpandableRowVector ( const integer  n)

Definition at line 46 of file JacSubMatrix.cc.

References ReDim().

46  {
47  ReDim(n);
48 }
void ReDim(const integer n)
Definition: JacSubMatrix.cc:50

Here is the call graph for this function:

ExpandableRowVector::~ExpandableRowVector ( void  )
virtual

Definition at line 49 of file JacSubMatrix.cc.

49 {};

Member Function Documentation

void ExpandableRowVector::Add ( doublereal  xx,
integer  i 
)

Definition at line 119 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

Referenced by Brake::AssJac(), ModLugreFriction::AssJac(), DiscreteCoulombFriction::AssJac(), and AxialRotationJoint::AssJac().

119  {
120  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Add() underflow");
121  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Add() overflow");
122  v[i - 1].x += xx;
123 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::Add ( SubVectorHandler WorkVec,
const doublereal  c = 1. 
) const

Definition at line 129 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, VectorHandler::IncCoef(), and v.

129  {
130  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
131  if (v[i].x == 0.) {
132  continue;
133  }
134 
135  if (v[i].idx != 0) {
136  WorkVec.IncCoef(v[i].idx, c*v[i].x);
137  } else {
138  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
139  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
140  v[i].xm[rhs_block]->Add(WorkVec, c*v[i].x);
141  }
142  }
143  }
144 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
virtual void IncCoef(integer iRow, const doublereal &dCoef)=0
static std::stack< cleanup * > c
Definition: cleanup.cc:59

Here is the call graph for this function:

void ExpandableRowVector::Add ( FullSubMatrixHandler WM,
const integer  eq,
const doublereal  c = 1. 
) const

Definition at line 161 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, FullSubMatrixHandler::IncCoef(), and v.

163  {
164 // std::cerr << "\t\t\tExpandableRowVector::Add" << std::endl;
165  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
166 // std::cerr << "\t\t\t\ti " << i << std::endl;
167 
168  if (v[i].x == 0.) {
169  continue;
170  }
171 
172  if (v[i].idx != 0) {
173 // std::cerr << "Adding("<< eq << ", " << v[i].idx << ") = " <<
174 // c*v[i].x << std::endl;
175 // std::cerr << "\t\t\t\tdentro if" << std::endl;
176  WM.IncCoef(eq, v[i].idx, c*v[i].x);
177  } else {
178 // std::cerr << "\t\t\t\tdentro else" << std::endl;
179  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
180 // std::cerr << "\t\t\t\t\trhs_block " << rhs_block << std::endl;
181 // std::cerr << "\t\t\t\t\t\trhs_block_ptr " << v[i].xm[rhs_block] << std::endl;
182  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
183  v[i].xm[rhs_block]->Add(WM, eq, c*v[i].x);
184  }
185  }
186  }
187 // std::cerr << "\t\t\t ---- ExpandableRowVector::Add" << std::endl;
188 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:683
static const char * eq[]
Definition: drvdisp.cc:196
static std::stack< cleanup * > c
Definition: cleanup.cc:59

Here is the call graph for this function:

void ExpandableRowVector::Add ( FullSubMatrixHandler WM,
const std::vector< integer > &  eq,
const std::vector< doublereal > &  cc,
const doublereal  c = 1. 
) const

Definition at line 189 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, FullSubMatrixHandler::IncCoef(), and v.

193 {
194  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
195  if (v[i].x == 0.) {
196  continue;
197  }
198 
199  integer idx = v[i].idx;
200  if (idx != 0) {
201  doublereal d = c*v[i].x;
202  for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
203  WM.IncCoef(eq[j], idx, cc[j]*d);
204  }
205  } else {
206  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
207  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
208  v[i].xm[rhs_block]->Add(WM, eq, cc, c*v[i].x);
209  }
210  }
211  }
212 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void IncCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:683
static const char * eq[]
Definition: drvdisp.cc:196
static std::stack< cleanup * > c
Definition: cleanup.cc:59
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

integer ExpandableRowVector::GetDim ( void  ) const

Definition at line 57 of file JacSubMatrix.cc.

References v.

57  {
58  return v.size();
59 };
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::Link ( const integer  i,
const ExpandableRowVector *const  xp,
const integer  rhs_block = 1 
)

Definition at line 68 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

Referenced by Brake::AssJac(), ModLugreFriction::AssJac(), DiscreteCoulombFriction::AssJac(), AxialRotationJoint::AssJac(), SimpleShapeCoefficient::dSh_c(), SimplePlaneHingeJointSh_c::dSh_c(), and ScrewJointSh_c::dSh_c().

68  {
69  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Link() underflow");
70  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Link() overflow");
71  ASSERTMSGBREAK(v[i - 1].idx == 0, "ExpandableRowVector::Link() fatal error");
72  if (std::vector<ExpandableRowVector *>::size_type(rhs_block) > v[ i - 1].xm.size()) {
73  v[ i - 1].xm.resize(rhs_block);
74  }
75  v[i - 1].xm[rhs_block - 1] = xp;
76 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
doublereal & ExpandableRowVector::operator() ( integer  i)

Definition at line 106 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

107 {
108  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::() underflow");
109  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::() overflow");
110  return v[i - 1].x;
111 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
const doublereal & ExpandableRowVector::operator() ( integer  i) const

Definition at line 113 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

114 {
115  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::() underflow");
116  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::() overflow");
117  return v[i - 1].x;
118 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::ReDim ( const integer  n)

Definition at line 50 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

Referenced by Brake::AssJac(), PlaneHingeJoint::AssJac(), ModLugreFriction::AssJac(), DiscreteCoulombFriction::AssJac(), AxialRotationJoint::AssJac(), SimpleShapeCoefficient::dSh_c(), SimplePlaneHingeJointSh_c::dSh_c(), ScrewJointSh_c::dSh_c(), and ExpandableRowVector().

50  {
51  //we have to accept = 0, some elements do ReDim(0,0) (PointForceElement))
52  ASSERTMSGBREAK(n>=0, "ExpandableRowVector:ReDim(), n shold be >= 0");
53 // std::cerr << "ExpandableRowVector::ReDim(" << n << ")" << std::endl;
54 // std::cerr << "----------------------" << std::endl;
55  v.resize(n, er_Zero);
56 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
static ExpandableRowVector::ExpandableRowElement er_Zero
Definition: JacSubMatrix.cc:43
void ExpandableRowVector::Reset ( void  )

Definition at line 65 of file JacSubMatrix.cc.

References er_Zero, and v.

65  {
66  std::fill(v.begin(), v.end(), er_Zero);
67 }
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
static ExpandableRowVector::ExpandableRowElement er_Zero
Definition: JacSubMatrix.cc:43
void ExpandableRowVector::Set ( doublereal  xx,
integer  i,
integer  iidx 
)

Definition at line 95 of file JacSubMatrix.cc.

References SetIdx().

Referenced by Brake::AssJac(), PlaneHingeJoint::AssJac(), ModLugreFriction::AssJac(), DiscreteCoulombFriction::AssJac(), AxialRotationJoint::AssJac(), SimpleShapeCoefficient::dSh_c(), SimplePlaneHingeJointSh_c::dSh_c(), ScrewJointSh_c::dSh_c(), and Set().

95  {
96  Set(xx, i);
97  SetIdx(i, iidx);
98 }
void Set(doublereal xx, integer i, integer iidx)
Definition: JacSubMatrix.cc:95
void SetIdx(integer i, integer iidx)
Definition: JacSubMatrix.cc:89

Here is the call graph for this function:

void ExpandableRowVector::Set ( Vec3  xx,
integer  i,
integer  iidx 
)

Definition at line 99 of file JacSubMatrix.cc.

References Set(), and SetIdx().

99  {
100  Set(xx, i);
101  SetIdx(i, iidx);
102  SetIdx(i+1, iidx+1);
103  SetIdx(i+2, iidx+2);
104 }
void Set(doublereal xx, integer i, integer iidx)
Definition: JacSubMatrix.cc:95
void SetIdx(integer i, integer iidx)
Definition: JacSubMatrix.cc:89

Here is the call graph for this function:

void ExpandableRowVector::Set ( doublereal  xx,
integer  i 
)

Definition at line 77 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

77  {
78  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Set() underflow");
79  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Set() overflow");
80  v[i - 1].x = xx;
81 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::Set ( Vec3  xx,
integer  i 
)

Definition at line 82 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

82  {
83  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Set() underflow");
84  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i+3) <= v.size(), "ExpandableRowVector::Set() overflow");
85  v[i - 1].x = xx(1);
86  v[i - 0].x = xx(2);
87  v[i + 1].x = xx(3);
88 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::SetIdx ( integer  i,
integer  iidx 
)

Definition at line 89 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

Referenced by Set().

89  {
90  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::SetIdx() underflow");
91  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::SetIdx() overflow");
92 // std::cerr << "ExpandableRowVector::SetIdx(" << i <<", " << iidx << ")" << std::endl;
93  v[i - 1].idx = iidx;
94 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::Sub ( doublereal  xx,
integer  i 
)

Definition at line 124 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, and v.

Referenced by Brake::AssJac(), DiscreteCoulombFriction::AssJac(), and AxialRotationJoint::AssJac().

124  {
125  ASSERTMSGBREAK(i > 0, "ExpandableRowVector::Sub() underflow");
126  ASSERTMSGBREAK(std::vector<ExpandableRowVector>::size_type(i) <= v.size(), "ExpandableRowVector::Sub() overflow");
127  v[i - 1].x -= xx;
128 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::Sub ( SubVectorHandler WorkVec,
const doublereal  c = 1. 
) const

Definition at line 145 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, VectorHandler::DecCoef(), and v.

145  {
146  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
147  if (v[i].x == 0.) {
148  continue;
149  }
150 
151  if (v[i].idx != 0) {
152  WorkVec.DecCoef(v[i].idx, c*v[i].x);
153  } else {
154  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
155  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Sub() null pointer to ExpandableRowVector");
156  v[i].xm[rhs_block]->Sub(WorkVec, c*v[i].x);
157  }
158  }
159  }
160 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
virtual void DecCoef(integer iRow, const doublereal &dCoef)=0
static std::stack< cleanup * > c
Definition: cleanup.cc:59

Here is the call graph for this function:

void ExpandableRowVector::Sub ( FullSubMatrixHandler WM,
const integer  eq,
const doublereal  c = 1. 
) const

Definition at line 213 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, FullSubMatrixHandler::DecCoef(), and v.

215  {
216  for (std::vector<ExpandableRowElement>::size_type i = 0 ; i < v.size(); i++) {
217  if (v[i].x == 0.) {
218  continue;
219  }
220 
221  if (v[i].idx != 0) {
222  WM.DecCoef(eq, v[i].idx, c*v[i].x);
223  } else {
224  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
225  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Sub() null pointer to ExpandableRowVector");
226  v[i].xm[rhs_block]->Sub(WM, eq, c*v[i].x);
227  }
228  }
229  }
230 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void DecCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:694
static const char * eq[]
Definition: drvdisp.cc:196
static std::stack< cleanup * > c
Definition: cleanup.cc:59

Here is the call graph for this function:

void ExpandableRowVector::Sub ( FullSubMatrixHandler WM,
const std::vector< integer > &  eq,
const std::vector< doublereal > &  cc,
const doublereal  c = 1. 
) const

Definition at line 231 of file JacSubMatrix.cc.

References ASSERTMSGBREAK, FullSubMatrixHandler::DecCoef(), and v.

235 {
236  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
237  if (v[i].x == 0.) {
238  continue;
239  }
240 
241  integer idx = v[i].idx;
242  if (idx != 0) {
243  doublereal d = c*v[i].x;
244  for (std::vector<integer>::size_type j = 0; j < eq.size(); j++) {
245  WM.DecCoef(eq[j], idx, cc[j]*d);
246  }
247  } else {
248  for (std::vector<const ExpandableRowVector *>::size_type rhs_block = 0; rhs_block < v[i].xm.size(); rhs_block++) {
249  ASSERTMSGBREAK(v[i].xm[rhs_block] != 0, "ExpandableRowVector::Add() null pointer to ExpandableRowVector");
250  v[i].xm[rhs_block]->Sub(WM, eq, cc, c*v[i].x);
251  }
252  }
253  }
254 }
#define ASSERTMSGBREAK(expr, msg)
Definition: myassert.h:222
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void DecCoef(integer iRow, integer iCol, const doublereal &dCoef)
Definition: submat.h:694
static const char * eq[]
Definition: drvdisp.cc:196
static std::stack< cleanup * > c
Definition: cleanup.cc:59
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

std::ostream & ExpandableRowVector::Write ( std::ostream &  out,
const char *  sFill = "" 
) const

Definition at line 256 of file JacSubMatrix.cc.

References v.

Referenced by operator<<().

256  {
257  out << "LocalDof: ";
258  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
259  if (v[i].idx != 0) {
260  out << sFill << std::setw(12) << v[i].idx;
261  } else {
262  out << sFill << std::setw(12) << "linked";
263  }
264  }
265  out << std::endl;
266  out << " Value: ";
267  for (std::vector<ExpandableRowElement>::size_type i = 0; i < v.size(); i++) {
268  out << sFill << std::setw(12) << v[i].x;
269  }
270  out << std::endl;
271  return out;
272 }
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51
void ExpandableRowVector::Zero ( void  )

Definition at line 60 of file JacSubMatrix.cc.

References v.

60  {
61  for (std::vector<ExpandableRowElement>::iterator i = v.begin(); i != v.end(); ++i) {
62  i->x = 0.;
63  }
64 }
std::vector< ExpandableRowElement > v
Definition: JacSubMatrix.h:51

Member Data Documentation

std::vector<ExpandableRowElement> ExpandableRowVector::v
private

Definition at line 51 of file JacSubMatrix.h.

Referenced by Add(), GetDim(), Link(), operator()(), ReDim(), Reset(), Set(), SetIdx(), Sub(), Write(), and Zero().


The documentation for this class was generated from the following files: