Description
Base class for representing objects that introduce 'variables' (also referred as 'v') and their associated mass submatrices for a sparse representation of the problem.
See ChSystemDescriptor for more information about the overall problem and data representation.
Each ChVariables object must be able to compute a mass submatrix, that will be assembled directly inside the global matrix Z, (in particular inside the block H or M).
Because of this there is no need for ChVariables and derived classes to actually store their mass submatrix in memory: they just need to be able to compute it!
Moreover, in some cases, the mass submatrix is not even needed. In fact, some Chrono solvers are matrixfree.
This means that each ChVariables (and derived) object can be asked not to assemble its mass submatrix, but instead to provide operation related to it.
E.g. M*x, M\x, +=M*x, and so on... Each derived class must implement these methods!
Because of this, the ChVariables class does not include any mass submatrix by default
#include <ChVariables.h>
Public Member Functions  
ChVariables (int m_ndof)  
ChVariables &  operator= (const ChVariables &other) 
Assignment operator: copy from other object.  
void  SetDisabled (bool mdis) 
Deactivates/freezes the variable (these 'frozen', variables won't be modified by the system solver). More...  
bool  IsDisabled () const 
Tells if the variables have been deactivated (these 'frozen', variables won't be modified by the system solver). More...  
bool  IsActive () const 
Tells if these variables are currently active, in general, that is tells if they must be included into the system solver or not. More...  
virtual int  Get_ndof () const 
The number of scalar variables in the vector qb (dof=degrees of freedom) *** This function MUST BE OVERRIDDEN by specialized inherited classes. More...  
ChMatrix &  Get_qb () 
Returns reference to qb, bodyrelative part of degrees of freedom q in system:  M Cq'*q  f= 0 , c>0, l>0, l*r=0;  Cq 0  l b c.  
virtual void  Compute_fb () 
Compute fb, bodyrelative part of known vector f in system. More...  
ChMatrix &  Get_fb () 
Returns reference to fb, bodyrelative part of known vector f in system. More...  
virtual void  Compute_invMb_v (ChMatrix< double > &result, const ChMatrix< double > &vect) const =0 
Computes the product of the inverse mass matrix by a vector, and store in result: result = [invMb]*vect *** This function MUST BE OVERRIDDEN by specialized inherited classes.  
virtual void  Compute_inc_invMb_v (ChMatrix< double > &result, const ChMatrix< double > &vect) const =0 
Computes the product of the inverse mass matrix by a vector, and increment result: result += [invMb]*vect *** This function MUST BE OVERRIDDEN by specialized inherited classes.  
virtual void  Compute_inc_Mb_v (ChMatrix< double > &result, const ChMatrix< double > &vect) const =0 
Computes the product of the mass matrix by a vector, and increment result: result = [Mb]*vect *** This function MUST BE OVERRIDDEN by specialized inherited classes.  
virtual void  MultiplyAndAdd (ChMatrix< double > &result, const ChMatrix< double > &vect, const double c_a) const =0 
Computes the product of the corresponding block in the system matrix (ie. More...  
virtual void  DiagonalAdd (ChMatrix< double > &result, const double c_a) const =0 
Add the diagonal of the mass matrix scaled by c_a, to 'result', as a vector. More...  
virtual void  Build_M (ChSparseMatrix &storage, int insrow, int inscol, const double c_a)=0 
Build the mass submatrix (for these variables) multiplied by c_a, storing it in 'storage' sparse matrix, at given column/row offset. More...  
void  SetOffset (int moff) 
Set offset in global q vector (set automatically by ChSystemDescriptor)  
int  GetOffset () const 
Get offset in global q vector.  
virtual void  ArchiveOUT (ChArchiveOut &marchive) 
virtual void  ArchiveIN (ChArchiveIn &marchive) 
Protected Attributes  
int  offset 
offset in global q state vector (needed by some solvers)  
Member Function Documentation

pure virtual 
Build the mass submatrix (for these variables) multiplied by c_a, storing it in 'storage' sparse matrix, at given column/row offset.
Most iterative solvers don't need to know this matrix explicitly. *** This function MUST BE OVERRIDDEN by specialized inherited classes
Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesGeneric, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.

virtual 
Compute fb, bodyrelative part of known vector f in system.
*** This function MAY BE OVERRIDDEN by specialized inherited classes (example, for impulsive multibody simulation, this may be fb=dt*Forces+[M]*previous_v ). Another option is to set values into fb vectors, accessing them by Get_fb() from an external procedure, for each body, before starting the solver.

pure virtual 
Add the diagonal of the mass matrix scaled by c_a, to 'result', as a vector.
NOTE: the 'result' vector must already have the size of system unknowns, ie the size of the total variables&constraints in the system; the procedure will use the ChVariable offset (that must be already updated) as index.
Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesGeneric, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.
ChMatrix& chrono::ChVariables::Get_fb  (  ) 
Returns reference to fb, bodyrelative part of known vector f in system.
 M Cq'*q  f= 0 , c>0, l>0, l*r=0;  Cq 0  l b c This function can be used to set values of fb vector before starting the solver.

virtual 
The number of scalar variables in the vector qb (dof=degrees of freedom) *** This function MUST BE OVERRIDDEN by specialized inherited classes.
Reimplemented in chrono::ChVariablesGeneric, chrono::ChVariablesBody, chrono::ChVariablesGenericDiagonalMass, chrono::ChVariablesNode, and chrono::ChVariablesShaft.
bool chrono::ChVariables::IsActive  (  )  const 
Tells if these variables are currently active, in general, that is tells if they must be included into the system solver or not.
bool chrono::ChVariables::IsDisabled  (  )  const 
Tells if the variables have been deactivated (these 'frozen', variables won't be modified by the system solver).

pure virtual 
Computes the product of the corresponding block in the system matrix (ie.
the mass matrix) by 'vect', scale by c_a, and add to 'result'. NOTE: the 'vect' and 'result' vectors must already have the size of the total variables&constraints in the system; the procedure will use the ChVariable offset (that must be already updated) to know the indexes in result and vect.
Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesGeneric, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.
void chrono::ChVariables::SetDisabled  (  bool  mdis  ) 
Deactivates/freezes the variable (these 'frozen', variables won't be modified by the system solver).