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

[SofaSparseSolver] Clean examples scenes of sparse linear solvers #2422

Merged
merged 12 commits into from
Oct 22, 2021
Merged
4 changes: 2 additions & 2 deletions examples/Benchmark/Performance/TorusFall.scn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

<VisualStyle displayFlags="showVisual showCollisionModels hideBehaviorModels showForceFields hideInteractionForceFields hideWireframe" />

<FreeMotionAnimationLoop name="animationLoop" solveVelocityConstraintFirst="true" />
<GenericConstraintSolver name="constraintSolver" maxIterations="100" tolerance="1.0e-9" multithreading="0"/>
<FreeMotionAnimationLoop name="animationLoop" solveVelocityConstraintFirst="true" parallelCollisionDetectionAndFreeMotion="true" parallelODESolving="true"/>
<GenericConstraintSolver name="constraintSolver" maxIterations="100" tolerance="1.0e-9" multithreading="1"/>
<DefaultPipeline name="Pipeline" />
<BruteForceBroadPhase name="BroadPhase" />
<BVHNarrowPhase name="NarrowPhase" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Node name="root" dt="0.02" gravity="0 -10 0">
<RequiredPlugin pluginName="SofaSparseSolver"/>
<RequiredPlugin pluginName='SofaBoundaryCondition'/>
<RequiredPlugin pluginName='SofaImplicitOdeSolver'/>
<RequiredPlugin pluginName='SofaMiscCollision'/>
<RequiredPlugin pluginName='SofaSimpleFem'/>

<VisualStyle displayFlags="showBehaviorModels showForceFields" />
<DefaultPipeline depth="6" verbose="0" draw="0" />
<BruteForceBroadPhase/>
<BVHNarrowPhase/>
<MinProximityIntersection name="Proximity" alarmDistance="0.5" contactDistance="0.3" />
<DefaultContactManager name="Response" response="default" />
<DefaultCollisionGroupManager name="Group" />
<Node name="M1">
<EulerImplicitSolver name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" />
<PrecomputedLinearSolver/>
<MechanicalObject />
<UniformMass vertexMass="1" />
<RegularGridTopology nx="4" ny="4" nz="20" xmin="-9" xmax="-6" ymin="0" ymax="3" zmin="0" zmax="19" />
<FixedConstraint indices="0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15" />
<HexahedronFEMForceField name="FEM" youngModulus="400000" poissonRatio="0.3" method="large" />
</Node>
</Node>
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<Node name="root" dt="0.02" gravity="0 -10 0">
<RequiredPlugin pluginName="SofaSparseSolver"/>
<RequiredPlugin pluginName='SofaBoundaryCondition'/>
<RequiredPlugin pluginName='SofaImplicitOdeSolver'/>
<RequiredPlugin pluginName='SofaMiscCollision'/>
<RequiredPlugin pluginName='SofaSimpleFem'/>

<VisualStyle displayFlags="showBehaviorModels showForceFields" />
<CollisionPipeline depth="6" verbose="0" draw="0" />
<DefaultPipeline depth="6" verbose="0" draw="0" />
<BruteForceBroadPhase/>
<BVHNarrowPhase/>
<MinProximityIntersection name="Proximity" alarmDistance="0.5" contactDistance="0.3" />
<CollisionResponse name="Response" response="default" />
<CollisionGroup name="Group" />
<DefaultContactManager name="Response" response="default" />
<DefaultCollisionGroupManager name="Group" />
<Node name="M1">
<EulerImplicit name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" />
<SparseLUSolver printLog="1" verbose="0" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well .. SVD you said? 😂

<EulerImplicitSolver name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I do not like seeing these rayleigh damping, especially in example scenes, but it's not the purpose of the PR ^^

<SVDLinearSolver template="CompressedRowSparseMatrixMat3x3d"/>
<MechanicalObject />
<UniformMass vertexMass="1" />
<RegularGridTopology nx="4" ny="4" nz="20" xmin="-9" xmax="-6" ymin="0" ymax="3" zmin="0" zmax="19" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<DefaultCollisionGroupManager name="Group" />
<Node name="M1">
<EulerImplicitSolver name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" />
<SparseLDLSolver printLog="1"/>
<SparseLDLSolver template="CompressedRowSparseMatrixMat3x3d"/>
<MechanicalObject />
<UniformMass vertexMass="1" />
<RegularGridTopology nx="4" ny="4" nz="20" xmin="-9" xmax="-6" ymin="0" ymax="3" zmin="0" zmax="19" />
Expand Down
2 changes: 1 addition & 1 deletion examples/Components/linearsolver/FEMBAR-SparseLUSolver.scn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<DefaultCollisionGroupManager name="Group" />
<Node name="M1">
<EulerImplicitSolver name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" />
<SparseLUSolver printLog="1" verbose="0"/>
<SparseLUSolver/>
<MechanicalObject />
<UniformMass vertexMass="1" />
<RegularGridTopology nx="4" ny="4" nz="20" xmin="-9" xmax="-6" ymin="0" ymax="3" zmin="0" zmax="19" />
Expand Down
28 changes: 0 additions & 28 deletions modules/SofaSparseSolver/examples/FEM_SparseCholeskySolver.scn

This file was deleted.

22 changes: 0 additions & 22 deletions modules/SofaSparseSolver/examples/FEM_SparseLDLSolver.scn

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void PrecomputedLinearSolver<TMatrix,TVector >::loadMatrix(TMatrix& M)
template<class TMatrix,class TVector>
void PrecomputedLinearSolver<TMatrix,TVector>::loadMatrixWithCSparse(TMatrix& M)
{
msg_info("PrecomputedLinearSolver") << "Compute the initial invert matrix with CS_PARSE" ;
msg_info() << "Compute the initial invert matrix with CS_PARSE" ;

CompressedRowSparseMatrix<double> matSolv;
FullVector<double> r;
Expand All @@ -143,15 +143,15 @@ void PrecomputedLinearSolver<TMatrix,TVector>::loadMatrixWithCSparse(TMatrix& M)
b.set(j,0.0);
}

msg_info("PrecomputedLinearSolver") << "Precomputing constraint correction LU decomposition " ;
msg_info() << "Precomputing constraint correction LU decomposition " ;
solver.invert(matSolv);

for (unsigned int j=0; j<systemSize; j++)
{
std::stringstream tmp;
tmp.precision(2);
tmp << "Precomputing constraint correction : " << std::fixed << (float)j/(float)systemSize*100.0f << " % " << '\xd';
msg_info("PrecomputedLinearSolver") << tmp.str() ;
msg_info() << tmp.str() ;

if (j>0) b.set(j-1,0.0);
b.set(j,1.0);
Expand All @@ -162,7 +162,7 @@ void PrecomputedLinearSolver<TMatrix,TVector>::loadMatrixWithCSparse(TMatrix& M)
internalData.Minv.set(j,i,r.element(i) * factInt);
}
}
msg_info("PrecomputedLinearSolver") << "Precomputing constraint correction : " << std::fixed << 100.0f << " % " << '\xd';
msg_info() << "Precomputing constraint correction : " << std::fixed << 100.0f << " % " << '\xd';

}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#define SOFA_COMPONENT_LINEARSOLVER_SPARSELUSOLVER_CPP
#include <sofa/core/ObjectFactory.h>
#include <SofaSparseSolver/SparseLUSolver.inl>

Expand All @@ -29,5 +30,7 @@ int SparseLUSolverClass = core::RegisterObject("Direct linear solver based on Sp
.add< SparseLUSolver< CompressedRowSparseMatrix<double>,FullVector<double> > >()
;

template class SOFA_SOFASPARSESOLVER_API SparseLUSolver< CompressedRowSparseMatrix<double>,FullVector<double> >;

} // namespace sofa::component::linearsolver

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
namespace sofa::component::linearsolver
{

//defaut structure for a LDL factorization
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice copy-paste ..

//defaut structure for a LU factorization
template<class Real>
class SparseLUInvertData : public MatrixInvertData {
public :
Expand Down Expand Up @@ -81,6 +81,10 @@ protected :

};

#if !defined(SOFA_COMPONENT_LINEARSOLVER_SPARSELUSOLVER_CPP)
extern template class SOFA_SOFASPARSESOLVER_API SparseLUSolver< CompressedRowSparseMatrix< double>,FullVector<double> >;
#endif

} // namespace sofa::component::linearsolver

#endif