All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
ContextImpl.h
#ifndef OPENMM_CONTEXTIMPL_H_
#define OPENMM_CONTEXTIMPL_H_
/* -------------------------------------------------------------------------- *
* OpenMM *
* -------------------------------------------------------------------------- *
* This is part of the OpenMM molecular simulation toolkit originating from *
* Simbios, the NIH National Center for Physics-Based Simulation of *
* Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. *
* *
* Portions copyright (c) 2008-2013 Stanford University and the Authors. *
* Authors: Peter Eastman *
* Contributors: *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the "Software"), *
* to deal in the Software without restriction, including without limitation *
* the rights to use, copy, modify, merge, publish, distribute, sublicense, *
* and/or sell copies of the Software, and to permit persons to whom the *
* Software is furnished to do so, subject to the following conditions: *
* *
* The above copyright notice and this permission notice shall be included in *
* all copies or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *
* THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "openmm/Kernel.h"
#include "openmm/Platform.h"
#include "openmm/Vec3.h"
#include <iosfwd>
#include <map>
#include <vector>
namespace OpenMM {
class ForceImpl;
class Integrator;
class Context;
class System;
class OPENMM_EXPORT ContextImpl {
public:
ContextImpl(Context& owner, const System& system, Integrator& integrator, Platform* platform, const std::map<std::string, std::string>& properties);
~ContextImpl();
Context& getOwner() {
return owner;
}
const System& getSystem() const {
return system;
}
Integrator& getIntegrator() {
return integrator;
}
Platform& getPlatform() {
return *platform;
}
double getTime() const;
void setTime(double t);
void getPositions(std::vector<Vec3>& positions);
void setPositions(const std::vector<Vec3>& positions);
void getVelocities(std::vector<Vec3>& velocities);
void setVelocities(const std::vector<Vec3>& velocities);
void getForces(std::vector<Vec3>& forces);
const std::map<std::string, double>& getParameters() const;
double getParameter(std::string name);
void setParameter(std::string name, double value);
void getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c);
void setPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3& c);
void applyConstraints(double tol);
void applyVelocityConstraints(double tol);
void computeVirtualSites();
double calcForcesAndEnergy(bool includeForces, bool includeEnergy, int groups=0xFFFFFFFF);
int getLastForceGroups() const;
double calcKineticEnergy();
void updateContextState();
const std::vector<ForceImpl*>& getForceImpls() const;
std::vector<ForceImpl*>& getForceImpls();
void* getPlatformData();
const void* getPlatformData() const;
void setPlatformData(void* data);
const std::vector<std::vector<int> >& getMolecules() const;
void createCheckpoint(std::ostream& stream);
void loadCheckpoint(std::istream& stream);
void integratorDeleted() {
integratorIsDeleted = true;
}
static std::vector<std::vector<int> > findMolecules(int numParticles, std::vector<std::vector<int> >& particleBonds);
private:
friend class Context;
Context& owner;
const System& system;
Integrator& integrator;
std::vector<ForceImpl*> forceImpls;
std::map<std::string, double> parameters;
mutable std::vector<std::vector<int> > molecules;
bool hasInitializedForces, hasSetPositions, integratorIsDeleted;
int lastForceGroups;
Platform* platform;
Kernel initializeForcesKernel, updateStateDataKernel, applyConstraintsKernel, virtualSitesKernel;
void* platformData;
};
} // namespace OpenMM
#endif /*OPENMM_CONTEXTIMPL_H_*/
OpenMM::ContextImpl
This is the internal implementation of a Context.
Definition: ContextImpl.h:53
OpenMM::ContextImpl::getOwner
Context & getOwner()
Get the Context for which this is the implementation.
Definition: ContextImpl.h:63
OpenMM::Context
A Context stores the complete state of a simulation.
Definition: Context.h:67
OpenMM::ContextImpl::getPlatform
Platform & getPlatform()
Get the Platform implementation being used for computations.
Definition: ContextImpl.h:81
OpenMM::Integrator
An Integrator defines a method for simulating a System by integrating the equations of motion...
Definition: Integrator.h:54
OpenMM::System
This class represents a molecular system.
Definition: System.h:66
OpenMM::Vec3
This class represents a three component vector.
Definition: Vec3.h:45
OpenMM::ContextImpl::getIntegrator
Integrator & getIntegrator()
Get Integrator being used to by this context.
Definition: ContextImpl.h:75
OpenMM::Kernel
A Kernel encapsulates a particular implementation of a calculation that can be performed on the data ...
Definition: Kernel.h:58
OpenMM::ContextImpl::integratorDeleted
void integratorDeleted()
This is invoked by the Integrator when it is deleted.
Definition: ContextImpl.h:250
OpenMM::ContextImpl::getSystem
const System & getSystem() const
Get System being simulated in this context.
Definition: ContextImpl.h:69
OpenMM::Platform
A Platform defines an implementation of all the kernels needed to perform some calculation.
Definition: Platform.h:64