Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ class AdaptiveBeamForceFieldAndMass : public core::behavior::Mass<DataTypes>
/// 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
Expand Down Expand Up @@ -166,8 +166,7 @@ class AdaptiveBeamForceFieldAndMass : public core::behavior::Mass<DataTypes>
}

using sofa::core::behavior::ForceField<DataTypes>::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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addMDx(const sofa::core::Mechanic


template<class DataTypes>
void AdaptiveBeamForceFieldAndMass<DataTypes>::addMToMatrix(const sofa::core::MechanicalParams *mparams,
void AdaptiveBeamForceFieldAndMass<DataTypes>::doAddMToMatrix(const sofa::core::MechanicalParams *mparams,
const sofa::core::behavior::MultiMatrixAccessor* matrix)
{
sofa::core::behavior::MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(mstate);
Expand Down Expand Up @@ -382,7 +382,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addMToMatrix(const sofa::core::Me
}

template<class DataTypes>
void AdaptiveBeamForceFieldAndMass<DataTypes>::buildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices)
void AdaptiveBeamForceFieldAndMass<DataTypes>::doBuildMassMatrix(sofa::core::behavior::MassMatrixAccumulator* matrices)
{
const auto numBeams = l_interpolation->getNumBeams();

Expand Down Expand Up @@ -471,7 +471,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addMBKToMatrix(const sofa::core::
}

template <class DataTypes>
void AdaptiveBeamForceFieldAndMass<DataTypes>::buildDampingMatrix(core::behavior::DampingMatrix*)
void AdaptiveBeamForceFieldAndMass<DataTypes>::doBuildDampingMatrix(core::behavior::DampingMatrix*)
{
// No damping in this ForceField
}
Expand Down Expand Up @@ -695,12 +695,8 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addDForce(const sofa::core::Mecha


template<class DataTypes>
void AdaptiveBeamForceFieldAndMass<DataTypes>::addKToMatrix(const sofa::core::MechanicalParams* mparams,
const sofa::core::behavior::MultiMatrixAccessor* matrix)
void AdaptiveBeamForceFieldAndMass<DataTypes>::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<numBeams; b++)
Expand All @@ -720,25 +716,25 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::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<class DataTypes>
void AdaptiveBeamForceFieldAndMass<DataTypes>::buildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix)
void AdaptiveBeamForceFieldAndMass<DataTypes>::doBuildStiffnessMatrix(core::behavior::StiffnessMatrix* matrix)
{
const auto numBeams = l_interpolation->getNumBeams();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class AdaptiveInflatableBeamForceField : public Mass<DataTypes>
/// 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.
Expand Down Expand Up @@ -200,8 +200,7 @@ class AdaptiveInflatableBeamForceField : public Mass<DataTypes>
}

using sofa::core::behavior::ForceField<DataTypes>::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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void AdaptiveInflatableBeamForceField<DataTypes>::addMDx(const MechanicalParams*


template<class DataTypes>
void AdaptiveInflatableBeamForceField<DataTypes>::addMToMatrix(const MechanicalParams *mparams,
void AdaptiveInflatableBeamForceField<DataTypes>::doAddMToMatrix(const MechanicalParams *mparams,
const MultiMatrixAccessor* matrix)
{
MultiMatrixAccessor::MatrixRef r = matrix->getMatrix(this->mstate);
Expand Down Expand Up @@ -673,12 +673,9 @@ void AdaptiveInflatableBeamForceField<DataTypes>::addDForce(const MechanicalPara


template<class DataTypes>
void AdaptiveInflatableBeamForceField<DataTypes>::addKToMatrix(const MechanicalParams* mparams,
const MultiMatrixAccessor* matrix)
void AdaptiveInflatableBeamForceField<DataTypes>::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<numBeams; b++)
Expand All @@ -699,18 +696,18 @@ void AdaptiveInflatableBeamForceField<DataTypes>::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);
}
}
}
Expand Down
Loading