iMSTK
Interactive Medical Simulation Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
imstkPbdFemConstraint.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 "imstkPbdConstraint.h"
10 
11 namespace imstk
12 {
19 {
20  PbdFemConstraintConfig(double mu, double lambda, double youngModulus, double poissonRatio) :
21  m_mu(mu), m_lambda(lambda), m_YoungModulus(youngModulus), m_PoissonRatio(poissonRatio)
22  {
23  }
24 
25  void setYoungAndPoisson(double youngModulus, double poissonRatio)
26  {
27  m_YoungModulus = youngModulus;
28  m_PoissonRatio = poissonRatio;
29  const double E = youngModulus;
30  const double nu = poissonRatio;
31  m_mu = E / 2.0 / (1.0 + nu);
32  m_lambda = E * nu / ((1.0 + nu) * (1.0 - 2.0 * nu));
33  }
34 
35  void setMuAndLambda(double mu, double lambda)
36  {
37  m_mu = mu;
38  m_lambda = lambda;
39  m_YoungModulus = mu * (3.0 * lambda + 2.0 * mu) / (lambda + mu);
40  m_PoissonRatio = lambda / 2.0 / (lambda + mu);
41  }
42 
43  PbdFemConstraintConfig() = default;
44 
45  double m_mu = 0.0;
46  double m_lambda = 0.0;
47 
48  double m_YoungModulus = 1000;
49  double m_PoissonRatio = 0.2;
50 };
51 
61 {
62 public:
63  enum class MaterialType
64  {
65  Linear,
66  Corotation,
67  StVK,
68  NeoHookean
69  };
70 
71  PbdFemConstraint(const unsigned int cardinality,
72  MaterialType mType = MaterialType::StVK) : PbdConstraint(cardinality),
73  m_initialElementVolume(0.0),
74  m_material(mType),
75  m_invRestMat(Mat3d::Identity())
76  {
77  }
78 
79  IMSTK_TYPE_NAME(PbdFemConstraint)
80 
81 public:
82  double m_initialElementVolume = 0.0;
83  MaterialType m_material;
84  Mat3d m_invRestMat;
85 
86  PbdFemConstraintConfig m_config;
87 };
88 } // namespace imstk
MaterialType m_material
Material type.
Compound Geometry.
double m_lambda
Lame constant, if constraint type is Fem.
double m_mu
Lame constant, if constraint type is Fem.
Base Constraint class for Position based dynamics constraints.
double m_PoissonRatio
Fem parameter, if constraint type is Fem.
The PbdFemConstraint class for constraint as the elastic energy computed by linear shape functions wi...
double m_YoungModulus
Fem parameter, if constraint type is Fem.
Either mu/lambda used, may be computed from youngs modulus and poissons ratio.