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

Renamed OpenMMContext to Context

parent 95b8dbd6
......@@ -134,11 +134,11 @@ public:
void stepTo(double time);
protected:
/**
* This will be called by the OpenMMContext when it is created. It informs the Integrator
* This will be called by the Context when it is created. It informs the Integrator
* of what context it will be integrating, and gives it a chance to do any necessary initialization.
* It will also get called again if the application calls reinitialize() on the OpenMMContext.
* It will also get called again if the application calls reinitialize() on the Context.
*/
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
/**
* Get the names of all Kernels used by this Integrator.
*/
......@@ -146,7 +146,7 @@ protected:
private:
double temperature, friction, errorTol;
int randomNumberSeed;
OpenMMContextImpl* context;
ContextImpl* context;
Kernel kernel;
};
......
......@@ -95,18 +95,18 @@ public:
void stepTo(double time);
protected:
/**
* This will be called by the OpenMMContext when it is created. It informs the Integrator
* This will be called by the Context when it is created. It informs the Integrator
* of what context it will be integrating, and gives it a chance to do any necessary initialization.
* It will also get called again if the application calls reinitialize() on the OpenMMContext.
* It will also get called again if the application calls reinitialize() on the Context.
*/
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
/**
* Get the names of all Kernels used by this Integrator.
*/
std::vector<std::string> getKernelNames();
private:
double errorTol;
OpenMMContextImpl* context;
ContextImpl* context;
Kernel kernel;
};
......
......@@ -58,17 +58,17 @@ public:
void step(int steps);
protected:
/**
* This will be called by the OpenMMContext when it is created. It informs the Integrator
* This will be called by the Context when it is created. It informs the Integrator
* of what context it will be integrating, and gives it a chance to do any necessary initialization.
* It will also get called again if the application calls reinitialize() on the OpenMMContext.
* It will also get called again if the application calls reinitialize() on the Context.
*/
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
/**
* Get the names of all Kernels used by this Integrator.
*/
std::vector<std::string> getKernelNames();
private:
OpenMMContextImpl* context;
ContextImpl* context;
Kernel kernel;
};
......
......@@ -46,15 +46,15 @@ namespace OpenMM {
class AndersenThermostatImpl : public ForceImpl {
public:
AndersenThermostatImpl(AndersenThermostat& owner);
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
AndersenThermostat& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context);
void calcForces(OpenMMContextImpl& context, Stream& forces) {
void updateContextState(ContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces) {
// This force doesn't apply forces to particles.
}
double calcEnergy(OpenMMContextImpl& context) {
double calcEnergy(ContextImpl& context) {
return 0.0; // This force doesn't contribute to the potential energy.
}
std::map<std::string, double> getDefaultParameters();
......
......@@ -45,15 +45,15 @@ namespace OpenMM {
class CMMotionRemoverImpl : public ForceImpl {
public:
CMMotionRemoverImpl(CMMotionRemover& owner);
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
CMMotionRemover& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context);
void calcForces(OpenMMContextImpl& context, Stream& forces) {
void updateContextState(ContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces) {
// This force doesn't apply forces to particles.
}
double calcEnergy(OpenMMContextImpl& context) {
double calcEnergy(ContextImpl& context) {
return 0.0; // This force doesn't contribute to the potential energy.
}
std::map<std::string, double> getDefaultParameters() {
......
#ifndef OPENMM_OPENMMCONTEXTIMPL_H_
#define OPENMM_OPENMMCONTEXTIMPL_H_
#ifndef OPENMM_CONTEXTIMPL_H_
#define OPENMM_CONTEXTIMPL_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
......@@ -42,24 +42,24 @@ namespace OpenMM {
class ForceImpl;
class Integrator;
class OpenMMContext;
class Context;
class System;
/**
* This is the internal implementation of an OpenMMContext.
* This is the internal implementation of a Context.
*/
class OPENMM_EXPORT OpenMMContextImpl {
class OPENMM_EXPORT ContextImpl {
public:
/**
* Create an OpenMMContextImpl for an OpenMMContext;
* Create an ContextImpl for a Context;
*/
OpenMMContextImpl(OpenMMContext& owner, System& system, Integrator& integrator, Platform* platform);
~OpenMMContextImpl();
ContextImpl(Context& owner, System& system, Integrator& integrator, Platform* platform);
~ContextImpl();
/**
* Get the OpenMMContext for which this is the implementation.
* Get the Context for which this is the implementation.
*/
OpenMMContext& getOwner() {
Context& getOwner() {
return owner;
}
/**
......@@ -149,8 +149,8 @@ public:
*/
void setPlatformData(void* data);
private:
friend class OpenMMContext;
OpenMMContext& owner;
friend class Context;
Context& owner;
System& system;
Integrator& integrator;
std::vector<ForceImpl*> forceImpls;
......@@ -163,4 +163,4 @@ private:
} // namespace OpenMM
#endif /*OPENMM_OPENMMCONTEXTIMPL_H_*/
#endif /*OPENMM_CONTEXTIMPL_H_*/
......@@ -39,14 +39,14 @@
namespace OpenMM {
class Force;
class OpenMMContextImpl;
class ContextImpl;
class Stream;
/**
* A ForceImpl provides the internal implementation of a Force. When an OpenMMContext is
* A ForceImpl provides the internal implementation of a Force. When a Context is
* created for a System, it creates a ForceImpl for each Force in the System. The ForceImpl
* is permitted to cache information from the Force or System which is needed to apply the
* force efficiently. If the user calls reinitialize() on the OpenMMContext, all ForceImpl
* force efficiently. If the user calls reinitialize() on the Context, all ForceImpl
* objects it had previously created are deleted and recreated from scratch.
*
* This is an abstract class. Each Force subclass is responsible for defining its own
......@@ -61,7 +61,7 @@ public:
* This is called after the ForceImpl is created and before updateContextState(), calcForces(),
* or calcEnergy() is called on it. This allows it to do any necessary initialization.
*/
virtual void initialize(OpenMMContextImpl& context) = 0;
virtual void initialize(ContextImpl& context) = 0;
/**
* Get the Force object from which this ForceImpl was created.
*/
......@@ -69,11 +69,11 @@ public:
/**
* This method is called at the beginning of each time step. It give the ForceImpl a chance
* to modify the state variables (positions, velocities, and parameters) stored in the
* OpenMMContext in arbitrary ways before integration is performed.
* Context in arbitrary ways before integration is performed.
*
* @param context the context in which the system is being simulated
*/
virtual void updateContextState(OpenMMContextImpl& context) = 0;
virtual void updateContextState(ContextImpl& context) = 0;
/**
* Calculate the force on each particle generated by this ForceImpl. The forces should be <i>added</i>
* to the values already present in the array that is passed in. If this ForceImpl does not generate
......@@ -82,7 +82,7 @@ public:
* @param context the context in which the system is being simulated
* @param forces new forces should be added to the value already stored in this
*/
virtual void calcForces(OpenMMContextImpl& context, Stream& forces) = 0;
virtual void calcForces(ContextImpl& context, Stream& forces) = 0;
/**
* Calculate this ForceImpl's contribution to the potential energy of the system.
*
......@@ -90,10 +90,10 @@ public:
* @return this force's contribution to the potential energy of the system, or 0 if this
* force does not contribute to potential energy
*/
virtual double calcEnergy(OpenMMContextImpl& context) = 0;
virtual double calcEnergy(ContextImpl& context) = 0;
/**
* Get a map containing the default values for all adjustable parameters defined by this ForceImpl. These
* parameters and their default values will automatically be added to the OpenMMContext.
* parameters and their default values will automatically be added to the Context.
*/
virtual std::map<std::string, double> getDefaultParameters() = 0;
/**
......
......@@ -46,15 +46,15 @@ namespace OpenMM {
class GBSAOBCForceImpl : public ForceImpl {
public:
GBSAOBCForceImpl(GBSAOBCForce& owner);
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
GBSAOBCForce& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context) {
void updateContextState(ContextImpl& context) {
// This force field doesn't update the state directly.
}
void calcForces(OpenMMContextImpl& context, Stream& forces);
double calcEnergy(OpenMMContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces);
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters() {
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
......
......@@ -46,7 +46,7 @@ namespace OpenMM {
class GBVIForceImpl : public ForceImpl {
public:
GBVIForceImpl(GBVIForce& owner);
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
GBVIForce& getOwner() {
return owner;
}
......@@ -56,11 +56,11 @@ public:
void findScaledRadii( int numberOfParticles, const std::vector<std::vector<int> >& bondIndices,
const std::vector<double> & bondLengths, std::vector<double> & scaledRadii) const;
void updateContextState(OpenMMContextImpl& context) {
void updateContextState(ContextImpl& context) {
// This force field doesn't update the state directly.
}
void calcForces(OpenMMContextImpl& context, Stream& forces);
double calcEnergy(OpenMMContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces);
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters() {
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
......
......@@ -49,15 +49,15 @@ class HarmonicAngleForceImpl : public ForceImpl {
public:
HarmonicAngleForceImpl(HarmonicAngleForce& owner);
~HarmonicAngleForceImpl();
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
HarmonicAngleForce& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context) {
void updateContextState(ContextImpl& context) {
// This force field doesn't update the state directly.
}
void calcForces(OpenMMContextImpl& context, Stream& forces);
double calcEnergy(OpenMMContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces);
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters() {
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
......
......@@ -49,15 +49,15 @@ class HarmonicBondForceImpl : public ForceImpl {
public:
HarmonicBondForceImpl(HarmonicBondForce& owner);
~HarmonicBondForceImpl();
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
HarmonicBondForce& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context) {
void updateContextState(ContextImpl& context) {
// This force field doesn't update the state directly.
}
void calcForces(OpenMMContextImpl& context, Stream& forces);
double calcEnergy(OpenMMContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces);
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters() {
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
......
......@@ -49,15 +49,15 @@ class NonbondedForceImpl : public ForceImpl {
public:
NonbondedForceImpl(NonbondedForce& owner);
~NonbondedForceImpl();
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
NonbondedForce& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context) {
void updateContextState(ContextImpl& context) {
// This force field doesn't update the state directly.
}
void calcForces(OpenMMContextImpl& context, Stream& forces);
double calcEnergy(OpenMMContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces);
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters() {
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
......
......@@ -49,15 +49,15 @@ class PeriodicTorsionForceImpl : public ForceImpl {
public:
PeriodicTorsionForceImpl(PeriodicTorsionForce& owner);
~PeriodicTorsionForceImpl();
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
PeriodicTorsionForce& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context) {
void updateContextState(ContextImpl& context) {
// This force field doesn't update the state directly.
}
void calcForces(OpenMMContextImpl& context, Stream& forces);
double calcEnergy(OpenMMContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces);
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters() {
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
......
......@@ -49,15 +49,15 @@ class RBTorsionForceImpl : public ForceImpl {
public:
RBTorsionForceImpl(RBTorsionForce& owner);
~RBTorsionForceImpl();
void initialize(OpenMMContextImpl& context);
void initialize(ContextImpl& context);
RBTorsionForce& getOwner() {
return owner;
}
void updateContextState(OpenMMContextImpl& context) {
void updateContextState(ContextImpl& context) {
// This force field doesn't update the state directly.
}
void calcForces(OpenMMContextImpl& context, Stream& forces);
double calcEnergy(OpenMMContextImpl& context);
void calcForces(ContextImpl& context, Stream& forces);
double calcEnergy(ContextImpl& context);
std::map<std::string, double> getDefaultParameters() {
return std::map<std::string, double>(); // This force field doesn't define any parameters.
}
......
......@@ -30,7 +30,7 @@
* -------------------------------------------------------------------------- */
#include "openmm/internal/AndersenThermostatImpl.h"
#include "openmm/internal/OpenMMContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/Integrator.h"
#include "openmm/System.h"
#include "openmm/kernels.h"
......@@ -42,12 +42,12 @@ using std::vector;
AndersenThermostatImpl::AndersenThermostatImpl(AndersenThermostat& owner) : owner(owner) {
}
void AndersenThermostatImpl::initialize(OpenMMContextImpl& context) {
void AndersenThermostatImpl::initialize(ContextImpl& context) {
kernel = context.getPlatform().createKernel(ApplyAndersenThermostatKernel::Name(), context);
dynamic_cast<ApplyAndersenThermostatKernel&>(kernel.getImpl()).initialize(context.getSystem(), owner);
}
void AndersenThermostatImpl::updateContextState(OpenMMContextImpl& context) {
void AndersenThermostatImpl::updateContextState(ContextImpl& context) {
dynamic_cast<ApplyAndersenThermostatKernel&>(kernel.getImpl()).execute(context);
}
......
......@@ -30,8 +30,8 @@
* -------------------------------------------------------------------------- */
#include "openmm/BrownianIntegrator.h"
#include "openmm/OpenMMContext.h"
#include "openmm/internal/OpenMMContextImpl.h"
#include "openmm/Context.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include <ctime>
#include <string>
......@@ -48,7 +48,7 @@ BrownianIntegrator::BrownianIntegrator(double temperature, double frictionCoeff,
setRandomNumberSeed((int) time(NULL));
}
void BrownianIntegrator::initialize(OpenMMContextImpl& contextRef) {
void BrownianIntegrator::initialize(ContextImpl& contextRef) {
context = &contextRef;
kernel = context->getPlatform().createKernel(IntegrateBrownianStepKernel::Name(), contextRef);
dynamic_cast<IntegrateBrownianStepKernel&>(kernel.getImpl()).initialize(contextRef.getSystem(), *this);
......
......@@ -30,7 +30,7 @@
* -------------------------------------------------------------------------- */
#include "openmm/internal/CMMotionRemoverImpl.h"
#include "openmm/internal/OpenMMContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/Integrator.h"
#include "openmm/System.h"
#include "openmm/kernels.h"
......@@ -42,13 +42,13 @@ using std::vector;
CMMotionRemoverImpl::CMMotionRemoverImpl(CMMotionRemover& owner) : owner(owner) {
}
void CMMotionRemoverImpl::initialize(OpenMMContextImpl& context) {
void CMMotionRemoverImpl::initialize(ContextImpl& context) {
kernel = context.getPlatform().createKernel(RemoveCMMotionKernel::Name(), context);
const System& system = context.getSystem();
dynamic_cast<RemoveCMMotionKernel&>(kernel.getImpl()).initialize(system, owner);
}
void CMMotionRemoverImpl::updateContextState(OpenMMContextImpl& context) {
void CMMotionRemoverImpl::updateContextState(ContextImpl& context) {
dynamic_cast<RemoveCMMotionKernel&>(kernel.getImpl()).execute(context);
}
......
......@@ -31,7 +31,7 @@
#include "openmm/OpenMMException.h"
#include "openmm/internal/GBSAOBCForceImpl.h"
#include "openmm/internal/OpenMMContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/kernels.h"
#include <vector>
......@@ -41,18 +41,18 @@ using std::vector;
GBSAOBCForceImpl::GBSAOBCForceImpl(GBSAOBCForce& owner) : owner(owner) {
}
void GBSAOBCForceImpl::initialize(OpenMMContextImpl& context) {
void GBSAOBCForceImpl::initialize(ContextImpl& context) {
kernel = context.getPlatform().createKernel(CalcGBSAOBCForceKernel::Name(), context);
if (owner.getNumParticles() != context.getSystem().getNumParticles())
throw OpenMMException("GBSAOBCForce must have exactly as many particles as the System it belongs to.");
dynamic_cast<CalcGBSAOBCForceKernel&>(kernel.getImpl()).initialize(context.getSystem(), owner);
}
void GBSAOBCForceImpl::calcForces(OpenMMContextImpl& context, Stream& forces) {
void GBSAOBCForceImpl::calcForces(ContextImpl& context, Stream& forces) {
dynamic_cast<CalcGBSAOBCForceKernel&>(kernel.getImpl()).executeForces(context);
}
double GBSAOBCForceImpl::calcEnergy(OpenMMContextImpl& context) {
double GBSAOBCForceImpl::calcEnergy(ContextImpl& context) {
return dynamic_cast<CalcGBSAOBCForceKernel&>(kernel.getImpl()).executeEnergy(context);
}
......
......@@ -30,7 +30,7 @@
* -------------------------------------------------------------------------- */
#include "openmm/internal/GBVIForceImpl.h"
#include "openmm/internal/OpenMMContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/OpenMMException.h"
#include "openmm/kernels.h"
#include <vector>
......@@ -43,7 +43,7 @@ using std::vector;
GBVIForceImpl::GBVIForceImpl(GBVIForce& owner) : owner(owner) {
}
void GBVIForceImpl::initialize(OpenMMContextImpl& context) {
void GBVIForceImpl::initialize(ContextImpl& context) {
kernel = context.getPlatform().createKernel(CalcGBVIForceKernel::Name(), context);
if (owner.getNumParticles() != context.getSystem().getNumParticles())
throw OpenMMException("GBVIForce must have exactly as many particles as the System it belongs to.");
......@@ -188,11 +188,11 @@ void GBVIForceImpl::findScaledRadii( int numberOfParticles, const std::vector<st
}
void GBVIForceImpl::calcForces(OpenMMContextImpl& context, Stream& forces) {
void GBVIForceImpl::calcForces(ContextImpl& context, Stream& forces) {
dynamic_cast<CalcGBVIForceKernel&>(kernel.getImpl()).executeForces(context);
}
double GBVIForceImpl::calcEnergy(OpenMMContextImpl& context) {
double GBVIForceImpl::calcEnergy(ContextImpl& context) {
return dynamic_cast<CalcGBVIForceKernel&>(kernel.getImpl()).executeEnergy(context);
}
......
......@@ -29,7 +29,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/internal/OpenMMContextImpl.h"
#include "openmm/internal/ContextImpl.h"
#include "openmm/internal/HarmonicAngleForceImpl.h"
#include "openmm/kernels.h"
......@@ -44,16 +44,16 @@ HarmonicAngleForceImpl::HarmonicAngleForceImpl(HarmonicAngleForce& owner) : owne
HarmonicAngleForceImpl::~HarmonicAngleForceImpl() {
}
void HarmonicAngleForceImpl::initialize(OpenMMContextImpl& context) {
void HarmonicAngleForceImpl::initialize(ContextImpl& context) {
kernel = context.getPlatform().createKernel(CalcHarmonicAngleForceKernel::Name(), context);
dynamic_cast<CalcHarmonicAngleForceKernel&>(kernel.getImpl()).initialize(context.getSystem(), owner);
}
void HarmonicAngleForceImpl::calcForces(OpenMMContextImpl& context, Stream& forces) {
void HarmonicAngleForceImpl::calcForces(ContextImpl& context, Stream& forces) {
dynamic_cast<CalcHarmonicAngleForceKernel&>(kernel.getImpl()).executeForces(context);
}
double HarmonicAngleForceImpl::calcEnergy(OpenMMContextImpl& context) {
double HarmonicAngleForceImpl::calcEnergy(ContextImpl& context) {
return dynamic_cast<CalcHarmonicAngleForceKernel&>(kernel.getImpl()).executeEnergy(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