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

[WriteState] minor fix with the time attribute, default values #776

Merged
merged 2 commits into from
Oct 3, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Correct initialization of default period value
  • Loading branch information
olivier-goury committed Sep 20, 2018
commit f0351f1a8dfd424c7bc8a64907790cfbd5de4ff6
17 changes: 13 additions & 4 deletions modules/SofaExporter/WriteState.inl
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ WriteState::WriteState()
, d_writeV( initData(&d_writeV, false, "writeV", "flag enabling output of V vector"))
, d_writeF( initData(&d_writeF, false, "writeF", "flag enabling output of F vector"))
, d_time( initData(&d_time, helper::vector<double>(0), "time", "set time to write outputs (by default export at t=0)"))
, d_period( initData(&d_period, this->getContext()->getDt(), "period", "period between outputs"))
, d_period( initData(&d_period, 0.0, "period", "period between outputs"))
, d_DOFsX( initData(&d_DOFsX, helper::vector<unsigned int>(0), "DOFsX", "set the position DOFs to write"))
, d_DOFsV( initData(&d_DOFsV, helper::vector<unsigned int>(0), "DOFsV", "set the velocity DOFs to write"))
, d_stopAt( initData(&d_stopAt, 0.0, "stopAt", "stop the simulation when the given threshold is reached"))
@@ -81,7 +81,7 @@ WriteState::~WriteState()
void WriteState::init()
{
validInit = true;
periodicExport = true;
periodicExport = false;
mmodel = this->getContext()->getMechanicalState();

// test the size and range of the DOFs to write in the file output
@@ -130,6 +130,8 @@ void WriteState::init()
//check period
if(d_period.isSet())
{
periodicExport = true;

if(d_time.getValue().size() == 0)
{
msg_warning() << "starting time should be specified to know when to start the periodic export"
@@ -159,6 +161,14 @@ void WriteState::init()
msg_warning() << "starting export time ("<< d_time.getValue()[0] <<") is too low regarding the time step ("<< dt <<")";
}
}
else
{
if(!d_time.isSet())
{
d_period.setValue(this->getContext()->getDt());
periodicExport = true;
}
}


//check time
@@ -204,8 +214,7 @@ void WriteState::init()
msg_warning() << "desired export time ("<< d_time.getValue()[i] <<") can not be met with the chosen time step("<< dt <<")";
}
}
if(!d_period.isSet())
periodicExport = false;

}

//check stopAt