From 47694355c4bb5b9721a3b884aa4af56e6f007799 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 19 Oct 2023 11:06:34 +0200 Subject: [PATCH] Add compatibility layer for buildStiffnessMatrix For components not implementing it already --- .../forcefield/HyperReducedHexahedronFEMForceField.h | 1 + .../forcefield/HyperReducedHexahedronFEMForceField.inl | 7 +++++++ .../forcefield/HyperReducedRestShapeSpringsForceField.h | 2 ++ .../forcefield/HyperReducedRestShapeSpringsForceField.inl | 7 +++++++ .../HyperReducedTetrahedralCorotationalFEMForceField.h | 1 + .../HyperReducedTetrahedralCorotationalFEMForceField.inl | 8 ++++++++ .../HyperReducedTetrahedronHyperelasticityFEMForceField.h | 1 + ...yperReducedTetrahedronHyperelasticityFEMForceField.inl | 6 ++++++ 8 files changed, 33 insertions(+) diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.h b/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.h index 5d1bf7f1..0f35490e 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.h +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.h @@ -144,6 +144,7 @@ class HyperReducedHexahedronFEMForceField : public virtual HexahedronFEMForceFie // getPotentialEnergy is implemented for polar method void addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.inl b/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.inl index 8de38b9e..63e80b36 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.inl +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedHexahedronFEMForceField.inl @@ -451,6 +451,13 @@ void HyperReducedHexahedronFEMForceField::addKToMatrix(const core::Me } } +template +void HyperReducedHexahedronFEMForceField::buildStiffnessMatrix( + core::behavior::StiffnessMatrix* matrix) +{ + core::behavior::ForceField::buildStiffnessMatrix(matrix); +} + template void HyperReducedHexahedronFEMForceField::draw(const core::visual::VisualParams* vparams) diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.h b/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.h index 2431dec0..f61f19c3 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.h +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.h @@ -106,6 +106,8 @@ class HyperReducedRestShapeSpringsForceField : public virtual RestShapeSpringsFo /// Brings ForceField contribution to the global system stiffness matrix. virtual void addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) override; + void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override; + virtual void draw(const core::visual::VisualParams* vparams) override; const DataVecCoord* getExtPosition() const; diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.inl b/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.inl index 02b6d5fd..00e54e52 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.inl +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedRestShapeSpringsForceField.inl @@ -488,6 +488,13 @@ void HyperReducedRestShapeSpringsForceField::addKToMatrix(const Mecha } } +template +void HyperReducedRestShapeSpringsForceField::buildStiffnessMatrix( + core::behavior::StiffnessMatrix* matrix) +{ + core::behavior::ForceField::buildStiffnessMatrix(matrix); +} + } // namespace sofa::component::solidmechanics::spring diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.h b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.h index d04a8b06..7a934dbf 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.h +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.h @@ -131,6 +131,7 @@ class HyperReducedTetrahedralCorotationalFEMForceField : public virtual Tetrahed virtual void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; virtual void addKToMatrix(sofa::linearalgebra::BaseMatrix *m, SReal kFactor, unsigned int &offset) override; + void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.inl b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.inl index ec955cf2..d50fb689 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.inl +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedralCorotationalFEMForceField.inl @@ -756,4 +756,12 @@ void HyperReducedTetrahedralCorotationalFEMForceField::addKToMatrix(s } } } + +template +void HyperReducedTetrahedralCorotationalFEMForceField:: +buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +{ + core::behavior::ForceField::buildStiffnessMatrix(matrix); +} + } // namespace sofa::component::solidmechanics::fem::elastic diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.h b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.h index 69bd8288..2aecbcd9 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.h +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.h @@ -118,6 +118,7 @@ public : virtual void addForce(const core::MechanicalParams* mparams /* PARAMS FIRST */, DataVecDeriv& d_f, const DataVecCoord& d_x, const DataVecDeriv& d_v) override; virtual void addDForce(const core::MechanicalParams* mparams /* PARAMS FIRST */, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; virtual void addKToMatrix(sofa::linearalgebra::BaseMatrix *mat, SReal k, unsigned int &offset) override; + void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.inl b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.inl index 411c2ecc..a5eb1d5e 100644 --- a/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.inl +++ b/src/ModelOrderReduction/component/forcefield/HyperReducedTetrahedronHyperelasticityFEMForceField.inl @@ -573,6 +573,12 @@ void HyperReducedTetrahedronHyperelasticityFEMForceField::addKToMatri m_edgeInfo.endEdit(); } +template +void HyperReducedTetrahedronHyperelasticityFEMForceField:: +buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +{ + core::behavior::ForceField::buildStiffnessMatrix(matrix); +} template