Commit b44ff2fd authored by Peter Eastman's avatar Peter Eastman
Browse files

CustomIntegrator checks for writing to an unknown variable

parent 985d927a
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2011-2014 Stanford University and the Authors. * * Portions copyright (c) 2011-2016 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -63,6 +63,15 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) { ...@@ -63,6 +63,15 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
if (contextRef.getParameters().find(name) != contextRef.getParameters().end()) if (contextRef.getParameters().find(name) != contextRef.getParameters().end())
throw OpenMMException("The Integrator defines a variable with the same name as a Context parameter: "+name); throw OpenMMException("The Integrator defines a variable with the same name as a Context parameter: "+name);
} }
set<std::string> globalTargets;
globalTargets.insert(globalNames.begin(), globalNames.end());
globalTargets.insert("dt");
for (map<string, double>::const_iterator iter = contextRef.getParameters().begin(); iter != contextRef.getParameters().end(); ++iter)
globalTargets.insert(iter->first);
for (int i = 0; i < computations.size(); i++) {
if (computations[i].type == ComputeGlobal && globalTargets.find(computations[i].variable) == globalTargets.end())
throw OpenMMException("Unknown global variable: "+computations[i].variable);
}
context = &contextRef; context = &contextRef;
owner = &contextRef.getOwner(); owner = &contextRef.getOwner();
kernel = context->getPlatform().createKernel(IntegrateCustomStepKernel::Name(), contextRef); kernel = context->getPlatform().createKernel(IntegrateCustomStepKernel::Name(), contextRef);
......
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