BeamAdapter
Loading...
Searching...
No Matches
BeamInterpolation< DataTypes > Class Template Reference

#include <BeamInterpolation.h>

Inheritance diagram for BeamInterpolation< DataTypes >:
BaseBeamInterpolation< DataTypes >

Public Types

using Inherit = BaseBeamInterpolation<DataTypes>
using Coord = typename DataTypes::Coord
using VecCoord = typename DataTypes::VecCoord
using Real = typename Coord::value_type
using Deriv = typename DataTypes::Deriv
using VecDeriv = typename DataTypes::VecDeriv
using Vec2 = sofa::type::Vec<2, Real>
using Vec3 = sofa::type::Vec<3, Real>
using Vec3NoInit = sofa::type::VecNoInit<3, Real>
using Quat = sofa::type::Quat<Real>
using VectorVec3 = type::vector <Vec3>
using Transform = typename sofa::defaulttype::SolidTypes<Real>::Transform
using SpatialVector = typename sofa::defaulttype::SolidTypes<Real>::SpatialVector
using PointID = BaseMeshTopology::PointID
using ElementID = BaseMeshTopology::EdgeID
using EdgeID = BaseMeshTopology::EdgeID
using VecElementID = type::vector<BaseMeshTopology::EdgeID>
using VecEdges = type::vector<BaseMeshTopology::Edge>
Public Types inherited from BaseBeamInterpolation< DataTypes >
using Inherit = sofa::core::behavior::SingleStateAccessor<DataTypes>
using Coord = typename DataTypes::Coord
using VecCoord = typename DataTypes::VecCoord
using Real = typename Coord::value_type
using Deriv = typename DataTypes::Deriv
using VecDeriv = typename DataTypes::VecDeriv
using Transform = sofa::type::Transform<Real>
using SpatialVector = sofa::type::SpatialVector<Real>
using Vec2 = sofa::type::Vec<2, Real>
using Vec3 = sofa::type::Vec<3, Real>
using Vec3NoInit = sofa::type::VecNoInit<3, Real>
using Quat = sofa::type::Quat<Real>
using VectorVec3 = type::vector <Vec3>
using PointID = BaseMeshTopology::PointID
using EdgeID = BaseMeshTopology::EdgeID
using VecEdgeID = type::vector<BaseMeshTopology::EdgeID>
using VecEdges = type::vector<BaseMeshTopology::Edge>
using StateDataTypes = sofa::defaulttype::StdVectorTypes< sofa::type::Vec<DataTypes::spatial_dimensions, Real>, sofa::type::Vec<DataTypes::spatial_dimensions, Real>, Real >
 DATA INPUT (that could change in real-time).

Public Member Functions

 SOFA_CLASS (SOFA_TEMPLATE(BeamInterpolation, DataTypes), SOFA_TEMPLATE(BaseBeamInterpolation, DataTypes))
void init () override
void reinit () override
void reset () override
void storeResetState () override
 In the context of beam interpolation, this function (easily access with Python) is used to update the interpolation (input / output).
void updateInterpolation ()
bool interpolationIsAlreadyInitialized ()
 Returns true if the interpolation is specified in the scene file (case of saved executed scenes...).
bool verifyTopology ()
void computeCrossSectionInertiaMatrix ()
const BeamSection & getBeamSection (sofa::Index beamId) override
 Returns the BeamSection.
void getInterpolationParameters (sofa::Index beamId, Real &_L, Real &_A, Real &_Iy, Real &_Iz, Real &_Asy, Real &_Asz, Real &J) override
 Returns the BeamSection data depending on the beam position at the given beam, similar to @getBeamSection.
void getMechanicalParameters (sofa::Index beamId, Real &youngModulus, Real &cPoisson, Real &massDensity) override
 Returns the Young modulus, Poisson's ratio and massDensity coefficient of the section at the given curvilinear abscissa.
void getTangentUsingSplinePoints (const EdgeID edgeInList, const Real baryCoord, const sofa::core::ConstVecCoordId &vecXId, Vec3 &t)
virtual void getCurvAbsAtBeam (const EdgeID edgeInList_input, const Real baryCoord_input, Real &x_output) override
 computeActualLength => given the 4 control points of the spline, it provides an estimate of the length (using gauss points integration)
virtual void getBeamAtCurvAbs (const Real x_input, unsigned int &edgeInList_output, Real &baryCoord_output, unsigned int start=0) override
virtual void clear () override
virtual void addBeam (const EdgeID eID, const Real length, const Real x0, const Real x1, const Real angle) override
virtual void getSamplingParameters (type::vector< Real > &xP_noticeable, type::vector< sofa::Size > &nbP_density) override
Real getRestTotalLength () override
 getLength / setLength => provides the rest length of each spline using
void getMechanicalSampling (Real &dx, const Real x_localcurv_abs) override
void getCollisionSampling (Real &dx, const Real x_localcurv_abs) override
 Collision information using.
void getNumberOfCollisionSegment (Real &dx, unsigned int &numLines) override
void setTransformBetweenDofAndNode (const sofa::Index beam, const Transform &DOF_H_Node, unsigned int zeroORone)
void getSplineRestTransform (const EdgeID edgeInList, Transform &local_H_local0_rest, Transform &local_H_local1_rest) override
unsigned int getNumBeamsNotUnderControl ()
Public Member Functions inherited from BaseBeamInterpolation< DataTypes >
 SOFA_CLASS (SOFA_TEMPLATE(BaseBeamInterpolation, DataTypes), SOFA_TEMPLATE(sofa::core::behavior::SingleStateAccessor, DataTypes))
void init () override
sofa::Size getNumBeams () const
void getAbsCurvXFromBeam (const sofa::Index beam, Real &x_curv)
void getAbsCurvXFromBeam (const sofa::Index beam, Real &x_curv_start, Real &x_curv_end)
Real getLength (const EdgeID edgeInList)
void setLength (const EdgeID edgeInList, Real &length)
void addCollisionOnBeam (const sofa::Index beam)
 Set collision information.
void clearCollisionOnBeam ()
virtual void getNumberOfCollisionSegment (Real &dx, sofa::Size &numLines)=0
virtual void getSplineRestTransform (const EdgeID edgeInList, Transform &local_H_local0_rest, Transform &local_H_local1_rest)=0
virtual void getBeamAtCurvAbs (const Real x_input, sofa::Index &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)
int computeTransform (const EdgeID edgeInList, const PointID node0Idx, const PointID node1Idx, Transform &global_H_local0, Transform &global_H_local1, const VecCoord &x)
void getDOFtoLocalTransform (const EdgeID edgeInList, Transform &DOF0_H_local0, Transform &DOF1_H_local1)
void getDOFtoLocalTransformInGlobalFrame (const EdgeID edgeInList, Transform &DOF0Global_H_local0, Transform &DOF1Global_H_local1, const VecCoord &x)
void setTransformBetweenDofAndNode (const sofa::Index beam, const Transform &DOF_H_Node, unsigned int zeroORone)
void getTangent (Vec3 &t, const Real baryCoord, const Transform &global_H_local0, const Transform &global_H_local1, const Real L)
 getTangent : Computation of a Tangent for the beam (it is given by the derivative of the spline formulation)
int getNodeIndices (const EdgeID edgeInList, unsigned int &node0Idx, unsigned int &node1Idx)
void getSplinePoints (const EdgeID edgeInList, const VecCoord &x, Vec3 &P0, Vec3 &P1, Vec3 &P2, Vec3 &P3)
unsigned int getStateSize () const
void computeActualLength (Real &length, const Vec3 &P0, const Vec3 &P1, const Vec3 &P2, const Vec3 &P3)
void computeStrechAndTwist (const EdgeID edgeInList, const VecCoord &x, Vec3 &ResultNodeO, Vec3 &ResultNode1)
void updateBezierPoints (const VecCoord &x, sofa::core::VecCoordId &vId_Out)
 vId_Out provides the id of the multiVecId which stores the position of the Bezier Points
void updateBezierPoints (const VecCoord &x, sofa::Index index, VectorVec3 &v)
void interpolatePointUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, Vec3 &posResult)
 spline base interpolation of points and transformation
void interpolatePointUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, Vec3 &posResult, bool recompute, const sofa::core::ConstVecCoordId &vecXId)
void InterpolateTransformUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, Transform &global_H_localInterpol)
void InterpolateTransformUsingSpline (Transform &global_H_localResult, const Real baryCoord, const Transform &global_H_local0, const Transform &global_H_local1, const Real L)
void InterpolateTransformAndVelUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, const VecDeriv &v, Transform &global_H_localInterpol, Deriv &v_interpol)
Real ComputeTotalBendingRotationAngle (const Real dx_computation, const Transform &global_H_local0, const Transform &global_H_local1, const Real L, const Real baryCoordMin, const Real baryCoordMax)
 compute the total bending Rotation Angle while going through the Spline (to estimate the curvature)
void MapForceOnNodeUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, const Vec3 &finput, SpatialVector &FNode0output, SpatialVector &FNode1output)
 3DOF mapping
void MapForceOnNodeUsingSpline (const EdgeID edgeInList, const Real baryCoord, const Vec3 &localPos, const VecCoord &x, const SpatialVector &f6DofInput, SpatialVector &FNode0output, SpatialVector &FNode1output)
 6DoF mapping

Static Public Member Functions

template<class T>
static bool canCreate (T *obj, sofa::core::objectmodel::BaseContext *context, sofa::core::objectmodel::BaseObjectDescription *arg)
Static Public Member Functions inherited from BaseBeamInterpolation< DataTypes >
static void getControlPointsFromFrame (const Transform &global_H_local0, const Transform &global_H_local1, const Real L, Vec3 &P0, Vec3 &P1, Vec3 &P2, Vec3 &P3)
static void RotateFrameForAlignX (const Quat &input, Vec3 &x, Quat &output)
 Method to rotate a Frame define by a Quat.
static void RotateFrameForAlignNormalizedX (const Quat &input, const Vec3 &x, Quat &output)
 Method to rotate a Frame define by a Quat.

Public Attributes

Data< helper::OptionsGroup > crossSectionShape
Real m_defaultRadius
 Circular Cross Section.
Data< type::vector< Real > > d_radius
Real m_defaultInnerRadius
Data< type::vector< Real > > d_innerRadius
Data< Real > d_sideLength
 Square Cross Section.
Data< Real > d_smallRadius
 Elliptic Cross Section.
Data< Real > d_largeRadius
Real m_defaultLengthY
 Rectangular Cross Section.
Data< type::vector< Real > > d_lengthY
Real m_defaultLengthZ
Data< type::vector< Real > > d_lengthZ
Data< bool > d_dofsAndBeamsAligned
Real m_defaultYoungModulus
Data< type::vector< Real > > d_defaultYoungModulus
Real m_defaultPoissonRatio
Data< type::vector< Real > > d_poissonRatio
Data< bool > d_straight
Public Attributes inherited from BaseBeamInterpolation< DataTypes >
MechanicalObject< StateDataTypes >::SPtr m_StateNodes
Data< VecEdgeID > d_edgeList
Data< type::vector< SReal > > d_lengthList
Data< type::vector< Transform > > d_DOF0TransformNode0
Data< type::vector< Transform > > d_DOF1TransformNode1
Data< type::vector< Vec2 > > d_curvAbsList
 Vector of 2 Real. absciss curv of first and second point defining the beam.
Data< sofa::type::vector< EdgeID > > d_beamCollision
Data< bool > d_dofsAndBeamsAligned
Data< sofa::Index > d_wireTipIndex
 index of the beam extremity that is considered as the tip of the wire
SingleLink< BaseBeamInterpolation< DataTypes >, BaseMeshTopology, BaseLink::FLAG_STOREPATH|BaseLink::FLAG_STRONGLINK > l_topology
 link to the (edge) topology

Protected Member Functions

void checkDataSize (Real &defaultValue, Data< type::vector< Real > > &dataList, const size_t &nbEdges)
void computeRectangularCrossSectionInertiaMatrix (const Real Ly, const Real Lz, BeamSection &section)
void computeCircularCrossSectionInertiaMatrix (const Real r, const Real rInner, BeamSection &section)

Protected Attributes

Data< OptionsGroup > d_vecID
Data< type::vector< Vec2 > > d_InterpolationInputs
 Input 2. Vector of 2-tuples (indice of the beam , barycentric between 0 and 1).
Data< VecCoord > d_InterpolatedPos
 Output.
Data< VecDeriv > d_InterpolatedVel
bool m_constantBeam {true}
 GEOMETRICAL COMPUTATION (for now we suppose that the radius of the beam do not vary in space / in time).
BeamSection m_constantSection
type::vector< BeamSection > m_section

Detailed Description

template<class DataTypes>
class beamadapter::BeamInterpolation< DataTypes >

This class implements a Sofa Component that provide interpolation method to compute Finite Element elastic force and mass based on Adaptive 6D beam elements.

  • Adaptive beam interpolation
  • Adaptive Force and Mass computation
  • Adaptive Mapping

AdaptiveBeam Interpolation provides the basis of the Beam computation As the computation is adaptive, the interpolation can be modified at each time step.

More informations about SOFA components: https://www.sofa-framework.org/community/doc/programming-with-sofa/create-your-component/ https://www.sofa-framework.org/community/doc/programming-with-sofa/components-api/components-and-datas/

Member Function Documentation

◆ addBeam()

template<class DataTypes>
void addBeam ( const EdgeID eID,
const Real length,
const Real x0,
const Real x1,
const Real angle )
overridevirtual

◆ canCreate()

template<class DataTypes>
template<class T>
bool canCreate ( T * obj,
sofa::core::objectmodel::BaseContext * context,
sofa::core::objectmodel::BaseObjectDescription * arg )
inlinestatic

Exposing this object in the factory /////////////////////// Pre-construction check method called by ObjectFactory. Check that DataTypes matches the MechanicalState.

◆ clear()

template<class DataTypes>
void clear ( )
overridevirtual

◆ computeCircularCrossSectionInertiaMatrix()

template<class DataTypes>
void computeCircularCrossSectionInertiaMatrix ( const Real r,
const Real rInner,
BeamSection & section )
protected

_Iz = M_PI*(r*r*r*r)/4.0;

◆ getBeamSection()

template<class DataTypes>
const BeamSection & getBeamSection ( sofa::Index beamId)
inlineoverridevirtual

Returns the BeamSection.

See also
m_beamSection corresponding to the given beam

Implements BaseBeamInterpolation< DataTypes >.

◆ getCollisionSampling()

template<class DataTypes>
void getCollisionSampling ( Real & dx,
const Real x_localcurv_abs )
overridevirtual

Collision information using.

See also
d_beamCollision

Implements BaseBeamInterpolation< DataTypes >.

◆ getCurvAbsAtBeam()

template<class DataTypes>
virtual void getCurvAbsAtBeam ( const EdgeID edgeInList_input,
const Real baryCoord_input,
Real & x_output )
inlineoverridevirtual

computeActualLength => given the 4 control points of the spline, it provides an estimate of the length (using gauss points integration)

Implements BaseBeamInterpolation< DataTypes >.

◆ getInterpolationParameters()

template<class DataTypes>
void getInterpolationParameters ( sofa::Index beamId,
Real & _L,
Real & _A,
Real & _Iy,
Real & _Iz,
Real & _Asy,
Real & _Asz,
Real & J )
overridevirtual

Returns the BeamSection data depending on the beam position at the given beam, similar to @getBeamSection.

get the length of the beam:

Implements BaseBeamInterpolation< DataTypes >.

◆ getMechanicalParameters()

template<class DataTypes>
void getMechanicalParameters ( sofa::Index beamId,
Real & youngModulus,
Real & cPoisson,
Real & massDensity )
overridevirtual

Returns the Young modulus, Poisson's ratio and massDensity coefficient of the section at the given curvilinear abscissa.

Implements BaseBeamInterpolation< DataTypes >.

◆ getMechanicalSampling()

template<class DataTypes>
void getMechanicalSampling ( Real & dx,
const Real x_localcurv_abs )
overridevirtual

◆ getRestTotalLength()

template<class DataTypes>
BeamInterpolation< DataTypes >::Real getRestTotalLength ( )
overridevirtual

getLength / setLength => provides the rest length of each spline using

See also
d_lengthList

Implements BaseBeamInterpolation< DataTypes >.

◆ getSamplingParameters()

template<class DataTypes>
void getSamplingParameters ( type::vector< Real > & xP_noticeable,
type::vector< sofa::Size > & nbP_density )
overridevirtual

◆ getSplineRestTransform()

template<class DataTypes>
void getSplineRestTransform ( const EdgeID edgeInList,
Transform & local_H_local0_rest,
Transform & local_H_local1_rest )
override

the beam is straight: local is in the middle of local0 and local1 the transformation between local0 and local1 is provided by the length of the beam

◆ updateInterpolation()

template<class DataTypes>
void updateInterpolation ( )

this function allow to use BeamInterpolation using data (TODO: see if it could fall into engine concept) inputs :

  • 1.Data<helper::OptionsGroup > d_vecID; VecID => (1) "current" Pos, Vel (2) "free" PosFree, VelFree (3) "rest" PosRest, V=0
  • 2. Data< type::vector< Vec2 > > d_InterpolationInputs; Vector of 2-tuples (indice of the beam , barycentric between 0 and 1) ouptus:
  • 1. d_InterpolatedPos => result interpolate the position (6 D0Fs type rigid: position/quaterion)
  • 2. d_InterpolatedVel => result interpolate the velocities (linear velocity / angular velocity)

const Data< VecDeriv > *v;

rest position

convert position (RigidTypes) in Transform

compute the length of the spline

get the result of the transform:

assign the result in the output data

◆ verifyTopology()

template<class DataTypes>
bool verifyTopology ( )

verify that we got a non-null pointer on the topology verify that the m_edgeList do not contain non existing edges

Member Data Documentation

◆ d_vecID

template<class DataTypes>
Data< OptionsGroup > d_vecID
protected

INPUT / OUTPUT FOR DOING EXTERNAL COMPUTATION OF Beam Interpolation (use it as a kind of data engine) Input 1. VecID => (1) "current" Pos, Vel (2) "free" PosFree, VelFree (3) "rest" PosRest, V=0