Skip to content

Commit 1a38648

Browse files
alxbilgerhugtalbot
andauthored
[Constraint] replace bwdInit by init (#5504)
Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
1 parent 4715cd1 commit 1a38648

2 files changed

Lines changed: 19 additions & 22 deletions

File tree

Sofa/Component/Constraint/Lagrangian/Correction/src/sofa/component/constraint/lagrangian/correction/GenericConstraintCorrection.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ GenericConstraintCorrection::GenericConstraintCorrection()
5858

5959
GenericConstraintCorrection::~GenericConstraintCorrection() {}
6060

61-
void GenericConstraintCorrection::bwdInit()
61+
void GenericConstraintCorrection::init()
6262
{
63+
BaseConstraintCorrection::init();
64+
6365
const BaseContext* context = this->getContext();
6466

6567
// Find linear solver
@@ -72,23 +74,20 @@ void GenericConstraintCorrection::bwdInit()
7274

7375
if (l_linearSolver.get() == nullptr)
7476
{
75-
msg_error() << "No LinearSolver component found at path: " << l_linearSolver.getLinkedPath() << ", nor in current context: " << context->name;
76-
sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
77+
msg_error() << "No LinearSolver component found at path: " << l_linearSolver.getLinkedPath()
78+
<< ", nor in current context: " << context->name;
79+
d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
7780
return;
7881
}
79-
else
82+
83+
if (l_linearSolver->getTemplateName() == "GraphScattered")
8084
{
81-
if (l_linearSolver.get()->getTemplateName() == "GraphScattered")
82-
{
83-
msg_error() << "Can not use the solver " << l_linearSolver.get()->getName() << " because it is templated on GraphScatteredType";
84-
sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
85-
return;
86-
}
87-
else
88-
{
89-
msg_info() << "LinearSolver path used: '" << l_linearSolver.getLinkedPath() << "'";
90-
}
85+
msg_error() << "Can not use the solver " << l_linearSolver->getName()
86+
<< " because it is templated on GraphScatteredType";
87+
d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
88+
return;
9189
}
90+
msg_info() << "LinearSolver path used: '" << l_linearSolver.getLinkedPath() << "'";
9291

9392
// Find ODE solver
9493
if (l_ODESolver.empty())
@@ -104,16 +103,14 @@ void GenericConstraintCorrection::bwdInit()
104103

105104
if (l_ODESolver.get() == nullptr)
106105
{
107-
msg_error() << "No ODESolver component found at path: " << l_ODESolver.getLinkedPath() << ", nor in current context: " << context->name;
108-
sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
106+
msg_error() << "No ODESolver component found at path: " << l_ODESolver.getLinkedPath()
107+
<< ", nor in current context: " << context->name;
108+
d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
109109
return;
110110
}
111-
else
112-
{
113-
msg_info() << "ODESolver path used: '" << l_ODESolver.getLinkedPath() << "'";
114-
}
111+
msg_info() << "ODESolver path used: '" << l_ODESolver.getLinkedPath() << "'";
115112

116-
sofa::core::objectmodel::BaseObject::d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid);
113+
d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid);
117114
}
118115

119116
void GenericConstraintCorrection::cleanup()

Sofa/Component/Constraint/Lagrangian/Correction/src/sofa/component/constraint/lagrangian/correction/GenericConstraintCorrection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_CORRECTION_API GenericConstraintCorre
3333
public:
3434
SOFA_CLASS(GenericConstraintCorrection, core::behavior::BaseConstraintCorrection);
3535

36-
void bwdInit() override;
36+
void init() override;
3737
void cleanup() override;
3838
void addConstraintSolver(core::behavior::ConstraintSolver *s) override;
3939
void removeConstraintSolver(core::behavior::ConstraintSolver *s) override;

0 commit comments

Comments
 (0)