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

#include <vh.h>

Inheritance diagram for MyVectorHandler:
Collaboration diagram for MyVectorHandler:

Public Member Functions

 MyVectorHandler (const MyVectorHandler &)
 
 MyVectorHandler (integer iSize=0, doublereal *pdTmpVec=NULL)
 
virtual ~MyVectorHandler (void)
 
virtual void Resize (integer iSize)
 
void Detach (void)
 
void Attach (integer iSize, doublereal *pd, integer iMSize=0)
 
virtual doublerealpdGetVec (void) const
 
virtual integer iGetSize (void) const
 
virtual void Reset (void)
 
virtual void PutCoef (integer iRow, const doublereal &dCoef)
 
virtual void IncCoef (integer iRow, const doublereal &dCoef)
 
virtual void DecCoef (integer iRow, const doublereal &dCoef)
 
virtual const doublerealdGetCoef (integer iRow) const
 
virtual const doublerealoperator() (integer iRow) const
 
virtual doublerealoperator() (integer iRow)
 
virtual void Add (integer iRow, const Vec3 &v)
 
virtual void Sub (integer iRow, const Vec3 &v)
 
virtual void Put (integer iRow, const Vec3 &v)
 
virtual VectorHandlerScalarAddMul (const VectorHandler &VH, const VectorHandler &VH1, const doublereal &d)
 
virtual VectorHandlerScalarAddMul (const VectorHandler &VH, const doublereal &d)
 
virtual VectorHandlerScalarMul (const VectorHandler &VH, const doublereal &d)
 
virtual VectorHandleroperator+= (const VectorHandler &VH)
 
virtual MyVectorHandleroperator+= (const MyVectorHandler &VH)
 
virtual VectorHandleroperator-= (const VectorHandler &VH)
 
virtual VectorHandleroperator*= (const doublereal &d)
 
virtual MyVectorHandleroperator-= (const MyVectorHandler &VH)
 
virtual VectorHandleroperator= (const VectorHandler &VH)
 
virtual MyVectorHandleroperator= (const MyVectorHandler &VH)
 
doublereal Dot (void) const
 
- Public Member Functions inherited from VectorHandler
virtual ~VectorHandler (void)
 
virtual void ResizeReset (integer)
 
virtual VectorHandleroperator+= (const SubVectorHandler &SubVH)
 
virtual doublereal Norm (void) const
 
virtual doublereal InnerProd (const VectorHandler &VH) const
 

Protected Attributes

bool bOwnsMemory
 
integer iMaxSize
 
integer iCurSize
 
doublerealpdVecm1
 

Friends

class FullMatrixHandler
 

Detailed Description

Definition at line 149 of file vh.h.

Constructor & Destructor Documentation

MyVectorHandler::MyVectorHandler ( const MyVectorHandler VH)

Definition at line 321 of file vh.cc.

References ASSERT, bOwnsMemory, iCurSize, pdVecm1, and Resize().

322 : bOwnsMemory(false),
324 {
325  if (iCurSize == 0) {
326  ASSERT(VH.pdVecm1 == 0);
327 
328  } else {
329  bOwnsMemory = true;
330  Resize(iCurSize);
331 #ifdef DEBUG
332  IsValid();
333 #endif /* DEBUG */
334 
335  for (integer i = 1; i <= iCurSize; i++) {
336  pdVecm1[i] = VH.pdVecm1[i];
337  }
338  }
339 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
virtual void Resize(integer iSize)
Definition: vh.cc:347
integer iMaxSize
Definition: vh.h:155
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51
bool bOwnsMemory
Definition: vh.h:152

Here is the call graph for this function:

MyVectorHandler::MyVectorHandler ( integer  iSize = 0,
doublereal pdTmpVec = NULL 
)

Definition at line 300 of file vh.cc.

References ASSERT, bOwnsMemory, pdVecm1, Reset(), and Resize().

301 : bOwnsMemory(false),
302 iMaxSize(iSize), iCurSize(iSize), pdVecm1(0)
303 {
304  if (iSize == 0) {
305  ASSERT(pdVecm1 == NULL);
306 
307  } else {
308  if (pdTmpVec == NULL) {
309  bOwnsMemory = true;
310  Resize(iSize);
311  Reset();
312  } else {
313  pdVecm1 = pdTmpVec - 1;
314  }
315 #ifdef DEBUG
316  IsValid();
317 #endif /* DEBUG */
318  }
319 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
virtual void Resize(integer iSize)
Definition: vh.cc:347
integer iMaxSize
Definition: vh.h:155
#define ASSERT(expression)
Definition: colamd.c:977
virtual void Reset(void)
Definition: vh.cc:459
bool bOwnsMemory
Definition: vh.h:152

Here is the call graph for this function:

MyVectorHandler::~MyVectorHandler ( void  )
virtual

Definition at line 341 of file vh.cc.

References Detach().

342 {
343  Detach();
344 }
void Detach(void)
Definition: vh.cc:403

Here is the call graph for this function:

Member Function Documentation

void MyVectorHandler::Add ( integer  iRow,
const Vec3 v 
)
virtual

Reimplemented from VectorHandler.

Definition at line 673 of file vh.cc.

References ASSERT, Vec3::dGet(), iCurSize, and pdVecm1.

674 {
675 #ifdef DEBUG
676  IsValid();
677  ASSERT((iRow > 0) && (iRow <= iCurSize-2));
678 #endif /* DEBUG */
679 
680  pdVecm1[iRow] += v.dGet(1);
681  pdVecm1[++iRow] += v.dGet(2);
682  pdVecm1[++iRow] += v.dGet(3);
683 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
const doublereal & dGet(unsigned short int iRow) const
Definition: matvec3.h:285
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

void MyVectorHandler::Attach ( integer  iSize,
doublereal pd,
integer  iMSize = 0 
)

Definition at line 418 of file vh.cc.

References bOwnsMemory, Detach(), iCurSize, iMaxSize, MBDYN_EXCEPT_ARGS, and pdVecm1.

Referenced by ThirdOrderIntegrator::Jacobian(), ThirdOrderIntegrator::Residual(), and SchurMatrixHandlerUm::SchurMatrixHandlerUm().

419 {
420  if (bOwnsMemory || pdVecm1 != NULL) {
421  Detach();
422  bOwnsMemory = false;
423  }
424 
425  iMaxSize = iCurSize = iSize;
426  if (iMSize > 0) {
427  if (iMSize >= iSize) {
428  iMaxSize = iMSize;
429 
430  } else if (iMSize < iSize) {
432  }
433  }
434 
435  pdVecm1 = pd - 1;
436 }
integer iCurSize
Definition: vh.h:156
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
void Detach(void)
Definition: vh.cc:403
doublereal * pdVecm1
Definition: vh.h:158
integer iMaxSize
Definition: vh.h:155
bool bOwnsMemory
Definition: vh.h:152

Here is the call graph for this function:

void MyVectorHandler::DecCoef ( integer  iRow,
const doublereal dCoef 
)
inlinevirtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 291 of file vh.h.

References ASSERT, iCurSize, and pdVecm1.

Referenced by SchurMatrixHandler::DecCoef(), SchurMatrixHandlerUm::DecCoef(), and MySubVectorHandler::DecCoef().

292 {
293  /* Vedi nota di PutCoef() */
294 
295 #ifdef DEBUG
296  IsValid();
297  ASSERT((iRow > 0) && (iRow <= iCurSize));
298 #endif /* DEBUG */
299 
300  pdVecm1[iRow] -= dCoef;
301 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
#define ASSERT(expression)
Definition: colamd.c:977
void MyVectorHandler::Detach ( void  )

Definition at line 403 of file vh.cc.

References bOwnsMemory, iCurSize, iMaxSize, pdVecm1, and SAFEDELETEARR.

Referenced by Attach(), Gmres::~Gmres(), and ~MyVectorHandler().

404 {
405  if (bOwnsMemory) {
406  if (pdVecm1 != NULL) {
407  doublereal *pd = pdVecm1 + 1;
408  SAFEDELETEARR(pd);
409  }
410  bOwnsMemory = false;
411  }
412 
413  iMaxSize = iCurSize = 0;
414  pdVecm1 = NULL;
415 }
integer iCurSize
Definition: vh.h:156
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdVecm1
Definition: vh.h:158
integer iMaxSize
Definition: vh.h:155
double doublereal
Definition: colamd.c:52
bool bOwnsMemory
Definition: vh.h:152
const doublereal & MyVectorHandler::dGetCoef ( integer  iRow) const
inlinevirtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 304 of file vh.h.

References ASSERT, iCurSize, and pdVecm1.

Referenced by MySubVectorHandler::dGetCoef().

305 {
306  /* Vedi nota di PutCoef() */
307 
308 #ifdef DEBUG
309  IsValid();
310  ASSERT((iRow > 0) && (iRow <= iCurSize));
311 #endif /* DEBUG */
312 
313  return pdVecm1[iRow];
314 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
#define ASSERT(expression)
Definition: colamd.c:977
doublereal MyVectorHandler::Dot ( void  ) const
virtual

Reimplemented from VectorHandler.

Definition at line 713 of file vh.cc.

References iCurSize, and pdVecm1.

Referenced by DataManager::InitialJointAssembly().

714 {
715 #ifdef DEBUG
716  IsValid();
717 #endif /* DEBUG */
718 
719  doublereal d2 = 0.;
720 
721  for (integer i = iCurSize; i > 0; i--) {
722  d2 += pdVecm1[i]*pdVecm1[i];
723  }
724 
725  return d2;
726 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
integer MyVectorHandler::iGetSize ( void  ) const
inlinevirtual
void MyVectorHandler::IncCoef ( integer  iRow,
const doublereal dCoef 
)
inlinevirtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 278 of file vh.h.

References ASSERT, iCurSize, and pdVecm1.

Referenced by AerodynamicModal::AssVec(), SchurMatrixHandler::IncCoef(), SchurMatrixHandlerUm::IncCoef(), and MySubVectorHandler::IncCoef().

279 {
280  /* Vedi nota di PutCoef() */
281 
282 #ifdef DEBUG
283  IsValid();
284  ASSERT((iRow > 0) && (iRow <= iCurSize));
285 #endif /* DEBUG */
286 
287  pdVecm1[iRow] += dCoef;
288 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
#define ASSERT(expression)
Definition: colamd.c:977
const doublereal & MyVectorHandler::operator() ( integer  iRow) const
inlinevirtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 317 of file vh.h.

References ASSERT, iCurSize, and pdVecm1.

Referenced by MySubVectorHandler::operator()().

318 {
319  /* Vedi nota di PutCoef() */
320 
321 #ifdef DEBUG
322  IsValid();
323  ASSERT((iRow > 0) && (iRow <= iCurSize));
324 #endif /* DEBUG */
325 
326  return pdVecm1[iRow];
327 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
#define ASSERT(expression)
Definition: colamd.c:977
doublereal & MyVectorHandler::operator() ( integer  iRow)
inlinevirtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 330 of file vh.h.

References ASSERT, iCurSize, and pdVecm1.

331 {
332  /* Vedi nota di PutCoef() */
333 
334 #ifdef DEBUG
335  IsValid();
336  ASSERT((iRow > 0) && (iRow <= iCurSize));
337 #endif /* DEBUG */
338 
339  return pdVecm1[iRow];
340 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
#define ASSERT(expression)
Definition: colamd.c:977
VectorHandler & MyVectorHandler::operator*= ( const doublereal d)
virtual

Reimplemented from VectorHandler.

Definition at line 600 of file vh.cc.

References iGetSize(), and pdVecm1.

601 {
602 #ifdef DEBUG
603  IsValid();
604 #endif /* DEBUG */
605 
606  for (integer i = iGetSize(); i > 0; i--) {
607  pdVecm1[i] *= d;
608  }
609 
610  return *this;
611 }
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

VectorHandler & MyVectorHandler::operator+= ( const VectorHandler VH)
virtual

Reimplemented from VectorHandler.

Definition at line 542 of file vh.cc.

References ASSERT, iCurSize, VectorHandler::iGetSize(), iGetSize(), and pdVecm1.

543 {
544 #ifdef DEBUG
545  IsValid();
546  VH.IsValid();
547 #endif /* DEBUG */
548 
549  ASSERT(VH.iGetSize() > 0);
550  ASSERT(iCurSize == VH.iGetSize());
551 
552  for (integer i = iGetSize(); i > 0; i--) {
553  pdVecm1[i] += VH(i);
554  }
555 
556  return *this;
557 }
integer iCurSize
Definition: vh.h:156
virtual integer iGetSize(void) const =0
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

MyVectorHandler & MyVectorHandler::operator+= ( const MyVectorHandler VH)
virtual

Definition at line 561 of file vh.cc.

References ASSERT, iCurSize, iGetSize(), pdGetVec(), and pdVecm1.

562 {
563 #ifdef DEBUG
564  IsValid();
565  VH.IsValid();
566 #endif /* DEBUG */
567 
568  ASSERT(VH.iGetSize() > 0);
569  ASSERT(iCurSize == VH.iGetSize());
570 
571  doublereal* pdFrom = VH.pdGetVec() - 1;
572  for (integer i = iGetSize(); i > 0; i--) {
573  pdVecm1[i] += pdFrom[i];
574  }
575 
576  return *this;
577 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
double doublereal
Definition: colamd.c:52
virtual doublereal * pdGetVec(void) const
Definition: vh.h:245
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

VectorHandler & MyVectorHandler::operator-= ( const VectorHandler VH)
virtual

Reimplemented from VectorHandler.

Definition at line 581 of file vh.cc.

References ASSERT, iCurSize, VectorHandler::iGetSize(), iGetSize(), and pdVecm1.

582 {
583 #ifdef DEBUG
584  IsValid();
585  VH.IsValid();
586 #endif /* DEBUG */
587 
588  ASSERT(VH.iGetSize() > 0);
589  ASSERT(iCurSize == VH.iGetSize());
590 
591  for (integer i = iGetSize(); i > 0; i--) {
592  pdVecm1[i] -= VH(i);
593  }
594 
595  return *this;
596 }
integer iCurSize
Definition: vh.h:156
virtual integer iGetSize(void) const =0
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

MyVectorHandler & MyVectorHandler::operator-= ( const MyVectorHandler VH)
virtual

Definition at line 615 of file vh.cc.

References ASSERT, iCurSize, iGetSize(), pdGetVec(), and pdVecm1.

616 {
617 #ifdef DEBUG
618  IsValid();
619  VH.IsValid();
620 #endif /* DEBUG */
621 
622  ASSERT(VH.iGetSize() > 0);
623  ASSERT(iCurSize == VH.iGetSize());
624 
625  doublereal* pdFrom = VH.pdGetVec() - 1;
626  for (integer i = iGetSize(); i > 0; i--) {
627  pdVecm1[i] -= pdFrom[i];
628  }
629 
630  return *this;
631 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
double doublereal
Definition: colamd.c:52
virtual doublereal * pdGetVec(void) const
Definition: vh.h:245
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

VectorHandler & MyVectorHandler::operator= ( const VectorHandler VH)
virtual

Reimplemented from VectorHandler.

Definition at line 635 of file vh.cc.

References ASSERT, iCurSize, VectorHandler::iGetSize(), iGetSize(), and pdVecm1.

636 {
637 #ifdef DEBUG
638  IsValid();
639  VH.IsValid();
640 #endif /* DEBUG */
641 
642  ASSERT(VH.iGetSize() > 0);
643  ASSERT(iCurSize == VH.iGetSize());
644 
645  for (integer i = iGetSize(); i > 0; i--) {
646  pdVecm1[i] = VH(i);
647  }
648 
649  return *this;
650 }
integer iCurSize
Definition: vh.h:156
virtual integer iGetSize(void) const =0
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

MyVectorHandler & MyVectorHandler::operator= ( const MyVectorHandler VH)
virtual

Definition at line 654 of file vh.cc.

References ASSERT, iCurSize, iGetSize(), pdGetVec(), and pdVecm1.

655 {
656 #ifdef DEBUG
657  IsValid();
658  VH.IsValid();
659 #endif /* DEBUG */
660 
661  ASSERT(VH.iGetSize() > 0);
662  ASSERT(iCurSize == VH.iGetSize());
663 
664  doublereal* pdFrom = VH.pdGetVec() - 1;
665  for (integer i = iGetSize(); i > 0; i--) {
666  pdVecm1[i] = pdFrom[i];
667  }
668 
669  return *this;
670 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
double doublereal
Definition: colamd.c:52
virtual doublereal * pdGetVec(void) const
Definition: vh.h:245
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

doublereal * MyVectorHandler::pdGetVec ( void  ) const
inlinevirtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 245 of file vh.h.

References pdVecm1.

Referenced by MySubVectorHandler::AddTo(), NaiveSparseSolutionManager::NaiveSparseSolutionManager(), operator+=(), operator-=(), operator=(), and MySubVectorHandler::pdGetVec().

246 {
247 #ifdef DEBUG
248  IsValid();
249 #endif /* DEBUG */
250 
251  return &pdVecm1[1];
252 }
doublereal * pdVecm1
Definition: vh.h:158
void MyVectorHandler::Put ( integer  iRow,
const Vec3 v 
)
virtual

Reimplemented from VectorHandler.

Definition at line 699 of file vh.cc.

References ASSERT, Vec3::dGet(), iCurSize, and pdVecm1.

Referenced by AerodynamicModal::AssRes(), Membrane4EAS::AssRes(), Shell4EAS::AssRes(), Shell4EASANS::AssRes(), and AerodynamicModal::InitialAssRes().

700 {
701 #ifdef DEBUG
702  IsValid();
703  ASSERT((iRow > 0) && (iRow <= iCurSize-2));
704 #endif /* DEBUG */
705 
706  pdVecm1[iRow] = v.dGet(1);
707  pdVecm1[++iRow] = v.dGet(2);
708  pdVecm1[++iRow] = v.dGet(3);
709 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
const doublereal & dGet(unsigned short int iRow) const
Definition: matvec3.h:285
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

void MyVectorHandler::PutCoef ( integer  iRow,
const doublereal dCoef 
)
inlinevirtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 261 of file vh.h.

References ASSERT, iCurSize, and pdVecm1.

Referenced by AerodynamicModal::AssRes(), Solver::Flip(), AerodynamicModal::InitialAssRes(), SchurMatrixHandler::PutCoef(), SchurMatrixHandlerUm::PutCoef(), MySubVectorHandler::PutCoef(), and Gmres::Solve().

262 {
263  /* Nota: il flag di ritorno e' pleonastico. Lo si e' messo per
264  * analogia con le matrici sparse, in cui l'aggiunta
265  * di un coefficiente puo' risultare in un errore.
266  * Qui, per motivi di efficienza, il controllo sulla validita'
267  * dell'indice e del vettore viene svolto solo in debug */
268 
269 #ifdef DEBUG
270  IsValid();
271  ASSERT((iRow > 0) && (iRow <= iCurSize));
272 #endif /* DEBUG */
273 
274  pdVecm1[iRow] = dCoef;
275 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
#define ASSERT(expression)
Definition: colamd.c:977
void MyVectorHandler::Reset ( void  )
virtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 459 of file vh.cc.

References ASSERT, iCurSize, iGetSize(), and pdVecm1.

Referenced by AerodynamicModal::AssVec(), ImplicitStepIntegrator::EvalProd(), InverseDynamicsStepSolver::EvalProd(), DataManager::InitialJointAssembly(), SchurMatrixHandler::MatEFCReset(), SchurMatrixHandlerUm::MatEFCReset(), MyVectorHandler(), InverseSolver::Prepare(), Solver::Prepare(), ReadMembrane4EAS(), ReadShell4EAS(), ReadShell4EASANS(), MySubVectorHandler::Reset(), ScalarMul(), BiCGStab::Solve(), Gmres::Solve(), and LineSearchSolver::Solve().

460 {
461 #ifdef DEBUG
462  IsValid();
463 #endif /* DEBUG */
464 
465  ASSERT(iCurSize > 0);
466 
467 #if defined HAVE_MEMSET
468  memset(pdVecm1 + 1, 0, iGetSize()*sizeof(doublereal));
469 #else /* !HAVE_MEMSET */
470  for (integer i = iGetSize(); i > 0; i--) {
471  pdVecm1[i] = 0.;
472  }
473 #endif /* HAVE_MEMSET */
474 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

void MyVectorHandler::Resize ( integer  iSize)
virtual

Implements VectorHandler.

Reimplemented in MySubVectorHandler.

Definition at line 347 of file vh.cc.

References bOwnsMemory, iCurSize, iMaxSize, MBDYN_EXCEPT_ARGS, pdVecm1, SAFEDELETEARR, and SAFENEWARR.

Referenced by ThirdOrderIntegrator::Advance(), ImplicitStepIntegrator::EvalProd(), InverseDynamicsStepSolver::EvalProd(), MyVectorHandler(), BiCGStab::Solve(), Gmres::Solve(), and LineSearchSolver::Solve().

348 {
349  if (iSize < 0) {
350  silent_cerr("Negative size!" << std::endl);
352  }
353 
354  if (pdVecm1 == NULL || bOwnsMemory) {
355  if (pdVecm1 != NULL) {
356  if (iSize > iMaxSize) {
357  doublereal* pd = NULL;
358 
359  SAFENEWARR(pd, doublereal, iSize);
360  pd--;
361 #ifdef HAVE_MEMMOVE
362  memmove(pd + 1, pdVecm1 + 1, iCurSize*sizeof(doublereal));
363 #else /* ! HAVE_MEMMOVE */
364  for (integer i = iCurSize; i > 0; i--) {
365  pd[i] = pdVecm1[i];
366  }
367 #endif /* ! HAVE_MEMMOVE */
368  doublereal *pdv = pdVecm1 + 1;
369  SAFEDELETEARR(pdv);
370  pdVecm1 = pd;
371  iMaxSize = iCurSize = iSize;
372 
373  } else {
374  iCurSize = iSize;
375  }
376 
377  } else {
378  SAFENEWARR(pdVecm1, doublereal, iSize);
379  pdVecm1--;
380  iMaxSize = iCurSize = iSize;
381  bOwnsMemory = true;
382  }
383 
384  } else {
385  if (pdVecm1 != NULL) {
386  if (iSize > iMaxSize) {
387  silent_cerr("Can't resize to " << iSize
388  << ": larger than "
389  "max size " << iMaxSize << std::endl);
391 
392  } else {
393  iCurSize = iSize;
394  }
395  } else {
396  silent_cerr("internal error!" << std::endl);
398  }
399  }
400 }
integer iCurSize
Definition: vh.h:156
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
doublereal * pdVecm1
Definition: vh.h:158
integer iMaxSize
Definition: vh.h:155
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
bool bOwnsMemory
Definition: vh.h:152
VectorHandler & MyVectorHandler::ScalarAddMul ( const VectorHandler VH,
const VectorHandler VH1,
const doublereal d 
)
virtual

Reimplemented from VectorHandler.

Definition at line 499 of file vh.cc.

References ASSERT, VectorHandler::iGetSize(), iGetSize(), and pdVecm1.

Referenced by BiCGStab::Solve(), and Gmres::Solve().

501 {
502 #ifdef DEBUG
503  IsValid();
504  VH.IsValid();
505  ASSERT(iGetSize() == VH.iGetSize());
506  VH1.IsValid();
507  ASSERT(iGetSize() == VH1.iGetSize());
508 #endif /* DEBUG */
509 
510  for (integer i = iGetSize(); i > 0; i--) {
511  pdVecm1[i] = VH(i) + d*VH1(i);
512  }
513 
514  return *this;
515 }
virtual integer iGetSize(void) const =0
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

VectorHandler & MyVectorHandler::ScalarAddMul ( const VectorHandler VH,
const doublereal d 
)
virtual

Reimplemented from VectorHandler.

Definition at line 478 of file vh.cc.

References ASSERT, iCurSize, VectorHandler::iGetSize(), iGetSize(), and pdVecm1.

479 {
480 #ifdef DEBUG
481  IsValid();
482  VH.IsValid();
483  ASSERT(iCurSize > 0);
484  ASSERT(VH.iGetSize() > 0);
485  ASSERT(iCurSize == VH.iGetSize());
486 #endif /* DEBUG */
487 
488  if (d != 0.) {
489  for (integer i = iGetSize(); i > 0; i--) {
490  pdVecm1[i] += d*VH(i);
491  }
492  }
493 
494  return *this;
495 }
integer iCurSize
Definition: vh.h:156
virtual integer iGetSize(void) const =0
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

VectorHandler & MyVectorHandler::ScalarMul ( const VectorHandler VH,
const doublereal d 
)
virtual

Reimplemented from VectorHandler.

Definition at line 519 of file vh.cc.

References ASSERT, iCurSize, VectorHandler::iGetSize(), iGetSize(), pdVecm1, and Reset().

Referenced by ImplicitStepIntegrator::EvalProd(), InverseDynamicsStepSolver::EvalProd(), and Gmres::Solve().

520 {
521 #ifdef DEBUG
522  IsValid();
523  VH.IsValid();
524  ASSERT(iCurSize > 0);
525  ASSERT(VH.iGetSize() > 0);
526  ASSERT(iCurSize == VH.iGetSize());
527 #endif /* DEBUG */
528 
529  if (d == 0.) {
530  Reset();
531  } else {
532  for (integer i = iGetSize(); i > 0; i--) {
533  pdVecm1[i] = d*VH(i);
534  }
535  }
536 
537  return *this;
538 }
integer iCurSize
Definition: vh.h:156
virtual integer iGetSize(void) const =0
doublereal * pdVecm1
Definition: vh.h:158
virtual integer iGetSize(void) const
Definition: vh.h:255
#define ASSERT(expression)
Definition: colamd.c:977
virtual void Reset(void)
Definition: vh.cc:459
long int integer
Definition: colamd.c:51

Here is the call graph for this function:

void MyVectorHandler::Sub ( integer  iRow,
const Vec3 v 
)
virtual

Reimplemented from VectorHandler.

Definition at line 686 of file vh.cc.

References ASSERT, Vec3::dGet(), iCurSize, and pdVecm1.

687 {
688 #ifdef DEBUG
689  IsValid();
690  ASSERT((iRow > 0) && (iRow <= iCurSize-2));
691 #endif /* DEBUG */
692 
693  pdVecm1[iRow] -= v.dGet(1);
694  pdVecm1[++iRow] -= v.dGet(2);
695  pdVecm1[++iRow] -= v.dGet(3);
696 }
integer iCurSize
Definition: vh.h:156
doublereal * pdVecm1
Definition: vh.h:158
const doublereal & dGet(unsigned short int iRow) const
Definition: matvec3.h:285
#define ASSERT(expression)
Definition: colamd.c:977

Here is the call graph for this function:

Friends And Related Function Documentation

friend class FullMatrixHandler
friend

Definition at line 150 of file vh.h.

Member Data Documentation

integer MyVectorHandler::iMaxSize
protected

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