chrono::ChVariables Class Referenceabstract

## Description

Base class for representing items which introduce 'variables', that is variables 'v' (and associated masses M) for a sparse representation of the problem.

The problem is described by a variational inequality VI(Z*x-d,K):

| M -Cq'|*|q|- | f|= |0| , l Y, C Ny, normal cone to Y | Cq -E | |l| |-b| |c|

Also Z symmetric by flipping sign of l_i: |M Cq'|*| q|-| f|=|0| |Cq E | |-l| |-b| |c|

• case linear problem: all Y_i = R, Ny=0, ex. all bilaterals
• case LCP: all Y_i = R+: c>=0, l>=0, l*c=0
• case CCP: Y_i are friction cones

Note, all masses and variables are assembled in huge matrices, but there's no need to really build such matrices, in order to exploit sparsity).

Note: in sake of highest generalization, this base class does NOT include a mass submatrix (a sub part of the M matrix) but just declares methods such as Compute_invMb_v(), (which are used by iterative solvers) which MUST be implemented by child classes. This doing, some child classes too may implement all three methods without needing to store entire mass submatrices, if possible, in sake of efficiency.

#include <ChVariables.h>

Inheritance diagram for chrono::ChVariables:

## Public Member Functions

ChVariables (int m_ndof)

ChVariablesoperator= (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...

ChMatrixGet_qb ()
Returns reference to qb, body-relative 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, body-relative part of known vector f in system. More...

ChMatrixGet_fb ()
Returns reference to fb, body-relative 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

 virtual void chrono::ChVariables::Build_M ( ChSparseMatrix & storage, int insrow, int inscol, const double c_a )
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

 virtual void chrono::ChVariables::Compute_fb ( )
virtual

Compute fb, body-relative 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.

 virtual void chrono::ChVariables::DiagonalAdd ( ChMatrix< double > & result, const double c_a ) const
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.

 ChMatrix& chrono::ChVariables::Get_fb ( )

Returns reference to fb, body-relative 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 int chrono::ChVariables::Get_ndof ( ) const
virtual

The number of scalar variables in the vector qb (dof=degrees of freedom) *** This function MUST BE OVERRIDDEN by specialized inherited classes.

 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).

 virtual void chrono::ChVariables::MultiplyAndAdd ( ChMatrix< double > & result, const ChMatrix< double > & vect, const double c_a ) const
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.

 void chrono::ChVariables::SetDisabled ( bool mdis )

Deactivates/freezes the variable (these 'frozen', variables won't be modified by the system solver).