## Description

Class for applyings loads to a triangle mesh belonging to a ChBody, as a cluster of forces operating on the underlying rigid body.

It is useful for doing cosimulation: one can pass this object's vertex & faces to an external software (ex. CFD) that in turn will perform collision detection with its entities, compute forces, send forces back to Chrono via this object. Note, this is based on a cluster of std::vector< std::shared_ptr<ChLoadBodyForce> >, but the class itself could bypass all methods of ChLoadBodyForce and directly implement a more efficient LoadIntLoadResidual_F, however this is left in this way for didactical reasons.

#include <ChLoadBodyMesh.h>

Inheritance diagram for chrono::ChLoadBodyMesh:
Collaboration diagram for chrono::ChLoadBodyMesh:

## Public Member Functions

ChLoadBodyMesh (std::shared_ptr< ChBody > cbody, geometry::ChTriangleMeshConnected &cmesh)

void OutputSimpleMesh (std::vector< ChVector<> > &vert_pos, std::vector< ChVector<> > &vert_vel, std::vector< ChVector< int > > &triangles)
A –> B Get the collision mesh where vertex are given in a vector of xyz points, expressed in absolute coordinates, and triangles are given as indexes to the three vertexes in that vector. More...

void InputSimpleForces (const std::vector< ChVector<> > vert_forces, const std::vector< int > vert_ind)
A <– B Set the forces to the body, where forces are given as a vector of xyz vectors (expressed in absolute coordinates) and indexes to the referenced vertex, as obtained by OutputSimpleMesh. More...

void SetContactMesh (geometry::ChTriangleMeshConnected &mmesh)
Set the contact mesh (also resets the applied nodes)

geometry::ChTriangleMeshConnectedGetContactMesh ()
Get the contact mesh.

std::vector< std::shared_ptr
< ChLoadBodyForce > > &
GetForceList ()
Access the list of applied forces, so you can add new ones by using push_back(), remove them, count them, etc. More...

virtual int LoadGet_ndof_x ()
Gets the number of DOFs affected by this load (position part)

virtual int LoadGet_ndof_w ()
Gets the number of DOFs affected by this load (speed part)

virtual void LoadGetStateBlock_x (ChState &mD)
Gets all the current DOFs packed in a single vector (position part)

virtual void LoadGetStateBlock_w (ChStateDelta &mD)
Gets all the current DOFs packed in a single vector (speed part)

virtual void LoadStateIncrement (const ChState &x, const ChStateDelta &dw, ChState &x_new) override
Increment a packed state (ex. More...

virtual int LoadGet_field_ncoords ()
Number of coordinates in the interpolated field, ex=3 for a tetrahedron finite element or a cable, = 1 for a thermal problem, etc. More...

virtual void ComputeQ (ChState *state_x, ChStateDelta *state_w)
Compute Q, the generalized load. More...

virtual void ComputeJacobian (ChState *state_x, ChStateDelta *state_w, ChMatrix<> &mK, ChMatrix<> &mR, ChMatrix<> &mM)
Compute jacobians. More...

virtual bool IsStiff ()
Report if this is load is stiff. More...

virtual void CreateJacobianMatrices ()
Create the jacobian loads if needed, and also set the ChVariables referenced by the sparse KRM block. More...

virtual void LoadIntLoadResidual_F (ChVectorDynamic<> &R, const double c)
Adds the internal loads Q (pasted at global nodes offsets) into a global vector R, multiplied by a scaling factor c, as R += forces * c.

virtual void InjectKRMmatrices (ChSystemDescriptor &mdescriptor)
Tell to a system descriptor that there are item(s) of type ChKblock in this object (for further passing it to a solver) Basically does nothing, but inherited classes must specialize this. More...

virtual void KRMmatricesLoad (double Kfactor, double Rfactor, double Mfactor)
Adds the current stiffness K and damping R and mass M matrices in encapsulated ChKblock item(s), if any. More...

Public Member Functions inherited from chrono::ChLoadBase
Access the jacobians (if any, i.e. if this is a stiff load)

virtual void Update ()
Update: this is called at least at each time step. More...

## Additional Inherited Members

Protected Attributes inherited from chrono::ChLoadBase

## Member Function Documentation

 virtual void chrono::ChLoadBodyMesh::ComputeJacobian ( ChState * state_x, ChStateDelta * state_w, ChMatrix<> & mK, ChMatrix<> & mR, ChMatrix<> & mM )
virtual

Compute jacobians.

Not needed when forces are constant, btw.

Parameters
 state_x state position to evaluate jacobians state_w state speed to evaluate jacobians mK result dQ/dx mR result dQ/dv mM result dQ/da

 virtual void chrono::ChLoadBodyMesh::ComputeQ ( ChState * state_x, ChStateDelta * state_w )
virtual

Compute Q, the generalized load.

Parameters
 state_x state position to evaluate Q state_w state speed to evaluate Q

 virtual void chrono::ChLoadBodyMesh::CreateJacobianMatrices ( )
virtual

Create the jacobian loads if needed, and also set the ChVariables referenced by the sparse KRM block.

 std::vector< std::shared_ptr >& chrono::ChLoadBodyMesh::GetForceList ( )

Access the list of applied forces, so you can add new ones by using push_back(), remove them, count them, etc.

Note that if you add nodes, these should belong to the referenced mesh.

 virtual void chrono::ChLoadBodyMesh::InjectKRMmatrices ( ChSystemDescriptor & mdescriptor )
virtual

Tell to a system descriptor that there are item(s) of type ChKblock in this object (for further passing it to a solver) Basically does nothing, but inherited classes must specialize this.

 void chrono::ChLoadBodyMesh::InputSimpleForces ( const std::vector< ChVector<> > vert_forces, const std::vector< int > vert_ind )

A <– B Set the forces to the body, where forces are given as a vector of xyz vectors (expressed in absolute coordinates) and indexes to the referenced vertex, as obtained by OutputSimpleMesh.

NOTE! do not insert/remove nodes from the collision mesh between the OutputSimpleMesh-InputSimpleForces pair!

Parameters
 vert_forces array of forces (absolute xyz forces in [N]) vert_ind array of indexes to vertexes to whom you apply forces
 virtual bool chrono::ChLoadBodyMesh::IsStiff ( )
virtual

Report if this is load is stiff.

If so, InjectKRMmatrices will provide the jacobians of the load.

 virtual void chrono::ChLoadBodyMesh::KRMmatricesLoad ( double Kfactor, double Rfactor, double Mfactor )
virtual

Adds the current stiffness K and damping R and mass M matrices in encapsulated ChKblock item(s), if any.

The K, R, M matrices are added with scaling values Kfactor, Rfactor, Mfactor.

virtual

Number of coordinates in the interpolated field, ex=3 for a tetrahedron finite element or a cable, = 1 for a thermal problem, etc.

 virtual void chrono::ChLoadBodyMesh::LoadStateIncrement ( const ChState & x, const ChStateDelta & dw, ChState & x_new )
overridevirtual

Increment a packed state (ex.

as obtained by LoadGetStateBlock_x()) by a given packed state-delta. Compute: x_new = x + dw. Ex. this is called by the BDF numerical differentiation routine that computes jacobian in the default ComputeJacobian() fallback, if not overriding ComputeJacobian() with an analytical form.