Skip to content

Commit

Permalink
Merge branch 'master' into inf_fix_meshtopology_init
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod authored Dec 26, 2024
2 parents 37b409e + e2b9428 commit 515f390
Show file tree
Hide file tree
Showing 493 changed files with 41,482 additions and 4,218 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "CI - Nix"

on:
push:

jobs:
nix:
runs-on: "${{ matrix.os }}-latest"
if: ${{ github.repository_owner == 'sofa-framework' }}
strategy:
matrix:
os: [ubuntu, macos]
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
# TODO: the "sofa" account on cachix does not exist yet
#- uses: cachix/cachix-action@v15
#with:
#name: sofa
#authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build -L
78 changes: 0 additions & 78 deletions .github/workflows/post-agenda-sofa-dev-meeting.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void ConstraintAnimationLoop::freeMotion(const core::ExecParams* params, simulat
if(d_schemeCorrection.getValue())
{
sofa::core::ConstraintParams cparams(*params);
sofa::core::MultiVecDerivId f = core::VecDerivId::externalForce();
sofa::core::MultiVecDerivId f = core::vec_id::write_access::externalForce;

for (auto cc : constraintCorrections)
{
Expand All @@ -319,7 +319,7 @@ void ConstraintAnimationLoop::freeMotion(const core::ExecParams* params, simulat

{
sofa::core::MechanicalParams mparams(*params);
sofa::core::MultiVecCoordId xfree = sofa::core::VecCoordId::freePosition();
sofa::core::MultiVecCoordId xfree = sofa::core::vec_id::write_access::freePosition;
mparams.x() = xfree;
MechanicalProjectPositionVisitor(&mparams, 0, xfree ).execute(context);
MechanicalPropagateOnlyPositionVisitor(&mparams, 0, xfree ).execute(context);
Expand All @@ -331,7 +331,7 @@ void ConstraintAnimationLoop::freeMotion(const core::ExecParams* params, simulat
////////propagate acceleration ? //////

//this is done to set dx to zero in subgraph
core::MultiVecDerivId dx_id = core::VecDerivId::dx();
core::MultiVecDerivId dx_id = core::vec_id::write_access::dx;
MechanicalVOpVisitor(params, dx_id, core::ConstVecId::null(), core::ConstVecId::null(), 1.0 ).setMapped(true).execute(context);

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -393,28 +393,28 @@ void ConstraintAnimationLoop::setConstraintEquations(const core::ExecParams* par
void ConstraintAnimationLoop::writeAndAccumulateAndCountConstraintDirections(const core::ExecParams* params, simulation::Node *context, unsigned int &numConstraints)
{
core::ConstraintParams cparams = core::ConstraintParams(*params);
cparams.setX(core::ConstVecCoordId::freePosition());
cparams.setV(core::ConstVecDerivId::freeVelocity());
cparams.setX(core::vec_id::read_access::freePosition);
cparams.setV(core::vec_id::read_access::freeVelocity);

// calling resetConstraint on LMConstraints and MechanicalStates
MechanicalResetConstraintVisitor(&cparams).execute(context);

// calling applyConstraint on each constraint
MechanicalSetConstraint(&cparams, core::MatrixDerivId::constraintJacobian(), numConstraints).execute(context);
MechanicalSetConstraint(&cparams, core::vec_id::write_access::constraintJacobian, numConstraints).execute(context);

sofa::helper::AdvancedTimer::valSet("numConstraints", numConstraints);

// calling accumulateConstraint on the mappings
MechanicalAccumulateConstraint2(&cparams, core::MatrixDerivId::constraintJacobian()).execute(context);
MechanicalAccumulateConstraint2(&cparams, core::vec_id::write_access::constraintJacobian).execute(context);

getCP()->clear(numConstraints,this->d_tol.getValue());
}

void ConstraintAnimationLoop::getIndividualConstraintViolations(const core::ExecParams* params, simulation::Node *context)
{
core::ConstraintParams cparams = core::ConstraintParams(*params);
cparams.setX(core::ConstVecCoordId::freePosition());
cparams.setV(core::ConstVecDerivId::freeVelocity());
cparams.setX(core::vec_id::read_access::freePosition);
cparams.setV(core::vec_id::read_access::freeVelocity);

constraint::lagrangian::solver::MechanicalGetConstraintViolationVisitor(&cparams, getCP()->getDfree()).execute(context);
}
Expand All @@ -423,8 +423,8 @@ void ConstraintAnimationLoop::getIndividualConstraintSolvingProcess(const core::
{
/// calling getConstraintResolution: each constraint provides a method that is used to solve it during GS iterations
core::ConstraintParams cparams = core::ConstraintParams(*params);
cparams.setX(core::ConstVecCoordId::freePosition());
cparams.setV(core::ConstVecDerivId::freeVelocity());
cparams.setX(core::vec_id::read_access::freePosition);
cparams.setV(core::vec_id::read_access::freeVelocity);

MechanicalGetConstraintResolutionVisitor(&cparams, getCP()->getConstraintResolutions(), 0).execute(context);
}
Expand Down Expand Up @@ -467,12 +467,12 @@ void ConstraintAnimationLoop::correctiveMotion(const core::ExecParams* params, s

simulation::common::MechanicalOperations mop(params, node);

mop.propagateV(core::VecDerivId::velocity());
mop.propagateV(core::vec_id::write_access::velocity);

mop.propagateDx(core::VecDerivId::dx(), true);
mop.propagateDx(core::vec_id::write_access::dx, true);

// "mapped" x = xfree + dx
MechanicalVOpVisitor(params, core::VecCoordId::position(), core::ConstVecCoordId::freePosition(), core::ConstVecDerivId::dx(), 1.0 ).setOnlyMapped(true).execute(node);
MechanicalVOpVisitor(params, core::vec_id::write_access::position, core::vec_id::read_access::freePosition, core::vec_id::read_access::dx, 1.0 ).setOnlyMapped(true).execute(node);

if(!d_schemeCorrection.getValue())
{
Expand Down Expand Up @@ -564,8 +564,8 @@ void ConstraintAnimationLoop::step ( const core::ExecParams* params, SReal dt )

// This solver will work in freePosition and freeVelocity vectors.
// We need to initialize them if it's not already done.
MechanicalVInitVisitor<core::V_COORD>(params, core::VecCoordId::freePosition(), core::ConstVecCoordId::position(), true).execute(node);
MechanicalVInitVisitor<core::V_DERIV>(params, core::VecDerivId::freeVelocity(), core::ConstVecDerivId::velocity()).execute(node);
MechanicalVInitVisitor<core::V_COORD>(params, core::vec_id::write_access::freePosition, core::vec_id::read_access::position, true).execute(node);
MechanicalVInitVisitor<core::V_DERIV>(params, core::vec_id::write_access::freeVelocity, core::vec_id::read_access::velocity).execute(node);

if (d_doCollisionsFirst.getValue())
{
Expand Down Expand Up @@ -622,8 +622,8 @@ void ConstraintAnimationLoop::step ( const core::ExecParams* params, SReal dt )

//////////////// BEFORE APPLYING CONSTRAINT : propagate position through mapping
core::MechanicalParams mparams(*params);
MechanicalProjectPositionVisitor(&mparams, 0, core::VecCoordId::position()).execute(node);
MechanicalPropagateOnlyPositionVisitor(&mparams, 0, core::VecCoordId::position()).execute(node);
MechanicalProjectPositionVisitor(&mparams, 0, core::vec_id::write_access::position).execute(node);
MechanicalPropagateOnlyPositionVisitor(&mparams, 0, core::vec_id::write_access::position).execute(node);


/// CONSTRAINT SPACE & COMPLIANCE COMPUTATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ void FreeMotionAnimationLoop::init()

simulation::common::VectorOperations vop(core::execparams::defaultInstance(), getContext());

MultiVecDeriv dx(&vop, core::VecDerivId::dx());
MultiVecDeriv dx(&vop, core::vec_id::write_access::dx);
dx.realloc(&vop, !d_threadSafeVisitor.getValue(), true);

MultiVecDeriv df(&vop, core::VecDerivId::dforce());
MultiVecDeriv df(&vop, core::vec_id::write_access::dforce);
df.realloc(&vop, !d_threadSafeVisitor.getValue(), true);

if (!l_constraintSolver)
Expand Down Expand Up @@ -163,10 +163,10 @@ void FreeMotionAnimationLoop::step(const sofa::core::ExecParams* params, SReal d
simulation::common::VectorOperations vop(params, node);
simulation::common::MechanicalOperations mop(params, getContext());

MultiVecCoord pos(&vop, core::VecCoordId::position() );
MultiVecDeriv vel(&vop, core::VecDerivId::velocity() );
MultiVecCoord freePos(&vop, core::VecCoordId::freePosition() );
MultiVecDeriv freeVel(&vop, core::VecDerivId::freeVelocity() );
MultiVecCoord pos(&vop, core::vec_id::write_access::position );
MultiVecDeriv vel(&vop, core::vec_id::write_access::velocity );
MultiVecCoord freePos(&vop, core::vec_id::write_access::freePosition );
MultiVecDeriv freeVel(&vop, core::vec_id::write_access::freeVelocity );

core::ConstraintParams cparams(*params);
cparams.setX(freePos);
Expand All @@ -175,18 +175,18 @@ void FreeMotionAnimationLoop::step(const sofa::core::ExecParams* params, SReal d
cparams.setLambda(l_constraintSolver->getLambda());
cparams.setOrder(m_solveVelocityConstraintFirst.getValue() ? core::ConstraintOrder::VEL : core::ConstraintOrder::POS_AND_VEL);

MultiVecDeriv dx(&vop, core::VecDerivId::dx());
MultiVecDeriv dx(&vop, core::vec_id::write_access::dx);
dx.realloc(&vop, !d_threadSafeVisitor.getValue(), true);

MultiVecDeriv df(&vop, core::VecDerivId::dforce());
MultiVecDeriv df(&vop, core::vec_id::write_access::dforce);
df.realloc(&vop, !d_threadSafeVisitor.getValue(), true);

// This solver will work in freePosition and freeVelocity vectors.
// We need to initialize them if it's not already done.
{
SCOPED_TIMER("MechanicalVInitVisitor");
MechanicalVInitVisitor< core::V_COORD >(params, core::VecCoordId::freePosition(), core::ConstVecCoordId::position(), true).execute(node);
MechanicalVInitVisitor< core::V_DERIV >(params, core::VecDerivId::freeVelocity(), core::ConstVecDerivId::velocity(), true).execute(node);
MechanicalVInitVisitor< core::V_COORD >(params, core::vec_id::write_access::freePosition, core::vec_id::read_access::position, true).execute(node);
MechanicalVInitVisitor< core::V_DERIV >(params, core::vec_id::write_access::freeVelocity, core::vec_id::read_access::velocity, true).execute(node);
}

// This animation loop works with lagrangian constraints. Forces derive from the constraints.
Expand Down Expand Up @@ -352,7 +352,14 @@ void FreeMotionAnimationLoop::computeFreeMotionAndCollisionDetection(const sofa:
preCollisionComputation(params);

{
ScopedAdvancedTimer collisionResetTimer("CollisionReset");
SCOPED_TIMER("ProcessGeometricalData");
ProcessGeometricalDataVisitor act(params);
act.setTags(this->getTags());
act.execute(node);
}

{
SCOPED_TIMER("CollisionReset");
CollisionResetVisitor act(params);
act.setTags(this->getTags());
act.execute(node);
Expand All @@ -362,19 +369,19 @@ void FreeMotionAnimationLoop::computeFreeMotionAndCollisionDetection(const sofa:
taskScheduler->addTask(freeMotionTaskStatus, [&]() { computeFreeMotion(params, cparams, dt, pos, freePos, freeVel, mop); });

{
ScopedAdvancedTimer collisionDetectionTimer("CollisionDetection");
SCOPED_TIMER("CollisionDetection");
CollisionDetectionVisitor act(params);
act.setTags(this->getTags());
act.execute(node);
}

{
ScopedAdvancedTimer waitFreeMotionTimer("WaitFreeMotion");
SCOPED_TIMER("WaitFreeMotion");
taskScheduler->workUntilDone(&freeMotionTaskStatus);
}

{
ScopedAdvancedTimer collisionResponseTimer("CollisionResponse");
SCOPED_TIMER("CollisionResponse");
CollisionResponseVisitor act(params);
act.setTags(this->getTags());
act.execute(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ bool LocalMinDistance::testValidity(Point &p, const Vec3 &PQ) const
return true;

BaseMeshTopology* topology = p.getCollisionModel()->getCollisionTopology();
const auto& x =(p.getCollisionModel()->getMechanicalState()->read(core::ConstVecCoordId::position())->getValue());
const auto& x =(p.getCollisionModel()->getMechanicalState()->read(core::vec_id::read_access::position)->getValue());

const auto& trianglesAroundVertex = topology->getTrianglesAroundVertex(p.getIndex());
const auto& edgesAroundVertex = topology->getEdgesAroundVertex(p.getIndex());
Expand Down Expand Up @@ -1278,7 +1278,7 @@ bool LocalMinDistance::testValidity(Line &l, const Vec3 &PQ) const
AB.normalize();

BaseMeshTopology* topology = l.getCollisionModel()->getCollisionTopology();
const auto& x =(l.getCollisionModel()->getMechanicalState()->read(core::ConstVecCoordId::position())->getValue());
const auto& x =(l.getCollisionModel()->getMechanicalState()->read(core::vec_id::read_access::position)->getValue());
const auto& trianglesAroundEdge = topology->getTrianglesAroundEdge(l.getIndex());

if ( trianglesAroundEdge.size() == 2)
Expand Down
Loading

0 comments on commit 515f390

Please sign in to comment.