Since SOFA is working a lot on solid mechanics, this introduction to physics integration using the FEM is applied on continuum mechanics.
Conservation of linear momentum
The Newton's second law gives:
the force \(f_{\text{surf}}\) corresponds to the integration of traction forces and the force \(f_{\text{vol}}\) corresponds to the body forces. With the Cauchy's law and Gauss's theorem, the conservation of linear momentum in the strong (or generalized) form is written:
where \(\boldsymbol{\sigma}\) is the Cauchy's stress tensor (as a reminder \(\nabla \cdot \boldsymbol{\sigma}=\text{div}(\boldsymbol{\sigma})\)), \(\boldsymbol{b}\) is the density of external forces (force per mass unit), \(\rho\) is the mass density and \(\dot{v}\) is the acceleration of the body. The conservation of linear momentum equation relates the change of momentum (LHS inertia term) and the equilibrium equation (RHS with the internal and external forces), which must be solved at each time step.
In order to find a solution over the domain of simulation, we need to integrate this momentum equation. However, in much cases, no exact solution can directly be found. To ensure the existence of a solution, this strong form must be converted into a discrete problem, known as the weak or variational formulation. This is done by taking the product of a test function with the momentum equation and integrating over the current configuration. The test function is also known as weight function or basis functions, noted \(\psi_j\). Let \(\Omega\) denote the volume of our domain and \(\Gamma\) denote the surface of the domain, the weak form of the momentum equation becomes:
The divergence term can be split as follows:
where appear both a traction boundary condition and an interior traction condition, so that the equation is:
FEM at a glance
Since no exact integration can be performed on a random domain \(\Omega\), the Finite Element Method (FEM) relies on the subdivision of the domain into subdomains: the finite elements. Many different elements can be considered: quads, triangles, tetrahedra, hexahedra etc. The integration of any function f over the domain \(\Omega\) will therefore result in the sum of the integrals over each finite element (E being the total number of finite elements) so that:
The FEM will take advantage of the simple shape of these finite elements to compute these integrals. Within an element, any field like the displacement field u can be evaluated in any point P(x) as a linear combination of interpolation functions \(\phi_i\) (called shape functions) and the values of this field \(u(x_i)=u_i\) at each vertex i of the element (N being the total number of vertices in one element):
The shape functions \(\phi_i\) ensures the continuity of any field over the element. Each element type therefore has specific shape functions. In SOFA, linear interpolation functions are used in the open-source core. Note that higher order (non-linear) elements are available in a SOFA plugin: SofaHighOrder.
Note: the Galerkin-Ritz method, the test function \(\psi\) corresponds to the shape function, noted \(\phi\). In SOFA, we rely here on this method.
The shape functions \(\phi\) can be expressed with regard to local coordinates \((\xi ,\eta ,\zeta )\), corresponding to a reference configuration of the element. Even if the elements get distorted during the simulation, each element can always be mapped back to one common reference configuration with local coordinates \((\xi ,\eta ,\zeta )\), as shown in the figure below. In other words, for any point in space \(\textbf{x}=(x,y,z)\) inside the element \(K\) a corresponding point \(\boldsymbol{\xi}=(\xi ,\eta ,\zeta )\) can be found in the reference space of the element \(\hat{K}\).
Therefore, it always exists a transformation \(T^K\) which can be defined as:
This transformation \(T^K\) is bijective if the determinant of the Jacobian of the transformation is non-null \(det(J)\neq0\). Moreover, the transformation \(T^K\) will allow for the integration of the weak form by change of variables: instead of integrating over \(d\Omega=dxdydz\), the integration will be reported on the reference element \(d\xi d\eta d\zeta\).
Example
Let's consider an example. A density of force \(\boldsymbol{b}\) that depends linearly on the coordinates \(\textbf{x}=(x,y,z)\): \(\boldsymbol{b}=\alpha \textbf{x}\). The integration of this term can be done as follows:
For each finite element, the shape function \(\phi_i\) is defined regarding the local coordinates \(\boldsymbol{\xi}\). The expression of \(\phi_j(\boldsymbol{\xi}) \phi_i(\boldsymbol{\xi})\) results from it. Finally, using a Gauss quadrature (or Gauss point integration), it is possible to find a numerical solution to this integral over the reference element.
Integration of physics
In SOFA, the physics will be mainly implemented in Mass components and ForceField. You can have a look at the integration of:
- the mass in MeshMatrixMass
- the integration of linear elasticity in TetrahedronFEMForceField