Skip to content

Commit 68930c9

Browse files
committed
Update Simbody to the most recent commit, revert StatesTrajectory changes, and update Manager documentation
1 parent 07fbbed commit 68930c9

File tree

5 files changed

+254
-182
lines changed

5 files changed

+254
-182
lines changed

OpenSim/Simulation/Manager/Manager.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ using namespace OpenSim;
3939
//=============================================================================
4040
// CONSTRUCTOR(S)
4141
//=============================================================================
42-
Manager::Manager(Model& model) : _recordStatesTrajectory(false),
42+
Manager::Manager(Model& model) : _recordStatesTrajectory(false),
4343
_performAnalyses(true), _writeToStorage(true), _model(&model) {
4444
_sessionName = _model->getName();
4545
_integ.reset(new SimTK::RungeKuttaMersonIntegrator(
@@ -135,7 +135,7 @@ Manager::IntegratorMethod Manager::getIntegratorMethod() const {
135135

136136
void Manager::setIntegratorAccuracy(double accuracy) {
137137
OPENSIM_THROW_IF(!_integ->methodHasErrorControl(), Exception,
138-
"Integrator method {} does not support error control.",
138+
"Integrator method {} does not support error control.",
139139
_integ->getMethodName());
140140

141141
_integ->setAccuracy(accuracy);
@@ -198,7 +198,7 @@ void Manager::record(const SimTK::State& state, int step) {
198198
vec.setStates(state.getTime(), stateValues);
199199
_stateStore->append(vec);
200200
if (_model->isControlled()) {
201-
_model->updControllerSet().storeControls(state,
201+
_model->updControllerSet().storeControls(state,
202202
(step < 0) ? getStateStorage().getSize() : step);
203203
}
204204
}
@@ -217,9 +217,9 @@ void Manager::record(const SimTK::State& state, int step) {
217217
}
218218

219219
if (_recordStatesTrajectory) {
220-
if (_statesTraj->getSize() > 0 &&
221-
_statesTraj->back().getTime() == state.getTime()) {
222-
return;
220+
if (_statesTraj->getSize() > 0 &&
221+
_statesTraj->back().getTime() == state.getTime()) {
222+
return;
223223
}
224224
_statesTraj->append(state);
225225
}
@@ -232,22 +232,21 @@ void Manager::initialize(const SimTK::State& s) {
232232

233233
if (_recordStatesTrajectory || _writeToStorage || _performAnalyses) {
234234
_integ->setReturnEveryInternalStep(true);
235-
}
235+
}
236236

237237
// Initialize the time stepper.
238238
_timeStepper->setReportAllSignificantStates(true);
239239
_timeStepper->initialize(s);
240-
241-
// TODO: find a better way to intialize capacity.
240+
241+
// Initialize the states trajectory.
242242
if (_recordStatesTrajectory) {
243-
// Initialize the states trajectory.
244243
_statesTraj->clear();
245-
_statesTraj->reserve(1024);
246244
}
247-
245+
246+
// Initialize the states storage.
248247
if (_writeToStorage) {
249-
// Initialize the states storage.
250-
_stateStore.reset(new Storage(1024, "states"));
248+
_stateStore.reset(new Storage(512));
249+
_stateStore->setName(_sessionName);
251250
Array<std::string> stateNames = _model->getStateVariableNames();
252251
Array<std::string> columnLabels;
253252
columnLabels.setSize(0);
@@ -292,7 +291,7 @@ const SimTK::State& Manager::integrate(double finalTime) {
292291
record(s, step++);
293292
double time = s.getTime();
294293
auto status = SimTK::Integrator::InvalidSuccessfulStepStatus;
295-
while (time < finalTime) {
294+
while (time < finalTime) {
296295
status = _timeStepper->stepTo(finalTime);
297296
const SimTK::State& s = _integ->getState();
298297

@@ -317,7 +316,7 @@ const SimTK::State& Manager::integrate(double finalTime) {
317316
_integ->getTerminationReasonString(
318317
_integ->getTerminationReason()));
319318
return s;
320-
}
319+
}
321320
}
322321
time = s.getTime();
323322
}
@@ -331,7 +330,7 @@ const SimTK::State& Manager::integrate(double finalTime) {
331330
log_info(" - ratio sim-to-real time: {:.3f}", simFinalTime / realTime);
332331
log_info(" - integrator method: {}", _integ->getMethodName());
333332
log_info(" - number of realizations: {}", _integ->getNumRealizations());
334-
log_info(" - number of steps taken / attempted: {} / {}",
333+
log_info(" - number of steps taken / attempted: {} / {}",
335334
_integ->getNumStepsTaken(), _integ->getNumStepsAttempted());
336335
log_info(" - number of projections: {}", _integ->getNumProjections());
337336
log_info(" - number of iterations: {}", _integ->getNumIterations());

0 commit comments

Comments
 (0)