diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.h b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.h index 1ad75539831..45726200615 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.h +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.h @@ -118,10 +118,11 @@ class PenalityContactForceField : public core::behavior::PairInteractionForceFie void addDForce(const sofa::core::MechanicalParams* mparams, DataVecDeriv& data_df1, DataVecDeriv& data_df2, const DataVecDeriv& data_dx1, const DataVecDeriv& data_dx2) override; - void addKToMatrix(const sofa::core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doAddKToMatrix(const sofa::core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const sofa::core::MechanicalParams*, const DataVecCoord&, const DataVecCoord& ) const override; diff --git a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.inl b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.inl index 3e68dcad433..cead7f35c97 100644 --- a/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.inl +++ b/Sofa/Component/Collision/Response/Contact/src/sofa/component/collision/response/contact/PenalityContactForceField.inl @@ -133,7 +133,7 @@ void PenalityContactForceField::addDForce(const sofa::core::Mechanica } template -void PenalityContactForceField::addKToMatrix(const sofa::core::MechanicalParams* mparams, +void PenalityContactForceField::doAddKToMatrix(const sofa::core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) { static constexpr auto N = DataTypes::spatial_dimensions; @@ -200,7 +200,7 @@ void PenalityContactForceField::addKToMatrix(const sofa::core::Mechan } template -void PenalityContactForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void PenalityContactForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { const type::vector& cc = contacts.getValue(); @@ -257,7 +257,7 @@ void PenalityContactForceField::buildStiffnessMatrix(core::behavior:: } template -void PenalityContactForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void PenalityContactForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/Diffusion/src/sofa/component/diffusion/TetrahedronDiffusionFEMForceField.h b/Sofa/Component/Diffusion/src/sofa/component/diffusion/TetrahedronDiffusionFEMForceField.h index 7b2afa1a710..636ca351352 100644 --- a/Sofa/Component/Diffusion/src/sofa/component/diffusion/TetrahedronDiffusionFEMForceField.h +++ b/Sofa/Component/Diffusion/src/sofa/component/diffusion/TetrahedronDiffusionFEMForceField.h @@ -73,10 +73,10 @@ class TetrahedronDiffusionFEMForceField : public core::behavior::ForceField::addDForce(const sofa::core::M template -void TetrahedronDiffusionFEMForceField::addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void TetrahedronDiffusionFEMForceField::addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFactor, unsigned int &offset) { SCOPED_TIMER("addKToMatrix"); const auto N = defaulttype::DataTypeInfo::size(); - sofa::core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate); - sofa::linearalgebra::BaseMatrix* mat = r.matrix; - if((sofa::Size)(mat->colSize()) != (m_topology->getNbPoints()*N) || (sofa::Size)(mat->rowSize()) != (m_topology->getNbPoints()*N)) + if((sofa::Size)(matrix->colSize()) != (m_topology->getNbPoints()*N) || (sofa::Size)(matrix->rowSize()) != (m_topology->getNbPoints()*N)) { msg_error()<<"Wrong size of the input Matrix: need resize in addKToMatrix function."; - mat->resize(m_topology->getNbPoints()*N,m_topology->getNbPoints()*N); + matrix->resize(m_topology->getNbPoints()*N,m_topology->getNbPoints()*N); } - Real kFactor = mparams->kFactor(); - unsigned int &offset = r.offset; - sofa::Index v0,v1; const auto& edges = m_topology->getEdges(); @@ -381,15 +376,15 @@ void TetrahedronDiffusionFEMForceField::addKToMatrix(const core::Mech v0 = edges[i][0]; v1 = edges[i][1]; - mat->add(offset+N*v1, offset+N*v0, -kFactor * edgeDiffusionCoefficient[i]); - mat->add(offset+N*v0, offset+N*v1, -kFactor * edgeDiffusionCoefficient[i]); - mat->add(offset+N*v0, offset+N*v0, kFactor * edgeDiffusionCoefficient[i]); - mat->add(offset+N*v1, offset+N*v1, kFactor * edgeDiffusionCoefficient[i]); + matrix->add(offset+N*v1, offset+N*v0, -kFactor * edgeDiffusionCoefficient[i]); + matrix->add(offset+N*v0, offset+N*v1, -kFactor * edgeDiffusionCoefficient[i]); + matrix->add(offset+N*v0, offset+N*v0, kFactor * edgeDiffusionCoefficient[i]); + matrix->add(offset+N*v1, offset+N*v1, kFactor * edgeDiffusionCoefficient[i]); } } template -void TetrahedronDiffusionFEMForceField::buildStiffnessMatrix( +void TetrahedronDiffusionFEMForceField::doBuildStiffnessMatrix( core::behavior::StiffnessMatrix* matrix) { constexpr auto N = DataTypes::deriv_total_size; diff --git a/Sofa/Component/LinearSystem/tests/MatrixLinearSystem_test.cpp b/Sofa/Component/LinearSystem/tests/MatrixLinearSystem_test.cpp index 104a062297a..8758bc3a6b1 100644 --- a/Sofa/Component/LinearSystem/tests/MatrixLinearSystem_test.cpp +++ b/Sofa/Component/LinearSystem/tests/MatrixLinearSystem_test.cpp @@ -244,7 +244,7 @@ template public: SOFA_CLASS(BuggyForceField, sofa::core::behavior::ForceField); - void buildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) override + void doBuildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) override { auto dfdx = matrix->getForceDerivativeIn(this->mstate).withRespectToPositionsIn(this->mstate); dfdx(10, 20) += 0.; diff --git a/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.h b/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.h index 47c53f8f8b8..43f000ef1ac 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.h +++ b/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.h @@ -311,12 +311,12 @@ class DiagonalMass : public core::behavior::Mass /// Add Mass contribution to global Matrix assembling void addMToMatrix(sofa::linearalgebra::BaseMatrix * mat, SReal mFact, unsigned int &offset) override; - void buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override {} - void buildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} + void doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override {} + void doBuildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} - SReal getElementMass(sofa::Index index) const override; - void getElementMass(sofa::Index, linearalgebra::BaseMatrix *m) const override; + SReal doGetElementMass(sofa::Index index) const override; + void doGetElementMass(sofa::Index, linearalgebra::BaseMatrix *m) const override; bool isDiagonal() const override {return true;} diff --git a/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.inl b/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.inl index 427c31a4aba..9977ad91eae 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.inl +++ b/Sofa/Component/Mass/src/sofa/component/mass/DiagonalMass.inl @@ -628,7 +628,7 @@ void DiagonalMass::addMToMatrix(sofa::linearalgebra } template -void DiagonalMass::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) +void DiagonalMass::doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) { const MassVector &masses= d_vertexMass.getValue(); static constexpr auto N = Deriv::total_size; @@ -642,7 +642,7 @@ void DiagonalMass::buildMassMatrix(sofa::core::beha template -SReal DiagonalMass::getElementMass(sofa::Index index) const +SReal DiagonalMass::doGetElementMass(sofa::Index index) const { return SReal(d_vertexMass.getValue()[index]); } @@ -650,7 +650,7 @@ SReal DiagonalMass::getElementMass(sofa::Index inde //TODO: special case for Rigid Mass template -void DiagonalMass::getElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const +void DiagonalMass::doGetElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const { static const linearalgebra::BaseMatrix::Index dimension = linearalgebra::BaseMatrix::Index(defaulttype::DataTypeInfo::size()); if (m->rowSize() != dimension || m->colSize() != dimension) m->resize(dimension,dimension); diff --git a/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.h b/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.h index e67680dbcb4..358b707dc2b 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.h +++ b/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.h @@ -220,12 +220,12 @@ class MeshMatrixMass : public core::behavior::Mass /// Add Mass contribution to global Matrix assembling void addMToMatrix(sofa::linearalgebra::BaseMatrix * mat, SReal mFact, unsigned int &offset) override; - void buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override {} - void buildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} + void doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override {} + void doBuildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} - SReal getElementMass(Index index) const override; - void getElementMass(Index index, linearalgebra::BaseMatrix *m) const override; + SReal doGetElementMass(Index index) const override; + void doGetElementMass(Index index, linearalgebra::BaseMatrix *m) const override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.inl b/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.inl index c21e3b62d45..61511eaca5e 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.inl +++ b/Sofa/Component/Mass/src/sofa/component/mass/MeshMatrixMass.inl @@ -2271,7 +2271,7 @@ void MeshMatrixMass::addMToMatrix(sofa::linearalgeb } template -void MeshMatrixMass::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) +void MeshMatrixMass::doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) { const MassVector &vertexMass= d_vertexMass.getValue(); const MassVector &edgeMass= d_edgeMass.getValue(); @@ -2312,7 +2312,7 @@ void MeshMatrixMass::buildMassMatrix(sofa::core::be template -SReal MeshMatrixMass::getElementMass(Index index) const +SReal MeshMatrixMass::doGetElementMass(Index index) const { const auto &vertexMass= d_vertexMass.getValue(); const SReal mass = vertexMass[index] * m_massLumpingCoeff; @@ -2323,7 +2323,7 @@ SReal MeshMatrixMass::getElementMass(Index index) c //TODO: special case for Rigid Mass template -void MeshMatrixMass::getElementMass(Index index, linearalgebra::BaseMatrix *m) const +void MeshMatrixMass::doGetElementMass(Index index, linearalgebra::BaseMatrix *m) const { static const linearalgebra::BaseMatrix::Index dimension = linearalgebra::BaseMatrix::Index(defaulttype::DataTypeInfo::size()); if (m->rowSize() != dimension || m->colSize() != dimension) m->resize(dimension,dimension); diff --git a/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.h b/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.h index 258eb345e10..e0f10a12a22 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.h +++ b/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.h @@ -148,12 +148,12 @@ class UniformMass : public core::behavior::Mass void addGravityToV(const core::MechanicalParams* mparams, DataVecDeriv& d_v) override; void addMToMatrix(sofa::linearalgebra::BaseMatrix * mat, SReal mFact, unsigned int &offset) override; /// Add Mass contribution to global Matrix assembling - void buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override {} - void buildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} + void doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* /* matrix */) override {} + void doBuildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} - SReal getElementMass(sofa::Index index) const override; - void getElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const override; + SReal doGetElementMass(sofa::Index index) const override; + void doGetElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const override; bool isDiagonal() const override {return true;} diff --git a/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.inl b/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.inl index 2b87e5f9379..1845d0a8d35 100644 --- a/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.inl +++ b/Sofa/Component/Mass/src/sofa/component/mass/UniformMass.inl @@ -573,7 +573,7 @@ void UniformMass::addMToMatrix (sofa::linearalgebra::BaseMatrix * mat } template -void UniformMass::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) +void UniformMass::doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) { if (!this->isComponentStateValid()) { @@ -594,14 +594,14 @@ void UniformMass::buildMassMatrix(sofa::core::behavior::MassMatrixAcc template -SReal UniformMass::getElementMass (sofa::Index ) const +SReal UniformMass::doGetElementMass (sofa::Index ) const { return (SReal ( d_vertexMass.getValue() )); } template -void UniformMass::getElementMass (sofa::Index index, BaseMatrix *m ) const +void UniformMass::doGetElementMass (sofa::Index index, BaseMatrix *m ) const { SOFA_UNUSED(index); diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.h index 849d0e80b48..0978f031df2 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.h @@ -105,14 +105,15 @@ class ConicalForceField : public core::behavior::ForceField void addForce(const sofa::core::MechanicalParams* /*mparams*/, DataVecDeriv & dataF, const DataVecCoord & dataX , const DataVecDeriv & dataV ) override; void addDForce(const sofa::core::MechanicalParams* /*mparams*/, DataVecDeriv& datadF , const DataVecDeriv& datadX ) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override { msg_warning() << "Method getPotentialEnergy not implemented yet."; return 0.0; } - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; - + virtual void updateStiffness( const VecCoord& x ); virtual bool isIn(Coord p); diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.inl index 82be58c1f99..e104a662621 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConicalForceField.inl @@ -157,7 +157,7 @@ void ConicalForceField::addDForce(const sofa::core::MechanicalParams* } template -void ConicalForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void ConicalForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) .withRespectToPositionsIn(this->mstate); @@ -174,7 +174,7 @@ void ConicalForceField::buildStiffnessMatrix(core::behavior::Stiffnes } template -void ConicalForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void ConicalForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.h index d50ec09b740..a4c0b9f226b 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.h @@ -85,8 +85,13 @@ class ConstantForceField : public core::behavior::ForceField /// Constant force has null variation virtual void addKToMatrix(const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/, SReal /*kFact*/) ; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final + { + // No damping in this ForceField + } + SReal getPotentialEnergy(const core::MechanicalParams* params, const DataVecCoord& x) const override; void draw(const core::visual::VisualParams* vparams) override; @@ -97,10 +102,7 @@ class ConstantForceField : public core::behavior::ForceField using Inherit::addAlias ; using Inherit::addKToMatrix; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final - { - // No damping in this ForceField - } + protected: diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.inl index c9b1b4db71c..391ea4a3324 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/ConstantForceField.inl @@ -443,7 +443,7 @@ void ConstantForceField::addKToMatrix(const sofa::core::behavior::Mul } template -void ConstantForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void ConstantForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { SOFA_UNUSED(matrix); } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.h index 997a8330f9b..e425fe87f6d 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/DiagonalVelocityDampingForceField.h @@ -58,10 +58,10 @@ class DiagonalVelocityDampingForceField : public core::behavior::ForceField::addDForce(const core::Mechani } template -void DiagonalVelocityDampingForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix*) +void DiagonalVelocityDampingForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix*) { // DiagonalVelocityDampingForceField is a pure damping component: stiffness is not computed } @@ -126,7 +126,7 @@ void DiagonalVelocityDampingForceField::addBToMatrix(sofa::linearalge } template -void DiagonalVelocityDampingForceField::buildDampingMatrix(core::behavior::DampingMatrix* matrix) +void DiagonalVelocityDampingForceField::doBuildDampingMatrix(core::behavior::DampingMatrix* matrix) { const auto& coefs = d_dampingCoefficients.getValue(); const std::size_t nbDampingCoeff = coefs.size(); diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.h index c7710f0f137..d14095622b5 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.h @@ -114,8 +114,8 @@ class EdgePressureForceField : public core::behavior::ForceField void setNormal(const Coord n) { d_normal.setValue(n);} void setPressure(Deriv _pressure) { this->d_pressure = _pressure; updateEdgeInformation(); } - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) final; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; protected : void selectEdgesAlongPlane(); diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.inl index 8bb637ecb6b..004a7a8f15a 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EdgePressureForceField.inl @@ -317,13 +317,13 @@ void EdgePressureForceField::updateEdgeInformation() } template -void EdgePressureForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix*) +void EdgePressureForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix*) { // No stiffness in this ForceField } template -void EdgePressureForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void EdgePressureForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.h index 3f8fffe9e93..2a41ed47814 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.h @@ -105,8 +105,8 @@ class EllipsoidForceField : public core::behavior::ForceField void addDForce(const sofa::core::MechanicalParams* /*mparams*/, DataVecDeriv& datadF , const DataVecDeriv& datadX ) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl index b40de9a6464..395aca7ad46 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/EllipsoidForceField.inl @@ -165,7 +165,7 @@ void EllipsoidForceField::addDForce(const sofa::core::MechanicalParam } template -void EllipsoidForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void EllipsoidForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) .withRespectToPositionsIn(this->mstate); @@ -178,7 +178,7 @@ void EllipsoidForceField::buildStiffnessMatrix(core::behavior::Stiffn } template -void EllipsoidForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void EllipsoidForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.h index 0a9cccd4b7b..30beae528c8 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.h @@ -146,7 +146,7 @@ class InteractionEllipsoidForceField : public core::behavior::MixedInteractionFo SReal getPotentialEnergy(const sofa::core::MechanicalParams* mparams, const DataVecCoord1& x1, const DataVecCoord2& x2)const override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void init() override; void reinit() override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.inl index 02b8e5e91b5..9d5837009e4 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/InteractionEllipsoidForceField.inl @@ -358,7 +358,7 @@ SReal InteractionEllipsoidForceField::getPotentialEnergy } template -void InteractionEllipsoidForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void InteractionEllipsoidForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.h index fc522be67de..fb233a6b99f 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.h @@ -108,9 +108,9 @@ class LinearForceField : public core::behavior::ForceField void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* mparams, const DataVecCoord& x) const override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.inl index f95f33738e1..66a12991f25 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/LinearForceField.inl @@ -183,13 +183,13 @@ void LinearForceField::addKToMatrix(linearalgebra::BaseMatrix* matrix } template -void LinearForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void LinearForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } template -void LinearForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void LinearForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { SOFA_UNUSED(matrix); } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.h index 5524e63b383..67aa4417899 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/OscillatingTorsionPressureForceField.h @@ -102,8 +102,8 @@ class OscillatingTorsionPressureForceField : public core::behavior::ForceField::getPotentialEnergy(const } template -void OscillatingTorsionPressureForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix*) +void OscillatingTorsionPressureForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix*) { } template -void OscillatingTorsionPressureForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void OscillatingTorsionPressureForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.h index 4114be3b96e..c2be371c931 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.h @@ -112,10 +112,9 @@ class PlaneForceField : public core::behavior::ForceField SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override; virtual void updateStiffness( const VecCoord& x ); - void addKToMatrix(const core::MechanicalParams* - mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) override; - void buildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) override; + void doBuildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void draw(const core::visual::VisualParams* vparams) override; void drawPlane(const core::visual::VisualParams*, float size=0.0f); diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.inl index 842b738c656..d908c62b7bf 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/PlaneForceField.inl @@ -226,17 +226,13 @@ void PlaneForceField::addDForce(const core::MechanicalParams* mparams } template -void PlaneForceField::addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) +void PlaneForceField::addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) { if(this->d_componentState.getValue() != ComponentState::Valid) return ; - const Real fact = (Real)(-this->d_stiffness.getValue()*sofa::core::mechanicalparams::kFactorIncludingRayleighDamping(mparams, this->rayleighStiffness.getValue())); Deriv normal; DataTypes::setDPos(normal, d_planeNormal.getValue()); - const sofa::core::behavior::MultiMatrixAccessor::MatrixRef mref = matrix->getMatrix(this->mstate); - sofa::linearalgebra::BaseMatrix* mat = mref.matrix; - unsigned int offset = mref.offset; for (unsigned int i=0; im_contacts.size(); i++) { @@ -244,14 +240,14 @@ void PlaneForceField::addKToMatrix(const core::MechanicalParams* mpar for (sofa::Index l=0; ladd(offset + p*Deriv::total_size + l, offset + p*Deriv::total_size + c, coef); + SReal coef = normal[l] * kFact * normal[c]; + matrix->add(offset + p*Deriv::total_size + l, offset + p*Deriv::total_size + c, coef); } } } template -void PlaneForceField::buildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) +void PlaneForceField::doBuildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) { if (!this->isComponentStateValid()) { @@ -273,7 +269,7 @@ void PlaneForceField::buildStiffnessMatrix(sofa::core::behavior::Stif } template -void PlaneForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void PlaneForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.h index 5880a219c41..426e95d0b1a 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.h @@ -110,13 +110,11 @@ class QuadPressureForceField : public core::behavior::ForceField void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; /// Constant pressure has null variation + using Inherit1::addKToMatrix; void addKToMatrix(sofa::linearalgebra::BaseMatrix * /*m*/, SReal /*kFactor*/, unsigned int & /*offset*/) override {} - /// Constant pressure has null variation - void addKToMatrix(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/ ) override {} - - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* /*matrix*/) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* /*matrix*/) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override { msg_warning() << "Method getPotentialEnergy not implemented yet."; return 0.0; } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.inl index 0b869038c8c..fa00dce0d3d 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/QuadPressureForceField.inl @@ -220,14 +220,14 @@ bool QuadPressureForceField::isPointInPlane(Coord p) } template -void QuadPressureForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* ) +void QuadPressureForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* ) { // force does not depend on the position, so the derivative with respect // to position is null => stiffness matrix is null } template -void QuadPressureForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void QuadPressureForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.h index abe3cff4ec4..bcb458b1a1c 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.h @@ -109,8 +109,8 @@ class SphereForceField : public core::behavior::ForceField void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override; virtual void updateStiffness( const VecCoord& x ); - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void addKToMatrix(sofa::linearalgebra::BaseMatrix *, SReal, unsigned int &) override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.inl index b9599ff4f5f..01ce2c684e3 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SphereForceField.inl @@ -180,7 +180,7 @@ void SphereForceField::updateStiffness( const VecCoord& x ) } template -void SphereForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void SphereForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { const Real fact = (Real)(-this->d_stiffness.getValue()); @@ -202,7 +202,7 @@ void SphereForceField::buildStiffnessMatrix(core::behavior::Stiffness } template -void SphereForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void SphereForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.h index e866cd70f32..6afbe372fc4 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.h @@ -100,9 +100,10 @@ class SurfacePressureForceField : public core::behavior::ForceField void addForce(const core::MechanicalParams* mparams, DataVecDeriv& d_f, const DataVecCoord& d_x, const DataVecDeriv& d_v) override; void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& /* d_df */, const DataVecDeriv& /* d_dx */) override; - void addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + using Inherit1::addKToMatrix; + void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.inl index 7635436a57f..874cea35109 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/SurfacePressureForceField.inl @@ -237,13 +237,8 @@ void SurfacePressureForceField::addDForce(const core::MechanicalParam template -void SurfacePressureForceField::addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void SurfacePressureForceField::addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) { - const sofa::core::behavior::MultiMatrixAccessor::MatrixRef mref = matrix->getMatrix(this->mstate); - sofa::linearalgebra::BaseMatrix* mat = mref.matrix; - unsigned int offset = mref.offset; - Real kFact = (Real)sofa::core::mechanicalparams::kFactorIncludingRayleighDamping(mparams, this->rayleighStiffness.getValue()); - const int N = Coord::total_size; if (d_useTangentStiffness.getValue()) { @@ -258,7 +253,7 @@ void SurfacePressureForceField::addKToMatrix(const core::MechanicalPa { for (unsigned int c = 0; c < 3; c++) { - mat->add(offset + N * i + l, offset + N * v + c, kFact * Kiv(l,c)); + matrix->add(offset + N * i + l, offset + N * v + c, kFact * Kiv(l,c)); } } } @@ -267,7 +262,7 @@ void SurfacePressureForceField::addKToMatrix(const core::MechanicalPa } template -void SurfacePressureForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void SurfacePressureForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { if (d_useTangentStiffness.getValue()) { @@ -290,7 +285,7 @@ void SurfacePressureForceField::buildStiffnessMatrix(core::behavior:: } template -void SurfacePressureForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void SurfacePressureForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.h index 9620bb0272d..e1801974d8f 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.h @@ -105,12 +105,12 @@ class TaitSurfacePressureForceField : public core::behavior::ForceField void addKToMatrixT(const core::MechanicalParams* mparams, MatrixWriter mwriter); - void buildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.inl index ddb33a32be5..3c4970c4777 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TaitSurfacePressureForceField.inl @@ -318,7 +318,7 @@ void TaitSurfacePressureForceField::addDForce(const core::MechanicalP } template -void TaitSurfacePressureForceField::addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) +void TaitSurfacePressureForceField::doAddKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) { core::behavior::BlocMatrixWriter writer; writer.addKToMatrix(this, mparams, matrix->getMatrix(this->mstate)); @@ -398,7 +398,7 @@ void TaitSurfacePressureForceField::addKToMatrixT(const core::Mechani } template -void TaitSurfacePressureForceField::buildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) +void TaitSurfacePressureForceField::doBuildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) { const auto mstateSize = this->mstate->getSize(); const helper::ReadAccessor< Data< SeqTriangles > > pressureTriangles = d_pressureTriangles; @@ -456,7 +456,7 @@ void TaitSurfacePressureForceField::buildStiffnessMatrix(sofa::core:: } template -void TaitSurfacePressureForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TaitSurfacePressureForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.h index f1ac77d5e8b..6d0e68dbbb6 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.h @@ -76,8 +76,8 @@ class TorsionForceField : public ForceField void addForce(const MechanicalParams *, DataVecDeriv &f, const DataVecCoord &x, const DataVecDeriv &v) override; void addDForce(const MechanicalParams *mparams, DataVecDeriv &df, const DataVecDeriv &dx) override; void addKToMatrix(linearalgebra::BaseMatrix *matrix, SReal kFact, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.inl index b3e092cf8cb..137a27f3bbc 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TorsionForceField.inl @@ -121,7 +121,7 @@ void TorsionForceField::addKToMatrix(linearalgebra::BaseMatrix* matri } template -void TorsionForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void TorsionForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) .withRespectToPositionsIn(this->mstate); @@ -143,7 +143,7 @@ void TorsionForceField::buildStiffnessMatrix(core::behavior::Stiffnes } template -void TorsionForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TorsionForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.h index 8aeffb3ad10..55b3d8a7211 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.h @@ -110,12 +110,13 @@ class TrianglePressureForceField : public core::behavior::ForceField void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; /// Constant pressure has null variation + using Inherit1::addKToMatrix; void addKToMatrix(sofa::linearalgebra::BaseMatrix * /*m*/, SReal /*kFactor*/, unsigned int & /*offset*/) override {} /// Constant pressure has null variation - void addKToMatrix(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/ ) override {} + void doAddKToMatrix(const core::MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/ ) override {} - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.inl b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.inl index a21fdac2882..63efc489d38 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.inl +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/TrianglePressureForceField.inl @@ -229,7 +229,7 @@ void TrianglePressureForceField::draw(const core::visual::VisualParam } template -void TrianglePressureForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TrianglePressureForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.h b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.h index 70ae8848ef6..8abafcf7f43 100644 --- a/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.h +++ b/Sofa/Component/MechanicalLoad/src/sofa/component/mechanicalload/UniformVelocityDampingForceField.h @@ -63,7 +63,7 @@ class UniformVelocityDampingForceField : public core::behavior::ForceField::addBToMatrix(sofa::linearalgeb } template -void UniformVelocityDampingForceField::buildDampingMatrix(core::behavior::DampingMatrix* matrix) +void UniformVelocityDampingForceField::doBuildDampingMatrix(core::behavior::DampingMatrix* matrix) { if( !d_implicit.getValue() ) return; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.h index 24cd94323d4..9cdc7e2cb46 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.h @@ -167,8 +167,8 @@ class BeamFEMForceField : public BaseLinearElasticityFEMForceField void addForce(const MechanicalParams* mparams, DataVecDeriv & dataF, const DataVecCoord & dataX , const DataVecDeriv & dataV ) override; void addDForce(const MechanicalParams* mparams, DataVecDeriv& datadF , const DataVecDeriv& datadX ) override; void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const MechanicalParams* mparams, const DataVecCoord& x) const override; void draw(const core::visual::VisualParams* vparams) override; void computeBBox(const core::ExecParams* params, bool onlyVisible) override; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.inl index 80ff0061698..8665aa957b1 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/BeamFEMForceField.inl @@ -578,7 +578,7 @@ void BeamFEMForceField::addKToMatrix(sofa::linearalgebra::BaseMatrix } template -void BeamFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void BeamFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) .withRespectToPositionsIn(this->mstate); @@ -678,7 +678,7 @@ void BeamFEMForceField::buildStiffnessMatrix(core::behavior::Stiffnes } template -void BeamFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void BeamFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.h index 770ea885bd2..dcf1e2d4e60 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.h @@ -149,8 +149,8 @@ class FastTetrahedralCorotationalForceField : public BaseLinearElasticityFEMForc using Inherit1::addKToMatrix; void addKToMatrix(sofa::linearalgebra::BaseMatrix *m, SReal kFactor, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* matrix) override; void updateTopologyInformation(); diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.inl index 434e54e7261..57fd746f502 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/FastTetrahedralCorotationalForceField.inl @@ -466,7 +466,7 @@ void FastTetrahedralCorotationalForceField::addDForce(const sofa::cor } template -void FastTetrahedralCorotationalForceField::buildStiffnessMatrix( +void FastTetrahedralCorotationalForceField::doBuildStiffnessMatrix( core::behavior::StiffnessMatrix* matrix) { const sofa::Size nbEdges = this->l_topology->getNbEdges(); @@ -554,7 +554,7 @@ void FastTetrahedralCorotationalForceField::buildStiffnessMatrix( } template -void FastTetrahedralCorotationalForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void FastTetrahedralCorotationalForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.h index 27af165194a..7cc8efba877 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.h @@ -153,9 +153,9 @@ class HexahedralFEMForceField : virtual public BaseLinearElasticityFEMForceField } void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl index 949d5421c4f..1285170a7e8 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceField.inl @@ -613,7 +613,7 @@ void HexahedralFEMForceField::addKToMatrix(sofa::linearalgebra::BaseM } template -void HexahedralFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void HexahedralFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { const type::vector& hexahedronInf = d_hexahedronInfo.getValue(); @@ -646,7 +646,7 @@ void HexahedralFEMForceField::buildStiffnessMatrix(core::behavior::St } } template -void HexahedralFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void HexahedralFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.h index e85613ce8d1..92d007aa158 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.h @@ -106,7 +106,7 @@ class HexahedralFEMForceFieldAndMass : virtual public sofa::core::behavior::Mass void draw(const core::visual::VisualParams* vparams) override; - SReal getElementMass(sofa::Index index) const override; + SReal doGetElementMass(sofa::Index index) const override; void setDensity(Real d) {d_density.setValue(d );} Real getDensity() {return d_density.getValue();} diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl index d65b5794ad9..a9cbf7cf0d7 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedralFEMForceFieldAndMass.inl @@ -436,7 +436,7 @@ void HexahedralFEMForceFieldAndMass::addDForce(const core::Mechanical template -SReal HexahedralFEMForceFieldAndMass::getElementMass(sofa::Index /*index*/) const +SReal HexahedralFEMForceFieldAndMass::doGetElementMass(sofa::Index /*index*/) const { msg_error() << "HexahedralFEMForceFieldAndMass::getElementMass not yet implemented"; return 0.0; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.h index 81171ce7709..2f73b867bf3 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.h @@ -149,8 +149,8 @@ class HexahedronFEMForceField : using Inherit1::addKToMatrix; void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /* matrices */) override {} void computeBBox(const core::ExecParams* params, bool onlyVisible) override; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl index af0cb62553b..54c748a47ca 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceField.inl @@ -1146,7 +1146,7 @@ void HexahedronFEMForceField::addKToMatrix(sofa::linearalgebra::BaseM } template -void HexahedronFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void HexahedronFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { sofa::Index e { 0 }; //index of the element in the topology diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.h index d6e8b1531a1..0f04fc1f8df 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/HexahedronFEMForceFieldAndMass.h @@ -84,8 +84,8 @@ class HexahedronFEMForceFieldAndMass : virtual public core::behavior::Mass::addMToMatrix(sofa::linearalgebra } template -void HexahedronFEMForceFieldAndMass::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void HexahedronFEMForceFieldAndMass::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { - HexahedronFEMForceFieldT::buildStiffnessMatrix(matrix); + HexahedronFEMForceFieldT::doBuildStiffnessMatrix(matrix); } template -void HexahedronFEMForceFieldAndMass::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) +void HexahedronFEMForceFieldAndMass::doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) { int e = 0; for(auto it = this->getIndexedElements()->begin(); it != this->getIndexedElements()->end() ; ++it, ++e) @@ -337,7 +337,7 @@ void HexahedronFEMForceFieldAndMass::addDForce(const core::Mechanical template -SReal HexahedronFEMForceFieldAndMass::getElementMass(sofa::Index /*index*/) const +SReal HexahedronFEMForceFieldAndMass::doGetElementMass(sofa::Index /*index*/) const { msg_warning()<<"HexahedronFEMForceFieldAndMass::getElementMass not yet implemented"< void reinit() override; void addForce(const core::MechanicalParams* mparams, DataVecDeriv& f, const DataVecCoord& x, const DataVecDeriv& v) override; void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& df, const DataVecDeriv& dx) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* mparams, const DataVecCoord& x) const override; /// Class to store FEM information on each quad, for topology modification handling class QuadInformation diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.inl index d03287b4903..f1e5a387585 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/QuadBendingFEMForceField.inl @@ -713,7 +713,7 @@ void QuadBendingFEMForceField::addDForce(const core::MechanicalParams } template -void QuadBendingFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void QuadBendingFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { static constexpr auto N = Deriv::total_size; auto dfdx = matrix->getForceDerivativeIn(this->mstate) @@ -742,7 +742,7 @@ void QuadBendingFEMForceField::buildStiffnessMatrix(core::behavior::S } template -void QuadBendingFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void QuadBendingFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.h index bb48014af31..b58bcaef440 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.h @@ -191,9 +191,9 @@ class TetrahedralCorotationalFEMForceField : public BaseLinearElasticityFEMForce } void addKToMatrix(sofa::linearalgebra::BaseMatrix *m, SReal kFactor, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; // Getting the rotation of the vertex by averaing the rotation of neighboring elements void getRotation(Transformation& R, Index nodeIdx); diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.inl index a574c00230a..eaae33dc9a5 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedralCorotationalFEMForceField.inl @@ -1426,7 +1426,7 @@ void TetrahedralCorotationalFEMForceField::addKToMatrix(sofa::lineara } template -void TetrahedralCorotationalFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void TetrahedralCorotationalFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { StiffnessMatrix JKJt, RJKJtRt; sofa::type::Mat<3, 3, Real> localMatrix(type::NOINIT); @@ -1464,7 +1464,7 @@ void TetrahedralCorotationalFEMForceField::buildStiffnessMatrix(core: } } template -void TetrahedralCorotationalFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TetrahedralCorotationalFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.h index 8f9b3992c4b..e4b0b4a0779 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TetrahedronFEMForceField.h @@ -279,8 +279,8 @@ class TetrahedronFEMForceField : public BaseLinearElasticityFEMForceField::addKToMatrix(sofa::linearalgebra::Base } template -void TetrahedronFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void TetrahedronFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { StiffnessMatrix JKJt, RJKJtRt; sofa::type::Mat<3, 3, Real> localMatrix(type::NOINIT); @@ -2000,7 +2000,7 @@ void TetrahedronFEMForceField::buildStiffnessMatrix(core::behavior::S } template -void TetrahedronFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TetrahedronFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.h index b17f79a837b..b208439c6c7 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangleFEMForceField.h @@ -102,8 +102,8 @@ class TriangleFEMForceField : public BaseLinearElasticityFEMForceField::addKToMatrix(sofa::linearalgebra::BaseMat } template -void TriangleFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void TriangleFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { StiffnessMatrix JKJt, RJKJtRt; sofa::type::Mat<3, 3, Real> localMatrix(type::NOINIT); @@ -656,7 +656,7 @@ void TriangleFEMForceField::buildStiffnessMatrix(core::behavior::Stif } template -void TriangleFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TriangleFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.h index cd4b126c66c..fbac2dbbacc 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.h @@ -105,12 +105,12 @@ class TriangularFEMForceField : public BaseLinearElasticityFEMForceField& S, type::Mat<9, 9, Real>& SR, const MaterialStiffness& K, const StrainDisplacement& J, const Transformation& Rot); void addKToMatrix(sofa::linearalgebra::BaseMatrix *mat, SReal k, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.inl index baa1b35e450..88c89a0fd47 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceField.inl @@ -388,7 +388,7 @@ void TriangularFEMForceField::addKToMatrix(sofa::linearalgebra::BaseM } template -void TriangularFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void TriangularFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { type::Mat<9, 9, Real> JKJt, RJKJtRt; sofa::type::Mat<3, 3, Real> localMatrix(type::NOINIT); @@ -1197,7 +1197,7 @@ void TriangularFEMForceField::addDForce(const core::MechanicalParams* } template -void TriangularFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TriangularFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.h b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.h index 23ea6aa0a20..1161c96a05c 100644 --- a/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.h +++ b/Sofa/Component/SolidMechanics/FEM/Elastic/src/sofa/component/solidmechanics/fem/elastic/TriangularFEMForceFieldOptim.h @@ -105,8 +105,8 @@ class TriangularFEMForceFieldOptim : public BaseLinearElasticityFEMForceField::addKToMatrix(sofa::linearalgebra:: } template -void TriangularFEMForceFieldOptim::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void TriangularFEMForceFieldOptim::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) .withRespectToPositionsIn(this->mstate); @@ -537,7 +537,7 @@ void TriangularFEMForceFieldOptim::buildStiffnessMatrix(core::behavio } template -void TriangularFEMForceFieldOptim::buildDampingMatrix(core::behavior::DampingMatrix*) +void TriangularFEMForceFieldOptim::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.h index fc111a7b248..7bf4f495cc2 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.h @@ -184,8 +184,8 @@ public : msg_warning() << "Method getPotentialEnergy not implemented yet."; return 0.0; } - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.inl index 2f3b4245ba9..26ea9ca6399 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/StandardTetrahedralFEMForceField.inl @@ -565,7 +565,7 @@ void StandardTetrahedralFEMForceField::addKToMatrix(sofa::linearalge } template -void StandardTetrahedralFEMForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void StandardTetrahedralFEMForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { const sofa::Size nbEdges = m_topology->getNbEdges(); const type::vector< Edge>& edgeArray=m_topology->getEdges(); @@ -594,7 +594,7 @@ void StandardTetrahedralFEMForceField::buildStiffnessMatrix(core::beh } template -void StandardTetrahedralFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void StandardTetrahedralFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.h b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.h index f089c097572..4733ac99d2b 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.h +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.h @@ -172,8 +172,8 @@ class TetrahedronHyperelasticityFEMForceField : public core::behavior::ForceFiel SReal getPotentialEnergy(const core::MechanicalParams*, const DataVecCoord&) const override; using Inherit1::addKToMatrix; void addKToMatrix(sofa::linearalgebra::BaseMatrix *mat, SReal k, unsigned int &offset) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.inl b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.inl index f021dc9defb..f82a44149ff 100644 --- a/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.inl +++ b/Sofa/Component/SolidMechanics/FEM/HyperElastic/src/sofa/component/solidmechanics/fem/hyperelastic/TetrahedronHyperelasticityFEMForceField.inl @@ -536,7 +536,7 @@ void TetrahedronHyperelasticityFEMForceField::addKToMatrix(sofa::line } template -void TetrahedronHyperelasticityFEMForceField::buildStiffnessMatrix( +void TetrahedronHyperelasticityFEMForceField::doBuildStiffnessMatrix( core::behavior::StiffnessMatrix* matrix) { /// if the matrix needs to be updated @@ -578,7 +578,7 @@ void TetrahedronHyperelasticityFEMForceField::buildStiffnessMatrix( } template -void TetrahedronHyperelasticityFEMForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TetrahedronHyperelasticityFEMForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.h index 2244a33072f..6fa8c1b79f5 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.h @@ -89,9 +89,9 @@ class AngularSpringForceField : public core::behavior::ForceField } /// Brings ForceField contribution to the global system stiffness matrix. - void addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doAddKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void draw(const core::visual::VisualParams* vparams) override; protected : diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.inl b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.inl index c25fabfded0..7eb69bd794e 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.inl +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/AngularSpringForceField.inl @@ -145,7 +145,7 @@ void AngularSpringForceField::addDForce(const core::MechanicalParams* template -void AngularSpringForceField::addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) +void AngularSpringForceField::doAddKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) { const int N = 6; const sofa::core::behavior::MultiMatrixAccessor::MatrixRef mref = matrix->getMatrix(this->mstate); @@ -163,7 +163,7 @@ void AngularSpringForceField::addKToMatrix(const core::MechanicalPara } template -void AngularSpringForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void AngularSpringForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) .withRespectToPositionsIn(this->mstate); @@ -193,7 +193,7 @@ void AngularSpringForceField::buildStiffnessMatrix(core::behavior::St } template -void AngularSpringForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void AngularSpringForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.h index f89a0514d21..a7e317938d0 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.h @@ -82,8 +82,8 @@ class FastTriangularBendingSprings : public core::behavior::ForceField< _DataTyp void addForce(const core::MechanicalParams* mparams, DataVecDeriv& d_f, const DataVecCoord& d_x, const DataVecDeriv& d_v) override; void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; void addKToMatrix(sofa::linearalgebra::BaseMatrix *mat, SReal k, unsigned int &offset) override; // compute and add all the element stiffnesses to the global stiffness matrix - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* mparams, const DataVecCoord& d_x) const override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.inl b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.inl index 5e798211b63..7dde2cccb6a 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.inl +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FastTriangularBendingSprings.inl @@ -433,7 +433,7 @@ void FastTriangularBendingSprings::addKToMatrix(sofa::linearalgebra:: } template -void FastTriangularBendingSprings<_DataTypes>::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void FastTriangularBendingSprings<_DataTypes>::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { static constexpr auto blockSize = DataTypes::deriv_total_size; static constexpr auto spatialDimension = DataTypes::spatial_dimensions; @@ -458,7 +458,7 @@ void FastTriangularBendingSprings<_DataTypes>::buildStiffnessMatrix(core::behavi } template -void FastTriangularBendingSprings<_DataTypes>::buildDampingMatrix(core::behavior::DampingMatrix*) +void FastTriangularBendingSprings<_DataTypes>::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.h index 6896b63d2e2..1d7ac74e12f 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/FrameSpringForceField.h @@ -186,7 +186,7 @@ class FrameSpringForceField : public core::behavior::PairInteractionForceField::addDForce(const core::MechanicalParams* / } template -void FrameSpringForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void FrameSpringForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.h index 56e9e9b0bbf..426fd381f47 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/GearSpringForceField.h @@ -213,7 +213,7 @@ class GearSpringForceField : public core::behavior::PairInteractionForceField::addDForce(const core::MechanicalParams *mp } template -void GearSpringForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void GearSpringForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.h index c3d0c4e2251..aa48818f613 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/JointSpringForceField.h @@ -123,7 +123,7 @@ class JointSpringForceField : public core::behavior::PairInteractionForceField::addDForce(const core::MechanicalParams *m } template -void JointSpringForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void JointSpringForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.h index 0186434fb40..febab011bb2 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialRestShapeSpringsForceField.h @@ -126,10 +126,10 @@ class PolynomialRestShapeSpringsForceField : public core::behavior::ForceField::draw(const core::visual::V template -void PolynomialRestShapeSpringsForceField::addKToMatrix(const core::MechanicalParams* mparams, +void PolynomialRestShapeSpringsForceField::doAddKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) { msg_info() << "[" << this->getName() << "]: addKToMatrix"; @@ -477,7 +477,7 @@ void PolynomialRestShapeSpringsForceField::addKToMatrix(const core::M } template -void PolynomialRestShapeSpringsForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void PolynomialRestShapeSpringsForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { static constexpr sofa::SignedIndex Dimension = Coord::total_size; @@ -496,7 +496,7 @@ void PolynomialRestShapeSpringsForceField::buildStiffnessMatrix(core: } template -void PolynomialRestShapeSpringsForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void PolynomialRestShapeSpringsForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.h index 6d8e692a021..06a12d50d49 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.h @@ -125,11 +125,11 @@ class PolynomialSpringsForceField : public core::behavior::PairInteractionForceF const DataVecDeriv& data_dx1, const DataVecDeriv& data_dx2) override; /// Brings ForceField contribution to the global system stiffness matrix. - virtual void addKToMatrix(const core::MechanicalParams* mparams, const core::behavior::MultiMatrixAccessor* matrix) override; + virtual void doAddKToMatrix(const core::MechanicalParams* mparams, const core::behavior::MultiMatrixAccessor* matrix) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; virtual void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.inl b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.inl index 3c718a63ddb..ce6ecf04820 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.inl +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/PolynomialSpringsForceField.inl @@ -394,7 +394,7 @@ void PolynomialSpringsForceField::draw(const core::visual::VisualPara } template -void PolynomialSpringsForceField::addKToMatrix(const core::MechanicalParams* mparams, +void PolynomialSpringsForceField::doAddKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) { msg_info() << "[" << this->getName() << "]: addKToMatrix"; @@ -459,7 +459,7 @@ void PolynomialSpringsForceField::addKToMatrix(const core::Mechanical } template -void PolynomialSpringsForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void PolynomialSpringsForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { unsigned int firstIndex = 0; unsigned int secondIndex = 0; @@ -525,7 +525,7 @@ void PolynomialSpringsForceField::buildStiffnessMatrix(core::behavior } template -void PolynomialSpringsForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void PolynomialSpringsForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.h index c77f0e7ffa7..ce29058b5b2 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.h @@ -120,8 +120,8 @@ class QuadularBendingSprings : public core::behavior::ForceField void addForce(const core::MechanicalParams* mparams, DataVecDeriv& d_f, const DataVecCoord& d_x, const DataVecDeriv& d_v) override; void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* /* mparams */, const DataVecCoord& /* d_x */) const override; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.inl b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.inl index b1e6df35014..d715dfff3d0 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.inl +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/QuadularBendingSprings.inl @@ -557,7 +557,7 @@ void QuadularBendingSprings::addDForce(const core::MechanicalParams* } template -void QuadularBendingSprings::buildStiffnessMatrix( +void QuadularBendingSprings::doBuildStiffnessMatrix( core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) @@ -586,7 +586,7 @@ void QuadularBendingSprings::buildStiffnessMatrix( } template -void QuadularBendingSprings::buildDampingMatrix(core::behavior::DampingMatrix*) +void QuadularBendingSprings::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.h index bba03aad7c0..387a56b58de 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.h @@ -111,9 +111,9 @@ class RestShapeSpringsForceField : public core::behavior::ForceField } /// Brings ForceField contribution to the global system stiffness matrix. - void addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* matrix) override; + void doAddKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) override; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* matrix) override; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.inl b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.inl index c62e448f5e6..b7e3f0c8614 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.inl +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/RestShapeSpringsForceField.inl @@ -543,7 +543,7 @@ void RestShapeSpringsForceField::draw(const VisualParams *vparams) } template -void RestShapeSpringsForceField::addKToMatrix(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix ) +void RestShapeSpringsForceField::doAddKToMatrix(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix ) { const MultiMatrixAccessor::MatrixRef mref = matrix->getMatrix(this->mstate); BaseMatrix* mat = mref.matrix; @@ -589,7 +589,7 @@ void RestShapeSpringsForceField::addKToMatrix(const MechanicalParams* } template -void RestShapeSpringsForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void RestShapeSpringsForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { const VecReal& k = d_stiffness.getValue(); const VecReal& k_a = d_angularStiffness.getValue(); @@ -628,7 +628,7 @@ void RestShapeSpringsForceField::buildStiffnessMatrix(core::behavior: } template -void RestShapeSpringsForceField::buildDampingMatrix( +void RestShapeSpringsForceField::doBuildDampingMatrix( core::behavior::DampingMatrix* matrix) { SOFA_UNUSED(matrix); diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.h index ab6568d8d6d..318f4abcf8f 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/SpringForceField.h @@ -96,9 +96,9 @@ class SpringForceField : public core::behavior::PairInteractionForceField::addToMatrix(Matrix* globalMatrix, } template -void SpringForceField::addKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void SpringForceField::doAddKToMatrix(const core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) { const Real kFact = (Real)sofa::core::mechanicalparams::kFactorIncludingRayleighDamping(mparams,this->rayleighStiffness.getValue()); if (this->mstate1 == this->mstate2) @@ -733,7 +733,7 @@ void SpringForceField::addKToMatrix(const core::MechanicalParams* mpa } template -void SpringForceField::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void SpringForceField::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { const sofa::type::vector& ss = this->d_springs.getValue(); const auto n = std::min(ss.size(), this->dfdx.size()); @@ -795,7 +795,7 @@ void SpringForceField::buildStiffnessMatrix(core::behavior::Stiffness } template -void SpringForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void SpringForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.h index 4d7c2a04e14..6b7efe7f088 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.h @@ -139,8 +139,8 @@ class TriangularBendingSprings : public core::behavior::ForceField void addForce(const core::MechanicalParams* mparams, DataVecDeriv& d_f, const DataVecCoord& d_x, const DataVecDeriv& d_v) override; void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; - void buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) override; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; void draw(const core::visual::VisualParams* vparams) override; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.inl b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.inl index 5e06620876f..8d75d082ce6 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.inl +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBendingSprings.inl @@ -526,7 +526,7 @@ void TriangularBendingSprings::addDForce(const core::MechanicalParams } template -void TriangularBendingSprings::buildStiffnessMatrix( +void TriangularBendingSprings::doBuildStiffnessMatrix( core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) @@ -553,7 +553,7 @@ void TriangularBendingSprings::buildStiffnessMatrix( } template -void TriangularBendingSprings::buildDampingMatrix(core::behavior::DampingMatrix*) +void TriangularBendingSprings::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.h index ca2da174cd8..afd9e497ad4 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.h @@ -152,7 +152,7 @@ class TriangularBiquadraticSpringsForceField : public core::behavior::ForceField void addForce(const core::MechanicalParams* mparams, DataVecDeriv& d_f, const DataVecCoord& d_x, const DataVecDeriv& d_v) override; void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df, const DataVecDeriv& d_dx) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override { msg_warning() << "Method getPotentialEnergy not implemented yet."; diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.inl b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.inl index 71f30cb6252..28611c8c475 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.inl +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularBiquadraticSpringsForceField.inl @@ -520,7 +520,7 @@ void TriangularBiquadraticSpringsForceField::addDForce(const core::Me } template -void TriangularBiquadraticSpringsForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TriangularBiquadraticSpringsForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.h index 5d0ef97bf44..2b958f5c4b2 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/TriangularQuadraticSpringsForceField.h @@ -136,7 +136,7 @@ class TriangularQuadraticSpringsForceField : public core::behavior::ForceField::addDForce(const core::Mech } template -void TriangularQuadraticSpringsForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TriangularQuadraticSpringsForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.h b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.h index b896bfd5a1a..8a5b02b6933 100644 --- a/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.h +++ b/Sofa/Component/SolidMechanics/Spring/src/sofa/component/solidmechanics/spring/VectorSpringForceField.h @@ -139,7 +139,7 @@ class VectorSpringForceField: public core::behavior::PairInteractionForceField::addDForce(const core::MechanicalParams* } template -void VectorSpringForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void VectorSpringForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.h b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.h index 8a02630cb23..f01cbc164f9 100644 --- a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.h +++ b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TetrahedralTensorMassForceField.h @@ -107,18 +107,14 @@ class TetrahedralTensorMassForceField : public core::behavior::ForceField::initNeighbourhoodPoints() {} template -SReal TetrahedralTensorMassForceField::getPotentialEnergy(const core::MechanicalParams* /* mparams */) const +SReal TetrahedralTensorMassForceField::getPotentialEnergy(const sofa::core::MechanicalParams* mparams, const DataVecCoord& pos) const { SCOPED_TIMER("getPotentialEnergy"); + SOFA_UNUSED(mparams); - const VecCoord& x = this->mstate->read(core::vec_id::read_access::position)->getValue(); - + sofa::helper::ReadAccessor< Data< VecCoord > > x = pos; SReal energy=0; unsigned int v0,v1; @@ -447,7 +447,7 @@ void TetrahedralTensorMassForceField::addDForce(const core::Mechanica } template -void TetrahedralTensorMassForceField::buildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) +void TetrahedralTensorMassForceField::doBuildStiffnessMatrix(sofa::core::behavior::StiffnessMatrix* matrix) { auto dfdx = matrix->getForceDerivativeIn(this->mstate) .withRespectToPositionsIn(this->mstate); @@ -474,7 +474,7 @@ void TetrahedralTensorMassForceField::buildStiffnessMatrix(sofa::core } template -void TetrahedralTensorMassForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TetrahedralTensorMassForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.h b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.h index 1a1778334aa..9265b16c710 100644 --- a/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.h +++ b/Sofa/Component/SolidMechanics/TensorMass/src/sofa/component/solidmechanics/tensormass/TriangularTensorMassForceField.h @@ -137,7 +137,7 @@ class TriangularTensorMassForceField : public core::behavior::ForceField::addDForce(const core::Mechanical } template -void TriangularTensorMassForceField::buildDampingMatrix(core::behavior::DampingMatrix*) +void TriangularTensorMassForceField::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.cpp b/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.cpp index d4cc43b94c2..fbc98d83804 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.cpp +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.cpp @@ -36,6 +36,36 @@ BaseForceField::BaseForceField() { } +void BaseForceField::addForce(const MechanicalParams* mparams, MultiVecDerivId fId ) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAddForce(mparams, fId); +} + +void BaseForceField::addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAddDForce(mparams, dfId); +} + +SReal BaseForceField::getPotentialEnergy( const MechanicalParams* mparams ) const +{ + //TODO (SPRINT SED 2025): Component state mechanism + return doGetPotentialEnergy(mparams); +} + +void BaseForceField::addKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAddKToMatrix(mparams, matrix); +} + +void BaseForceField::addBToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAddBToMatrix(mparams, matrix); +} + void BaseForceField::addMBKdx(const MechanicalParams* mparams, MultiVecDerivId dfId) { const auto kFactor = sofa::core::mechanicalparams::kFactorIncludingRayleighDamping(mparams,rayleighStiffness.getValue()); @@ -47,10 +77,6 @@ void BaseForceField::addMBKdx(const MechanicalParams* mparams, MultiVecDerivId d } } -void BaseForceField::addBToMatrix(const MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/) -{ -} - void BaseForceField::addMBKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) { if (sofa::core::mechanicalparams::kFactorIncludingRayleighDamping(mparams,rayleighStiffness.getValue()) != 0.0 ) @@ -60,6 +86,12 @@ void BaseForceField::addMBKToMatrix(const MechanicalParams* mparams, const sofa: } void BaseForceField::buildStiffnessMatrix(StiffnessMatrix* matrix) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doBuildStiffnessMatrix(matrix); +} + +void BaseForceField::doBuildStiffnessMatrix(StiffnessMatrix* matrix) { static std::set hasEmittedWarning; if (hasEmittedWarning.insert(this).second) @@ -101,10 +133,16 @@ void BaseForceField::buildStiffnessMatrix(StiffnessMatrix* matrix) params.setKFactor(1.); params.setMFactor(1.); - addKToMatrix(¶ms, &accessor); + doAddKToMatrix(¶ms, &accessor); } void BaseForceField::buildDampingMatrix(DampingMatrix* matrix) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doBuildDampingMatrix(matrix); +} + +void BaseForceField::doBuildDampingMatrix(DampingMatrix* matrix) { static std::set hasEmittedWarning; if (hasEmittedWarning.insert(this).second) @@ -146,7 +184,7 @@ void BaseForceField::buildDampingMatrix(DampingMatrix* matrix) params.setKFactor(1.); params.setMFactor(1.); - addBToMatrix(¶ms, &accessor); + doAddBToMatrix(¶ms, &accessor); } bool BaseForceField::insertInNode( objectmodel::BaseNode* node ) diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.h b/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.h index 63a704eb319..3252bbaf670 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseForceField.h @@ -55,6 +55,14 @@ class SOFA_CORE_API BaseForceField : public virtual StateAccessor BaseForceField(); ~BaseForceField() override = default; + virtual void doAddForce(const MechanicalParams* mparams, MultiVecDerivId fId ) = 0; + virtual void doAddDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) = 0; + virtual SReal doGetPotentialEnergy( const MechanicalParams* mparams ) const = 0; + virtual void doAddKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) = 0; + virtual void doAddBToMatrix(const MechanicalParams* /*mparams*/, const sofa::core::behavior::MultiMatrixAccessor* /*matrix*/ ) { }; + virtual void doBuildStiffnessMatrix(StiffnessMatrix* matrix); + virtual void doBuildDampingMatrix(DampingMatrix* matrix); + private: BaseForceField(const BaseForceField& n) = delete; BaseForceField& operator=(const BaseForceField& n) = delete; @@ -64,6 +72,15 @@ class SOFA_CORE_API BaseForceField : public virtual StateAccessor /// @name Vector operations /// @{ + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAddForce" internally, + * which is the method to override from now on. + * + **/ + /// \brief Given the current position and velocity states, update the current force /// vector by computing and adding the forces associated with this /// ForceField. @@ -85,8 +102,17 @@ class SOFA_CORE_API BaseForceField : public virtual StateAccessor /// - if \a mparams->energy() is true, the method computes and internally stores the potential energy, /// which will be subsequently returned by method getPotentialEnergy() /// \param fId the output vector of forces - virtual void addForce(const MechanicalParams* mparams, MultiVecDerivId fId )=0; - + virtual void addForce(const MechanicalParams* mparams, MultiVecDerivId fId ) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAddDForce" internally, + * which is the method to override from now on. + * + **/ + /// \brief Compute the force derivative given a small displacement from the /// position and velocity used in the previous call to addForce(). /// @@ -106,7 +132,7 @@ class SOFA_CORE_API BaseForceField : public virtual StateAccessor /// - \a mparams->kFactor() is the coefficient for stiffness contributions (i.e. DOFs term in the ODE) /// - \a mparams->readDx() input vector /// \param dfId the output vector - virtual void addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId )=0; + virtual void addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) final; /// \brief Accumulate the contribution of M, B, and/or K matrices multiplied /// by the dx vector with the given coefficients. @@ -132,30 +158,56 @@ class SOFA_CORE_API BaseForceField : public virtual StateAccessor /// \param dfId the output vector virtual void addMBKdx(const MechanicalParams* mparams, MultiVecDerivId dfId); + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doGetPotentialEnergy" internally, + * which is the method to override from now on. + * + **/ + /// \brief Get the potential energy associated to this ForceField during the /// last call of addForce( const MechanicalParams* mparams ); /// /// Used to estimate the total energy of the system by some /// post-stabilization techniques. - virtual SReal getPotentialEnergy( const MechanicalParams* mparams = mechanicalparams::defaultInstance() ) const=0; + virtual SReal getPotentialEnergy( const MechanicalParams* mparams = mechanicalparams::defaultInstance() ) const final; /// @} /// @name Matrix operations /// @{ + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAddKToMatrix" internally, + * which is the method to override from now on. + * + **/ + /// \brief Compute the system matrix corresponding to \f$ k K \f$ /// /// \param mparams \a mparams->kFactor() is the coefficient for stiffness contributions (i.e. DOFs term in the ODE) /// \param matrix the matrix to add the result to - virtual void addKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) = 0; + virtual void addKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAddBToMatrix" internally, + * which is the method to override from now on. + * + **/ /// \brief Compute the system matrix corresponding to \f$ b B \f$ /// /// \param mparams \a sofa::core::mechanicalparams::bFactor(mparams) is the coefficient for damping contributions (i.e. first derivatives term in the ODE) /// \param matrix the matrix to add the result to - virtual void addBToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ); - //virtual void addBToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal bFact, unsigned int &offset); + virtual void addBToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) final; /// \brief Compute the system matrix corresponding to \f$ m M + b B + k K \f$ /// @@ -165,11 +217,28 @@ class SOFA_CORE_API BaseForceField : public virtual StateAccessor /// - \a mparams->kFactor() is the coefficient for stiffness contributions (i.e. DOFs term in the ODE) /// \param matrix the matrix to add the result to virtual void addMBKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ); - ////virtual void addMBKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal mFact, SReal bFact, SReal kFact, unsigned int &offset); - - virtual void buildStiffnessMatrix(StiffnessMatrix* matrix); - virtual void buildDampingMatrix(DampingMatrix* matrix); + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doBuildStiffnessMatrix" internally, + * which is the method to override from now on. + * + **/ + + virtual void buildStiffnessMatrix(StiffnessMatrix* matrix) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doBuildDampingMatrix" internally, + * which is the method to override from now on. + * + **/ + + virtual void buildDampingMatrix(DampingMatrix* matrix) final; /// @} diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseInteractionForceField.h b/Sofa/framework/Core/src/sofa/core/behavior/BaseInteractionForceField.h index 3bf36e8d422..84977c70edd 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseInteractionForceField.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseInteractionForceField.h @@ -48,12 +48,11 @@ class SOFA_CORE_API BaseInteractionForceField : public BaseForceField /// \todo Rename to getMechState2() virtual BaseMechanicalState* getMechModel2(); - void addKToMatrix(const MechanicalParams* /* mparams */, const sofa::core::behavior::MultiMatrixAccessor* /* matrix */ ) override + void doAddKToMatrix(const MechanicalParams* /* mparams */, const sofa::core::behavior::MultiMatrixAccessor* /* matrix */ ) override { msg_error() << "addKToMatrix not implemented."; } - /// initialization to export potential energy to gnuplot files format virtual void initGnuplot(const std::string path) { diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseLagrangianConstraint.h b/Sofa/framework/Core/src/sofa/core/behavior/BaseLagrangianConstraint.h index 29483011a2f..ad0bbaec94f 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseLagrangianConstraint.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseLagrangianConstraint.h @@ -81,7 +81,6 @@ class SOFA_CORE_API BaseLagrangianConstraint : public BaseConstraintSet /// \param cParams defines the state vectors to use for positions and velocities. Also defines the order of the constraint (POS, VEL, ACC) and resolution parameters (smoothness, ...) virtual void getConstraintInfo(const ConstraintParams* cParams, VecConstraintBlockInfo& blocks, VecPersistentID& ids); - //DEPRECATED(v25.06, v25.12) typedef sofa::type::vector> VecConstCoord; typedef sofa::type::vector> VecConstDeriv; diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.cpp b/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.cpp index 340ee5a4ae9..ecb44d8e02d 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.cpp +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.cpp @@ -35,6 +35,78 @@ BaseMass::BaseMass() { } +void BaseMass::addMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAddMDx(mparams, fid, factor); +} + +void BaseMass::accFromF(const MechanicalParams* mparams, MultiVecDerivId aid) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAccFromF(mparams, aid); +} + +void BaseMass::addGravityToV(const MechanicalParams* mparams, MultiVecDerivId vid) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAddGravityToV(mparams, vid); +} + +SReal BaseMass::getKineticEnergy(const MechanicalParams* mparams) const +{ + //TODO (SPRINT SED 2025): Component state mechanism + return doGetKineticEnergy(mparams); +} + +SReal BaseMass::getPotentialEnergy(const MechanicalParams* mparams) const +{ + //TODO (SPRINT SED 2025): Component state mechanism + return doGetPotentialEnergy(mparams); +} + +type::Vec6 BaseMass::getMomentum(const MechanicalParams* mparams) const +{ + //TODO (SPRINT SED 2025): Component state mechanism + return doGetMomentum(mparams); +} + +void BaseMass::addMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doAddMToMatrix(mparams, matrix); +} + +void BaseMass::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doBuildMassMatrix(matrices); +} + +void BaseMass::initGnuplot(const std::string path) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doInitGnuplot(path); +} + +void BaseMass::exportGnuplot(const MechanicalParams* mparams, SReal time) +{ + //TODO (SPRINT SED 2025): Component state mechanism + doExportGnuplot(mparams, time); +} + +SReal BaseMass::getElementMass(sofa::Index index) const +{ + //TODO (SPRINT SED 2025): Component state mechanism + return doGetElementMass(index); +} + +void BaseMass::getElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const +{ + //TODO (SPRINT SED 2025): Component state mechanism + doGetElementMass(index, m); +} + bool BaseMass::insertInNode( objectmodel::BaseNode* node ) { node->addMass(this); @@ -49,7 +121,7 @@ bool BaseMass::removeInNode( objectmodel::BaseNode* node ) return true; } -void BaseMass::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) +void BaseMass::doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) { static std::set hasEmittedWarning; if (hasEmittedWarning.insert(this).second) diff --git a/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.h b/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.h index d2e28de59b5..dca10a427d1 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/BaseMass.h @@ -47,9 +47,21 @@ class SOFA_CORE_API BaseMass : public virtual StateAccessor protected: BaseMass(); - ~BaseMass() override = default; + virtual void doAddMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) = 0; + virtual void doAccFromF(const MechanicalParams* mparams, MultiVecDerivId aid) = 0; + virtual void doAddGravityToV(const MechanicalParams* mparams, MultiVecDerivId vid) = 0; + virtual SReal doGetKineticEnergy(const MechanicalParams* mparams) const = 0; + virtual SReal doGetPotentialEnergy(const MechanicalParams* mparams) const = 0; + virtual type::Vec6 doGetMomentum(const MechanicalParams* mparams) const = 0; + virtual void doAddMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) = 0; + virtual void doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices); + virtual void doInitGnuplot(const std::string path) = 0; + virtual void doExportGnuplot(const MechanicalParams* mparams, SReal time) = 0; + virtual SReal doGetElementMass(sofa::Index index) const = 0; + virtual void doGetElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const = 0; + private: BaseMass(const BaseMass& n) = delete; BaseMass& operator=(const BaseMass& n) = delete; @@ -58,51 +70,161 @@ class SOFA_CORE_API BaseMass : public virtual StateAccessor /// @name Vector operations /// @{ + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAddMDx", internally, + * which is the method to override from now on. + * + **/ + /// f += factor M dx - virtual void addMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) =0; + virtual void addMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAccFromF", internally, + * which is the method to override from now on. + * + **/ /// dx = M^-1 f - virtual void accFromF(const MechanicalParams* mparams, MultiVecDerivId aid) = 0; + virtual void accFromF(const MechanicalParams* mparams, MultiVecDerivId aid) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAddGravityToV", internally, + * which is the method to override from now on. + * + **/ /// \brief Perform v += dt*g operation. Used if mass wants to added G separately from the other forces to v. /// /// \param mparams \a sofa::core::mechanicalparams::dt(mparams) is the time step of for temporal discretization. - virtual void addGravityToV(const MechanicalParams* mparams, MultiVecDerivId vid) = 0; + virtual void addGravityToV(const MechanicalParams* mparams, MultiVecDerivId vid) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doGetKineticEnergy", internally, + * which is the method to override from now on. + * + **/ /// vMv/2 - virtual SReal getKineticEnergy(const MechanicalParams* mparams = mechanicalparams::defaultInstance()) const = 0; + virtual SReal getKineticEnergy(const MechanicalParams* mparams = mechanicalparams::defaultInstance()) const final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doGetPotentialEnergy", internally, + * which is the method to override from now on. + * + **/ + /// Mgx - virtual SReal getPotentialEnergy(const MechanicalParams* mparams = mechanicalparams::defaultInstance()) const = 0; + virtual SReal getPotentialEnergy(const MechanicalParams* mparams = mechanicalparams::defaultInstance()) const final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doGetMomentum", internally, + * which is the method to override from now on. + * + **/ /// (Mv,xMv+Iw) (linear and angular momenta against world origin) - virtual type::Vec6 getMomentum(const MechanicalParams* mparams = mechanicalparams::defaultInstance()) const = 0; + virtual type::Vec6 getMomentum(const MechanicalParams* mparams = mechanicalparams::defaultInstance()) const final; /// @} /// @name Matrix operations /// @{ + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doAddMToMatrix", internally, + * which is the method to override from now on. + * + **/ + /// \brief Add Mass contribution to global Matrix assembling. /// /// This method must be implemented by the component. /// \param matrix matrix to add the result to /// \param mparams \a mparams->mFactor() is the coefficient for mass contributions (i.e. second-order derivatives term in the ODE) - virtual void addMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) = 0; + virtual void addMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) final; - virtual void buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices); + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doBuildMassMatrix", internally, + * which is the method to override from now on. + * + **/ + + virtual void buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) final; /// @} + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doInitGnuplot", internally, + * which is the method to override from now on. + * + **/ + /// initialization to export kinetic and potential energy to gnuplot files format - virtual void initGnuplot(const std::string path)=0; + virtual void initGnuplot(const std::string path) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doExportGnuplot", internally, + * which is the method to override from now on. + * + **/ /// export kinetic and potential energy state at "time" to a gnuplot file - virtual void exportGnuplot(const MechanicalParams* mparams, SReal time)=0; + virtual void exportGnuplot(const MechanicalParams* mparams, SReal time) final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doGetElementMass", internally, + * which is the method to override from now on. + * + **/ /// Get the mass relative to the DOF at \a index. - virtual SReal getElementMass(sofa::Index index) const =0; + virtual SReal getElementMass(sofa::Index index) const final; + + /** + * !!! WARNING since v26.06 !!! + * + * The template method pattern has been applied to this part of the API. + * This method calls the newly introduced method "doGetElementMass", internally, + * which is the method to override from now on. + * + **/ + /// Get the matrix relative to the DOF at \a index. - virtual void getElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const = 0; + virtual void getElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const final; virtual bool isDiagonal() const = 0; diff --git a/Sofa/framework/Core/src/sofa/core/behavior/ForceField.h b/Sofa/framework/Core/src/sofa/core/behavior/ForceField.h index fd493afff0f..9e4b6245b7b 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/ForceField.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/ForceField.h @@ -55,10 +55,20 @@ class ForceField : public BaseForceField, public virtual SingleStateAccessor DataVecCoord; typedef core::objectmodel::Data DataVecDeriv; + + // Avoid warning : hidden [-Woverloaded-virtual=] + using BaseForceField::addForce; + using BaseForceField::addDForce; + using BaseForceField::getPotentialEnergy; + using BaseForceField::addKToMatrix; + using BaseForceField::addBToMatrix; + using BaseForceField::buildStiffnessMatrix; + using BaseForceField::buildDampingMatrix; + protected: explicit ForceField(MechanicalState *mm = nullptr); - ~ForceField() override; + public: /// @name Vector operations @@ -74,7 +84,7 @@ class ForceField : public BaseForceField, public virtual SingleStateAccessor ForceField::~ForceField() = default; template -void ForceField::addForce(const MechanicalParams* mparams, MultiVecDerivId fId ) +void ForceField::doAddForce(const MechanicalParams* mparams, MultiVecDerivId fId ) { auto mstate = this->mstate.get(); if (mparams && mstate) @@ -51,7 +51,7 @@ void ForceField::addForce(const MechanicalParams* mparams, MultiVecDe } template -void ForceField::addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) +void ForceField::doAddDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) { if (mparams && this->mstate) { @@ -77,7 +77,7 @@ void ForceField::addDForce(const MechanicalParams* mparams, MultiVecD } template -SReal ForceField::getPotentialEnergy(const MechanicalParams* mparams) const +SReal ForceField::doGetPotentialEnergy(const MechanicalParams* mparams) const { if (this->mstate) return getPotentialEnergy(mparams, *mparams->readX(this->mstate.get())); @@ -85,7 +85,7 @@ SReal ForceField::getPotentialEnergy(const MechanicalParams* mparams) } template -void ForceField::addKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) +void ForceField::doAddKToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix ) { if (this->mstate) { @@ -99,19 +99,14 @@ void ForceField::addKToMatrix(const MechanicalParams* mparams, const template void ForceField::addKToMatrix(sofa::linearalgebra::BaseMatrix * /*mat*/, SReal /*kFact*/, unsigned int &/*offset*/) { - static int i=0; - if (i < 10) - { - // This function is called for implicit time integration where stiffness matrix assembly is expected - msg_warning() << "This force field does not support stiffness matrix assembly. " - "Therefore, the forces are integrated explicitly. " - "To support stiffness matrix assembly, addKToMatrix must be implemented."; - i++; - } + // This function is called for implicit time integration where stiffness matrix assembly is expected + msg_warning() << "This force field does not support stiffness matrix assembly. " + "Therefore, the forces are integrated explicitly. " + "To support stiffness matrix assembly, addKToMatrix must be implemented."; } template -void ForceField::addBToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void ForceField::doAddBToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) { if (this->mstate) { diff --git a/Sofa/framework/Core/src/sofa/core/behavior/Mass.h b/Sofa/framework/Core/src/sofa/core/behavior/Mass.h index 1dec7f93119..a2d6f03bdf2 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/Mass.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/Mass.h @@ -54,17 +54,26 @@ class Mass : virtual public ForceField, public BaseMass protected: Mass(MechanicalState *mm = nullptr); - ~Mass() override; + public: + // Avoid warning : hidden [-Woverloaded-virtual=] + using BaseMass::addMDx; + using BaseMass::accFromF; + using BaseMass::getKineticEnergy; + using BaseMass::getPotentialEnergy; + using BaseMass::getMomentum; + using BaseMass::addMToMatrix; + using BaseMass::addGravityToV; + /// @name Vector operations /// @{ /// $ f += factor M dx $ /// /// This method retrieves the force and dx vector and call the internal /// addMDx(const MechanicalParams*, DataVecDeriv&, const DataVecDeriv&, SReal) method implemented by the component. - void addMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) override; + void doAddMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) override; virtual void addMDx(const MechanicalParams* mparams, DataVecDeriv& f, const DataVecDeriv& dx, SReal factor); @@ -72,7 +81,7 @@ class Mass : virtual public ForceField, public BaseMass /// /// This method retrieves the force and dx vector and call the internal /// accFromF(VecDeriv&,const VecDeriv&) method implemented by the component. - void accFromF(const MechanicalParams* mparams, MultiVecDerivId aid) override; + void doAccFromF(const MechanicalParams* mparams, MultiVecDerivId aid) override; virtual void accFromF(const MechanicalParams* mparams, DataVecDeriv& a, const DataVecDeriv& f); @@ -96,14 +105,14 @@ class Mass : virtual public ForceField, public BaseMass /// /// This method retrieves the velocity vector and call the internal /// getKineticEnergy(const MechanicalParams*, const DataVecDeriv&) method implemented by the component. - SReal getKineticEnergy( const MechanicalParams* mparams) const override; + SReal doGetKineticEnergy( const MechanicalParams* mparams) const override; virtual SReal getKineticEnergy( const MechanicalParams* mparams, const DataVecDeriv& v) const; /// $ e = M g x $ /// /// This method retrieves the positions vector and call the internal /// getPotentialEnergy(const MechanicalParams*, const VecCoord&) method implemented by the component. - SReal getPotentialEnergy( const MechanicalParams* mparams) const override; + SReal doGetPotentialEnergy( const MechanicalParams* mparams) const override; SReal getPotentialEnergy( const MechanicalParams* mparams, const DataVecCoord& x ) const override; @@ -112,7 +121,7 @@ class Mass : virtual public ForceField, public BaseMass /// /// This method retrieves the positions and velocity vectors and call the internal /// getMomentum(const MechanicalParams*, const VecCoord&, const VecDeriv&) method implemented by the component. - type::Vec6 getMomentum( const MechanicalParams* mparams ) const override; + type::Vec6 doGetMomentum( const MechanicalParams* mparams ) const override; virtual type::Vec6 getMomentum( const MechanicalParams* , const DataVecCoord& , const DataVecDeriv& ) const; @@ -125,7 +134,7 @@ class Mass : virtual public ForceField, public BaseMass void addKToMatrix(sofa::linearalgebra::BaseMatrix * /*matrix*/, SReal /*kFact*/, unsigned int &/*offset*/) override {} void addBToMatrix(sofa::linearalgebra::BaseMatrix * /*matrix*/, SReal /*bFact*/, unsigned int &/*offset*/) override {} - void addMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void doAddMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; virtual void addMToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal mFact, unsigned int &offset); @@ -140,19 +149,19 @@ class Mass : virtual public ForceField, public BaseMass /// @} /// initialization to export kinetic and potential energy to gnuplot files format - void initGnuplot(const std::string path) override; + void doInitGnuplot(const std::string path) override; /// export kinetic and potential energy state at "time" to a gnuplot file - void exportGnuplot(const MechanicalParams* mparams, SReal time) override; + void doExportGnuplot(const MechanicalParams* mparams, SReal time) override; /// perform v += dt*g operation. Used if mass wants to added G separately from the other forces to v. - void addGravityToV(const MechanicalParams* mparams, MultiVecDerivId /*vid*/) override; + void doAddGravityToV(const MechanicalParams* mparams, MultiVecDerivId /*vid*/) override; virtual void addGravityToV(const MechanicalParams* /* mparams */, DataVecDeriv& /* d_v */); /// recover the mass of an element - SReal getElementMass(sofa::Index) const override; - void getElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const override; + SReal doGetElementMass(sofa::Index) const override; + void doGetElementMass(sofa::Index index, linearalgebra::BaseMatrix *m) const override; protected: /// stream to export Kinematic, Potential and Mechanical Energy to gnuplot files diff --git a/Sofa/framework/Core/src/sofa/core/behavior/Mass.inl b/Sofa/framework/Core/src/sofa/core/behavior/Mass.inl index 88f94b7bea5..6bb9dd604f7 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/Mass.inl +++ b/Sofa/framework/Core/src/sofa/core/behavior/Mass.inl @@ -45,7 +45,7 @@ Mass::~Mass() } template -void Mass::addMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) +void Mass::doAddMDx(const MechanicalParams* mparams, MultiVecDerivId fid, SReal factor) { if (mparams) { @@ -62,7 +62,7 @@ void Mass::addMDx(const MechanicalParams* /*mparams*/, DataVecDeriv& template -void Mass::accFromF(const MechanicalParams* mparams, MultiVecDerivId aid) +void Mass::doAccFromF(const MechanicalParams* mparams, MultiVecDerivId aid) { if(mparams) { @@ -98,7 +98,7 @@ void Mass::addMBKdx(const MechanicalParams* mparams, MultiVecDerivId } template -SReal Mass::getKineticEnergy(const MechanicalParams* mparams) const +SReal Mass::doGetKineticEnergy(const MechanicalParams* mparams) const { if (this->mstate) return getKineticEnergy(mparams /* PARAMS FIRST */, *mparams->readV(this->mstate.get())); @@ -114,7 +114,7 @@ SReal Mass::getKineticEnergy(const MechanicalParams* /*mparams*/, con template -SReal Mass::getPotentialEnergy(const MechanicalParams* mparams) const +SReal Mass::doGetPotentialEnergy(const MechanicalParams* mparams) const { if (this->mstate) return getPotentialEnergy(mparams /* PARAMS FIRST */, *mparams->readX(this->mstate.get())); @@ -130,7 +130,7 @@ SReal Mass::getPotentialEnergy(const MechanicalParams* /*mparams*/, c template -type::Vec6 Mass::getMomentum( const MechanicalParams* mparams ) const +type::Vec6 Mass::doGetMomentum( const MechanicalParams* mparams ) const { auto state = this->mstate.get(); if (state) @@ -148,7 +148,7 @@ type::Vec6 Mass::getMomentum( const MechanicalParams* /*mparams*/, co template -void Mass::addMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void Mass::doAddMToMatrix(const MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) { sofa::core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate); if (r) @@ -158,11 +158,7 @@ void Mass::addMToMatrix(const MechanicalParams* mparams, const sofa:: template void Mass::addMToMatrix(sofa::linearalgebra::BaseMatrix * /*mat*/, SReal /*mFact*/, unsigned int &/*offset*/) { - static int i=0; - if (i < 10) { - msg_warning() << "Method addMToMatrix with Scalar not implemented"; - i++; - } + msg_warning() << "Method addMToMatrix with Scalar not implemented"; } template @@ -170,11 +166,11 @@ void Mass::addMBKToMatrix(const MechanicalParams* mparams, const sofa { this->ForceField::addMBKToMatrix(mparams, matrix); if (mparams->mFactorIncludingRayleighDamping(rayleighMass.getValue()) != 0.0) - addMToMatrix(mparams, matrix); + BaseMass::addMToMatrix(mparams, matrix); } template -void Mass::addGravityToV(const MechanicalParams* mparams, MultiVecDerivId vid) +void Mass::doAddGravityToV(const MechanicalParams* mparams, MultiVecDerivId vid) { if(this->mstate) { @@ -186,16 +182,12 @@ void Mass::addGravityToV(const MechanicalParams* mparams, MultiVecDer template void Mass::addGravityToV(const MechanicalParams* /* mparams */, DataVecDeriv& /* d_v */) { - static int i=0; - if (i < 10) { - msg_warning() << "Method addGravityToV with Scalar not implemented"; - i++; - } + msg_warning() << "Method addGravityToV with Scalar not implemented"; } template -void Mass::initGnuplot(const std::string path) +void Mass::doInitGnuplot(const std::string path) { if (!this->getName().empty()) { @@ -207,26 +199,26 @@ void Mass::initGnuplot(const std::string path) } template -void Mass::exportGnuplot(const MechanicalParams* mparams, SReal time) +void Mass::doExportGnuplot(const MechanicalParams* mparams, SReal time) { if (m_gnuplotFileEnergy!=nullptr) { - (*m_gnuplotFileEnergy) << time <<"\t"<< this->getKineticEnergy(mparams) - <<"\t"<< this->getPotentialEnergy(mparams) - <<"\t"<< this->getPotentialEnergy(mparams) - +this->getKineticEnergy(mparams)<< std::endl; + (*m_gnuplotFileEnergy) << time <<"\t"<< BaseMass::getKineticEnergy(mparams) + <<"\t"<< BaseMass::getPotentialEnergy(mparams) + <<"\t"<< BaseMass::getPotentialEnergy(mparams) + +BaseMass::getKineticEnergy(mparams)<< std::endl; } } template -SReal Mass::getElementMass(sofa::Index ) const +SReal Mass::doGetElementMass(sofa::Index ) const { msg_warning() << "Method getElementMass with Scalar not implemented"; return 0.0; } template -void Mass::getElementMass(sofa::Index, linearalgebra::BaseMatrix *m) const +void Mass::doGetElementMass(sofa::Index, linearalgebra::BaseMatrix *m) const { static const linearalgebra::BaseMatrix::Index dimension = (linearalgebra::BaseMatrix::Index) defaulttype::DataTypeInfo::size(); if (m->rowSize() != dimension || m->colSize() != dimension) m->resize(dimension,dimension); diff --git a/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.h b/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.h index 8d7ee120809..efe5d4f0c90 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.h @@ -61,6 +61,13 @@ class MixedInteractionForceField : public BaseInteractionForceField, public Pair typedef core::objectmodel::Data DataVecCoord2; typedef core::objectmodel::Data DataVecDeriv2; + // Avoid warning : hidden [-Woverloaded-virtual=] + using BaseForceField::addForce; + using BaseForceField::addDForce; + using BaseForceField::getPotentialEnergy; + using BaseInteractionForceField::getMechModel1; + using BaseInteractionForceField::getMechModel2; + protected: explicit MixedInteractionForceField(MechanicalState *mm1 = nullptr, MechanicalState *mm2 = nullptr); @@ -80,7 +87,7 @@ class MixedInteractionForceField : public BaseInteractionForceField, public Pair /// This method retrieves the force, x and v vector from the two MechanicalState /// and call the internal addForce(VecDeriv&,VecDeriv&,const VecCoord&,const VecCoord&,const VecDeriv&,const VecDeriv&) /// method implemented by the component. - void addForce(const MechanicalParams* mparams, MultiVecDerivId fId ) override; + void doAddForce(const MechanicalParams* mparams, MultiVecDerivId fId ) override; /// Compute the force derivative given a small displacement from the /// position and velocity used in the previous call to addForce(). @@ -95,19 +102,9 @@ class MixedInteractionForceField : public BaseInteractionForceField, public Pair /// This method retrieves the force and dx vector from the two MechanicalState /// and call the internal addDForce(VecDeriv1&,VecDeriv2&,const VecDeriv1&,const VecDeriv2&,SReal,SReal) /// method implemented by the component. - void addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) override; + void doAddDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) override; - /// Get the potential energy associated to this ForceField. - /// - /// Used to estimate the total energy of the system by some - /// post-stabilization techniques. - /// - /// This method retrieves the x vector from the MechanicalState and call - /// the internal getPotentialEnergy(const VecCoord&,const VecCoord&) method implemented by - /// the component. - SReal getPotentialEnergy(const MechanicalParams* mparams) const override; - /// Given the current position and velocity states, update the current force /// vector by computing and adding the forces associated with this /// ForceField. @@ -135,6 +132,17 @@ class MixedInteractionForceField : public BaseInteractionForceField, public Pair virtual void addDForce(const MechanicalParams* mparams, DataVecDeriv1& df1, DataVecDeriv2& df2, const DataVecDeriv1& dx1, const DataVecDeriv2& dx2)=0; + + /// Get the potential energy associated to this ForceField. + /// + /// Used to estimate the total energy of the system by some + /// post-stabilization techniques. + /// + /// This method retrieves the x vector from the MechanicalState and call + /// the internal getPotentialEnergy(const VecCoord&,const VecCoord&) method implemented by + /// the component. + SReal doGetPotentialEnergy(const MechanicalParams* mparams) const override; + /// Get the potential energy associated to this ForceField. /// /// Used to estimate the total energy of the system by some @@ -152,9 +160,6 @@ class MixedInteractionForceField : public BaseInteractionForceField, public Pair sofa::helper::replaceAll(name, "ForceField", "FF"); return name; } - - using Inherit2::getMechModel1; - using Inherit2::getMechModel2; }; #if !defined(SOFA_CORE_BEHAVIOR_MIXEDINTERACTIONFORCEFIELD_CPP) diff --git a/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.inl b/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.inl index 8cbd487f143..24b8b555106 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.inl +++ b/Sofa/framework/Core/src/sofa/core/behavior/MixedInteractionForceField.inl @@ -43,7 +43,7 @@ MixedInteractionForceField::~MixedInteractionForceField( } template -void MixedInteractionForceField::addForce(const MechanicalParams* mparams, MultiVecDerivId fId ) +void MixedInteractionForceField::doAddForce(const MechanicalParams* mparams, MultiVecDerivId fId ) { if (this->mstate1 && this->mstate2) @@ -58,7 +58,7 @@ void MixedInteractionForceField::addForce(const Mechanic } template -void MixedInteractionForceField::addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) +void MixedInteractionForceField::doAddDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) { if (this->mstate1 && this->mstate2) { @@ -73,7 +73,7 @@ void MixedInteractionForceField::addDForce(const Mechani template -SReal MixedInteractionForceField::getPotentialEnergy(const MechanicalParams* mparams) const +SReal MixedInteractionForceField::doGetPotentialEnergy(const MechanicalParams* mparams) const { if (this->mstate1 && this->mstate2) return getPotentialEnergy(mparams, *mparams->readX(this->mstate1.get()),*mparams->readX(this->mstate2.get())); diff --git a/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.h b/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.h index 20db861a697..8ff1c8bc2fc 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.h +++ b/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.h @@ -51,6 +51,11 @@ class PairInteractionForceField : public BaseInteractionForceField, public PairS typedef core::objectmodel::Data DataVecCoord; typedef core::objectmodel::Data DataVecDeriv; + // Avoid warning : hidden [-Woverloaded-virtual=] + using BaseForceField::addForce; + using BaseForceField::addDForce; + using BaseForceField::getPotentialEnergy; + protected: explicit PairInteractionForceField(MechanicalState *mm1 = nullptr, MechanicalState *mm2 = nullptr); @@ -80,7 +85,7 @@ class PairInteractionForceField : public BaseInteractionForceField, public PairS /// This method retrieves the force, x and v vector from the two MechanicalState /// and call the internal addForce(VecDeriv&,VecDeriv&,const VecCoord&,const VecCoord&,const VecDeriv&,const VecDeriv&) /// method implemented by the component. - void addForce(const MechanicalParams* mparams, MultiVecDerivId fId ) override; + void doAddForce(const MechanicalParams* mparams, MultiVecDerivId fId ) override; /// Given the current position and velocity states, update the current force /// vector by computing and adding the forces associated with this @@ -108,7 +113,7 @@ class PairInteractionForceField : public BaseInteractionForceField, public PairS /// This method retrieves the force and dx vector from the two MechanicalState /// and call the internal addDForce(VecDeriv&,VecDeriv&,const VecDeriv&,const VecDeriv&,SReal,SReal) /// method implemented by the component. - void addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) override; + void doAddDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) override; /// Compute the force derivative given a small displacement from the /// position and velocity used in the previous call to addForce(). @@ -138,7 +143,7 @@ class PairInteractionForceField : public BaseInteractionForceField, public PairS /// This method retrieves the x vector from the MechanicalState and call /// the internal getPotentialEnergy(const VecCoord&,const VecCoord&) method implemented by /// the component. - SReal getPotentialEnergy(const MechanicalParams* mparams) const override; + SReal doGetPotentialEnergy(const MechanicalParams* mparams) const override; /// Get the potential energy associated to this ForceField. /// diff --git a/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.inl b/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.inl index 61e666c2e87..5552c9573f8 100644 --- a/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.inl +++ b/Sofa/framework/Core/src/sofa/core/behavior/PairInteractionForceField.inl @@ -46,7 +46,7 @@ PairInteractionForceField::~PairInteractionForceField() } template -void PairInteractionForceField::addForce(const MechanicalParams* mparams, MultiVecDerivId fId ) +void PairInteractionForceField::doAddForce(const MechanicalParams* mparams, MultiVecDerivId fId ) { auto state1 = this->mstate1.get(); auto state2 = this->mstate2.get(); @@ -61,7 +61,7 @@ void PairInteractionForceField::addForce(const MechanicalParams* mpar } template -void PairInteractionForceField::addDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) +void PairInteractionForceField::doAddDForce(const MechanicalParams* mparams, MultiVecDerivId dfId ) { auto state1 = this->mstate1.get(); auto state2 = this->mstate2.get(); @@ -76,7 +76,7 @@ void PairInteractionForceField::addDForce(const MechanicalParams* mpa } template -SReal PairInteractionForceField::getPotentialEnergy(const MechanicalParams* mparams) const +SReal PairInteractionForceField::doGetPotentialEnergy(const MechanicalParams* mparams) const { auto state1 = this->mstate1.get(); auto state2 = this->mstate2.get(); diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.h b/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.h index 17385757d47..105c91a1239 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.h +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.h @@ -87,7 +87,7 @@ class PenalityContactForceField : public core::behavior::PairInt virtual void addDForce(const core::MechanicalParams* mparams, DataVecDeriv& d_df1, DataVecDeriv& d_df2, const DataVecDeriv& d_dx1, const DataVecDeriv& d_dx2) override; - void buildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; + void doBuildDampingMatrix(core::behavior::DampingMatrix* /*matrix*/) final; virtual SReal getPotentialEnergy(const core::MechanicalParams* mparams, const DataVecCoord& x1, const DataVecCoord& x2) const override; diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.inl b/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.inl index 0b6a42d0858..c6e3089b706 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.inl +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/collision/response/contact/CudaPenalityContactForceField.inl @@ -195,7 +195,7 @@ void PenalityContactForceField::addDForce(const core::Mechanical d_df2.endEdit(); } -inline void PenalityContactForceField, Vec<3>>>::buildDampingMatrix(core::behavior::DampingMatrix* damping_matrix) +inline void PenalityContactForceField, Vec<3>>>::doBuildDampingMatrix(core::behavior::DampingMatrix* damping_matrix) { // No damping in this ForceField } diff --git a/applications/plugins/SofaCUDA/src/SofaCUDA/component/mass/CudaUniformMass.inl b/applications/plugins/SofaCUDA/src/SofaCUDA/component/mass/CudaUniformMass.inl index 617699b79b5..ac27f18d80c 100644 --- a/applications/plugins/SofaCUDA/src/SofaCUDA/component/mass/CudaUniformMass.inl +++ b/applications/plugins/SofaCUDA/src/SofaCUDA/component/mass/CudaUniformMass.inl @@ -205,7 +205,7 @@ SReal UniformMass::getPotentialEnergy(const core::M } template <> -SReal UniformMass::getElementMass(sofa::Index) const +SReal UniformMass::doGetElementMass(sofa::Index) const { return (SReal)(d_vertexMass.getValue().mass); } @@ -374,7 +374,7 @@ SReal UniformMass::getPotentialEnergy(const core::M } template <> -SReal UniformMass::getElementMass(sofa::Index) const +SReal UniformMass::doGetElementMass(sofa::Index) const { return (SReal)(d_vertexMass.getValue().mass); } diff --git a/applications/plugins/SofaCUDA/src/sofa/gpu/cuda/CudaHexahedronTLEDForceField.h b/applications/plugins/SofaCUDA/src/sofa/gpu/cuda/CudaHexahedronTLEDForceField.h index b912b1c3e17..194273e5b5c 100644 --- a/applications/plugins/SofaCUDA/src/sofa/gpu/cuda/CudaHexahedronTLEDForceField.h +++ b/applications/plugins/SofaCUDA/src/sofa/gpu/cuda/CudaHexahedronTLEDForceField.h @@ -105,8 +105,8 @@ class CudaHexahedronTLEDForceField : public core::behavior::ForceField void addForce(const sofa::core::MechanicalParams* /*mparams*/, DataVecDeriv & dataF, const DataVecCoord & dataX , const DataVecDeriv & dataV ) override; void addDForce(const sofa::core::MechanicalParams* mparams, DataVecDeriv& datadF , const DataVecDeriv& datadX ) override; - void addKToMatrix(const sofa::core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) override; SReal getPotentialEnergy(const core::MechanicalParams* /*mparams*/, const DataVecCoord& /* x */) const override { msg_warning() << "Get potentialEnergy not implemented"; diff --git a/applications/plugins/SofaDistanceGrid/src/SofaDistanceGrid/components/forcefield/DistanceGridForceField.inl b/applications/plugins/SofaDistanceGrid/src/SofaDistanceGrid/components/forcefield/DistanceGridForceField.inl index d41cfad73ab..b61437efdd5 100644 --- a/applications/plugins/SofaDistanceGrid/src/SofaDistanceGrid/components/forcefield/DistanceGridForceField.inl +++ b/applications/plugins/SofaDistanceGrid/src/SofaDistanceGrid/components/forcefield/DistanceGridForceField.inl @@ -393,31 +393,28 @@ void DistanceGridForceField::addDForce(const sofa::core::MechanicalPa } template -void DistanceGridForceField::addKToMatrix(const sofa::core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) +void DistanceGridForceField::addKToMatrix(sofa::linearalgebra::BaseMatrix * mat, SReal kFactor, unsigned int &offset) { - sofa::core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate); - Real kFactor = (Real)sofa::core::mechanicalparams::kFactorIncludingRayleighDamping(mparams, this->rayleighStiffness.getValue()); - unsigned int &offset = r.offset; - sofa::linearalgebra::BaseMatrix* mat = r.matrix; + if (!grid) + return; - if (r) + const sofa::type::vector& contacts = this->contacts.getValue(); + + if (contacts.empty()) + return; + + for (unsigned int i=0; i& contacts = this->contacts.getValue(); - if (contacts.empty()) return; - for (unsigned int i=0; iadd(offset + p*Deriv::total_size + l, offset + p*Deriv::total_size + c, coef); - } - } + const Contact& c = contacts[i]; + const int p = c.index; + const Real fact = (Real)(c.fact * -kFactor); + const Deriv& normal = c.normal; + for (sofa::Size l=0; ladd(offset + p*Deriv::total_size + l, offset + p*Deriv::total_size + c, coef); + } } }