Commit 67fc6658 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1608 from kyleabeauchamp/intser

Add support for customIntegrator serialization and test
parents c2166480 171f3a26
......@@ -107,6 +107,12 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const {
integrator->addConstrainVelocities();
} else if(computationType == CustomIntegrator::UpdateContextState) {
integrator->addUpdateContextState();
} else if(computationType == CustomIntegrator::IfBlockStart) {
integrator->beginIfBlock(cit->getStringProperty("computationExpression"));
} else if(computationType == CustomIntegrator::WhileBlockStart) {
integrator->beginWhileBlock(cit->getStringProperty("computationExpression"));
} else if(computationType == CustomIntegrator::BlockEnd) {
integrator->endBlock();
} else {
throw(OpenMMException("Custom Integrator Deserialization: Unknown computation type"));
}
......@@ -115,4 +121,4 @@ void* CustomIntegratorProxy::deserialize(const SerializationNode& node) const {
integrator->setRandomNumberSeed(node.getIntProperty("randomSeed"));
integrator->setConstraintTolerance(node.getDoubleProperty("constraintTolerance"));
return integrator;
}
\ No newline at end of file
}
......@@ -137,12 +137,20 @@ void testSerializeCustomIntegrator() {
intg->addGlobalVariable("oute", 0);
intg->addGlobalVariable("oute1", 0);
intg->addGlobalVariable("oute2", 0);
intg->addGlobalVariable("oute3_conditional_v1", 0);// HACK: need addGlobals to be alphabetical to work around bug
intg->addGlobalVariable("oute3_conditional_v2", 0);
intg->addComputePerDof("outf", "f");
intg->addComputePerDof("outf1", "f1");
intg->addComputePerDof("outf2", "f2");
intg->addComputeGlobal("oute", "energy");
intg->addComputeGlobal("oute1", "energy1");
intg->addComputeGlobal("oute2", "energy2");
intg->beginIfBlock("1 > 0");
intg->addComputeGlobal("oute3_conditional_v1", "energy");
intg->endBlock();
intg->beginWhileBlock("0 > 1");
intg->addComputeGlobal("oute3_conditional_v2", "energy");
intg->endBlock();
intg->addUpdateContextState();
intg->addConstrainVelocities();
intg->addComputeSum("summand2", "v*v+f*f");
......@@ -216,13 +224,13 @@ int main() {
testSerializeVerletIntegrator();
testSerializeVariableLangevinIntegrator();
testSerializeVariableVerletIntegrator();
testSerializeLangevinIntegrator();
testSerializeLangevinIntegrator();
testSerializeCompoundIntegrator();
}
catch(const exception& e) {
return 1;
cout << "exception: " << e.what() << endl;
return 1;
}
cout << "Done" << endl;
return 0;
}
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