Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 0806b07
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Fri Feb 21 15:55:34 2025 +0100

    [github] Use token for performance regression launching (sofa-framework#5287)

    Try fixing action

commit 9f56fca
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Fri Feb 21 15:16:12 2025 +0100

    [github] Add workflow for performance testing launch (sofa-framework#5286)

    * Add workflow for performance testing launch

    * Fix github token and sha

commit 700b6cd
Author: Olivier Roussel <olivier.roussel@inria.fr>
Date:   Thu Feb 20 23:27:00 2025 +0100

    [IO.Mesh] Fix missing `iomanip` header in tests (sofa-framework#5279)

    Fix missing header

commit 5307e85
Author: Hugo <hugo.talbot@sofa-framework.org>
Date:   Wed Feb 19 14:25:24 2025 +0100

    [ODESolver] Update data comment in EulerImplicit (sofa-framework#5282)

commit fee9657
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Feb 19 13:48:07 2025 +0100

    [ODESolver] Add option to compute residual at the end of the solving (sofa-framework#5263)

commit a229972
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Feb 19 12:20:51 2025 +0100

    [Helper] Deprecate findOrCreateAValidPath and introduce clearer functions (sofa-framework#5264)

    * [Helper] Fix findOrCreateAValidPath when given a file path

    * [Helper] Fix findOrCreateAValidPath when given a file path

    * Introduce clearer function names

    * deprecate findOrCreateAValidPath

    * restore previous findOrCreateAValidPath

commit 4ee24f6
Author: Frederick Roy <fredroy@users.noreply.github.com>
Date:   Wed Feb 19 20:15:38 2025 +0900

    [All] Fix compilation with FLOATING_POINT_TYPE=float (sofa-framework#5269)

    fix compilation with FLOATING_POINT_TYPE=float

commit ef7ff21
Author: Hugo <hugo.talbot@sofa-framework.org>
Date:   Wed Feb 19 09:52:47 2025 +0100

    [SceneUtility] Remove *AliasComponent (sofa-framework#5241)

    * [SceneUtility] Remove *AliasComponent

    * Update in the ComponentChange so that it appears as Removed

    * remove associated scenes

commit aa36098
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Feb 19 00:04:17 2025 +0100

    [SceneChecking] Check if a Node has an empty name (sofa-framework#5276)

commit f2f0b10
Author: EulalieCoevoet <eulalie.coevoet@gmail.com>
Date:   Wed Feb 12 12:14:48 2025 +0100

    [visual] Adds features to LineAxis and DrawTools (sofa-framework#5258)

    * [visual-gl] LineAxis & DrawTool:
    - fixes usage of thickness
    - new feature: infinite lines
    - new feature: vanishing infinite line
    - fixes typo

    * [visual] LineAxis: cleaning

commit b4e8b98
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Wed Feb 12 09:35:16 2025 +0100

    [GUI] Remove Qt and make SofaImGUI as default viewer (sofa-framework#5176)

    * Add possibility to fetch and add by default for external plugins and set SofaGLFW as ON by default

    * Remove Qt-based GUI from sources

    * Add way to pull and build Sofa.Qt plugin

    * Fix compilation

    * Change order so SofaGLFW and SofaIMGUI are already in the target stack when runSofa produce the plugin_list.cong.default

    * Merge master

    * Make the packaging possible without Qt

    * Remove GuiDataRepository that was Qt specific -> will need to include it to the Qt gui plugin

    * Add fetchable Qt

commit d2f194d
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Feb 12 07:26:17 2025 +0100

    [Contact] Clean FrictionContact (sofa-framework#5261)

    * [Contact] Replace double by SReal

    * add override keyword on destructor

commit 62264fb
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Mon Feb 10 14:20:15 2025 +0100

    [StateContainer] Allow coord difference in vOp for rigids (sofa-framework#5253)

    * [StateContainer] Allow coord difference in vOp for rigids

    * check that DataTypes support coordDifference

commit 5120328
Author: erik pernod <erik.pernod@gmail.com>
Date:   Mon Feb 10 14:19:28 2025 +0100

    [Topology.Container] Add new method computeSegmentTriangleIntersectionInPlane in TriangleSetGeometryAlgorithm (sofa-framework#5188)

    * Update TriangleSetGeometryAlgorithms.h

    * Update TriangleSetGeometryAlgorithms.inl

    * [TopologyTest] Add comments

    * [Topology.Dynamic_test] factorize some code in TriangleSetTopology_test

    * [Topology.Dynamic_test] Add some tests in TriangleSetTopology_test to test adding and removing triangles

    * typo errors

    * [Topology.Dynamic_test] Add tests in TriangleSetTopology_test tto test TriangleSegmentIntersection inside same plane or with projection

    * Update TriangleSetTopology_test.cpp

    * Update TriangleSetTopology_test.cpp

    * Update TriangleSetTopology_test.cpp

    * Fix namespace

commit 5448a14
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Jan 31 15:10:05 2025 +0100

    [StateContainer] Extend the possible vector operations in vOp (sofa-framework#5237)

    * missing test

    * remove duplicated test

    * [StateContainer] Extend the possible vector operations in vOp

    ---------

    Co-authored-by: Paul Baksic <30337881+bakpaul@users.noreply.github.com>

commit 6af25d5
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Jan 31 15:04:36 2025 +0100

    [Simulation] Trigger warning when Node already contains component (sofa-framework#5212)

    * [Simulation] Trigger error when Node already contains component

    * also mention the class name

    * convert error to warning

    * fix STLExporter_test

commit 9ceb6dc
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Jan 31 15:04:21 2025 +0100

    [SofaCUDA] Print CUDA standard at init of the module (sofa-framework#5166)

    * [SofaCUDA] Print CUDA standard at init of the module

    * add an empty scene loading the plugin

    * compiler output

    * remove empty scene

commit 3eecf8f
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Jan 29 22:18:50 2025 +0100

    Bump version of Tracy from v0.9.1 to v0.11.1 (sofa-framework#5249)

commit 3659403
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Jan 29 21:39:51 2025 +0100

    [Core] Remove some static functions create (sofa-framework#5239)

commit 989a885
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Jan 29 21:03:59 2025 +0100

    [StateContainer] Extensive tests of MechanicalObject::vOp (sofa-framework#5233)

    * [StateContainer] Extensive tests of MechanicalObject::vOp

    * fix wrong name

    * fix test

    * Use variable for the coefficients

    * missing test

    * remove duplicated test

commit 38c295d
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Wed Jan 29 19:54:39 2025 +0100

    [Playback] Remove deprecated macro (sofa-framework#5231)

commit ffddff7
Author: Paul Baksic <30337881+bakpaul@users.noreply.github.com>
Date:   Wed Jan 29 19:48:23 2025 +0100

    [CMake] Add possibility to remove auto installing of resource files (sofa-framework#5230)

    Add possibility to remove auto installing of ressource files

commit 7c6bddc
Author: Alex Bilger <alxbilger@users.noreply.github.com>
Date:   Fri Jan 24 14:24:02 2025 +0100

    [ODESolver] Remove repeated class name in log messages (sofa-framework#5242)
  • Loading branch information
bakpaul committed Feb 28, 2025
1 parent b4e8d43 commit eada37f
Show file tree
Hide file tree
Showing 230 changed files with 2,380 additions and 33,470 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/launch-perf-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Launch performance testing
on:
push:
branches:
- master
jobs:
run:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'sofa-framework' }}

steps:
- name: Launch performance regression test
run: |
sudo apt install curl
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERF_REG_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/sofa-framework/PerformanceRegression/dispatches \
-d '{"event_type":"Launch perf test from SOFA commit","client_payload":{"branch":"master","commit_hash":"${{ github.sha }}"}}'
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ AugmentedLagrangianResponse<TCollisionModel1,TCollisionModel2,ResponseDataTypes>
template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
AugmentedLagrangianResponse<TCollisionModel1,TCollisionModel2,ResponseDataTypes>::AugmentedLagrangianResponse(CollisionModel1* model1, CollisionModel2* model2, Intersection* intersectionMethod)
: BaseUnilateralContactResponse<TCollisionModel1, TCollisionModel2, constraint::lagrangian::model::AugmentedLagrangianContactParameters, ResponseDataTypes>(model1,model2,intersectionMethod)
, d_mu (initData(&d_mu, 0.0, "mu", "Friction coefficient (0 for frictionless contacts)"))
, d_epsilon (initData(&d_epsilon, 0.0, "epsilon", "Penalty parameter. It can be think of as a proportional controller, the Lagrange multiplier is augmented by the violation multiplied by this factor at each solving iteration."))
, d_mu (initData(&d_mu, 0.0_sreal, "mu", "Friction coefficient (0 for frictionless contacts)"))
, d_epsilon (initData(&d_epsilon, 0.0_sreal, "epsilon", "Penalty parameter. It can be thought of as a proportional controller, the Lagrange multiplier is augmented by the violation multiplied by this factor at each solving iteration."))
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class FrictionContact : public BaseUnilateralContactResponse<TCollisionModel1,
typedef core::behavior::MechanicalState<DataTypes1> MechanicalState1;
typedef core::behavior::MechanicalState<DataTypes2> MechanicalState2;

Data<double> d_mu; ///< friction parameter
Data<SReal> d_mu; ///< friction parameter

FrictionContact();
FrictionContact(CollisionModel1* model1, CollisionModel2* model2, Intersection* intersectionMethod);

virtual ~FrictionContact() = default;
~FrictionContact() override = default;

virtual constraint::lagrangian::model::UnilateralLagrangianContactParameters getParameterFromDatas() const override;
virtual void setupConstraint(MechanicalState1 *,MechanicalState2 *) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ FrictionContact<TCollisionModel1,TCollisionModel2,ResponseDataTypes>::FrictionCo
template < class TCollisionModel1, class TCollisionModel2, class ResponseDataTypes >
FrictionContact<TCollisionModel1,TCollisionModel2,ResponseDataTypes>::FrictionContact(CollisionModel1* model1, CollisionModel2* model2, Intersection* intersectionMethod)
: BaseUnilateralContactResponse<TCollisionModel1, TCollisionModel2, constraint::lagrangian::model::UnilateralLagrangianContactParameters, ResponseDataTypes>(model1,model2,intersectionMethod)
, d_mu (initData(&d_mu, 0.8, "mu", "Friction coefficient (0 for frictionless contacts)"))
, d_mu (initData(&d_mu, 0.8_sreal, "mu", "Friction coefficient (0 for frictionless contacts)"))
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class BilateralConstraintResolution3Dof : public ConstraintResolution
{
public:

BilateralConstraintResolution3Dof(sofa::type::Vec3d* vec = nullptr)
BilateralConstraintResolution3Dof(sofa::type::Vec3* vec = nullptr)
: ConstraintResolution(3)
, _f(vec)
{
Expand Down Expand Up @@ -130,7 +130,7 @@ class BilateralConstraintResolution3Dof : public ConstraintResolution

protected:
sofa::type::Mat<3,3,SReal> invW;
sofa::type::Vec3d* _f;
sofa::type::Vec3* _f;
};

class BilateralConstraintResolutionNDof : public ConstraintResolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using sofa::core::ConstraintParams ;
using sofa::core::ConstVecCoordId;

using sofa::linearalgebra::BaseVector ;
using sofa::type::Vec3d;
using sofa::type::Vec3;
using sofa::type::Quat ;

using sofa::defaulttype::Rigid3Types ;
Expand Down Expand Up @@ -123,7 +123,7 @@ class BilateralLagrangianConstraint : public PairInteractionConstraint<DataTypes
SingleLink<BilateralLagrangianConstraint<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology1; ///< Link to be set to the first topology container in order to support topological changes
SingleLink<BilateralLagrangianConstraint<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology2; ///< Link to be set to the second topology container in order to support topological changes

std::vector<Vec3d> prevForces;
std::vector<Vec3> prevForces;

BilateralLagrangianConstraint(MechanicalState* object1, MechanicalState* object2) ;
BilateralLagrangianConstraint(MechanicalState* object) ;
Expand Down
2 changes: 2 additions & 0 deletions Sofa/Component/IO/Mesh/tests/MeshExporter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <iomanip>

#include <vector>
using std::vector;

Expand Down
58 changes: 25 additions & 33 deletions Sofa/Component/IO/Mesh/tests/STLExporter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,22 @@ class STLExporter_test : public BaseSimulationTest {
}
}

void checkBasicBehavior(const std::string& filename, std::vector<std::string> pathes){
void checkBasicBehavior(const std::string& filename, std::vector<std::string> pathes)
{
dataPath = pathes ;

EXPECT_MSG_NOEMIT(Error, Warning) ;
std::stringstream scene1;
scene1 <<
"<?xml version='1.0'?> \n"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > \n"
" <DefaultAnimationLoop/> \n"
" <MechanicalObject position='0 1 2 3 4 5 6 7 8 9'/> \n"
" <MeshOBJLoader name='loader' filename='mesh/liver-smooth.obj'/> \n"
" <VisualModel src='@loader'/> \n"
" <STLExporter name='exporter1' printLog='false' filename='"<< filename << "' exportAtBegin='true' /> \n"
"</Node> \n" ;

const Node::SPtr root = SceneLoaderXML::loadFromMemory("testscene", scene1.str().c_str());

ASSERT_NE(root.get(), nullptr) << scene1.str() ;
root->init(sofa::core::execparams::defaultInstance()) ;

const Node::SPtr root = sofa::simpleapi::createRootNode(sofa::simulation::getSimulation(), "root", {{"gravity", "0 0 0"}});
sofa::simpleapi::createObject(root, "DefaultAnimationLoop");
sofa::simpleapi::createObject(root, "MechanicalObject", {{"position", "0 1 2 3 4 5 6 7 8 9"}});
sofa::simpleapi::createObject(root, "MeshOBJLoader", {{"name", "loader"}, {"filename", "mesh/liver-smooth.obj"}});
const Node::SPtr visualNode = sofa::simpleapi::createChild(root, "Visual");
sofa::simpleapi::createObject(visualNode, "VisualModel", {{"src", "@../loader"}});
sofa::simpleapi::createObject(visualNode, "STLExporter", {{"name", "exporter1"}, {"filename", filename}, {"exportAtBegin", "true"}});

ASSERT_NE(root.get(), nullptr);
sofa::simulation::node::initRoot(root.get());

// SimulationInitDoneEvent is used to trigger exportAtBegin
SimulationInitDoneEvent endInit;
Expand All @@ -119,32 +116,27 @@ class STLExporter_test : public BaseSimulationTest {

for(auto& pathToCheck : pathes)
{
EXPECT_TRUE( FileSystem::exists(pathToCheck) ) << "Problem with '" << pathToCheck << "'"<< std::endl
<< "================= scene dump ==========================="
<< scene1.str() ;
EXPECT_TRUE( FileSystem::exists(pathToCheck) );
}
}


void checkSimulationWriteEachNbStep(const std::string& filename, std::vector<std::string> pathes, unsigned int numstep){
void checkSimulationWriteEachNbStep(const std::string& filename, std::vector<std::string> pathes, unsigned int numstep)
{
dataPath = pathes ;

EXPECT_MSG_NOEMIT(Error, Warning) ;
std::stringstream scene1;
scene1 <<
"<?xml version='1.0'?> \n"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > \n"
" <DefaultAnimationLoop/> \n"
" <MechanicalObject position='0 1 2 3 4 5 6 7 8 9'/> \n"
" <MeshOBJLoader name='loader' filename='mesh/liver-smooth.obj'/> \n"
" <VisualModel src='@loader'/> \n"
" <STLExporter name='exporterA' printLog='false' filename='"<< filename << "' exportEveryNumberOfSteps='5' /> \n"
"</Node> \n" ;

const Node::SPtr root = SceneLoaderXML::loadFromMemory("testscene", scene1.str().c_str());

const Node::SPtr root = sofa::simpleapi::createRootNode(sofa::simulation::getSimulation(), "root", {{"gravity", "0 0 0"}});
sofa::simpleapi::createObject(root, "DefaultAnimationLoop");
sofa::simpleapi::createObject(root, "MechanicalObject", {{"position", "0 1 2 3 4 5 6 7 8 9"}});
sofa::simpleapi::createObject(root, "MeshOBJLoader", {{"name", "loader"}, {"filename", "mesh/liver-smooth.obj"}});
const Node::SPtr visualNode = sofa::simpleapi::createChild(root, "Visual");
sofa::simpleapi::createObject(visualNode, "VisualModel", {{"src", "@../loader"}});
sofa::simpleapi::createObject(visualNode, "STLExporter", {{"name", "exporterA"}, {"filename", filename}, {"exportEveryNumberOfSteps", "5"}});

ASSERT_NE(root.get(), nullptr) ;
root->init(sofa::core::execparams::defaultInstance()) ;
sofa::simulation::node::initRoot(root.get());

for(unsigned int i=0;i<numstep;i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/ScopedAdvancedTimer.h>

#include <iomanip>

namespace sofa::component::odesolver::backward
{
Expand All @@ -44,36 +45,44 @@ EulerImplicitSolver::EulerImplicitSolver()
, d_trapezoidalScheme( initData(&d_trapezoidalScheme,false,"trapezoidalScheme","Boolean to use the trapezoidal scheme instead of the implicit Euler scheme and get second order accuracy in time (false by default)") )
, d_solveConstraint(initData(&d_solveConstraint, false, "solveConstraint", "Apply ConstraintSolver (requires a ConstraintSolver in the same node as this solver, disabled by by default for now)") )
, d_threadSafeVisitor(initData(&d_threadSafeVisitor, false, "threadSafeVisitor", "If true, do not use realloc and free visitors in fwdInteractionForceField."))
, d_computeResidual(initData(&d_computeResidual, false, "computeResidual", "If true, the residual is computed at the end of the solving"))
, d_residual(initData(&d_residual, std::numeric_limits<SReal>::max(), "residual", "Residual norm at the end of the free-motion solving"))
{
f_rayleighStiffness.setOriginalData(&d_rayleighStiffness);
f_rayleighMass.setOriginalData(&d_rayleighMass);
f_velocityDamping.setOriginalData(&d_velocityDamping);
f_firstOrder.setOriginalData(&d_firstOrder);
f_solveConstraint.setOriginalData(&d_solveConstraint);

}

void EulerImplicitSolver::init()
{
sofa::core::behavior::OdeSolver::init();
sofa::core::behavior::LinearSolverAccessor::init();

if (!this->getTags().empty())
{
msg_info() << "EulerImplicitSolver: responsible for the following objects with tags " << this->getTags() << " :";
msg_info() << "Responsible for the following objects with tags " << this->getTags() << " :";
type::vector<core::objectmodel::BaseObject*> objs;
this->getContext()->get<core::objectmodel::BaseObject>(&objs,this->getTags(),sofa::core::objectmodel::BaseContext::SearchDown);
for (const auto* obj : objs)
{
msg_info() << " " << obj->getClassName() << ' ' << obj->getName();
}
}
sofa::core::behavior::OdeSolver::init();
sofa::core::behavior::LinearSolverAccessor::init();

simulation::common::VectorOperations vop(sofa::core::execparams::defaultInstance(), this->getContext());
reallocSolutionVector(&vop);
reallocRightHandSideVector(&vop);
}

void EulerImplicitSolver::cleanup()
{
// free the locally created vector x (including eventual external mechanical states linked by an InteractionForceField)
// free the locally created vectors (including eventual external mechanical states linked by an InteractionForceField)
sofa::simulation::common::VectorOperations vop( core::execparams::defaultInstance(), this->getContext() );
vop.v_free(x.id(), !d_threadSafeVisitor.getValue(), true);
vop.v_free(b.id(), !d_threadSafeVisitor.getValue(), true);
vop.v_free(m_residual.id(), !d_threadSafeVisitor.getValue(), true);
}

void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::core::MultiVecCoordId xResult, sofa::core::MultiVecDerivId vResult)
Expand All @@ -86,7 +95,6 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
MultiVecCoord pos(&vop, core::vec_id::write_access::position );
MultiVecDeriv vel(&vop, core::vec_id::write_access::velocity );
MultiVecDeriv f(&vop, core::vec_id::write_access::force );
MultiVecDeriv b(&vop, true, core::VecIdProperties{"RHS", GetClass()->className});
MultiVecCoord newPos(&vop, xResult );
MultiVecDeriv newVel(&vop, vResult );

Expand All @@ -98,8 +106,8 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
MultiVecDeriv dx(&vop, core::vec_id::write_access::dx);
dx.realloc(&vop, !d_threadSafeVisitor.getValue(), true);

x.realloc(&vop, !d_threadSafeVisitor.getValue(), true, core::VecIdProperties{"solution", GetClass()->className});

reallocSolutionVector(&vop);
reallocRightHandSideVector(&vop);

#ifdef SOFA_DUMP_VISITOR_INFO
sofa::simulation::Visitor::printCloseNode("SolverVectorAllocation");
Expand All @@ -125,7 +133,7 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
// compute the net forces at the beginning of the time step
mop.computeForce(f); //f = Kx + Bv

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

{
Expand All @@ -141,7 +149,7 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
// force in the current configuration
b.eq(f); // b = f

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

// add the change of force due to stiffness + Rayleigh damping
mop.addMBKv(b, core::MatricesFactors::M(-d_rayleighMass.getValue()),
Expand All @@ -152,11 +160,11 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
b.teq(h); // b = h(f + ( rm M + (h+rs) K ) v )
}

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

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

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

{
Expand Down Expand Up @@ -299,10 +307,38 @@ void EulerImplicitSolver::solve(const core::ExecParams* params, SReal dt, sofa::
mop.projectVelocity(newVel);
mop.propagateX(newPos);
mop.propagateV(newVel);
msg_info() << "EulerImplicitSolver, final x = " << newPos;
msg_info() << "EulerImplicitSolver, final v = " << newVel;
msg_info() << "final x = " << newPos;
msg_info() << "final v = " << newVel;
mop.computeForce(f);
msg_info() << "final f = " << f;
}

if (d_computeResidual.getValue())
{
reallocResidualVector(&vop);

// r = 0
vop.v_clear(m_residual);

// r += M (v - v_n)
{
core::behavior::MultiVecDeriv tmp(&vop);

vop.v_eq(tmp, newVel);
vop.v_peq(tmp, vel, -1);
mop.addMdx(m_residual, tmp);
}

// r += - dt * F
mop.computeForce(f);
msg_info() << "EulerImplicitSolver, final f = " << f;
vop.v_peq(m_residual, f, -dt);

mop.projectResponse(m_residual);

vop.v_dot(m_residual, m_residual);
d_residual.setValue(vop.finish());

msg_info() << "Residual norm: " << std::setw(6) << vop.finish();
}
}

Expand Down Expand Up @@ -338,13 +374,29 @@ SReal EulerImplicitSolver::getSolutionIntegrationFactor(int outputDerivative) co

SReal EulerImplicitSolver::getSolutionIntegrationFactor(int outputDerivative, SReal dt) const
{
const SReal vect[3] = { dt, 1, 1/dt};
const SReal vect[3] = {dt, 1, 1 / dt};
if (outputDerivative >= 3)
return 0;
else
return vect[outputDerivative];
}

void EulerImplicitSolver::reallocSolutionVector(sofa::simulation::common::VectorOperations* vop)
{
x.realloc(vop, !d_threadSafeVisitor.getValue(), true,
core::VecIdProperties{.label = "solution", .group = GetClass()->className});
}
void EulerImplicitSolver::reallocRightHandSideVector(sofa::simulation::common::VectorOperations* vop)
{
b.realloc(vop, !d_threadSafeVisitor.getValue(), true,
core::VecIdProperties{.label = "RHS", .group = GetClass()->className});
}
void EulerImplicitSolver::reallocResidualVector(sofa::simulation::common::VectorOperations* vop)
{
m_residual.realloc(vop, !d_threadSafeVisitor.getValue(), true,
core::VecIdProperties{.label = "residual", .group = GetClass()->className});
}

void registerEulerImplicitSolver(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Time integrator using implicit backward Euler scheme.")
Expand Down
Loading

0 comments on commit eada37f

Please sign in to comment.