We add a deformable model to the tongue. It means the tongue will move and deform depending on the forces applied on it. To do this, we use the component TetrahedralCorotanionalFEMForceField. It uses finite element methods to compute the internal forces.
To add a deformable model in the scene, we need to create a MechanicalObject. All the forces and displacement are computed using an Euler implicit solver (EulerImplicitSolver) for time integration and a Conjugate Gradient linear solver (CGLinearSolver) to solve a linear system. We also need a container to store the tetrahedra (TetrahedronSetTopologyContainer). With all these components, we can add a force field to compute internal forces (TetrahedralCorotanionalFEMForceField).
The visual model of the tongue is updated because of a mapping (BarycentricMapping) between the deformable model and the visual.
In the current scene, the visual model of the tongue is not displayed, but the deformable model is displayed with the blue tetrahedra.
The tetrahedric mesh of the tongue has been generated using the CGAL plugin in SOFA. Read this annex to learn more about mesh generation using CGAL plugin.
The mass chosen for the deformable model of the tongue is a DiagonalMass. It has been chosen to show the diversity of masses available in SOFA. This kind of mass computes the mass matrix with non uniform diagonal values, depending on the tetrahedra size.