Debian Codegraph @

tools/physicalModeling/mesh2faust/vega/libraries/include/StVKStiffnessMatrix.h

raw symbols SCIP
1 /*************************************************************************
2 * *
3 * Vega FEM Simulation Library Version 3.1 *
4 * *
5 * "StVK" library , Copyright (C) 2007 CMU, 2009 MIT, 2016 USC *
6 * All rights reserved. *
7 * *
8 * Code author: Jernej Barbic *
9 * http://www.jernejbarbic.com/code *
10 * *
11 * Research: Jernej Barbic, Fun Shing Sin, Daniel Schroeder, *
12 * Doug L. James, Jovan Popovic *
13 * *
14 * Funding: National Science Foundation, Link Foundation, *
15 * Singapore-MIT GAMBIT Game Lab, *
16 * Zumberge Research and Innovation Fund at USC *
17 * *
18 * This library is free software; you can redistribute it and/or *
19 * modify it under the terms of the BSD-style license that is *
20 * included with this library in the file LICENSE.txt *
21 * *
22 * This library is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file *
25 * LICENSE.TXT for more details. *
26 * *
27 *************************************************************************/
28
29 /*
30 Computes the tangent stiffness matrix of a StVK elastic deformable object.
31 The tangent stiffness matrix depends on the deformable configuration.
32 As a special case, the routine can compute the stiffness matrix in the rest configuration.
33 See also StVKInternalForces.h .
34 */
35
36 #ifndef _STVKSTIFFNESSMATRIX_H_
37 #define _STVKSTIFFNESSMATRIX_H_
38
39 #include "sparseMatrix.h"
40 #include "StVKInternalForces.h"
41
42 class StVKStiffnessMatrix
43 {
44 public:
45
46 // initializes the computation of the tangent stiffness matrix
47 StVKStiffnessMatrix(StVKInternalForces * stVKInternalForces);
48 virtual ~StVKStiffnessMatrix();
49
50 // generates a zero matrix with the same pattern of non-zero entries as the tangent stiffness matrix
51 // note: sparsity pattern does not depend on the deformable configuration
52 void GetStiffnessMatrixTopology(SparseMatrix ** stiffnessMatrixTopology);
53
54 // evaluates the tangent stiffness matrix in the given deformation configuration
55 // "vertexDisplacements" is an array of vertex deformations, of length 3*n, where n is the total number of mesh vertices
56 virtual void ComputeStiffnessMatrix(const double * vertexDisplacements, SparseMatrix * sparseMatrix);
57
58 inline void ResetStiffnessMatrix(SparseMatrix * sparseMatrix) {sparseMatrix->ResetToZero();}
59
60 inline VolumetricMesh * GetVolumetricMesh() { return volumetricMesh; }
61 inline StVKElementABCD * GetPrecomputedIntegrals() { return precomputedIntegrals; }
62
63 // === the routines below are meant for advanced usage ===
64
65 // auxiliary functions, these will add the contributions into 'forces'
66 void AddLinearTermsContribution(const double * vertexDisplacements, SparseMatrix * sparseMatrix, int elementLow=-1, int elementHigh=-1);
67 void AddQuadraticTermsContribution(const double * vertexDisplacements,SparseMatrix * sparseMatrix, int elementLow=-1, int elementHigh=-1);
68 void AddCubicTermsContribution(const double * vertexDisplacements, SparseMatrix * sparseMatrix, int elementLow=-1, int elementHigh=-1);
69
70 void GetMatrixAccelerationIndices(int *** row__, int *** column__) { *row__ = row_; *column__ = column_;}
71
72 protected:
73
74 int numElementVertices;
75
76 // acceleration indices
77 int ** row_;
78 int ** column_;
79
80 VolumetricMesh * volumetricMesh;
81 StVKInternalForces * stVKInternalForces;
82 StVKElementABCD * precomputedIntegrals;
83
84 double * lambdaLame;
85 double * muLame;
86
87 // adds a 3x3 block matrix corresponding to a derivative of force on vertex c wrt to vertex a
88 // c is 0..7
89 // a is 0..7
90 inline void AddMatrix3x3Block(int c, int a, int element, Mat3d & matrix, SparseMatrix * sparseMatrix);
91 };
92
93 inline void StVKStiffnessMatrix::AddMatrix3x3Block(int c, int a, int element, Mat3d & matrix, SparseMatrix * sparseMatrix)
94 {
95 int * row = row_[element];
96 int * column = column_[element];
97
98 for(int k=0; k<3; k++)
99 for(int l=0; l<3; l++)
100 sparseMatrix->AddEntry(3*row[c]+k, 3*column[numElementVertices*c+a]+l, matrix[k][l]);
101 }
102
103 #endif
104