Skip to content

Latest commit

 

History

History
92 lines (58 loc) · 5.11 KB

10_UniformMass.md

File metadata and controls

92 lines (58 loc) · 5.11 KB

UniformMass

This component belongs to the category of Masses. The UniformMass is a very simplistic mass component since it does not compute the volume integration of a density term. The mass is equally spread over the number of points, thus resulting in the following diagonal mass matrix:

Each diagonal term equals the nodal mass where is the total mass of the objet and is the number of nodes of the object. Spreading the mass over the nodes without considering their connectivity results in this diagonal mass matrix .

As all mass components, the UniformMass will contribute to the main matrix in the system . Depending on the type of LinearSolver used:

  • for iterative solvers, the result of the multiplication between the mass matrix and an approximated solution is computed by the function:
template <class DataTypes, class MassType>
void UniformMass<DataTypes, MassType>::addMDx ( const core::MechanicalParams*, DataVecDeriv& vres, const DataVecDeriv& vdx, SReal factor)
{
    helper::WriteAccessor<DataVecDeriv> res = vres;
    helper::ReadAccessor<DataVecDeriv> dx = vdx;

    WriteAccessor<Data<vector<int> > > indices = d_indices;

    MassType m = d_vertexMass.getValue();
    if ( factor != 1.0 )
        m *= ( typename DataTypes::Real ) factor;

    for ( unsigned int i=0; i<indices.size(); i++ )
        res[indices[i]] += dx[indices[i]] * m;
}
  • for direct solvers, the mass matrix is built by the function:
/// Add Mass contribution to global Matrix assembling
template <class DataTypes, class MassType>
void UniformMass<DataTypes, MassType>::addMToMatrix (const MechanicalParams *mparams, const MultiMatrixAccessor* matrix)
{
    const MassType& m = d_vertexMass.getValue();

    const size_t N = DataTypeInfo<Deriv>::size();

    AddMToMatrixFunctor<Deriv,MassType> calc;
    MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(mstate);

    Real mFactor = (Real)mparams->mFactorIncludingRayleighDamping(this->rayleighMass.getValue());

    ReadAccessor<Data<vector<int> > > indices = d_indices;
    for ( unsigned int i=0; i<indices.size(); i++ )
        calc ( r.matrix, m, r.offset + N*indices[i], mFactor);
}

Data

Since the UniformMass equally spread the total mass over all the nodes of the object, the component can be initialized using:

  • either the vertexMass data: corresponding to the nodal mass , set equally at each node
  • or the totalMass data: corresponding to the total mass of the object

Usage

The UniformMass only requires a MechanicalObject to store the degrees of freedom associated to the nodes. An integration scheme and a solver are also necessary to solve the linear system at each time step.

Since the UniformMass only set a constant mass at each node without considering their connectivity, no topology is needed for the UniformMass. For this reason, the UniformMass is suitable for rigid frames.

However, the UniformMass should be carefully used if accuracy is a criterion, especially when using surface or volumetric physical models. As written above, the UniformMass does not take into account the geometry and the topology of the object since no space integration is computed.

Example

This component is used as follows in XML format:

<UniformMass totalMass="10" />

or using SofaPython3:

node.addObject('UniformMass', totalMass='10')

An example scene involving a UniformMass is available in examples/Component/Mass/UniformMass.scn