@@ -492,15 +492,22 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const sofa::core::Mecha
492492
493493 auto f = sofa::helper::getWriteOnlyAccessor (dataf);
494494 const VecCoord& x = datax.getValue ();
495+ const auto & massDensity = helper::getReadAccessor (d_massDensity);
495496
496497 f.resize (x.size ()); // current content of the vector will remain the same (http://www.cplusplus.com/reference/vector/vector/resize/)
497498
498499 const auto numBeams = l_interpolation->getNumBeams ();
499500 m_localBeamMatrices.resize (numBeams);
500501
501- if (d_computeMass.getValue ())
502+ const bool computeMass = d_computeMass.getValue ();
503+ const bool reinforceLength = d_reinforceLength.getValue ();
504+ const bool useShearStressComputation = d_useShearStressComputation.getValue ();
505+
506+ if (computeMass)
507+ {
502508 computeGravityVector ();
503-
509+ }
510+
504511 // / TODO:
505512 // /* Redimentionner _localBeamMatrices
506513 // /* Calculer les rotation et les transformations
@@ -560,11 +567,9 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const sofa::core::Mecha
560567 // / Update Interpolation & geometrical parameters with current positions
561568
562569 // / material parameters
563- auto beamInterpolation = l_interpolation.get ();
564- beamInterpolation->getInterpolationParameters (beamId, beamMatrices._L , beamMatrices._A , beamMatrices._Iy ,
570+ l_interpolation->getInterpolationParameters (beamId, beamMatrices._L , beamMatrices._A , beamMatrices._Iy ,
565571 beamMatrices._Iz , beamMatrices._Asy , beamMatrices._Asz , beamMatrices._J );
566572
567- const auto & massDensity = helper::getReadAccessor (d_massDensity);
568573 // for BeamInterpolation which is not overidding the _rho
569574 if (beamId < static_cast <sofa::Index>(massDensity.size ()))
570575 {
@@ -574,12 +579,12 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const sofa::core::Mecha
574579 {
575580 beamMatrices._rho = m_defaultMassDensity;
576581 }
577- beamInterpolation ->getMechanicalParameters (beamId, beamMatrices._youngM , beamMatrices._cPoisson , beamMatrices._rho );
582+ l_interpolation ->getMechanicalParameters (beamId, beamMatrices._youngM , beamMatrices._cPoisson , beamMatrices._rho );
578583
579584 // / compute the local mass matrices
580- if (d_computeMass. getValue () )
585+ if (computeMass )
581586 {
582- computeMass (beamId, beamMatrices);
587+ this -> computeMass (beamId, beamMatrices);
583588 }
584589
585590 // / IF RIGIDIFICATION: no stiffness forces:
@@ -610,7 +615,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const sofa::core::Mecha
610615 U1local[i+3 ] = u1.getAngularVelocity ()[i];
611616 }
612617
613- if (d_reinforceLength. getValue () )
618+ if (reinforceLength )
614619 {
615620 Vec3 P0,P1,P2,P3;
616621 Real length;
@@ -622,7 +627,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const sofa::core::Mecha
622627 U1local[0 ]=( length-rest_length)/2 ;
623628 }
624629
625- if (!d_useShearStressComputation. getValue () )
630+ if (!useShearStressComputation )
626631 {
627632 // ///////////////// TEST //////////////////////
628633 // / test: correction due to spline computation;
@@ -657,7 +662,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::addForce (const sofa::core::Mecha
657662 }
658663 }
659664
660- if (d_computeMass. getValue () )
665+ if (computeMass )
661666 {
662667 // / will add gravity directly using m_gravity:
663668 DataVecDeriv emptyVec;
0 commit comments