Commit 44bfd168 authored by Peter Eastman's avatar Peter Eastman
Browse files

Added Integrator::stateChanged()

parent c1bdee13
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. * * USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
#include "State.h"
#include "Vec3.h" #include "Vec3.h"
#include <map> #include <map>
#include <vector> #include <vector>
...@@ -102,6 +103,17 @@ protected: ...@@ -102,6 +103,17 @@ protected:
* Get the names of all Kernels used by this Integrator. * Get the names of all Kernels used by this Integrator.
*/ */
virtual std::vector<std::string> getKernelNames() = 0; virtual std::vector<std::string> getKernelNames() = 0;
/**
* This will be called by the Context when the user modifies aspects of the context state, such
* as positions, velocities, or parameters. This gives the Integrator a chance to discard cached
* information. This is <i>only</i> called when the user modifies information using methods of the Context
* object. It is <i>not</i> called when a ForceImpl object modifies state information in its updateContextState()
* method (unless the ForceImpl calls a Context method to perform the modification).
*
* @param changed this specifies what aspect of the Context was changed
*/
virtual void stateChanged(State::DataType changed) {
}
private: private:
double stepSize, constraintTol; double stepSize, constraintTol;
}; };
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "openmm/kernels.h" #include "openmm/kernels.h"
#include "openmm/internal/ForceImpl.h" #include "openmm/internal/ForceImpl.h"
#include "openmm/internal/ContextImpl.h" #include "openmm/internal/ContextImpl.h"
#include "openmm/State.h"
#include <map> #include <map>
#include <utility> #include <utility>
#include <vector> #include <vector>
...@@ -104,6 +105,7 @@ void ContextImpl::getPositions(std::vector<Vec3>& positions) { ...@@ -104,6 +105,7 @@ void ContextImpl::getPositions(std::vector<Vec3>& positions) {
void ContextImpl::setPositions(const std::vector<Vec3>& positions) { void ContextImpl::setPositions(const std::vector<Vec3>& positions) {
dynamic_cast<UpdateStateDataKernel&>(updateStateDataKernel.getImpl()).setPositions(*this, positions); dynamic_cast<UpdateStateDataKernel&>(updateStateDataKernel.getImpl()).setPositions(*this, positions);
integrator.stateChanged(State::Positions);
} }
void ContextImpl::getVelocities(std::vector<Vec3>& velocities) { void ContextImpl::getVelocities(std::vector<Vec3>& velocities) {
...@@ -112,6 +114,7 @@ void ContextImpl::getVelocities(std::vector<Vec3>& velocities) { ...@@ -112,6 +114,7 @@ void ContextImpl::getVelocities(std::vector<Vec3>& velocities) {
void ContextImpl::setVelocities(const std::vector<Vec3>& velocities) { void ContextImpl::setVelocities(const std::vector<Vec3>& velocities) {
dynamic_cast<UpdateStateDataKernel&>(updateStateDataKernel.getImpl()).setVelocities(*this, velocities); dynamic_cast<UpdateStateDataKernel&>(updateStateDataKernel.getImpl()).setVelocities(*this, velocities);
integrator.stateChanged(State::Velocities);
} }
void ContextImpl::getForces(std::vector<Vec3>& forces) { void ContextImpl::getForces(std::vector<Vec3>& forces) {
...@@ -128,6 +131,7 @@ void ContextImpl::setParameter(std::string name, double value) { ...@@ -128,6 +131,7 @@ void ContextImpl::setParameter(std::string name, double value) {
if (parameters.find(name) == parameters.end()) if (parameters.find(name) == parameters.end())
throw OpenMMException("Called setParameter() with invalid parameter name"); throw OpenMMException("Called setParameter() with invalid parameter name");
parameters[name] = value; parameters[name] = value;
integrator.stateChanged(State::Parameters);
} }
void ContextImpl::getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) { void ContextImpl::getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c) {
......
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