iMSTK
Interactive Medical Simulation Toolkit
imstkPenaltyCH.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 "imstkCollisionHandling.h"
10 #include "imstkMacros.h"
11 
12 namespace imstk
13 {
14 class CollidingObject;
15 class CollisionData;
16 class FeDeformableObject;
17 class RigidObject2;
18 
25 {
26 public:
27  PenaltyCH() = default;
28  virtual ~PenaltyCH() override = default;
29 
30  IMSTK_TYPE_NAME(PenaltyCH)
31 
32 public:
33  void setInputFeObject(std::shared_ptr<FeDeformableObject> feObj);
34  void setInputRbdObject(std::shared_ptr<RigidObject2> rbdObj);
35 
36  std::shared_ptr<FeDeformableObject> getInputFeObject();
37  std::shared_ptr<RigidObject2> getInputRbdObject();
38 
39 public:
43  void setContactStiffness(const double stiffness) { m_stiffness = stiffness; }
44 
48  void setContactVelocityDamping(const double damping) { m_damping = damping; }
49 
50 protected:
51  void handle(
52  const std::vector<CollisionElement>& elementsA,
53  const std::vector<CollisionElement>& elementsB) override;
54 
60  const std::vector<CollisionElement>& elements,
61  std::shared_ptr<RigidObject2> analyticObj);
62 
67  const std::vector<CollisionElement>& elements,
68  std::shared_ptr<FeDeformableObject> deformableObj);
69 
70 protected:
71  double m_stiffness = 5.0e5;
72  double m_damping = 0.5;
73 };
74 } // namespace imstk
double m_stiffness
Stiffness of contact.
Compound Geometry.
void computeContactForcesDiscreteDeformable(const std::vector< CollisionElement > &elements, std::shared_ptr< FeDeformableObject > deformableObj)
Given the collision data, applies nodal forces in the FEM model.
void setContactStiffness(const double stiffness)
Set the contact stiffness.
void handle(const std::vector< CollisionElement > &elementsA, const std::vector< CollisionElement > &elementsB) override
Handle the input collision data. Elements will be flipped (if needed) such that elementsA corresponds...
Implements penalty collision handling between Fem and Rigid models.
void computeContactForcesAnalyticRigid(const std::vector< CollisionElement > &elements, std::shared_ptr< RigidObject2 > analyticObj)
Given the collision data, applies contact as external force to the rigid body (onyl supports PointDir...
Base class for all collision handling classes.
void setContactVelocityDamping(const double damping)
Set the contact velocity damping.
double m_damping
Damping of the contact.