Skip to content

Commit b46f2c0

Browse files
committed
change inheritance in ElementHyperelasticityFEMForceField
1 parent cdc5a9d commit b46f2c0

2 files changed

Lines changed: 145 additions & 145 deletions

File tree

src/Elasticity/component/ElementHyperelasticityFEMForceField.h

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
#include <Elasticity/component/HyperelasticMaterial.h>
44
#include <Elasticity/config.h>
5-
#include <sofa/fem/FiniteElement.h>
65
#include <sofa/component/solidmechanics/fem/elastic/impl/ElementStiffnessMatrix.h>
7-
#include <sofa/core/behavior/ForceField.h>
8-
#include <sofa/core/behavior/TopologyAccessor.h>
6+
#include <sofa/component/solidmechanics/fem/elastic/FEMForceField.h>
97

108
#if !defined(ELASTICITY_COMPONENT_ELEMENT_HYPERLASTICITY_FEM_FORCE_FIELD_CPP)
119
#include <sofa/fem/FiniteElement[all].h>
@@ -16,14 +14,12 @@ namespace elasticity
1614

1715
template <class TDataTypes, class TElementType>
1816
class ElementHyperelasticityFEMForceField :
19-
public sofa::core::behavior::TopologyAccessor,
20-
public sofa::core::behavior::ForceField<TDataTypes>
17+
public sofa::component::solidmechanics::fem::elastic::FEMForceField<TDataTypes, TElementType>
2118
{
2219
public:
23-
SOFA_CLASS2(
20+
SOFA_CLASS(
2421
SOFA_TEMPLATE2(ElementHyperelasticityFEMForceField, TDataTypes, TElementType),
25-
sofa::core::behavior::TopologyAccessor,
26-
sofa::core::behavior::ForceField<TDataTypes>);
22+
SOFA_TEMPLATE2(sofa::component::solidmechanics::fem::elastic::FEMForceField, TDataTypes, TElementType));
2723

2824
using DataTypes = TDataTypes;
2925

@@ -56,25 +52,22 @@ class ElementHyperelasticityFEMForceField :
5652
public:
5753
void init() override;
5854

59-
void addForce(const sofa::core::MechanicalParams* mparams, DataVecDeriv& f,
60-
const DataVecCoord& x, const DataVecDeriv& v) override;
61-
62-
void addDForce(const sofa::core::MechanicalParams* mparams, DataVecDeriv& df,
63-
const DataVecDeriv& dx) override;
64-
6555
void buildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) override;
6656

67-
using sofa::core::behavior::ForceField<DataTypes>::getPotentialEnergy;
57+
using Inherit1::getPotentialEnergy;
6858
SReal getPotentialEnergy(const sofa::core::MechanicalParams*, const DataVecCoord& x) const override;
6959

70-
using sofa::core::behavior::ForceField<DataTypes>::addKToMatrix;
60+
using Inherit1::addKToMatrix;
7161
// almost deprecated, but here for compatibility with unit tests
7262
void addKToMatrix(sofa::linearalgebra::BaseMatrix* matrix, SReal kFact, unsigned& offset) override;
7363

7464
sofa::SingleLink<MyType, HyperelasticMaterial<TDataTypes>,
7565
sofa::BaseLink::FLAG_STOREPATH | sofa::BaseLink::FLAG_STRONGLINK> l_material;
7666

7767
protected:
68+
using trait = sofa::component::solidmechanics::fem::elastic::trait<DataTypes, TElementType>;
69+
using ElementForce = typename trait::ElementForce;
70+
7871
void validateMaterial();
7972

8073
bool m_isHessianValid;
@@ -119,6 +112,24 @@ class ElementHyperelasticityFEMForceField :
119112
sofa::type::vector<std::array<PrecomputedData, NumberOfQuadraturePoints>> m_precomputedData;
120113

121114
void precomputeData();
115+
116+
void beforeElementForce(const sofa::core::MechanicalParams* mparams,
117+
sofa::type::vector<ElementForce>& f,
118+
const sofa::VecCoord_t<DataTypes>& x) override;
119+
120+
void computeElementsForces(
121+
const sofa::simulation::Range<std::size_t>& range,
122+
const sofa::core::MechanicalParams* mparams,
123+
sofa::type::vector<ElementForce>& f,
124+
const sofa::VecCoord_t<TDataTypes>& x) override;
125+
126+
void beforeElementForceDeriv(const sofa::core::MechanicalParams* mparams) override;
127+
128+
void computeElementsForcesDeriv(
129+
const sofa::simulation::Range<std::size_t>& range,
130+
const sofa::core::MechanicalParams* mparams,
131+
sofa::type::vector<ElementForce>& df,
132+
const sofa::VecDeriv_t<TDataTypes>& dx) override;
122133
};
123134

124135
#if !defined(ELASTICITY_COMPONENT_ELEMENT_HYPERLASTICITY_FEM_FORCE_FIELD_CPP)

0 commit comments

Comments
 (0)