Commit c2166480 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1603 from peastman/unknownglobal

CustomIntegrator checks for writing to an unknown variable
parents 6cf592be b44ff2fd
......@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* 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 *
* Contributors: *
* *
......@@ -63,6 +63,15 @@ void CustomIntegrator::initialize(ContextImpl& contextRef) {
if (contextRef.getParameters().find(name) != contextRef.getParameters().end())
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;
owner = &contextRef.getOwner();
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