diff --git a/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.h b/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.h index 62d29313..b98169f5 100644 --- a/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.h +++ b/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.h @@ -101,10 +101,6 @@ public : const DataVecCoord& x , const DataVecDeriv& v) override; - void addDForce(const MechanicalParams* mparams, - DataVecDeriv& df , - const DataVecDeriv& dx ) override; - double getPotentialEnergy(const MechanicalParams* mparams, const DataVecCoord& x) const override; @@ -126,6 +122,8 @@ protected : VecCoord m_pos; VecCoord m_restPos; + void doAddDForce(const MechanicalParams* mparams, const Inherit1::AddDForceVectors& vectors) override; + private : void computeForce(const VecCoord& pos, const VecCoord& restPos, VecDeriv& f); diff --git a/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.inl b/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.inl index bbdf4d1e..6b3ee0fd 100644 --- a/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.inl +++ b/src/SoftRobots/component/forcefield/PREquivalentStiffnessForceField.inl @@ -286,16 +286,17 @@ void PREquivalentStiffnessForceField::addForce(const MechanicalParams f.endEdit(); } -template -void PREquivalentStiffnessForceField::addDForce(const MechanicalParams* mparams, - DataVecDeriv& d_f , - const DataVecDeriv& d_x) -{ + +template +void PREquivalentStiffnessForceField::doAddDForce( + const MechanicalParams *mparams, + const typename Inherit1::AddDForceVectors &vectors) +{ if(d_componentState.getValue() != ComponentState::Valid) return ; - const VecDeriv& dx = d_x.getValue(); - VecDeriv& dfdq = *d_f.beginEdit(); + const VecDeriv& dx = vectors.dx.getValue(); + VecDeriv& dfdq = *vectors.df.beginEdit(); const size_t nFrames = dx.size(); const Real kFact = mparams->kFactor(); @@ -395,7 +396,7 @@ void PREquivalentStiffnessForceField::displaceFrames(const VecCoord& } } -template +template void PREquivalentStiffnessForceField::computeForce(const VecCoord& pos, const VecCoord& restPos, VecDeriv& f) diff --git a/src/SoftRobots/component/forcefield/PartialRigidificationForceField.h b/src/SoftRobots/component/forcefield/PartialRigidificationForceField.h index 620b1457..af1f01b3 100644 --- a/src/SoftRobots/component/forcefield/PartialRigidificationForceField.h +++ b/src/SoftRobots/component/forcefield/PartialRigidificationForceField.h @@ -173,6 +173,13 @@ class PartialRigidificationForceField : public MixedInteractionForceField + using AddDForceVectors = typename Inherit1::template AddDForceVectors; + + void doAddDForce(const MechanicalParams* mparams, + const AddDForceVectors& vectors1, + const AddDForceVectors& vectors2) override; + ////////////////////////// Inherited attributes //////////////////////////// /// https://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html diff --git a/src/SoftRobots/component/forcefield/PartialRigidificationForceField.inl b/src/SoftRobots/component/forcefield/PartialRigidificationForceField.inl index 3d1d9e9c..14b0daca 100644 --- a/src/SoftRobots/component/forcefield/PartialRigidificationForceField.inl +++ b/src/SoftRobots/component/forcefield/PartialRigidificationForceField.inl @@ -217,7 +217,7 @@ void PartialRigidificationForceField::addKToMatrix(const delete mappedFFMatrixAccessor; } -template +template void PartialRigidificationForceField::testBuildJacobian(const MechanicalParams* mparams) { CompressedRowSparseMatrix< _3_3_Matrix_Type >* mappedFFMatrix = new CompressedRowSparseMatrix< _3_3_Matrix_Type > ( ); @@ -391,8 +391,6 @@ void PartialRigidificationForceField::addForce(const Mec SOFA_UNUSED(v2); } -// Even though it does nothing, this method has to be implemented -// since it's a pure virtual in parent class template void PartialRigidificationForceField::addDForce(const MechanicalParams* mparams, DataVecDeriv1& df1, @@ -407,6 +405,19 @@ void PartialRigidificationForceField::addDForce(const Me SOFA_UNUSED(dx2); } +// Even though it does nothing, this method has to be implemented +// since it's a pure virtual in parent class +template +void PartialRigidificationForceField::doAddDForce( + const MechanicalParams *mparams, + const AddDForceVectors &vectors1, + const AddDForceVectors &vectors2) +{ + SOFA_UNUSED(mparams); + SOFA_UNUSED(vectors1); + SOFA_UNUSED(vectors2); +} + // Even though it does nothing, this method has to be implemented // since it's a pure virtual in parent class template diff --git a/src/SoftRobots/component/forcefield/PipeForceField.h b/src/SoftRobots/component/forcefield/PipeForceField.h index b4db27e6..def738bf 100644 --- a/src/SoftRobots/component/forcefield/PipeForceField.h +++ b/src/SoftRobots/component/forcefield/PipeForceField.h @@ -113,12 +113,6 @@ public : const DataVecCoord& x , const DataVecDeriv& v) override; - void addDForce(const MechanicalParams* mparams, - DataVecDeriv& df , - const DataVecDeriv& - dx ) override; - - void addKToMatrix(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix) override; @@ -133,6 +127,7 @@ public : sofa::SingleLink < PipeForceField, BarycentricMapping, sofa::BaseLink::FLAG_STOREPATH | sofa::BaseLink::FLAG_STRONGLINK > l_barycentricMapping; sofa::SingleLink < PipeForceField, MeshSpringForceField, sofa::BaseLink::FLAG_STOREPATH | sofa::BaseLink::FLAG_STRONGLINK > l_mappedForceField; + void doAddDForce(const MechanicalParams* mparams, const Inherit1::AddDForceVectors& vectors) override; /** * \brief Compressed sparse row matrices product diff --git a/src/SoftRobots/component/forcefield/PipeForceField.inl b/src/SoftRobots/component/forcefield/PipeForceField.inl index 1bcdfc7c..1318d3d1 100644 --- a/src/SoftRobots/component/forcefield/PipeForceField.inl +++ b/src/SoftRobots/component/forcefield/PipeForceField.inl @@ -88,14 +88,13 @@ void PipeForceField::addForce(const MechanicalParams* mparams, SOFA_UNUSED(v); } -template -void PipeForceField::addDForce(const MechanicalParams* mparams, - DataVecDeriv& d_f , - const DataVecDeriv& d_x) +template +void PipeForceField::doAddDForce( + const MechanicalParams *mparams, + const typename Inherit1::AddDForceVectors &vectors) { SOFA_UNUSED(mparams); - SOFA_UNUSED(d_f); - SOFA_UNUSED(d_x); + SOFA_UNUSED(vectors); } template @@ -188,8 +187,7 @@ void PipeForceField::addKToMatrix(const MechanicalParams* mparams, delete mappedFFMatrixAccessor; } - -template +template template void PipeForceField::multMatrices(const CompressedRowSparseMatrix >& A, const CompressedRowSparseMatrix >& B,