chrono::ChVariables Class Referenceabstract

Description

Base class for representing objects that introduce 'variables' and their associated mass submatrices.

Used for a sparse, distributed representation of the problem. See ChSystemDescriptor for more information about the overall problem and data representation.

Each ChVariables object must be able to define 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 with it.

Furthermore, the system-level mass matrix is not always formed explicitly. If a matrix-free solver is used, each ChVariables (and derived) object can be asked not to assemble its mass submatrix, but instead to provide operation related to it, Ee.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>

Inheritance diagram for chrono::ChVariables:

Public Member Functions

 ChVariables (unsigned int dof)
 
ChVariablesoperator= (const ChVariables &other)
 Assignment operator: copy from other object.
 
void SetDisabled (bool mdis)
 Deactivates/freezes the variable (these variables won't be modified by the system solver).
 
bool IsDisabled () const
 Check if the variables have been deactivated (these variables won't be modified by the system solver).
 
bool IsActive () const
 Check if these variables are currently active. More...
 
unsigned int GetDOF () const
 The number of scalar variables in the vector qb (dof=degrees of freedom).
 
ChVectorRef State ()
 Get a reference to the differential states encapsulated by these variables. More...
 
ChVectorRef Force ()
 Get a reference to the generalized force corresponding to these variables. More...
 
virtual void ComputeMassInverseTimesVector (ChVectorRef result, ChVectorConstRef vect) const =0
 Compute the product of the inverse mass matrix by a given vector and store in result. More...
 
virtual void AddMassTimesVector (ChVectorRef result, ChVectorConstRef vect) const =0
 Compute the product of the mass matrix by a given vector and increment result. More...
 
virtual void AddMassTimesVectorInto (ChVectorRef result, ChVectorConstRef vect, const double ca) const =0
 Add the product of the mass submatrix by a given vector, scaled by ca, to result. More...
 
virtual void AddMassDiagonalInto (ChVectorRef result, const double ca) const =0
 Add the diagonal of the mass matrix, as a vector scaled by ca, to result. More...
 
virtual void PasteMassInto (ChSparseMatrix &mat, unsigned int start_row, unsigned int start_col, const double ca) const =0
 Write the mass submatrix for these variables into the specified global matrix at the offsets of each variable. More...
 
void SetOffset (unsigned int moff)
 Set offset in the global state vector. More...
 
unsigned int GetOffset () const
 Get offset in the global state vector.
 
virtual void ArchiveOut (ChArchiveOut &archive_out)
 
virtual void ArchiveIn (ChArchiveIn &archive_in)
 

Protected Attributes

unsigned int offset
 offset in global q state vector (needed by some solvers)
 
unsigned int ndof
 number of degrees of freedom (number of contained scalar variables)
 

Member Function Documentation

◆ AddMassDiagonalInto()

virtual void chrono::ChVariables::AddMassDiagonalInto ( ChVectorRef  result,
const double  ca 
) const
pure virtual

Add the diagonal of the mass matrix, as a vector scaled by ca, to result.

Note: 'result' is a system-level vector of appropriate size. This function must index into this vector using the offsets of each variable.

Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesGeneric, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.

◆ AddMassTimesVector()

virtual void chrono::ChVariables::AddMassTimesVector ( ChVectorRef  result,
ChVectorConstRef  vect 
) const
pure virtual

Compute the product of the mass matrix by a given vector and increment result.

This function must perform the operation result += M * vect for a vector of same size as the variables state.

Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesGeneric, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.

◆ AddMassTimesVectorInto()

virtual void chrono::ChVariables::AddMassTimesVectorInto ( ChVectorRef  result,
ChVectorConstRef  vect,
const double  ca 
) const
pure virtual

Add the product of the mass submatrix by a given vector, scaled by ca, to result.

Note: 'result' and 'vect' are system-level vectors of appropriate size. This function must index into these vectors using the offsets of each variable.

Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesGeneric, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.

◆ ComputeMassInverseTimesVector()

virtual void chrono::ChVariables::ComputeMassInverseTimesVector ( ChVectorRef  result,
ChVectorConstRef  vect 
) const
pure virtual

Compute the product of the inverse mass matrix by a given vector and store in result.

This function must calculate result = M^(-1) * vect for a vector of same size as the variables state.

Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesGeneric, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.

◆ Force()

ChVectorRef chrono::ChVariables::Force ( )
inline

Get a reference to the generalized force corresponding to these variables.

These variable forces are part of 'f' in the system:

   | M -Cq'| * |q|- | f| = |0| ,  c>0, l>0, l*r=0;
   | Cq  0 |   |l|  |-b|   |c|

◆ IsActive()

bool chrono::ChVariables::IsActive ( ) const
inline

Check if these variables are currently active.

In general, tells if they must be included into the system solver or not.

◆ PasteMassInto()

virtual void chrono::ChVariables::PasteMassInto ( ChSparseMatrix mat,
unsigned int  start_row,
unsigned int  start_col,
const double  ca 
) const
pure virtual

Write the mass submatrix for these variables into the specified global matrix at the offsets of each variable.

The masses will be scaled by the given factor 'ca'. The (start_row, start_col) pair specifies the top-left corner of the system-level mass matrix in the provided matrix. Assembling the system-level sparse matrix is required only if using a direct sparse solver or for debugging/reporting purposes.

Implemented in chrono::ChVariablesBodySharedMass, chrono::ChVariablesBodyOwnMass, chrono::ChVariablesShaft, chrono::ChVariablesGeneric, chrono::ChVariablesNode, and chrono::ChVariablesGenericDiagonalMass.

◆ SetOffset()

void chrono::ChVariables::SetOffset ( unsigned int  moff)
inline

Set offset in the global state vector.

This offset if set automatically by the ChSystemDescriptor during set up.

◆ State()

ChVectorRef chrono::ChVariables::State ( )
inline

Get a reference to the differential states encapsulated by these variables.

These variable states are part of 'q' in the system:

   | M -Cq'| * |q|- | f| = |0| ,  c>0, l>0, l*r=0;
   | Cq  0 |   |l|  |-b|   |c|

The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/solver/ChVariables.h
  • /builds/uwsbel/chrono/src/chrono/solver/ChVariables.cpp