Vega FEM Library (v1.1) User's Manual - University of Southern ...
Vega FEM Library (v1.1) User's Manual - University of Southern ...
Vega FEM Library (v1.1) User's Manual - University of Southern ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
internal forces and stiffness matrices for arbitrary deformed object configurations. Let us use the corotational<br />
linear <strong>FEM</strong> model. Because that model only supports tet meshes, we need to first check if the mesh is indeed<br />
a TetMesh.<br />
#include "corotationalLinear<strong>FEM</strong>.h"<br />
...<br />
TetMesh * tetMesh;<br />
if (volumetricMesh->getElementType() == VolumetricMesh::TET)<br />
tetMesh = (TetMesh*) volumetricMesh; // such down-casting is safe in <strong>Vega</strong><br />
else<br />
{<br />
printf("Error: not a tet mesh.\n");<br />
exit(1);<br />
}<br />
CorotationalLinear<strong>FEM</strong> * deformableModel = new CorotationalLinear<strong>FEM</strong>(tetMesh);<br />
Note that the down-casting can be avoided if the mesh is known to be a tet mesh: simply initialize<br />
TetMesh directly using the constructor in the TetMesh class. We now have a valid deformable model, and<br />
it is possible to query internal forces and tangent stiffness matrices in any mesh configuration. Typically,<br />
we want to timestep the model in time, however, so let’s proceed with building an integrator for the model.<br />
We need to first create a ForceModel object, to connect our deformable model to an integrator. We also<br />
need the mass matrix, and specify which model vertices (if any) are to be fixed. Then, we can initialize the<br />
integrator. Let us use the implicit backward Euler integrator. Note that the sparse linear system solver to<br />
use for implicit integration is selected by editing the file ”integratorSolverSelection.h” inside the Integrator<br />
library. The default selection is to use <strong>Vega</strong>’s conjugate gradient solver.<br />
#include "corotationalLinear<strong>FEM</strong>ForceModel.h"<br />
#include "generateMassMatrix.h"<br />
#include "implicitBackwardEulerSparse.h"<br />
...<br />
// create the class to connect the deformable model to the integrator<br />
ForceModel * forceModel = new CorotationalLinear<strong>FEM</strong>ForceModel(deformableModel);<br />
int r = 3 * tetMesh->getNumVertices(); // total number <strong>of</strong> DOFs<br />
double timestep = 0.0333; // the timestep<br />
SparseMatrix * massMatrix;<br />
// create consistent (non-lumped) mass matrix<br />
GenerateMassMatrix::computeMassMatrix(tetMesh, &massMatrix, true);<br />
// This option only affects PARDISO and SPOOLES solvers, where it is best<br />
// to keep it at 0, which implies a symmetric, non-PD solve.<br />
// With CG, this option is ignored.<br />
int positiveDefiniteSolver = 0;<br />
// constraining vertices 4, 10, 14 (constrained DOFs are specified 0-indexed):<br />
int numConstrainedDOFs = 9;<br />
int constrainedDOFs[9] = { 12, 13, 14, 30, 31, 32, 42, 43, 44 };<br />
// (tangential) Rayleigh damping<br />
double dampingMassCoef = 0.0; // "underwater"-like damping (here turned <strong>of</strong>f)<br />
5