iMSTK
Interactive Medical Simulation Toolkit
imstkLinearFemForceModel.h
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #pragma once
8 
9 #include "imstkInternalForceModel.h"
10 
11 namespace vega
12 {
13 class StVKInternalForces;
14 class VolumetricMesh;
15 } // namespace vega
16 
17 namespace imstk
18 {
25 {
26 public:
27  LinearFemForceModel(std::shared_ptr<vega::VolumetricMesh> mesh,
28  const bool withGravity = true, const double gravity = -9.81);
29  ~LinearFemForceModel() override;
30 
34  inline void getInternalForce(const Vectord& u, Vectord& internalForce) override
35  {
36  double* data = const_cast<double*>(u.data());
37  m_stiffnessMatrix->MultiplyVector(data, internalForce.data());
38  }
39 
40 #ifdef WIN32
41 #pragma warning( push )
42 #pragma warning( disable : 4100 )
43 #endif
44  inline void getTangentStiffnessMatrix(const Vectord& u, SparseMatrixd& tangentStiffnessMatrix) override
49  {
50  InternalForceModel::updateValuesFromMatrix(m_stiffnessMatrix, tangentStiffnessMatrix.valuePtr());
51  }
52 
53 #ifdef WIN32
54 #pragma warning( pop )
55 #endif
56 
60  inline void getTangentStiffnessMatrixTopology(vega::SparseMatrix** tangentStiffnessMatrix) override
61  {
62  *tangentStiffnessMatrix = new vega::SparseMatrix(*m_stiffnessMatrix.get());
63  }
64 
68  inline void setTangentStiffness(std::shared_ptr<vega::SparseMatrix> K) override
69  {
70  m_stiffnessMatrix = K;
71  }
72 
73 protected:
74  std::shared_ptr<vega::SparseMatrix> m_stiffnessMatrix;
75  std::shared_ptr<vega::StVKInternalForces> m_stVKInternalForces;
76 
77  // tmp
78  vega::SparseMatrix* m_stiffnessMatrixRawPtr;
79 };
80 } // namespace imstk
Compound Geometry.
void getTangentStiffnessMatrixTopology(vega::SparseMatrix **tangentStiffnessMatrix) override
Get the tangent stiffness matrix topology.
void setTangentStiffness(std::shared_ptr< vega::SparseMatrix > K) override
Set the tangent stiffness matrix.
void getInternalForce(const Vectord &u, Vectord &internalForce) override
Compute the internal force.
Base class for internal force model within the following context.
Force model for linear finite element formulation.