iMSTK
Interactive Medical Simulation Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
imstkStVKForceModel.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 #include <StVKStiffnessMatrix.h>
12 
13 namespace vega
14 {
15 class StvkInternalForces;
16 class VolumetricMesh;
17 } // namespace vega
18 
19 namespace imstk
20 {
27 {
28 public:
29  StvkForceModel(std::shared_ptr<vega::VolumetricMesh> mesh,
30  const bool withGravity = true, const double gravity = 10.0);
31  ~StvkForceModel() override = default;
32 
36  inline void getInternalForce(const Vectord& u, Vectord& internalForce) override
37  {
38  double* data = const_cast<double*>(u.data());
39  m_stVKInternalForces->ComputeForces(data, internalForce.data());
40  }
41 
45  inline void getTangentStiffnessMatrixTopology(vega::SparseMatrix** tangentStiffnessMatrix) override
46  {
47  m_vegaStVKStiffnessMatrix->GetStiffnessMatrixTopology(tangentStiffnessMatrix);
48  }
49 
53  inline void getTangentStiffnessMatrix(const Vectord& u, SparseMatrixd& tangentStiffnessMatrix) override
54  {
55  double* data = const_cast<double*>(u.data());
56  m_vegaStVKStiffnessMatrix->ComputeStiffnessMatrix(data, m_vegaTangentStiffnessMatrix.get());
57  InternalForceModel::updateValuesFromMatrix(m_vegaTangentStiffnessMatrix, tangentStiffnessMatrix.valuePtr());
58  }
59 
63  inline void setTangentStiffness(std::shared_ptr<vega::SparseMatrix> K) override
64  {
65  m_vegaTangentStiffnessMatrix = K;
66  }
67 
68 protected:
69  std::shared_ptr<vega::StVKInternalForces> m_stVKInternalForces;
70  std::shared_ptr<vega::SparseMatrix> m_vegaTangentStiffnessMatrix;
71  std::shared_ptr<vega::StVKStiffnessMatrix> m_vegaStVKStiffnessMatrix;
72  bool ownStiffnessMatrix;
73 };
74 } // namespace imstk
void getInternalForce(const Vectord &u, Vectord &internalForce) override
Get the internal force.
Compound Geometry.
void getTangentStiffnessMatrix(const Vectord &u, SparseMatrixd &tangentStiffnessMatrix) override
Set the tangent stiffness matrix.
Base class for internal force model within the following context.
void setTangentStiffness(std::shared_ptr< vega::SparseMatrix > K) override
Speficy tangent stiffness matrix.
void getTangentStiffnessMatrixTopology(vega::SparseMatrix **tangentStiffnessMatrix) override
Get the tangent stiffness matrix topology.