- Main Page
- Related Pages
- Classes
- Files

- File List

# ContextImpl.h

    00001 #ifndef OPENMM_CONTEXTIMPL_H_
    00002 #define OPENMM_CONTEXTIMPL_H_
    00003
    00004 /* -------------------------------------------------------------------------- *
    00005  *                                   OpenMM                                   *
    00006  * -------------------------------------------------------------------------- *
    00007  * This is part of the OpenMM molecular simulation toolkit originating from   *
    00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
    00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
    00010  * Medical Research, grant U54 GM072970. See https://simtk.org.               *
    00011  *                                                                            *
    00012  * Portions copyright (c) 2008-2013 Stanford University and the Authors.      *
    00013  * Authors: Peter Eastman                                                     *
    00014  * Contributors:                                                              *
    00015  *                                                                            *
    00016  * Permission is hereby granted, free of charge, to any person obtaining a    *
    00017  * copy of this software and associated documentation files (the "Software"), *
    00018  * to deal in the Software without restriction, including without limitation  *
    00019  * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
    00020  * and/or sell copies of the Software, and to permit persons to whom the      *
    00021  * Software is furnished to do so, subject to the following conditions:       *
    00022  *                                                                            *
    00023  * The above copyright notice and this permission notice shall be included in *
    00024  * all copies or substantial portions of the Software.                        *
    00025  *                                                                            *
    00026  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
    00027  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
    00028  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
    00029  * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
    00030  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
    00031  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
    00032  * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
    00033  * -------------------------------------------------------------------------- */
    00034
    00035 #include "openmm/Kernel.h"
    00036 #include "openmm/Platform.h"
    00037 #include "openmm/Vec3.h"
    00038 #include <iosfwd>
    00039 #include <map>
    00040 #include <vector>
    00041
    00042 namespace OpenMM {
    00043
    00044 class ForceImpl;
    00045 class Integrator;
    00046 class Context;
    00047 class System;
    00048
    00053 class OPENMM_EXPORT ContextImpl {
    00054 public:
    00058     ContextImpl(Context& owner, const System& system, Integrator& integrator, Platform* platform, const std::map<std::string, std::string>& properties);
    00059     ~ContextImpl();
    00063     Context& getOwner() {
    00064         return owner;
    00065     }
    00069     const System& getSystem() const {
    00070         return system;
    00071     }
    00075     Integrator& getIntegrator() {
    00076         return integrator;
    00077     }
    00081     Platform& getPlatform() {
    00082         return *platform;
    00083     }
    00087     double getTime() const;
    00091     void setTime(double t);
    00097     void getPositions(std::vector<Vec3>& positions);
    00103     void setPositions(const std::vector<Vec3>& positions);
    00109     void getVelocities(std::vector<Vec3>& velocities);
    00115     void setVelocities(const std::vector<Vec3>& velocities);
    00121     void getForces(std::vector<Vec3>& forces);
    00125     const std::map<std::string, double>& getParameters() const;
    00132     double getParameter(std::string name);
    00140     void setParameter(std::string name, double value);
    00152     void getPeriodicBoxVectors(Vec3& a, Vec3& b, Vec3& c);
    00164     void setPeriodicBoxVectors(const Vec3& a, const Vec3& b, const Vec3& c);
    00171     void applyConstraints(double tol);
    00177     void applyVelocityConstraints(double tol);
    00184     void computeVirtualSites();
    00195     double calcForcesAndEnergy(bool includeForces, bool includeEnergy, int groups=0xFFFFFFFF);
    00199     int getLastForceGroups() const;
    00203     double calcKineticEnergy();
    00208     void updateContextState();
    00212     const std::vector<ForceImpl*>& getForceImpls() const;
    00216     std::vector<ForceImpl*>& getForceImpls();
    00220     void* getPlatformData();
    00224     const void* getPlatformData() const;
    00228     void setPlatformData(void* data);
    00233     const std::vector<std::vector<int> >& getMolecules() const;
    00239     void createCheckpoint(std::ostream& stream);
    00245     void loadCheckpoint(std::istream& stream);
    00250     void integratorDeleted() {
    00251         integratorIsDeleted = true;
    00252     }
    00257     static std::vector<std::vector<int> > findMolecules(int numParticles, std::vector<std::vector<int> >& particleBonds);
    00258 private:
    00259     friend class Context;
    00260     Context& owner;
    00261     const System& system;
    00262     Integrator& integrator;
    00263     std::vector<ForceImpl*> forceImpls;
    00264     std::map<std::string, double> parameters;
    00265     mutable std::vector<std::vector<int> > molecules;
    00266     bool hasInitializedForces, hasSetPositions, integratorIsDeleted;
    00267     int lastForceGroups;
    00268     Platform* platform;
    00269     Kernel initializeForcesKernel, updateStateDataKernel, applyConstraintsKernel, virtualSitesKernel;
    00270     void* platformData;
    00271 };
    00272
    00273 } // namespace OpenMM
    00274
    00275 #endif /*OPENMM_CONTEXTIMPL_H_*/