@@ -39,7 +39,7 @@ using namespace OpenSim;
39
39
// =============================================================================
40
40
// CONSTRUCTOR(S)
41
41
// =============================================================================
42
- Manager::Manager (Model& model) : _recordStatesTrajectory(false ),
42
+ Manager::Manager (Model& model) : _recordStatesTrajectory(false ),
43
43
_performAnalyses(true ), _writeToStorage(true ), _model(&model) {
44
44
_sessionName = _model->getName ();
45
45
_integ.reset (new SimTK::RungeKuttaMersonIntegrator (
@@ -135,7 +135,7 @@ Manager::IntegratorMethod Manager::getIntegratorMethod() const {
135
135
136
136
void Manager::setIntegratorAccuracy (double accuracy) {
137
137
OPENSIM_THROW_IF (!_integ->methodHasErrorControl (), Exception,
138
- " Integrator method {} does not support error control." ,
138
+ " Integrator method {} does not support error control." ,
139
139
_integ->getMethodName ());
140
140
141
141
_integ->setAccuracy (accuracy);
@@ -198,7 +198,7 @@ void Manager::record(const SimTK::State& state, int step) {
198
198
vec.setStates (state.getTime (), stateValues);
199
199
_stateStore->append (vec);
200
200
if (_model->isControlled ()) {
201
- _model->updControllerSet ().storeControls (state,
201
+ _model->updControllerSet ().storeControls (state,
202
202
(step < 0 ) ? getStateStorage ().getSize () : step);
203
203
}
204
204
}
@@ -217,9 +217,9 @@ void Manager::record(const SimTK::State& state, int step) {
217
217
}
218
218
219
219
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 ;
223
223
}
224
224
_statesTraj->append (state);
225
225
}
@@ -232,22 +232,21 @@ void Manager::initialize(const SimTK::State& s) {
232
232
233
233
if (_recordStatesTrajectory || _writeToStorage || _performAnalyses) {
234
234
_integ->setReturnEveryInternalStep (true );
235
- }
235
+ }
236
236
237
237
// Initialize the time stepper.
238
238
_timeStepper->setReportAllSignificantStates (true );
239
239
_timeStepper->initialize (s);
240
-
241
- // TODO: find a better way to intialize capacity .
240
+
241
+ // Initialize the states trajectory .
242
242
if (_recordStatesTrajectory) {
243
- // Initialize the states trajectory.
244
243
_statesTraj->clear ();
245
- _statesTraj->reserve (1024 );
246
244
}
247
-
245
+
246
+ // Initialize the states storage.
248
247
if (_writeToStorage) {
249
- // Initialize the states storage.
250
- _stateStore. reset ( new Storage ( 1024 , " states " ) );
248
+ _stateStore. reset ( new Storage ( 512 ));
249
+ _stateStore-> setName (_sessionName );
251
250
Array<std::string> stateNames = _model->getStateVariableNames ();
252
251
Array<std::string> columnLabels;
253
252
columnLabels.setSize (0 );
@@ -292,7 +291,7 @@ const SimTK::State& Manager::integrate(double finalTime) {
292
291
record (s, step++);
293
292
double time = s.getTime ();
294
293
auto status = SimTK::Integrator::InvalidSuccessfulStepStatus;
295
- while (time < finalTime) {
294
+ while (time < finalTime) {
296
295
status = _timeStepper->stepTo (finalTime);
297
296
const SimTK::State& s = _integ->getState ();
298
297
@@ -317,7 +316,7 @@ const SimTK::State& Manager::integrate(double finalTime) {
317
316
_integ->getTerminationReasonString (
318
317
_integ->getTerminationReason ()));
319
318
return s;
320
- }
319
+ }
321
320
}
322
321
time = s.getTime ();
323
322
}
@@ -331,7 +330,7 @@ const SimTK::State& Manager::integrate(double finalTime) {
331
330
log_info (" - ratio sim-to-real time: {:.3f}" , simFinalTime / realTime);
332
331
log_info (" - integrator method: {}" , _integ->getMethodName ());
333
332
log_info (" - number of realizations: {}" , _integ->getNumRealizations ());
334
- log_info (" - number of steps taken / attempted: {} / {}" ,
333
+ log_info (" - number of steps taken / attempted: {} / {}" ,
335
334
_integ->getNumStepsTaken (), _integ->getNumStepsAttempted ());
336
335
log_info (" - number of projections: {}" , _integ->getNumProjections ());
337
336
log_info (" - number of iterations: {}" , _integ->getNumIterations ());
0 commit comments