Skip to content

Commit

Permalink
Update code of BeamFF to use mechanical param retrieve from the BeamI…
Browse files Browse the repository at this point in the history
…nterpolation
  • Loading branch information
epernod committed Jul 19, 2024
1 parent 039ea8f commit 847928e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/BeamAdapter/component/BaseBeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject
virtual void getSplineRestTransform(unsigned int edgeInList, Transform& local_H_local0_rest, Transform& local_H_local1_rest) = 0;
virtual void getInterpolationParam(unsigned int edgeInList, Real& _L, Real& _A, Real& _Iy, Real& _Iz,
Real& _Asy, Real& _Asz, Real& J) = 0;
virtual void getMechanicalParam(int beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) = 0;

virtual const BeamSection& getBeamSection(int edgeIndex) = 0;
virtual void getBeamAtCurvAbs(const Real& x_input, unsigned int& edgeInList_output, Real& baryCoord_output, unsigned int start = 0);

Expand Down
2 changes: 2 additions & 0 deletions src/BeamAdapter/component/BeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class BeamInterpolation : public BaseBeamInterpolation<DataTypes>
void getCollisionSampling(Real &dx, const Real& x_localcurv_abs) override;
void getNumberOfCollisionSegment(Real &dx, unsigned int &numLines) override;
void getYoungModulusAtX(int beamId,Real& x_curv, Real& youngModulus, Real& cPoisson) override;
void getMechanicalParam(int beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) override;

void setTransformBetweenDofAndNode(int beam, const Transform &DOF_H_Node, unsigned int zeroORone );
void getSplineRestTransform(unsigned int edgeInList, Transform &local_H_local0_rest, Transform &local_H_local1_rest) override;

Expand Down
10 changes: 10 additions & 0 deletions src/BeamAdapter/component/BeamInterpolation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,15 @@ void BeamInterpolation<DataTypes>::getYoungModulusAtX(int beamId, Real& /*x_curv
}


template<class DataTypes>
void BeamInterpolation<DataTypes>::getMechanicalParam(int beamId, Real& youngModulus, Real& cPoisson, Real& massDensity)
{
Real xcurv;
return getYoungModulusAtX(beamId, xcurv, youngModulus, cPoisson);
}



template <class DataTypes>
void BeamInterpolation<DataTypes>::setTransformBetweenDofAndNode(int beam, const Transform &DOF_H_Node, unsigned int zeroORone )
{
Expand Down Expand Up @@ -505,6 +514,7 @@ void BeamInterpolation<DataTypes>::getInterpolationParam(unsigned int edgeInList




template<class DataTypes>
void BeamInterpolation<DataTypes>::getTangentUsingSplinePoints(unsigned int edgeInList, const Real& baryCoord,
const ConstVecCoordId &vecXId, Vec3& t )
Expand Down
7 changes: 7 additions & 0 deletions src/BeamAdapter/component/WireBeamInterpolation.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ class WireBeamInterpolation : public BaseBeamInterpolation<DataTypes>
}


void getMechanicalParam(int beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) override
{
Real x_curv = 0;
this->getAbsCurvXFromBeam(beamId, x_curv);
this->m_restShape->getMechanicalParamAtX(x_curv, youngModulus, cPoisson, massDensity);
}

virtual void getRestTransform(unsigned int edgeInList, Transform &local0_H_local1_rest);

void getCurvAbsAtBeam(const unsigned int& edgeInList_input, const Real& baryCoord_input, Real& x_output) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,20 +548,24 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const MechanicalParams*
/// material parameters
beamMatrices._rho = d_massDensity.getValue();


/// Temp : we only overide values for which a Data has been set in the WireRestShape
if (l_instrumentParameters.get())
if (!l_instrumentParameters.empty())
{
Real x_curv = 0;
l_interpolation->getAbsCurvXFromBeam(beamId, x_curv);

/// The length of the beams is only known to the interpolation !
l_instrumentParameters->getInterpolationParam(x_curv, beamMatrices._rho, beamMatrices._A, beamMatrices._Iy,
l_instrumentParameters.get()->getInterpolationParam(x_curv, beamMatrices._rho, beamMatrices._A, beamMatrices._Iy,
beamMatrices._Iz, beamMatrices._Asy, beamMatrices._Asz, beamMatrices._J);
}
else
{
l_interpolation->getInterpolationParam(beamId, beamMatrices._L, beamMatrices._A, beamMatrices._Iy,
beamMatrices._Iz, beamMatrices._Asy, beamMatrices._Asz, beamMatrices._J);

Real youngM, cPoisson;
l_interpolation->getMechanicalParam(beamId, youngM, cPoisson, beamMatrices._rho);
}


Expand Down

0 comments on commit 847928e

Please sign in to comment.