Skip to content
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 @@ -26,6 +26,7 @@
#include <sofa/core/visual/VisualParams.h>
#include <sofa/helper/AdvancedTimer.h>
#include <sofa/helper/ScopedAdvancedTimer.h>
#include <sofa/simulation/DifferentialOperations.h>
#include <sofa/simulation/MappingGraph.h>
#include <sofa/simulation/MechanicalOperations.h>
#include <sofa/simulation/VectorOperations.h>
Expand Down Expand Up @@ -187,7 +188,7 @@ void StaticEquilibriumIntegrationScheme::integrate(const core::ExecParams* param

//Already make a full step
updateStatesFromLinearSolution(alpha, firstIt);
m_mop->propagateX(xResult); //Need to propagate explicitly to enable recomputation of mapped Forcefield
simulation::common::DifferentialOperations::pushforwardCoord(m_mappingGraph, m_mop->mparams, xResult);

computeRHS(false);
newResidue = evaluateResidual();
Expand Down Expand Up @@ -215,7 +216,7 @@ void StaticEquilibriumIntegrationScheme::integrate(const core::ExecParams* param
alpha -= delta;

updateStatesFromLinearSolution(-delta, false);
m_mop->propagateX(xResult); //Need to propagate explicitly to enable recomputation of mapped Forcefield
simulation::common::DifferentialOperations::pushforwardCoord(m_mappingGraph, *m_params, xResult);

computeRHS(false);
newResidue = evaluateResidual();
Expand All @@ -232,7 +233,7 @@ void StaticEquilibriumIntegrationScheme::integrate(const core::ExecParams* param
if (fabs(alpha - bestalpha )> std::numeric_limits<SReal>::epsilon() )
{
updateStatesFromLinearSolution( bestalpha - alpha, false);
m_mop->propagateX(xResult); //Need to propagate explicitly to enable recomputation of mapped Forcefileld
simulation::common::DifferentialOperations::pushforwardCoord(m_mappingGraph, m_mop->mparams, xResult);

computeRHS(false);
newResidue = evaluateResidual();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <sofa/simulation/integrationscheme/AccelerationBasedImplicitIntegrationScheme.h>

#include <sofa/core/ObjectFactory.h>
#include <sofa/core/behavior/BaseMass.h>
#include <sofa/core/behavior/LinearSolver.h>
#include <sofa/core/visual/VisualParams.h>
#include <sofa/helper/AdvancedTimer.h>
#include <sofa/helper/ScopedAdvancedTimer.h>
#include <sofa/simulation/DifferentialOperations.h>
#include <sofa/simulation/mechanicalvisitor/MechanicalGetNonDiagonalMassesCountVisitor.h>
#include <sofa/simulation/mechanicalvisitor/MechanicalVOpVisitor.h>

Expand Down Expand Up @@ -124,9 +126,9 @@ void AccelerationBasedImplicitIntegrationScheme::doSetupIntegrationStep(const co
//Propagate intermediate vectors
for (unsigned i = 0; i < order; ++i)
{
m_mop->propagateX(m_x0[i]);
m_mop->propagateV(m_v0[i]);
m_mop->propagateV(m_a0[i]);
simulation::common::DifferentialOperations::pushforwardCoord(m_mappingGraph, m_mop->mparams, m_x0[i]);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_v0[i]);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_a0[i]);
}

}
Expand Down Expand Up @@ -202,8 +204,8 @@ void AccelerationBasedImplicitIntegrationScheme::computeRHS(bool firstIteration)

if (firstIteration)
{
m_mop->propagateDx(m_r1);
m_mop->propagateDx(m_r2);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r1);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r2);

m_mop->mparams.setV(m_r1);
m_mop->addMBKv(m_mappingGraph, m_r0, core::MatricesFactors::M(0.0),
Expand All @@ -217,7 +219,7 @@ void AccelerationBasedImplicitIntegrationScheme::computeRHS(bool firstIteration)
}

m_mop->mparams.setV(m_acceleration);
m_mop->propagateDx(m_acceleration);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_acceleration);

m_mop->addMBKv(m_mappingGraph, m_r0, core::MatricesFactors::M(-1.0),
core::MatricesFactors::B(0),
Expand All @@ -229,9 +231,9 @@ void AccelerationBasedImplicitIntegrationScheme::computeRHS(bool firstIteration)
m_mop->projectResponse(m_mappingGraph, m_r1);
m_mop->projectResponse(m_mappingGraph, m_r2);

m_mop->propagateDx(m_r0);
m_mop->propagateDx(m_r1);
m_mop->propagateDx(m_r2);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r0);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r1);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r2);
}

}
Expand All @@ -254,7 +256,7 @@ void AccelerationBasedImplicitIntegrationScheme::solveLinearEquation()
l_linearSolver->solveSystem();
l_linearSolver->getLinearSystem()->dispatchSystemSolution(m_systemUnknown);

m_mop->propagateDx(m_systemUnknown);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_systemUnknown);
}

void AccelerationBasedImplicitIntegrationScheme::updateStatesFromLinearSolution(SReal alpha, bool firstIteration)
Expand Down Expand Up @@ -287,9 +289,9 @@ void AccelerationBasedImplicitIntegrationScheme::updateStatesFromLinearSolution(

// TODO this collides with Free motion propagation using a MechanicalVOpVisitor and expecting a EulerImplicit
// future implementation of global Newton will reactivate those
// m_mop->propagateX(pos);
// m_mop->propagateV(vel);
// m_mop->propagateDx(acc);
// simulation::common::DifferentialOperations::pushforwardCoord(m_mappingGraph, m_mop->mparams, pos);
// simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, vel);
// simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, acc);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <sofa/simulation/integrationscheme/VelocityBasedImplicitIntegrationScheme.h>

#include <sofa/core/ObjectFactory.h>
#include <sofa/core/behavior/BaseMass.h>
#include <sofa/core/behavior/LinearSolver.h>
#include <sofa/core/visual/VisualParams.h>
#include <sofa/helper/AdvancedTimer.h>
#include <sofa/helper/ScopedAdvancedTimer.h>
#include <sofa/simulation/DifferentialOperations.h>

#include <sofa/simulation/mechanicalvisitor/MechanicalVOpVisitor.h>
using sofa::simulation::mechanicalvisitor::MechanicalVOpVisitor;
Expand Down Expand Up @@ -204,7 +206,7 @@ void VelocityBasedImplicitIntegrationScheme::computeRHS(bool firstIteration)
{
// This propagation is needed for forcefields that are applied to mapped objects. Then,
// those mapped objects need to have the r1 up to date otherwise it'll add 0.
m_mop->propagateDx(m_r1);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r1);

m_mop->mparams.setV(m_r1);
m_mop->addMBKv(m_mappingGraph,m_r0, core::MatricesFactors::M(0.0),
Expand All @@ -220,7 +222,7 @@ void VelocityBasedImplicitIntegrationScheme::computeRHS(bool firstIteration)
computeAccelerationFromVelocity(*m_vop, m_acceleration, m_vResult);

// Again, as for m_r1, this propagation is needed for Mapped mass.
m_mop->propagateDx(m_acceleration);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_acceleration);

m_mop->mparams.setV(m_acceleration);
m_mop->addMBKv(m_mappingGraph,m_r0, core::MatricesFactors::M(-1.0),
Expand All @@ -247,8 +249,8 @@ void VelocityBasedImplicitIntegrationScheme::computeRHS(bool firstIteration)
m_mop->projectResponse(m_mappingGraph,m_r0);
m_mop->projectResponse(m_mappingGraph,m_r1);

m_mop->propagateDx(m_r0);
m_mop->propagateDx(m_r1);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r0);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_r1);
}

}
Expand All @@ -270,7 +272,7 @@ void VelocityBasedImplicitIntegrationScheme::solveLinearEquation()
l_linearSolver->solveSystem();
l_linearSolver->getLinearSystem()->dispatchSystemSolution(m_systemUnknown);

m_mop->propagateDx(m_systemUnknown);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_systemUnknown);
}

void VelocityBasedImplicitIntegrationScheme::updateStatesFromLinearSolution(SReal alpha, bool firstIteration)
Expand All @@ -294,8 +296,8 @@ void VelocityBasedImplicitIntegrationScheme::updateStatesFromLinearSolution(SRea

// TODO this collides with Free motion propagation using a MechanicalVOpVisitor and expecting a EulerImplicit
// future implementation of global Newton will reactivate those
// m_mop->propagateX(pos);
// m_mop->propagateV(vel);
// simulation::common::DifferentialOperations::pushforwardCoord(m_mappingGraph, m_mop->mparams, pos);
// simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, vel);

}

Expand All @@ -305,7 +307,7 @@ void VelocityBasedImplicitIntegrationScheme::finalizeIntegrationStep()
if (d_computeFinalAcceleration.getValue())
{
computeAccelerationFromVelocity(*m_vop, m_acceleration, m_vResult);
m_mop->propagateDx(m_acceleration);
simulation::common::DifferentialOperations::pushforwardTangent(m_mappingGraph, m_mop->mparams, m_acceleration);
}
}

Expand Down
Loading