From 56548b8bdbcf3aced7ce2c9d5e97355528f8e7fc Mon Sep 17 00:00:00 2001 From: epernod Date: Fri, 19 Jul 2024 12:58:25 +0200 Subject: [PATCH] [src] Update RodSection, WireRestShape and All BeamInterpolation to correctly redirect the getters to the Data for: getBeamSection, getInterpolationParameters and getMechanicalParameters. Remove the now useless pointer to the RestShape inside the FEM. Go only through the Interpolation component. --- .../component/BaseBeamInterpolation.h | 13 ++-- src/BeamAdapter/component/BeamInterpolation.h | 12 ++-- .../component/BeamInterpolation.inl | 61 ++++++++----------- .../component/WireBeamInterpolation.h | 22 ++----- .../component/WireBeamInterpolation.inl | 28 ++++++--- .../component/engine/WireRestShape.h | 16 ++--- .../component/engine/WireRestShape.inl | 40 +++--------- .../AdaptiveBeamForceFieldAndMass.h | 3 +- .../AdaptiveBeamForceFieldAndMass.inl | 46 ++++---------- .../AdaptiveInflatableBeamForceField.h | 2 - .../AdaptiveInflatableBeamForceField.inl | 31 ++-------- .../component/model/BaseRodSectionMaterial.h | 12 ++-- .../model/BaseRodSectionMaterial.inl | 16 +---- 13 files changed, 105 insertions(+), 197 deletions(-) diff --git a/src/BeamAdapter/component/BaseBeamInterpolation.h b/src/BeamAdapter/component/BaseBeamInterpolation.h index 25be59ecc..8c4bbb51f 100644 --- a/src/BeamAdapter/component/BaseBeamInterpolation.h +++ b/src/BeamAdapter/component/BaseBeamInterpolation.h @@ -124,7 +124,6 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject void addCollisionOnBeam(unsigned int b); void clearCollisionOnBeam(); - virtual void getYoungModulusAtX(int beamId, Real& x_curv, Real& youngModulus, Real& cPoisson) = 0; virtual void getSamplingParameters(type::vector& xP_noticeable, type::vector& nbP_density) = 0; virtual void getNumberOfCollisionSegment(Real& dx, unsigned int& numLines) = 0; @@ -132,11 +131,15 @@ class BaseBeamInterpolation : public virtual sofa::core::objectmodel::BaseObject virtual void getCurvAbsAtBeam(const unsigned int& edgeInList_input, const Real& baryCoord_input, Real& x_output) = 0; 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; + + /// Returns the BeamSection @sa m_beamSection corresponding to the given beam + virtual const BeamSection& getBeamSection(sofa::Index beamId) = 0; + /// Returns the BeamSection data depending on the beam position at the given beam, similar to @getBeamSection + virtual void getInterpolationParameters(sofa::Index beamId, Real& _L, Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& J) = 0; + /// Returns the Young modulus, Poisson's ratio and massDensity coefficient of the section at the given curvilinear abscissa + virtual void getMechanicalParameters(sofa::Index 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); int computeTransform(const EdgeID edgeInList, Transform& global_H_local0, Transform& global_H_local1, const VecCoord& x); diff --git a/src/BeamAdapter/component/BeamInterpolation.h b/src/BeamAdapter/component/BeamInterpolation.h index 9343837b0..78346a5ab 100644 --- a/src/BeamAdapter/component/BeamInterpolation.h +++ b/src/BeamAdapter/component/BeamInterpolation.h @@ -140,9 +140,13 @@ class BeamInterpolation : public BaseBeamInterpolation bool verifyTopology(); void computeCrossSectionInertiaMatrix(); - void getInterpolationParam(unsigned int edgeInList, Real &_L, Real &_A, Real &_Iy , Real &_Iz, + const BeamSection& getBeamSection(sofa::Index beamId) override { + SOFA_UNUSED(beamId); + return this->m_constantSection; + } + void getInterpolationParameters(sofa::Index beamId, Real &_L, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &J) override; - + void getMechanicalParameters(sofa::Index beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) override; void getTangentUsingSplinePoints(unsigned int edgeInList, const Real& baryCoord, const ConstVecCoordId &vecXId, Vec3& t ); @@ -150,7 +154,7 @@ class BeamInterpolation : public BaseBeamInterpolation /// computeActualLength => given the 4 control points of the spline, it provides an estimate of the length (using gauss points integration) - const BeamSection &getBeamSection(int /*edgeIndex*/ ) override {return this->m_constantSection;} + virtual void getCurvAbsAtBeam(const unsigned int& edgeInList_input, const Real& baryCoord_input, Real& x_output) {} virtual void getBeamAtCurvAbs(const Real& x_input, unsigned int& edgeInList_output, Real& baryCoord_output, unsigned int start = 0) {} @@ -188,8 +192,6 @@ class BeamInterpolation : public BaseBeamInterpolation Real getRestTotalLength() override; 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; diff --git a/src/BeamAdapter/component/BeamInterpolation.inl b/src/BeamAdapter/component/BeamInterpolation.inl index 8e391d95c..51877342f 100644 --- a/src/BeamAdapter/component/BeamInterpolation.inl +++ b/src/BeamAdapter/component/BeamInterpolation.inl @@ -395,32 +395,44 @@ void BeamInterpolation::getNumberOfCollisionSegment(Real &dx, unsigne dx = getRestTotalLength()/numLines; } -template -void BeamInterpolation::getYoungModulusAtX(int beamId, Real& /*x_curv*/, Real& youngModulus, Real& cPoisson) + +template +void BeamInterpolation::getInterpolationParameters(sofa::Index beamId, Real& _L, Real& _A, Real& _Iy, + Real& _Iz, Real& _Asy, Real& _Asz, Real& _J) +{ + /// get the length of the beam: + _L = this->d_lengthList.getValue()[beamId]; + _A = m_constantSection._A; + _Iy = m_constantSection._Iy; + _Iz = m_constantSection._Iz; + _Asy = m_constantSection._Asy; + _Asz = m_constantSection._Asz; + _J = m_constantSection._J; +} + + +template +void BeamInterpolation::getMechanicalParameters(sofa::Index beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) { const auto& defaultYoungModuli = d_defaultYoungModulus.getValue(); if (beamId < int(defaultYoungModuli.size())) { youngModulus = defaultYoungModuli[beamId]; - } else { + } + else { youngModulus = m_defaultYoungModulus; } - + const auto& poissonRatios = d_poissonRatio.getValue(); if (beamId < int(poissonRatios.size())) { - cPoisson = poissonRatios[beamId]; - } else { - cPoisson = m_defaultPoissonRatio; + cPoisson = poissonRatios[beamId]; + } + else { + cPoisson = m_defaultPoissonRatio; } -} - -template -void BeamInterpolation::getMechanicalParam(int beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) -{ - Real xcurv; - return getYoungModulusAtX(beamId, xcurv, youngModulus, cPoisson); + //TODO: massDensity?? } @@ -494,27 +506,6 @@ void BeamInterpolation::getSplineRestTransform(unsigned int edgeInLis } -template -void BeamInterpolation::getInterpolationParam(unsigned int edgeInList, Real &_L, Real &_A, Real &_Iy , - Real &_Iz, Real &_Asy, Real &_Asz, Real &_J) -{ - /// get the length of the beam: - _L = this->d_lengthList.getValue()[edgeInList]; - - BeamSection bS = getBeamSection(edgeInList); - _A=bS._A; - _Iy=bS._Iy; - _Iz=bS._Iz; - _Asy=bS._Asy; - _Asz=bS._Asz; - _J=bS._J; -} - - - - - - template void BeamInterpolation::getTangentUsingSplinePoints(unsigned int edgeInList, const Real& baryCoord, const ConstVecCoordId &vecXId, Vec3& t ) diff --git a/src/BeamAdapter/component/WireBeamInterpolation.h b/src/BeamAdapter/component/WireBeamInterpolation.h index a298cc54d..987289449 100644 --- a/src/BeamAdapter/component/WireBeamInterpolation.h +++ b/src/BeamAdapter/component/WireBeamInterpolation.h @@ -131,27 +131,15 @@ class WireBeamInterpolation : public BaseBeamInterpolation } - void getYoungModulusAtX(int beamId,Real& x_curv, Real& youngModulus, Real& cPoisson) override - { - this->getAbsCurvXFromBeam(beamId, x_curv); - this->m_restShape->getYoungModulusAtX(x_curv, youngModulus, cPoisson); - } - - - 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; void getSplineRestTransform(unsigned int edgeInList, Transform &local_H_local0_rest, Transform &local_H_local1_rest) override; - void getInterpolationParam(unsigned int edgeInList, Real& _L, Real& _A, Real& _Iy, Real& _Iz, - Real& _Asy, Real& _Asz, Real& _J) override; - const BeamSection& getBeamSection(int edgeIndex) override; + + const BeamSection& getBeamSection(sofa::Index beamId) override; + void getInterpolationParameters(sofa::Index beamId, Real& _L, Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& _J) override; + void getMechanicalParameters(sofa::Index, Real& youngModulus, Real& cPoisson, Real& massDensity) override; + bool getApproximateCurvAbs(const Vec3& x_input, const VecCoord& x, Real& x_output); // Project a point on the segments, return false if cant project diff --git a/src/BeamAdapter/component/WireBeamInterpolation.inl b/src/BeamAdapter/component/WireBeamInterpolation.inl index 52c2252ae..4bd95cf73 100644 --- a/src/BeamAdapter/component/WireBeamInterpolation.inl +++ b/src/BeamAdapter/component/WireBeamInterpolation.inl @@ -163,29 +163,39 @@ void WireBeamInterpolation::getCurvAbsAtBeam(const unsigned int &edge template -void WireBeamInterpolation::getInterpolationParam(unsigned int edgeInList, Real& _L, Real& _A, Real& _Iy, Real& _Iz, - Real& _Asy, Real& _Asz, Real& _J) +const BeamSection& WireBeamInterpolation::getBeamSection(sofa::Index beamId) { - _L = this->d_lengthList.getValue()[edgeInList]; - Real _rho; Real x_curv = 0; - this->getAbsCurvXFromBeam(edgeInList, x_curv); + this->getAbsCurvXFromBeam(beamId, x_curv); auto restShape = this->m_restShape.get(); - restShape->getInterpolationParam(x_curv, _rho, _A, _Iy, _Iz, _Asy, _Asz, _J); + return restShape->getBeamSectionAtX(x_curv); } template -const BeamSection& WireBeamInterpolation::getBeamSection(int edgeIndex) +void WireBeamInterpolation::getInterpolationParameters(sofa::Index beamId, Real& _L, Real& _A, Real& _Iy, Real& _Iz, + Real& _Asy, Real& _Asz, Real& _J) { + _L = this->d_lengthList.getValue()[beamId]; + Real _rho; Real x_curv = 0; - this->getAbsCurvXFromBeam(edgeIndex, x_curv); + this->getAbsCurvXFromBeam(beamId, x_curv); auto restShape = this->m_restShape.get(); - return restShape->getBeamSectionAtX(x_curv); + restShape->getInterpolationParametersAtX(x_curv, _A, _Iy, _Iz, _Asy, _Asz, _J); } + +template +void WireBeamInterpolation::getMechanicalParameters(sofa::Index beamId, Real& youngModulus, Real& cPoisson, Real& massDensity) +{ + Real x_curv = 0; + this->getAbsCurvXFromBeam(beamId, x_curv); + this->m_restShape->getMechanicalParametersAtX(x_curv, youngModulus, cPoisson, massDensity); +} + + template bool WireBeamInterpolation::getApproximateCurvAbs(const Vec3& x_input, const VecCoord& x, Real& x_output) { diff --git a/src/BeamAdapter/component/engine/WireRestShape.h b/src/BeamAdapter/component/engine/WireRestShape.h index 7b493d0c6..021f92c21 100644 --- a/src/BeamAdapter/component/engine/WireRestShape.h +++ b/src/BeamAdapter/component/engine/WireRestShape.h @@ -90,18 +90,14 @@ class WireRestShape : public core::objectmodel::BaseObject /// This function is called by the force field to evaluate the rest position of each beam void getRestTransformOnX(Transform &global_H_local, const Real &x); - /// This function gives the Young modulus and Poisson's coefficient of the beam depending on the beam position - void getYoungModulusAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson) const; - - /// This function gives the mass density and the BeamSection data depending on the beam position - void getInterpolationParam(const Real& x_curv, Real &_rho, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &_J) const; - + /// Returns the BeamSection @sa m_beamSection corresponding to the given curvilinear abscissa, will call @sa BaseRodSectionMaterial::getBeamSection + [[nodiscard]] const BeamSection& getBeamSectionAtX(const Real& x_curv) const; - /// Returns the Young modulus, Poisson's and massDensity coefficient of the section at the given curvilinear abscissa - void getMechanicalParamAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson, Real& massDensity) const; + /// Returns the BeamSection data depending on the beam position at the given curvilinear abscissa, will call @sa BaseRodSectionMaterial::getInterpolationParameters + void getInterpolationParametersAtX(const Real& x_curv, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &_J) const; - /// Returns the BeamSection @sa m_beamSection corresponding to the given curvilinear abscissa - [[nodiscard]] const BeamSection& getBeamSectionAtX(const Real& x_curv) const; + /// Returns the Young modulus, Poisson's ratio and massDensity coefficient of the section at the given curvilinear abscissa, will call @sa BaseRodSectionMaterial::getMechanicalParameters + void getMechanicalParametersAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson, Real& massDensity) const; /** diff --git a/src/BeamAdapter/component/engine/WireRestShape.inl b/src/BeamAdapter/component/engine/WireRestShape.inl index a4aabadbd..043f180b9 100644 --- a/src/BeamAdapter/component/engine/WireRestShape.inl +++ b/src/BeamAdapter/component/engine/WireRestShape.inl @@ -258,26 +258,7 @@ void WireRestShape::getRestTransformOnX(Transform &global_H_local, co template -void WireRestShape::getYoungModulusAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson) const -{ - const Real x_used = x_curv - Real(EPSILON); - const type::vector& keyPts = d_keyPoints.getValue(); - - // Depending on the position of the beam, determine the corresponding section material and returning its Young modulus - for (sofa::Size i = 1; i < keyPts.size(); ++i) - { - if (x_used <= keyPts[i]) - { - return l_sectionMaterials.get(i - 1)->getYoungModulusAtX(youngModulus, cPoisson); - } - } - - msg_error() << " problem in getYoungModulusAtX : x_curv " << x_curv << " is not between keyPoints" << keyPts; -} - - -template -void WireRestShape::getInterpolationParam(const Real& x_curv, Real &_rho, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &_J) const +const BeamSection& WireRestShape::getBeamSectionAtX(const Real& x_curv) const { const Real x_used = x_curv - Real(EPSILON); const type::vector& keyPts = d_keyPoints.getValue(); @@ -287,17 +268,18 @@ void WireRestShape::getInterpolationParam(const Real& x_curv, Real &_ { if (x_used <= keyPts[i]) { - return l_sectionMaterials.get(i - 1)->getInterpolationParam(_rho, _A, _Iy, _Iz, _Asy, _Asz, _J); + return l_sectionMaterials.get(i - 1)->getBeamSection(); } } - msg_error() << " problem in getInterpolationParam : x_curv " << x_curv << " is not between keyPoints" << keyPts; + msg_error() << " problem in getBeamSection : x_curv " << x_curv << " is not between keyPoints" << keyPts; + static const BeamSection emptySection{}; + return emptySection; } - template -const BeamSection& WireRestShape::getBeamSectionAtX(const Real& x_curv) const +void WireRestShape::getInterpolationParametersAtX(const Real& x_curv, Real &_A, Real &_Iy , Real &_Iz, Real &_Asy, Real &_Asz, Real &_J) const { const Real x_used = x_curv - Real(EPSILON); const type::vector& keyPts = d_keyPoints.getValue(); @@ -307,18 +289,16 @@ const BeamSection& WireRestShape::getBeamSectionAtX(const Real& x_cur { if (x_used <= keyPts[i]) { - return l_sectionMaterials.get(i - 1)->getBeamSection(); + return l_sectionMaterials.get(i - 1)->getInterpolationParameters(_A, _Iy, _Iz, _Asy, _Asz, _J); } } - msg_error() << " problem in getBeamSection : x_curv " << x_curv << " is not between keyPoints" << keyPts; - static const BeamSection emptySection{}; - return emptySection; + msg_error() << " problem in getInterpolationParam : x_curv " << x_curv << " is not between keyPoints" << keyPts; } template -void WireRestShape::getMechanicalParamAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson, Real& massDensity) const +void WireRestShape::getMechanicalParametersAtX(const Real& x_curv, Real& youngModulus, Real& cPoisson, Real& massDensity) const { const Real x_used = x_curv - Real(EPSILON); const type::vector& keyPts = d_keyPoints.getValue(); @@ -328,7 +308,7 @@ void WireRestShape::getMechanicalParamAtX(const Real& x_curv, Real& y { if (x_used <= keyPts[i]) { - return l_sectionMaterials.get(i - 1)->getMechanicalParamAtX(youngModulus, cPoisson, massDensity); + return l_sectionMaterials.get(i - 1)->getMechanicalParameters(youngModulus, cPoisson, massDensity); } } diff --git a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h index c8ea23b1f..786c37fbf 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h +++ b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.h @@ -118,6 +118,8 @@ class AdaptiveBeamForceFieldAndMass : public core::behavior::Mass Real _A, _L, _Iy, _Iz, _Asy, _Asz, _J; ///< Interpolation & geometrical parameters Real _rho; + Real _youngM; + Real _cPoisson; }; public: @@ -198,7 +200,6 @@ class AdaptiveBeamForceFieldAndMass : public core::behavior::Mass protected : SingleLink, BInterpolation, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK> l_interpolation; - SingleLink, WireRestShape, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK> l_instrumentParameters; void applyMassLarge( VecDeriv& df, int bIndex, Index nd0Id, Index nd1Id, SReal factor); void applyStiffnessLarge( VecDeriv& df, const VecDeriv& dx, int beam, Index nd0Id, Index nd1Id, SReal factor ); diff --git a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl index df39b10ec..a7f215d59 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl +++ b/src/BeamAdapter/component/forcefield/AdaptiveBeamForceFieldAndMass.inl @@ -65,7 +65,6 @@ AdaptiveBeamForceFieldAndMass::AdaptiveBeamForceFieldAndMass() , d_useShearStressComputation(initData(&d_useShearStressComputation, true, "shearStressComputation","if false, suppress the shear stress in the computation")) , d_reinforceLength(initData(&d_reinforceLength, false, "reinforceLength", "if true, a separate computation for the error in elongation is peformed")) , l_interpolation(initLink("interpolation","Path to the Interpolation component on scene")) - , l_instrumentParameters(initLink("instrumentParameters", "link to an object specifying physical parameters based on abscissa")) { } @@ -105,37 +104,30 @@ void AdaptiveBeamForceFieldAndMass::computeGravityVector() template void AdaptiveBeamForceFieldAndMass::computeStiffness(int beamId, BeamLocalMatrices& beamLocalMatrices) { - Real x_curv = 0.0 ; - Real _nu = 0.0 ; - Real _E = 0.0 ; - - ///Get the curvilinear abscissa of the extremity of the beam - l_interpolation->getYoungModulusAtX(beamId, x_curv, _E, _nu); - /// material parameters - Real _G = _E / (2.0 * (1.0 + _nu)); + Real _G = beamLocalMatrices._youngM / (2.0 * (1.0 + beamLocalMatrices._cPoisson)); Real phiy, phiz; Real L2 = (Real) (beamLocalMatrices._L * beamLocalMatrices._L); Real L3 = (Real) (L2 * beamLocalMatrices._L); - Real EIy = (Real)(_E * beamLocalMatrices._Iy); - Real EIz = (Real)(_E * beamLocalMatrices._Iz); + Real EIy = (Real)(beamLocalMatrices._youngM * beamLocalMatrices._Iy); + Real EIz = (Real)(beamLocalMatrices._youngM * beamLocalMatrices._Iz); /// Find shear-deformation parameters if (beamLocalMatrices._Asy == 0) phiy = 0.0; else - phiy =(L2 ==0)? 0.0: (Real)(24.0*(1.0+_nu)* beamLocalMatrices._Iz/(beamLocalMatrices._Asy*L2)); + phiy = (L2 == 0) ? 0.0 : (Real)(24.0 * (1.0 + beamLocalMatrices._cPoisson) * beamLocalMatrices._Iz / (beamLocalMatrices._Asy * L2)); if (beamLocalMatrices._Asz == 0) phiz = 0.0; else - phiz =(L2 ==0)? 0.0: (Real)(24.0*(1.0+_nu)* beamLocalMatrices._Iy/(beamLocalMatrices._Asz*L2)); + phiz = (L2 == 0) ? 0.0 : (Real)(24.0 * (1.0 + beamLocalMatrices._cPoisson) * beamLocalMatrices._Iy / (beamLocalMatrices._Asz * L2)); beamLocalMatrices.m_K00.clear(); beamLocalMatrices.m_K01.clear(); beamLocalMatrices.m_K10.clear(); beamLocalMatrices.m_K11.clear(); /// diagonal values - beamLocalMatrices.m_K00[0][0] = beamLocalMatrices.m_K11[0][0] = (beamLocalMatrices._L == 0.0)? 0.0 :_E* beamLocalMatrices._A/ beamLocalMatrices._L; + beamLocalMatrices.m_K00[0][0] = beamLocalMatrices.m_K11[0][0] = (beamLocalMatrices._L == 0.0)? 0.0 : beamLocalMatrices._youngM * beamLocalMatrices._A/ beamLocalMatrices._L; beamLocalMatrices.m_K00[1][1] = beamLocalMatrices.m_K11[1][1] = (L3 == 0.0)? 0.0 :(Real)(12.0*EIz/(L3*(1.0+phiy))); beamLocalMatrices.m_K00[2][2] = beamLocalMatrices.m_K11[2][2] = (L3 == 0.0)? 0.0 : (Real)(12.0*EIy/(L3*(1.0+phiz))); beamLocalMatrices.m_K00[3][3] = beamLocalMatrices.m_K11[3][3] = (beamLocalMatrices._L == 0.0)? 0.0 : _G* beamLocalMatrices._J/ beamLocalMatrices._L; @@ -546,28 +538,12 @@ void AdaptiveBeamForceFieldAndMass::addForce (const MechanicalParams* /// Update Interpolation & geometrical parameters with current positions /// 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.empty()) - { - Real x_curv = 0; - l_interpolation->getAbsCurvXFromBeam(beamId, x_curv); - - /// The length of the beams is only known to the interpolation ! - 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); - } + auto beamInterpolation = l_interpolation.get(); + beamInterpolation->getInterpolationParameters(beamId, beamMatrices._L, beamMatrices._A, beamMatrices._Iy, + beamMatrices._Iz, beamMatrices._Asy, beamMatrices._Asz, beamMatrices._J); + beamMatrices._rho = d_massDensity.getValue(); // for BeamInterpolation which is not overidding the _rho + beamInterpolation->getMechanicalParameters(beamId, beamMatrices._youngM, beamMatrices._cPoisson, beamMatrices._rho); /// compute the local mass matrices if(d_computeMass.getValue()) diff --git a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h index 4e6278a0a..40b68f1b4 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h +++ b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.h @@ -234,9 +234,7 @@ class AdaptiveInflatableBeamForceField : public Mass DataVecDeriv d_dataG; protected : - SingleLink, BInterpolation , BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK> l_interpolation; - SingleLink, WireRestShape, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK> l_instrumentParameters; void applyMassLarge( VecDeriv& df, const VecDeriv& dx, int bIndex, Index nd0Id, Index nd1Id, SReal factor); void applyStiffnessLarge( VecDeriv& df, const VecDeriv& dx, int beam, Index nd0Id, Index nd1Id, SReal factor ); diff --git a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl index 6dcc2ad06..d719597ab 100644 --- a/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl +++ b/src/BeamAdapter/component/forcefield/AdaptiveInflatableBeamForceField.inl @@ -67,9 +67,7 @@ AdaptiveInflatableBeamForceField::AdaptiveInflatableBeamForceField() , d_reinforceLength(initData(&d_reinforceLength, false, "reinforceLength", "if true, a separate computation for the error in elongation is peformed")) , d_pressure(initData(&d_pressure, (Real)0.0, "pressure", "pressure inside the inflatable Beam")) , d_dataG(initData(&d_dataG,"dataG","Gravity 3d vector")) - , l_interpolation(initLink("interpolation","Path to the Interpolation component on scene")) - , l_instrumentParameters(initLink("instrumentParameters", "link to an object specifying physical parameters based on abscissa")) { } @@ -126,11 +124,12 @@ template void AdaptiveInflatableBeamForceField::computeStiffness(int beam, BeamLocalMatrices& beamLocalMatrices) { Real x_curv = 0.0 ; + Real _rho = 0.0 ; Real _nu = 0.0 ; Real _E = 0.0 ; ///Get the curvilinear abscissa of the extremity of the beam - l_interpolation->getYoungModulusAtX(beam,x_curv, _E, _nu); + l_interpolation->getMechanicalParameters(beam, _E, _nu, _rho); /// material parameters Real _G; @@ -138,17 +137,7 @@ void AdaptiveInflatableBeamForceField::computeStiffness(int beam, Bea /// interpolation & geometrical parameters Real _A, _L, _Iy, _Iz, _Asy, _Asz, _J; - l_interpolation->getInterpolationParam(beam, _L, _A, _Iy , _Iz, _Asy, _Asz, _J); - - - - /// Temp : we only overide values for which a Data has been set in the WireRestShape - if(l_instrumentParameters.get()) - { - Real x_curv = 0, _rho; - l_interpolation->getAbsCurvXFromBeam(beam, x_curv); - l_instrumentParameters->getInterpolationParam(x_curv, _rho, _A, _Iy , _Iz, _Asy, _Asz, _J); // The length of the beams is only known to the interpolation ! - } + l_interpolation->getInterpolationParameters(beam, _L, _A, _Iy , _Iz, _Asy, _Asz, _J); /// correction for inflated beam (effective shear area for circular tubes with thin walls _Asy = 0.5; @@ -157,8 +146,6 @@ void AdaptiveInflatableBeamForceField::computeStiffness(int beam, Bea /// pressure Real P = this->d_pressure.getValue(); - - Real phiy, phiz; Real L2 = (Real) (_L * _L); Real L3 = (Real) (L2 * _L); @@ -231,17 +218,7 @@ void AdaptiveInflatableBeamForceField::computeMass(int beam, BeamLoca /// interpolation & geometrical parameters Real _A, _L, _Iy, _Iz, _Asy, _Asz, _J; - l_interpolation->getInterpolationParam(beam, _L, _A, _Iy , _Iz, _Asy, _Asz, _J); - - /// Temp : we only overide values for which a Data has been set in the WireRestShape - if(l_instrumentParameters.get()) - { - Real x_curv = 0; - l_interpolation->getAbsCurvXFromBeam(beam, x_curv); - - /// The length of the beams is only known to the interpolation ! - l_instrumentParameters->getInterpolationParam(x_curv, _rho, _A, _Iy , _Iz, _Asy, _Asz, _J); - } + l_interpolation->getInterpolationParameters(beam, _L, _A, _Iy , _Iz, _Asy, _Asz, _J); Real L2 = (Real) (_L * _L); beamLocalMatrix.m_M00.clear(); beamLocalMatrix.m_M01.clear(); beamLocalMatrix.m_M10.clear(); beamLocalMatrix.m_M11.clear(); diff --git a/src/BeamAdapter/component/model/BaseRodSectionMaterial.h b/src/BeamAdapter/component/model/BaseRodSectionMaterial.h index b2188145e..9050097d2 100644 --- a/src/BeamAdapter/component/model/BaseRodSectionMaterial.h +++ b/src/BeamAdapter/component/model/BaseRodSectionMaterial.h @@ -80,17 +80,15 @@ class BaseRodSectionMaterial : public core::objectmodel::BaseObject /// Returns the total length of this section. To be set or computed by child. [[nodiscard]] Real getLength() const { return d_length.getValue(); } - /// Returns the Young modulus and Poisson's coefficient of this section - void getYoungModulusAtX(Real& youngModulus, Real& cPoisson) const; + + /// Returns the BeamSection @sa m_beamSection corresponding to this section + [[nodiscard]] const BeamSection& getBeamSection() const { return m_beamSection; } /// Returns the mass density and the BeamSection of this section - void getInterpolationParam(Real& _rho, Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& _J) const; + void getInterpolationParameters(Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& _J) const; /// Returns the Young modulus, Poisson's and massDensity coefficient of this section - void getMechanicalParamAtX(Real& youngModulus, Real& cPoisson, Real& massDensity) const; - - /// Returns the BeamSection @sa m_beamSection corresponding to this section - [[nodiscard]] const BeamSection& getBeamSection() const { return m_beamSection; } + void getMechanicalParameters(Real& youngModulus, Real& cPoisson, Real& massDensity) const; /// This function is called to get the rest position of the beam depending on the current curved abscisse given in parameter virtual void getRestTransformOnX(Transform& global_H_local, const Real& x_used, const Real& x_start) diff --git a/src/BeamAdapter/component/model/BaseRodSectionMaterial.inl b/src/BeamAdapter/component/model/BaseRodSectionMaterial.inl index 58b9526f9..113f838f5 100644 --- a/src/BeamAdapter/component/model/BaseRodSectionMaterial.inl +++ b/src/BeamAdapter/component/model/BaseRodSectionMaterial.inl @@ -69,20 +69,8 @@ void BaseRodSectionMaterial::init() template -void BaseRodSectionMaterial::getYoungModulusAtX(Real& youngModulus, Real& cPoisson) const +void BaseRodSectionMaterial::getInterpolationParameters(Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& _J) const { - youngModulus = this->d_youngModulus.getValue(); - cPoisson = this->d_poissonRatio.getValue(); -} - - -template -void BaseRodSectionMaterial::getInterpolationParam(Real& _rho, Real& _A, Real& _Iy, Real& _Iz, Real& _Asy, Real& _Asz, Real& _J) const -{ - if (d_massDensity.isSet()) { - _rho = d_massDensity.getValue(); - } - _A = m_beamSection._A; _Iy = m_beamSection._Iy; _Iz = m_beamSection._Iz; @@ -93,7 +81,7 @@ void BaseRodSectionMaterial::getInterpolationParam(Real& _rho, Real& template -void BaseRodSectionMaterial::getMechanicalParamAtX(Real& youngModulus, Real& cPoisson, Real& massDensity) const +void BaseRodSectionMaterial::getMechanicalParameters(Real& youngModulus, Real& cPoisson, Real& massDensity) const { youngModulus = this->d_youngModulus.getValue(); cPoisson = this->d_poissonRatio.getValue();