Commit c096fa02 authored by peastman's avatar peastman
Browse files

Merge pull request #959 from kyleabeauchamp/intsegfault

Add check for null context inside integrator.step()
parents d557fa41 8be6e843
......@@ -72,6 +72,8 @@ double BrownianIntegrator::computeKineticEnergy() {
}
void BrownianIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......
......@@ -94,6 +94,8 @@ double CustomIntegrator::computeKineticEnergy() {
}
void CustomIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
globalsAreCurrent = false;
for (int i = 0; i < steps; ++i) {
kernel.getAs<IntegrateCustomStepKernel>().execute(*context, *this, forcesAreValid);
......
......@@ -72,6 +72,8 @@ double LangevinIntegrator::computeKineticEnergy() {
}
void LangevinIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......
......@@ -75,6 +75,8 @@ double VariableLangevinIntegrator::computeKineticEnergy() {
}
void VariableLangevinIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......@@ -83,6 +85,8 @@ void VariableLangevinIntegrator::step(int steps) {
}
void VariableLangevinIntegrator::stepTo(double time) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
while (time > context->getTime()) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......
......@@ -70,6 +70,8 @@ double VariableVerletIntegrator::computeKineticEnergy() {
}
void VariableVerletIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......@@ -78,6 +80,8 @@ void VariableVerletIntegrator::step(int steps) {
}
void VariableVerletIntegrator::stepTo(double time) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
while (time > context->getTime()) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......
......@@ -69,6 +69,8 @@ double VerletIntegrator::computeKineticEnergy() {
}
void VerletIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......
......@@ -89,6 +89,8 @@ double DrudeLangevinIntegrator::computeKineticEnergy() {
}
void DrudeLangevinIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......
......@@ -86,6 +86,8 @@ double DrudeSCFIntegrator::computeKineticEnergy() {
}
void DrudeSCFIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
for (int i = 0; i < steps; ++i) {
context->updateContextState();
context->calcForcesAndEnergy(true, false);
......
......@@ -168,6 +168,8 @@ double RPMDIntegrator::computeKineticEnergy() {
}
void RPMDIntegrator::step(int steps) {
if (context == NULL)
throw OpenMMException("This Integrator is not bound to a context!");
if (!hasSetPosition) {
// Initialize the positions from the context.
......
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