Skip to content

Commit

Permalink
Add compatibility layer for buildStiffnessMatrix (#82)
Browse files Browse the repository at this point in the history
For components not implementing it already
  • Loading branch information
alxbilger authored Nov 10, 2023
1 parent f4cf2e4 commit 11fa735
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,13 @@ void HyperReducedHexahedronFEMForceField<DataTypes>::addKToMatrix(const core::Me
}
}

template <class DataTypes>
void HyperReducedHexahedronFEMForceField<DataTypes>::buildStiffnessMatrix(
core::behavior::StiffnessMatrix* matrix)
{
core::behavior::ForceField<DataTypes>::buildStiffnessMatrix(matrix);
}


template<class DataTypes>
void HyperReducedHexahedronFEMForceField<DataTypes>::draw(const core::visual::VisualParams* vparams)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,13 @@ void HyperReducedRestShapeSpringsForceField<DataTypes>::addKToMatrix(const Mecha
}
}

template <class DataTypes>
void HyperReducedRestShapeSpringsForceField<DataTypes>::buildStiffnessMatrix(
core::behavior::StiffnessMatrix* matrix)
{
core::behavior::ForceField<DataTypes>::buildStiffnessMatrix(matrix);
}

} // namespace sofa::component::solidmechanics::spring


Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,4 +756,12 @@ void HyperReducedTetrahedralCorotationalFEMForceField<DataTypes>::addKToMatrix(s
}
}
}

template <class DataTypes>
void HyperReducedTetrahedralCorotationalFEMForceField<DataTypes>::
buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix)
{
core::behavior::ForceField<DataTypes>::buildStiffnessMatrix(matrix);
}

} // namespace sofa::component::solidmechanics::fem::elastic
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ void HyperReducedTetrahedronHyperelasticityFEMForceField<DataTypes>::addKToMatri
m_edgeInfo.endEdit();
}

template <class DataTypes>
void HyperReducedTetrahedronHyperelasticityFEMForceField<DataTypes>::
buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix)
{
core::behavior::ForceField<DataTypes>::buildStiffnessMatrix(matrix);
}


template<class DataTypes>
Expand Down

0 comments on commit 11fa735

Please sign in to comment.