diff --git a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h index 2bea4791e..42e86dbf5 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h +++ b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h @@ -119,12 +119,12 @@ class AdaptiveBeamForceFieldAndMass : public core::behavior::Mass /// Mass Interface ///////////////////////////////////// void addMDx(const sofa::core::MechanicalParams* mparams, DataVecDeriv& f, const DataVecDeriv& dx, SReal factor) override; - void addMToMatrix(const sofa::core::MechanicalParams *mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; + void doAddMToMatrix(const sofa::core::MechanicalParams *mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) override; void addMBKToMatrix(const sofa::core::MechanicalParams* mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) 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; //TODO(dmarchal 2017-05-17) So what do we do ? For who is this message intended for ? How can we make this code "more" manageable. void accFromF(const sofa::core::MechanicalParams* mparams, DataVecDeriv& , const DataVecDeriv& ) override @@ -166,8 +166,7 @@ class AdaptiveBeamForceFieldAndMass : public core::behavior::Mass } using sofa::core::behavior::ForceField::addKToMatrix; - 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; void computeStiffness(const sofa::Index beamID, BeamLocalMatrices& beamLocalMatrices); void computeMass(const sofa::Index beamID, BeamLocalMatrices& beamMatrices); diff --git a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl index 4a2f95161..44a3cb4f7 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl +++ b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl @@ -341,7 +341,7 @@ void AdaptiveBeamForceFieldAndMass::addMDx(const sofa::core::Mechanic template -void AdaptiveBeamForceFieldAndMass::addMToMatrix(const sofa::core::MechanicalParams *mparams, +void AdaptiveBeamForceFieldAndMass::doAddMToMatrix(const sofa::core::MechanicalParams *mparams, const sofa::core::behavior::MultiMatrixAccessor* matrix) { sofa::core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(mstate); @@ -382,7 +382,7 @@ void AdaptiveBeamForceFieldAndMass::addMToMatrix(const sofa::core::Me } template -void AdaptiveBeamForceFieldAndMass::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) +void AdaptiveBeamForceFieldAndMass::doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices) { const auto numBeams = l_interpolation->getNumBeams(); @@ -471,7 +471,7 @@ void AdaptiveBeamForceFieldAndMass::addMBKToMatrix(const sofa::core:: } template -void AdaptiveBeamForceFieldAndMass::buildDampingMatrix(core::behavior::DampingMatrix*) +void AdaptiveBeamForceFieldAndMass::doBuildDampingMatrix(core::behavior::DampingMatrix*) { // No damping in this ForceField } @@ -695,12 +695,8 @@ void AdaptiveBeamForceFieldAndMass::addDForce(const sofa::core::Mecha template -void AdaptiveBeamForceFieldAndMass::addKToMatrix(const sofa::core::MechanicalParams* mparams, - const sofa::core::behavior::MultiMatrixAccessor* matrix) +void AdaptiveBeamForceFieldAndMass::addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int &offset) { - sofa::core::behavior::MultiMatrixAccessor::MatrixRef matrixRef = matrix->getMatrix(mstate); - const Real k = (Real)mparams->kFactor(); - const auto numBeams = l_interpolation->getNumBeams(); for (sofa::Index b=0; b::addKToMatrix(const sofa::core::Me sofa::Index index0[6], index1[6]; for (sofa::Index i=0;i<6;i++) - index0[i] = matrixRef.offset+node0Idx*6+i; + index0[i] = offset+node0Idx*6+i; for (sofa::Index i=0;i<6;i++) - index1[i] = matrixRef.offset+node1Idx*6+i; + index1[i] = offset+node1Idx*6+i; for (sofa::Index i=0;i<6;i++) { for (sofa::Index j=0;j<6;j++) { - matrixRef.matrix->add(index0[i], index0[j], - K00(i,j)*k); - matrixRef.matrix->add(index0[i], index1[j], - K01(i,j)*k); - matrixRef.matrix->add(index1[i], index0[j], - K10(i,j)*k); - matrixRef.matrix->add(index1[i], index1[j], - K11(i,j)*k); + matrix->add(index0[i], index0[j], - K00(i,j)*kFact); + matrix->add(index0[i], index1[j], - K01(i,j)*kFact); + matrix->add(index1[i], index0[j], - K10(i,j)*kFact); + matrix->add(index1[i], index1[j], - K11(i,j)*kFact); } } } } template -void AdaptiveBeamForceFieldAndMass::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) +void AdaptiveBeamForceFieldAndMass::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix) { const auto numBeams = l_interpolation->getNumBeams(); diff --git a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h index fb35a2f4c..865667461 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h +++ b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h @@ -154,7 +154,7 @@ class AdaptiveInflatableBeamForceField : public Mass /// Mass Interface ///////////////////////////////////// virtual void addMDx(const MechanicalParams* mparams, DataVecDeriv& f, const DataVecDeriv& dx, SReal factor) override; - virtual void addMToMatrix(const MechanicalParams *mparams, const MultiMatrixAccessor* matrix) override; + virtual void doAddMToMatrix(const MechanicalParams *mparams, const MultiMatrixAccessor* matrix) override; virtual void addMBKToMatrix(const MechanicalParams* mparams, const MultiMatrixAccessor* matrix) override; //TODO(dmarchal 2017-05-17) So what do we do ? For who is this message intended for ? How can we make this code "more" manageable. @@ -200,8 +200,7 @@ class AdaptiveInflatableBeamForceField : public Mass } using sofa::core::behavior::ForceField::addKToMatrix; - void addKToMatrix(const MechanicalParams* mparams, - const MultiMatrixAccessor* matrix) override; + void addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, SReal kFact, unsigned int & offset) override; void computeStiffness(int beam, BeamLocalMatrices& beamLocalMatrices); void computeMass(int beam, BeamLocalMatrices& beamMatrices); diff --git a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl index 9566c6019..5d8c08590 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl +++ b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl @@ -370,7 +370,7 @@ void AdaptiveInflatableBeamForceField::addMDx(const MechanicalParams* template -void AdaptiveInflatableBeamForceField::addMToMatrix(const MechanicalParams *mparams, +void AdaptiveInflatableBeamForceField::doAddMToMatrix(const MechanicalParams *mparams, const MultiMatrixAccessor* matrix) { MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate); @@ -673,12 +673,9 @@ void AdaptiveInflatableBeamForceField::addDForce(const MechanicalPara template -void AdaptiveInflatableBeamForceField::addKToMatrix(const MechanicalParams* mparams, - const MultiMatrixAccessor* matrix) +void AdaptiveInflatableBeamForceField::addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix, + SReal kFact, unsigned int & offset) { - MultiMatrixAccessor::MatrixRef matrixRef = matrix->getMatrix(mstate); - Real k = (Real)mparams->kFactor(); - unsigned int numBeams = l_interpolation->getNumBeams(); for (unsigned int b=0; b::addKToMatrix(const MechanicalP int index0[6], index1[6]; for (int i=0;i<6;i++) - index0[i] = matrixRef.offset+node0Idx*6+i; + index0[i] = offset+node0Idx*6+i; for (int i=0;i<6;i++) - index1[i] = matrixRef.offset+node1Idx*6+i; + index1[i] = offset+node1Idx*6+i; for (int i=0;i<6;i++) { for (int j=0;j<6;j++) { - matrixRef.matrix->add(index0[i], index0[j], - K00(i,j)*k); - matrixRef.matrix->add(index0[i], index1[j], - K01(i,j)*k); - matrixRef.matrix->add(index1[i], index0[j], - K10(i,j)*k); - matrixRef.matrix->add(index1[i], index1[j], - K11(i,j)*k); + matrix->add(index0[i], index0[j], - K00(i,j)*kFact); + matrix->add(index0[i], index1[j], - K01(i,j)*kFact); + matrix->add(index1[i], index0[j], - K10(i,j)*kFact); + matrix->add(index1[i], index1[j], - K11(i,j)*kFact); } } }