Skip to content

Commit

Permalink
[Component] Update componentState at init in AdaptiveBeamForceFieldAn…
Browse files Browse the repository at this point in the history
…dMass (#47)

* [tests] Add more tests for AdaptiveBeamForceField and mass

* [tests] clean header includes and fix AdaptiveBeam FF test

* [test] Fix some includes

* [tests] Fix tests?

* [component] Update componentState at init in AdaptiveBeamFF

* [Tests] reactivate test on componentState check
  • Loading branch information
epernod authored Aug 12, 2022
1 parent 117ce37 commit 9dba895
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,15 @@ struct AdaptiveBeamForceFieldAndMassTest : public sofa::testing::BaseSimulationT
ASSERT_NE(beamForceFieldMass, nullptr);

// Check component state and Data default values

// TODO: activate this test in component init refactoring PR
//ASSERT_EQ(beamForceFieldMass->d_componentState.getValue(), sofa::core::objectmodel::ComponentState::Valid);
ASSERT_EQ(beamForceFieldMass->d_componentState.getValue(), sofa::core::objectmodel::ComponentState::Valid);
ASSERT_EQ(beamForceFieldMass->d_computeMass.getValue(), true);
ASSERT_FLOAT_EQ(beamForceFieldMass->d_massDensity.getValue(), 10.0);
ASSERT_FLOAT_EQ(beamForceFieldMass->rayleighMass.getValue(), 0.0);
ASSERT_FLOAT_EQ(beamForceFieldMass->rayleighStiffness.getValue(), 0.0);
}



void checkValues()
{
int nbrStep = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,18 @@ AdaptiveBeamForceFieldAndMass<DataTypes>::AdaptiveBeamForceFieldAndMass()
template <class DataTypes>
void AdaptiveBeamForceFieldAndMass<DataTypes>::init()
{
this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Loading);

if(!l_interpolation)
l_interpolation.set(dynamic_cast<BaseContext *>(this->getContext())->get<BInterpolation>(BaseContext::Local));

if(!l_interpolation)
if (!l_interpolation) {
msg_error() << "No Beam Interpolation found, the component can not work.";
this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
}

ForceField<DataTypes>::init();
this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Valid);
}


Expand Down

0 comments on commit 9dba895

Please sign in to comment.