Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow SOFA Lifecycle v24.06 #139

Merged
merged 4 commits into from
Mar 13, 2024
Merged
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 @@ -159,7 +159,6 @@ struct AdaptiveBeamForceFieldAndMassTest : public sofa::testing::BaseSimulationT
EXPECT_NEAR(positions[id][2], 0, 1e-4);

// run some simulation steps
auto simulation = sofa::simulation::getSimulation();
for (int i = 0; i < nbrStep; i++)
{
sofa::simulation::node::animate(root.get(), 0.01);
Expand Down
2 changes: 1 addition & 1 deletion BeamAdapter_test/component/model/WireRestShape_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void WireRestShape_test::testParameterInit()
EXPECT_EQ(nbP_density.size(), 2);
EXPECT_EQ(nbP_density, nbP_density_ref);

Real dx1, dx2, dx3, nbEdgesCol_ref = 20;
Real dx1, dx2, dx3;
wire->getCollisionSampling(dx1, 0.0);
wire->getCollisionSampling(dx2, fullLength);
wire->getCollisionSampling(dx3, 90.0);
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY FOLDER "plugins")

# Config files and install rules for pythons scripts
sofa_install_pythonscripts(PLUGIN_NAME ${PROJECT_NAME} PYTHONSCRIPTS_SOURCE_DIR "python")
sofa_install_pythonscripts(PLUGIN_NAME ${PROJECT_NAME} PYTHONSCRIPTS_SOURCE_DIR "examples/python3")

sofa_add_subdirectory(plugin extensions/CUDA BeamAdapter.CUDA)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def createScene(rootNode):

rootNode.addObject('DefaultVisualManagerLoop')
rootNode.addObject('FreeMotionAnimationLoop')
rootNode.addObject('GenericConstraintSolver', tolerance="1e-3", maxIterations="5000", unbuilt="false")
rootNode.addObject('GenericConstraintSolver', tolerance="1e-3", maxIterations="5000", resolutionMethod="UnbuiltGaussSeidel")
rootNode.addObject('CollisionPipeline', depth="6", verbose="0", draw="1")
rootNode.addObject('BruteForceBroadPhase', name='N2')
rootNode.addObject('BVHNarrowPhase')
Expand Down
6 changes: 4 additions & 2 deletions src/BeamAdapter/component/BeamInterpolation.inl
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,16 @@ template <class DataTypes>
void BeamInterpolation<DataTypes>::getYoungModulusAtX(int beamId, Real& /*x_curv*/, Real& youngModulus, Real& cPoisson)
{
const auto& defaultYoungModuli = d_defaultYoungModulus.getValue();
if (beamId < defaultYoungModuli.size()) {
if (beamId < int(defaultYoungModuli.size())) {

youngModulus = defaultYoungModuli[beamId];
} else {
youngModulus = m_defaultYoungModulus;
}

const auto& poissonRatios = d_poissonRatio.getValue();
if (beamId < poissonRatios.size()) {
if (beamId < int(poissonRatios.size())) {

cPoisson = poissonRatios[beamId];
} else {
cPoisson = m_defaultPoissonRatio;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ public:
AdaptiveBeamLengthConstraintResolution(SReal* initF=nullptr, bool* active=nullptr) : ConstraintResolution(1) ,m_initF(initF), m_active(active)
{
}
void init(int line, SReal** w, SReal* force) override;
void resolution(int line, SReal** w, SReal* d, SReal* force);
void store(int line, SReal* force, bool convergence) override;
virtual void init(int line, SReal** w, SReal* force) override;
virtual void store(int line, SReal* force, bool convergence) override;

using sofa::core::behavior::ConstraintResolution::resolution;
void resolution(int line, SReal** w, SReal* d, SReal* force);

protected:
SReal* m_initF;
bool* m_active;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void AdaptiveBeamSlidingConstraint<DataTypes>::draw(const VisualParams* vparams)
points.reserve(x.size());
colors.reserve(x.size());

for (auto i = 0; i < x.size(); i++)
for (sofa::Size i = 0; i < x.size(); i++)
{
point = DataTypes::getCPos(x[i]);
points.push_back(point);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ void ImplicitSurfaceAdaptiveConstraint<DataTypes>::draw(const core::visual::Visu
const auto stateLifeCycle = vparams->drawTool()->makeStateLifeCycle();
vparams->drawTool()->disableLighting();

std::vector<sofa::type::Vector3> pointsToDraw;
std::vector<sofa::type::Vec3> pointsToDraw;
std::vector<type::RGBAColor> colors;

typename sofa::type::vector<potentialContact>::iterator it = m_vecPotentialContact.begin();
Expand All @@ -664,7 +664,7 @@ void ImplicitSurfaceAdaptiveConstraint<DataTypes>::draw(const core::visual::Visu
vparams->drawTool()->drawPoints(pointsToDraw, 2, colors);

colors.clear();
std::vector<sofa::type::Vector3> linesToDraw;
std::vector<sofa::type::Vec3> linesToDraw;

for (unsigned int i=0; i<m_vecPotentialContact.size(); i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void BeamAdapterActionController<DataTypes>::onBeginAnimationStep(const double /
else
{
const type::vector<Real>& times = d_timeSteps.getValue();
if (!times.empty() && m_readStep < times.size())
if (!times.empty() && m_readStep < int(times.size()))
{
const Real& time = times[m_readStep];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ void InterventionalRadiologyController<DataTypes>::onBeginAnimationStep(const do
template <class DataTypes>
void InterventionalRadiologyController<DataTypes>::applyAction(sofa::beamadapter::BeamAdapterAction action)
{
int id = d_controlledInstrument.getValue();
if (id >= m_instrumentsList.size())
int id = d_controlledInstrument.getValue();
if (id >= int(m_instrumentsList.size()))
{
msg_warning() << "Controlled Instument num " << id << " does not exist (size =" << m_instrumentsList.size() << ").";
msg_warning() << "Controlled Instrument num " << id << " does not exist (size =" << m_instrumentsList.size() << ").";
return;
}

Expand Down Expand Up @@ -403,7 +403,7 @@ void InterventionalRadiologyController<DataTypes>::applyAction(sofa::beamadapter
}
case BeamAdapterAction::SWITCH_NEXT_TOOL:
{
if (id + 1 >= m_instrumentsList.size())
if (id + 1 >= int(m_instrumentsList.size()))
msg_warning() << "Switching to next tool is not possible, no more instrument in list.";
else
d_controlledInstrument.setValue(id + 1);
Expand Down Expand Up @@ -455,7 +455,7 @@ void InterventionalRadiologyController<DataTypes>::computeInstrumentsCurvAbs(typ
// Step 2 => add the beams given the sampling parameters
double maxAbsLength=0.0;
Real xSampling = 0.0;
for (auto i=0; i<m_instrumentsList.size(); i++)
for (sofa::Size i=0; i<m_instrumentsList.size(); i++)
{
type::vector<Real> xP_noticeable_I;
type::vector< int > density_I;
Expand Down
12 changes: 6 additions & 6 deletions src/BeamAdapter/component/engine/WireRestShape.inl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool WireRestShape<DataTypes>::initTopology()
Real prev_length = 0.0;
int prev_edges = 0;
int startPtId = 0;
for (auto i = 0; i < l_sectionMaterials.size(); ++i)
for (sofa::Size i = 0; i < l_sectionMaterials.size(); ++i)
{
// Add topology of the material
int nbrVisuEdges = l_sectionMaterials.get(i)->getNbVisualEdges();
Expand Down Expand Up @@ -212,7 +212,7 @@ void WireRestShape<DataTypes>::getCollisionSampling(Real &dx, const Real &x_curv
}

// Check in which section x_used belongs to and get access to this section material
for (auto i = 1; i< keyPts.size(); ++i)
for (sofa::Size i = 1; i< keyPts.size(); ++i)
{
if (x_used <= keyPts[i])
{
Expand Down Expand Up @@ -245,7 +245,7 @@ void WireRestShape<DataTypes>::getRestTransformOnX(Transform &global_H_local, co
}

const type::vector<Real>& keyPts = d_keyPoints.getValue();
for (auto i = 1; i < keyPts.size(); ++i)
for (sofa::Size i = 1; i < keyPts.size(); ++i)
{
if (x_used <= keyPts[i])
{
Expand All @@ -264,7 +264,7 @@ void WireRestShape<DataTypes>::getYoungModulusAtX(const Real& x_curv, Real& youn
const type::vector<Real>& keyPts = d_keyPoints.getValue();

// Depending on the position of the beam, determine the corresponding section material and returning its Young modulus
for (auto i = 1; i < keyPts.size(); ++i)
for (sofa::Size i = 1; i < keyPts.size(); ++i)
{
if (x_used <= keyPts[i])
{
Expand All @@ -283,7 +283,7 @@ void WireRestShape<DataTypes>::getInterpolationParam(const Real& x_curv, Real &_
const type::vector<Real>& keyPts = d_keyPoints.getValue();

// Check in which section x_used belongs to and get access to this section material
for (auto i = 1; i < keyPts.size(); ++i)
for (sofa::Size i = 1; i < keyPts.size(); ++i)
{
if (x_used <= keyPts[i])
{
Expand All @@ -306,7 +306,7 @@ template <class DataTypes>
void WireRestShape<DataTypes>::getNumberOfCollisionSegment(Real &dx, unsigned int &numLines)
{
numLines = 0;
for (auto i = 0; i < l_sectionMaterials.size(); ++i)
for (sofa::Size i = 0; i < l_sectionMaterials.size(); ++i)
{
numLines += l_sectionMaterials.get(i)->getNbCollisionEdges();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ void AdaptiveBeamForceFieldAndMass<DataTypes>::computeStiffness(int beamId, Beam
template<class DataTypes>
void AdaptiveBeamForceFieldAndMass<DataTypes>::computeMass(int beamId, BeamLocalMatrices& beamLocalMatrix)
{
SOFA_UNUSED(beamId);
Real L2 = (Real) (beamLocalMatrix._L * beamLocalMatrix._L);
beamLocalMatrix.m_M00.clear(); beamLocalMatrix.m_M01.clear(); beamLocalMatrix.m_M10.clear(); beamLocalMatrix.m_M11.clear();

Expand Down
1 change: 0 additions & 1 deletion src/BeamAdapter/component/mapping/AdaptiveBeamMapping.inl
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ void AdaptiveBeamMapping< TIn, TOut>::computeDistribution()
else
{
m_pointBeamDistribution.reserve(points.size());
const bool printLog = this->f_printLog.getValue();
for (unsigned int i=0; i<points.size(); i++)
{
const unsigned int beamId = (int)floor(points[i][0]);
Expand Down
2 changes: 2 additions & 0 deletions src/BeamAdapter/component/mapping/BeamLengthMapping.inl
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ void BeamLengthMapping< TIn, TOut>::reset()
template <class TIn, class TOut>
void BeamLengthMapping< TIn, TOut>::apply(const MechanicalParams* mparams, Data<VecCoord>& dOut, const Data<InVecCoord>& dIn)
{
SOFA_UNUSED(mparams);
SCOPED_TIMER("AdaptiveBeamMappingApply");

VecCoord& out = *dOut.beginEdit();
Expand Down Expand Up @@ -591,6 +592,7 @@ void BeamLengthMapping< TIn, TOut>::applyDJT(const MechanicalParams* mparams, co
template <class TIn, class TOut>
void BeamLengthMapping<TIn, TOut>::updateK(const core::MechanicalParams* mparams, core::ConstMultiVecDerivId childForceId )
{
SOFA_UNUSED(mparams);
const unsigned& geometricStiffness = d_geometricStiffness.getValue();
if( !geometricStiffness ) { K_geom.resize(0,0); return; }
//helper::ReadAccessor<Data<VecDeriv> > childForce( *childForceId[(const core::State<TOut>*)this->getToModels()[0]].read() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BeamProjectionDifferenceMultiMapping<TIn1, TIn2, TOut>::BeamProjectionDifference
, m_updateJ(false)
{
auto directions = sofa::helper::getWriteAccessor(d_directions);
directions.resize(OutDeriv::total_size, true);
directions.resize(OutDeriv::total_size);
}


Expand Down Expand Up @@ -145,7 +145,7 @@ void BeamProjectionDifferenceMultiMapping<TIn1, TIn2, TOut>::computeProjection(c
Real distMin = std::numeric_limits<Real>::max();

// find the min distance between P and its projection on each edge of xTo
for (int e=0; e<edges.size(); e++)
for (sofa::Size e=0; e<edges.size(); e++)
{
const auto& edge = edges[e];
In2Coord Q1 = xTo[edge[0]];
Expand Down
Loading