From e467d9da19a1c045d1b904b822d39dba3223de00 Mon Sep 17 00:00:00 2001 From: Gabriel Studer <gabriel.studer@unibas.ch> Date: Wed, 30 Aug 2017 10:55:47 +0200 Subject: [PATCH] Hack to make context reinitialization openmm version agnostic --- modules/mol/mm/src/simulation.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/mol/mm/src/simulation.cc b/modules/mol/mm/src/simulation.cc index 09f6465a2..2a23ddb9a 100644 --- a/modules/mol/mm/src/simulation.cc +++ b/modules/mol/mm/src/simulation.cc @@ -900,12 +900,13 @@ void Simulation::ReinitializeContext() { // reinitializing requires to reset all those things! // Be aware, state of random number generators etc might not be // preserved! - OpenMM::State state = context_->getState(OpenMM::State::Positions | - OpenMM::State::Velocities | - OpenMM::State::Forces | - OpenMM::State::Energy | - OpenMM::State::Parameters | - OpenMM::State::ParameterDerivatives); + + // openmm uses bitmasks to selectively extract data from the context. + // The context data might change with different OpenMM versions. + // Passing -1 automagically sets all bits to true => ALL available + // data gets extracted. + int true_bitmask = -1; + OpenMM::State state = context_->getState(true_bitmask); context_->reinitialize(); context_->setState(state); } -- GitLab