9 #include "imstkPbdVolumeConstraint.h" 10 #include "imstkPbdConstraintFunctor.h" 25 void initConstraint(
const Vec3d& p0,
const Vec3d& p1,
const Vec3d& p2,
const Vec3d& p3,
34 const double getRestVolume()
const {
return m_restVolume; }
35 const double getInitRestVolume()
const {
return m_initialRestVolume; }
37 void setRestVolume(
const double restVolume) {
m_restVolume = restVolume; }
38 void setInitRestVolume(
const double initRestVolume) { m_initialRestVolume = initRestVolume; }
44 void resetStiffness() {
m_stiffness = m_initialStiffness; }
46 bool isInflated()
const {
return m_inflated; }
47 void setInflated() { m_inflated =
true; }
50 double m_initialRestVolume = 0.0;
51 double m_initialStiffness = 1.0;
52 double m_diffusionRate = 0.00001;
54 bool m_inflated =
false;
65 CHECK(std::dynamic_pointer_cast<TetrahedralMesh>(m_geom) !=
nullptr)
66 <<
"PbdInflatableVolumeConstraint can only be generated with a TetrahedralMesh";
72 std::shared_ptr<VecDataArray<int, 4>> elementsPtr = tetMesh->getCells();
75 ParallelUtils::parallelFor(elements.size(),
78 auto& tet = elements[k];
79 auto c = std::make_shared<PbdInflatableVolumeConstraint>();
81 vertices[tet[0]], vertices[tet[1]], vertices[tet[2]], vertices[tet[3]],
82 { m_bodyIndex, tet[0] }, { m_bodyIndex, tet[1] },
83 { m_bodyIndex, tet[2] }, { m_bodyIndex, tet[3] },
void initConstraint(const Vec3d &p0, const Vec3d &p1, const Vec3d &p2, const Vec3d &p3, const PbdParticleId &pIdx0, const PbdParticleId &pIdx1, const PbdParticleId &pIdx2, const PbdParticleId &pIdx3, const double k=2.0)
Initializes the volume constraint.
Container for pbd constraints.
std::pair< int, int > PbdParticleId
Index pair that refers to a particle in a PbdState. Index 0 is the body id, Index 1 is the particle i...
double m_restVolume
Rest volume.
void operator()(PbdConstraintContainer &constraints) override
Appends a set of constraint to the container given a geometry & body.
Represents a set of tetrahedrons & vertices via an array of Vec3d double vertices & Vec4i integer ind...
std::shared_ptr< VecDataArray< double, 3 > > getVertexPositions(DataType type=DataType::PostTransform) const
Returns the vector of current positions of the mesh vertices.
double m_stiffness
used in PBD, [0, 1]
void resetRestVolume()
Reset constraint rest volume.
void initConstraint(const Vec3d &p0, const Vec3d &p1, const Vec3d &p2, const Vec3d &p3, const PbdParticleId &pIdx0, const PbdParticleId &pIdx1, const PbdParticleId &pIdx2, const PbdParticleId &pIdx3, const double k=2.0)
Initializes the inflatable volume constraint.
virtual void addConstraint(std::shared_ptr< PbdConstraint > constraint)
Adds a constraint to the system, thread safe.
Volume constraint for tetrahedral element.
PbdVolumeConstraintFunctor generates constraints per cell of a TetrahedralMesh.