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.
Constructs a mass-spring system <strong>of</strong> numParticles particles and numEdges springs. masses specifies<br />
the mass <strong>of</strong> each particle, and restPositions contains three subsequent entries for the three-dimensional<br />
coordinates <strong>of</strong> each particle. edges contains 2 · numParticles particle indices, with each pair defining the<br />
endpoints <strong>of</strong> a spring. edgeGroups specifies for each spring the index <strong>of</strong> which <strong>of</strong> the numMaterialGroups<br />
material property groups it belongs to, while groupStiffness and groupDamping specify the stiffness and<br />
damping parameters for each <strong>of</strong> these groups.<br />
MassSpringSystem(int numParticles, double * restPositions,<br />
int numQuads, int * quads, double surfaceDensity,<br />
double tensileStiffness, double shearStiffness,<br />
double bendStiffness, double damping, int addGravity=0)<br />
Constructs a mass-spring system based upon an organization <strong>of</strong> the numParticles particles into numQuads<br />
quads in a quad mesh. The 4 · numQuads-entry array quads specifies each quad with four subsequent particle<br />
indices. Particle rest positions are defined as above, and particle masses are defined based upon<br />
surfaceDensity and the quad surface areas. The stiffness and damping settings determine the spring<br />
properties.<br />
MassSpringSystem(int numParticles, double * restPositions,<br />
MassSpringSystemElementType elementType, int numElements,<br />
int * elements, double density, double tensileStiffness,<br />
double damping, int addGravity=0)<br />
Constructs a mass-spring system based upon a tetrahedral mesh or cubic mesh, depending on whether<br />
elementType is set to TET or CUBE. The numParticles particles are organized into numElements tetrahedra<br />
or cubes, which are specified in the array elements (<strong>of</strong> size 4 times or 8 times numElements) by four or<br />
eight subsequent particle indices per element. Particle masses are set according to density and the element<br />
volumes, while spring properties are set according to the stiffness and damping variables.<br />
void SetGravity(bool addGravity, double g=9.81)<br />
Sets whether gravity is enabled, and optionally sets the gravitational constant.<br />
void ComputeForce(double * u, double * f, bool addForce=false)<br />
Computes the forces acting on the mass-spring particles given their displacements u and writes the result<br />
to the pre-allocated array f. If addForce is true, the forces are added to any existing force values in f.<br />
Important: the force f has the same sign as with the other deformable models in <strong>Vega</strong>, i.e., it appears on<br />
the left side in equation Mü + D ˙u + f = fext. If you want f to be interpreted as an external mass-spring<br />
force acting on the particles, you must flip the sign <strong>of</strong> f. The same applies to the damping forces, stiffness<br />
matrices and their Hessian corrections.<br />
void ComputeDampingForce(double * uvel, double * f, bool addForce=false)<br />
Computes the damping forces acting on the mass-spring particles given their current velocities uvel, and<br />
writes the result to the pre-allocated array f. If addForce is true, the forces are added to any existing forces<br />
in f.<br />
void GetStiffnessMatrixTopology(SparseMatrix ** stiffnessMatrixTopology)<br />
Writes to *stiffnessMatrixTopology a newly allocated (using new) zero matrix containing the pattern<br />
<strong>of</strong> non-zero entries <strong>of</strong> the stiffness matrix.<br />
void ComputeStiffnessMatrix(double * u, SparseMatrix * K, bool addMatrix=false)<br />
Computes the stiffness matrix <strong>of</strong> the mass-spring system given the vertex displacements u and writes<br />
the result to the SparseMatrix pointed to by K. If addMatrix is true, the stiffness matrix is added to the<br />
existing entries <strong>of</strong> *K.<br />
class MassSpringSystemFromTetMesh<br />
static int GenerateMassSpringSystem(TetMesh * tetMesh,<br />
19