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 @@ -168,7 +168,7 @@ class PartialRigidificationForceField : public MixedInteractionForceField<TDataT


///////////////////////// Inherited from BaseInteractionForceField ///////////////////
void addKToMatrix(const MechanicalParams* mparams,
void doAddKToMatrix(const MechanicalParams* mparams,
const MultiMatrixAccessor* matrix ) override;
////////////////////////////////////////////////////////////////////////////////////
protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ PartialRigidificationForceField<DataTypes1, DataTypes2>::PartialRigidificationFo


template<class DataTypes1, class DataTypes2>
void PartialRigidificationForceField<DataTypes1, DataTypes2>::addKToMatrix(const MechanicalParams* mparams,
void PartialRigidificationForceField<DataTypes1, DataTypes2>::doAddKToMatrix(const MechanicalParams* mparams,
const MultiMatrixAccessor* matrix)
{
MultiMatrixAccessor::MatrixRef mat11 = matrix->getMatrix(mstate1);
Expand Down
3 changes: 1 addition & 2 deletions src/SoftRobots/component/forcefield/PipeForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ public :
dx ) override;


void addKToMatrix(const MechanicalParams* mparams,
const MultiMatrixAccessor* matrix) override;
void addKToMatrix(sofa::linearalgebra::BaseMatrix * mat, SReal kFact, unsigned int & offset) override;

double getPotentialEnergy(const MechanicalParams* mparams,
const DataVecCoord& x) const override;
Expand Down
11 changes: 6 additions & 5 deletions src/SoftRobots/component/forcefield/PipeForceField.inl
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ double PipeForceField<DataTypes>::getPotentialEnergy(const MechanicalParams* mpa
}

template<typename DataTypes>
void PipeForceField<DataTypes>::addKToMatrix(const MechanicalParams* mparams,
const MultiMatrixAccessor* matrix)
void PipeForceField<DataTypes>::addKToMatrix(sofa::linearalgebra::BaseMatrix * matrix,
SReal kFact, unsigned int & offset)
{
SOFA_UNUSED(kFact);

if (l_barycentricMapping.get() == nullptr )
{
msg_error() << "Link to barycentric mapping is missing or incorrect. AddKToMatrix not computed.";
Expand Down Expand Up @@ -154,7 +156,7 @@ void PipeForceField<DataTypes>::addKToMatrix(const MechanicalParams* mparams,

MultiMatrixAccessor::MatrixRef mappedMatrixRef = mappedFFMatrixAccessor->getMatrix(springState);

l_mappedForceField.get()->addKToMatrix(mparams, mappedFFMatrixAccessor);
l_mappedForceField.get()->addKToMatrix(sofa::core::mechanicalparams::defaultInstance(), mappedFFMatrixAccessor);
CompressedRowSparseMatrix<_3_3_Matrix_Type> JtK ;
CompressedRowSparseMatrix<_3_3_Matrix_Type> JtKJ ;

Expand All @@ -167,7 +169,6 @@ void PipeForceField<DataTypes>::addKToMatrix(const MechanicalParams* mparams,
if(mstate==nullptr)
msg_error() << "Missing context mechanical state.";

MultiMatrixAccessor::MatrixRef matrixRef = matrix->getMatrix(mstate);
_3_3_Matrix_Type KMatrixBuffer;
for(size_t kRowIndex = 0 ; kRowIndex < (unsigned int)JtKJ.nBlockRow ; ++kRowIndex) {
for(_3_3_ColBlockConstIterator kColIter = JtKJ.bRowBegin(kRowIndex); kColIter < JtKJ.bRowEnd(kRowIndex) ; kColIter++) {
Expand All @@ -180,7 +181,7 @@ void PipeForceField<DataTypes>::addKToMatrix(const MechanicalParams* mparams,

for (int i = 0; i < 3 ; i++)
for (int j = 0; j < 3; j++)
matrixRef.matrix->add(matrixRef.offset + 3 * kRowIndex + i,matrixRef.offset + 3 * kColIndex + j, kBlockData(i, j));
matrix->add(offset + 3 * kRowIndex + i, offset + 3 * kColIndex + j, kBlockData(i, j));
}
}

Expand Down
Loading