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 @@ -101,10 +101,6 @@ public :
const DataVecCoord& x ,
const DataVecDeriv& v) override;

void addDForce(const MechanicalParams* mparams,
DataVecDeriv& df ,
const DataVecDeriv& dx ) override;

double getPotentialEnergy(const MechanicalParams* mparams,
const DataVecCoord& x) const override;

Expand All @@ -126,6 +122,8 @@ protected :
VecCoord m_pos;
VecCoord m_restPos;

void doAddDForce(const MechanicalParams* mparams, const Inherit1::AddDForceVectors& vectors) override;

private :
void computeForce(const VecCoord& pos, const VecCoord& restPos, VecDeriv& f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,17 @@ void PREquivalentStiffnessForceField<DataTypes>::addForce(const MechanicalParams
f.endEdit();
}

template<typename DataTypes>
void PREquivalentStiffnessForceField<DataTypes>::addDForce(const MechanicalParams* mparams,
DataVecDeriv& d_f ,
const DataVecDeriv& d_x)
{

template <typename DataTypes>
void PREquivalentStiffnessForceField<DataTypes>::doAddDForce(
const MechanicalParams *mparams,
const typename Inherit1::AddDForceVectors &vectors)
{
if(d_componentState.getValue() != ComponentState::Valid)
return ;

const VecDeriv& dx = d_x.getValue();
VecDeriv& dfdq = *d_f.beginEdit();
const VecDeriv& dx = vectors.dx.getValue();
VecDeriv& dfdq = *vectors.df.beginEdit();
const size_t nFrames = dx.size();

const Real kFact = mparams->kFactor();
Expand Down Expand Up @@ -395,7 +396,7 @@ void PREquivalentStiffnessForceField<DataTypes>::displaceFrames(const VecCoord&
}
}

template<typename DataTypes>
template <typename DataTypes>
void PREquivalentStiffnessForceField<DataTypes>::computeForce(const VecCoord& pos,
const VecCoord& restPos,
VecDeriv& f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ class PartialRigidificationForceField : public MixedInteractionForceField<TDataT
////////////////////////////////////////////////////////////////////////////////////
protected:

template<class DataTypes>
using AddDForceVectors = typename Inherit1::template AddDForceVectors<DataTypes>;

void doAddDForce(const MechanicalParams* mparams,
const AddDForceVectors<DataTypes1>& vectors1,
const AddDForceVectors<DataTypes2>& vectors2) override;


////////////////////////// Inherited attributes ////////////////////////////
/// https://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void PartialRigidificationForceField<DataTypes1, DataTypes2>::addKToMatrix(const
delete mappedFFMatrixAccessor;
}

template<class DataTypes1, class DataTypes2>
template <class DataTypes1, class DataTypes2>
void PartialRigidificationForceField<DataTypes1, DataTypes2>::testBuildJacobian(const MechanicalParams* mparams)
{
CompressedRowSparseMatrix< _3_3_Matrix_Type >* mappedFFMatrix = new CompressedRowSparseMatrix< _3_3_Matrix_Type > ( );
Expand Down Expand Up @@ -391,8 +391,6 @@ void PartialRigidificationForceField<DataTypes1, DataTypes2>::addForce(const Mec
SOFA_UNUSED(v2);
}

// Even though it does nothing, this method has to be implemented
// since it's a pure virtual in parent class
template<class DataTypes1, class DataTypes2>
void PartialRigidificationForceField<DataTypes1, DataTypes2>::addDForce(const MechanicalParams* mparams,
DataVecDeriv1& df1,
Expand All @@ -407,6 +405,19 @@ void PartialRigidificationForceField<DataTypes1, DataTypes2>::addDForce(const Me
SOFA_UNUSED(dx2);
}

// Even though it does nothing, this method has to be implemented
// since it's a pure virtual in parent class
template <typename TDataTypes1, typename TDataTypes2>
void PartialRigidificationForceField<TDataTypes1, TDataTypes2>::doAddDForce(
const MechanicalParams *mparams,
const AddDForceVectors<DataTypes1> &vectors1,
const AddDForceVectors<DataTypes2> &vectors2)
{
SOFA_UNUSED(mparams);
SOFA_UNUSED(vectors1);
SOFA_UNUSED(vectors2);
}

// Even though it does nothing, this method has to be implemented
// since it's a pure virtual in parent class
template<class DataTypes1, class DataTypes2>
Expand Down
7 changes: 1 addition & 6 deletions src/SoftRobots/component/forcefield/PipeForceField.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ public :
const DataVecCoord& x ,
const DataVecDeriv& v) override;

void addDForce(const MechanicalParams* mparams,
DataVecDeriv& df ,
const DataVecDeriv&
dx ) override;


void addKToMatrix(const MechanicalParams* mparams,
const MultiMatrixAccessor* matrix) override;

Expand All @@ -133,6 +127,7 @@ public :
sofa::SingleLink < PipeForceField<DataTypes>, BarycentricMapping<DataTypes, DataTypes>, sofa::BaseLink::FLAG_STOREPATH | sofa::BaseLink::FLAG_STRONGLINK > l_barycentricMapping;
sofa::SingleLink < PipeForceField<DataTypes>, MeshSpringForceField<DataTypes>, sofa::BaseLink::FLAG_STOREPATH | sofa::BaseLink::FLAG_STRONGLINK > l_mappedForceField;

void doAddDForce(const MechanicalParams* mparams, const Inherit1::AddDForceVectors& vectors) override;

/**
* \brief Compressed sparse row matrices product
Expand Down
14 changes: 6 additions & 8 deletions src/SoftRobots/component/forcefield/PipeForceField.inl
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,13 @@ void PipeForceField<DataTypes>::addForce(const MechanicalParams* mparams,
SOFA_UNUSED(v);
}

template<typename DataTypes>
void PipeForceField<DataTypes>::addDForce(const MechanicalParams* mparams,
DataVecDeriv& d_f ,
const DataVecDeriv& d_x)
template <typename DataTypes>
void PipeForceField<DataTypes>::doAddDForce(
const MechanicalParams *mparams,
const typename Inherit1::AddDForceVectors &vectors)
{
SOFA_UNUSED(mparams);
SOFA_UNUSED(d_f);
SOFA_UNUSED(d_x);
SOFA_UNUSED(vectors);
}

template<typename DataTypes>
Expand Down Expand Up @@ -188,8 +187,7 @@ void PipeForceField<DataTypes>::addKToMatrix(const MechanicalParams* mparams,
delete mappedFFMatrixAccessor;
}


template<class DataTypes>
template <class DataTypes>
template<unsigned int M, unsigned int N, unsigned int K>
void PipeForceField<DataTypes>::multMatrices(const CompressedRowSparseMatrix<Mat<M, N, Real> >& A,
const CompressedRowSparseMatrix<Mat<N, K, Real> >& B,
Expand Down
Loading