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

[Backward] Fix trapezoidal rule in EulerImplicitSolver #5169

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -130,33 +130,31 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::

{
SCOPED_TIMER("ComputeRHTerm");

if (firstOrder)
{
b.eq(f);
b.eq(f); // b = f
}
else
{
// new more powerful visitors

// force in the current configuration
b.eq(f, 1.0 / tr); // b = f
b.eq(f); // b = f

msg_info() << "EulerImplicitSolver, f = " << f;

// add the change of force due to stiffness + Rayleigh damping
mop.addMBKv(b, core::MatricesFactors::M(-d_rayleighMass.getValue()),
core::MatricesFactors::B(0),
core::MatricesFactors::K(h + d_rayleighStiffness.getValue())); // b = f + ( rm M + (h+rs) K ) v
core::MatricesFactors::K(h * tr + d_rayleighStiffness.getValue())); // b = f + ( rm M + (h+rs) K ) v

// integration over a time step
b.teq(h *
tr); // b = h(f + ( rm M + (h+rs) K ) v )
b.teq(h); // b = h(f + ( rm M + (h+rs) K ) v )
}

msg_info() << "EulerImplicitSolver, b = " << b;

mop.projectResponse(b); // b is projected to the constrained space
mop.projectResponse(b); // b is projected to the constrained space

msg_info() << "EulerImplicitSolver, projected b = " << b;
}
Expand All @@ -165,7 +163,7 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
SCOPED_TIMER("setSystemMBKMatrix");
const core::MatricesFactors::M mFact (firstOrder ? 1 : 1 + tr * h * d_rayleighMass.getValue());
const core::MatricesFactors::B bFact (firstOrder ? 0 : -tr * h);
const core::MatricesFactors::K kFact (firstOrder ? -h * tr : -tr * h * (h + d_rayleighStiffness.getValue()));
const core::MatricesFactors::K kFact (firstOrder ? -h * tr : -tr * h * (tr * h + d_rayleighStiffness.getValue()));

mop.setSystemMBKMatrix(mFact, bFact, kFact, l_linearSolver.get());

Expand Down Expand Up @@ -226,7 +224,7 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
sofa::helper::AdvancedTimer::stepBegin(prevStep);
#define SOFATIMER_NEXTSTEP(s) { sofa::helper::AdvancedTimer::stepNext(prevStep,s); prevStep=s; }

// vel = vel + x
// v(t+dt) = Δv + v(t)
newVel.eq(vel, x);

if (solveConstraint)
Expand All @@ -236,7 +234,7 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
}
SOFATIMER_NEXTSTEP("UpdateX");

// pos = pos + h vel
// x(t+dt) = x(t) + dt * v(t+dt)
newPos.eq(pos, newVel, h);

if (solveConstraint)
Expand Down
Loading