Commit 8cd52036 authored by peastman's avatar peastman
Browse files

Checkpoint records choice of current integrator

parent 5ee23330
......@@ -130,11 +130,13 @@ double CompoundIntegrator::computeKineticEnergy() {
}
void CompoundIntegrator::createCheckpoint(std::ostream& stream) const {
stream.write((char*) &currentIntegrator, sizeof(int));
for (int i = 0; i < integrators.size(); i++)
integrators[i]->createCheckpoint(stream);
}
void CompoundIntegrator::loadCheckpoint(std::istream& stream) {
stream.read((char*) &currentIntegrator, sizeof(int));
for (int i = 0; i < integrators.size(); i++)
integrators[i]->loadCheckpoint(stream);
}
......@@ -218,6 +218,7 @@ void testCheckpoint() {
custom->addPerDofVariable("b", 2.0);
CompoundIntegrator integrator;
integrator.addIntegrator(custom);
integrator.addIntegrator(new VerletIntegrator(0.005));
Context context(system, integrator, platform);
vector<Vec3> positions(1, Vec3());
context.setPositions(positions);
......@@ -229,7 +230,9 @@ void testCheckpoint() {
custom->setGlobalVariable(0, 10.0);
vector<Vec3> b2(1, Vec3(4, 5, 6));
custom->setPerDofVariable(0, b2);
integrator.setCurrentIntegrator(1);
context.loadCheckpoint(checkpoint);
ASSERT_EQUAL(0, integrator.getCurrentIntegrator());
ASSERT_EQUAL(5.0, custom->getGlobalVariable(0));
vector<Vec3> b3;
custom->getPerDofVariable(0, b3);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment