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

API changes to support variable time step integrators

parent 14f17de5
......@@ -32,6 +32,7 @@
* USE OR OTHER DEALINGS IN THE SOFTWARE. *
* -------------------------------------------------------------------------- */
#include "ReferencePlatform.h"
#include "openmm/kernels.h"
#include "SimTKUtilities/SimTKOpenMMRealType.h"
#include "SimTKReference/ReferenceNeighborList.h"
......@@ -67,6 +68,35 @@ public:
void execute(OpenMMContextImpl& context);
};
/**
* This kernel is invoked to get or set the current time.
*/
class ReferenceUpdateTimeKernel : public UpdateTimeKernel {
public:
ReferenceUpdateTimeKernel(std::string name, const Platform& platform, ReferencePlatform::PlatformData& data) : UpdateTimeKernel(name, platform), data(data) {
}
/**
* Initialize the kernel.
*
* @param system the System this kernel will be applied to
*/
void initialize(const System& system);
/**
* Get the current time (in picoseconds).
*
* @param context the context in which to execute this kernel
*/
double getTime(const OpenMMContextImpl& context) const;
/**
* Set the current time (in picoseconds).
*
* @param context the context in which to execute this kernel
*/
void setTime(OpenMMContextImpl& context, double time);
private:
ReferencePlatform::PlatformData& data;
};
/**
* This kernel is invoked by HarmonicBondForce to calculate the forces acting on the system and the energy of the system.
*/
......
......@@ -32,6 +32,7 @@
#include "ReferencePlatform.h"
#include "ReferenceKernelFactory.h"
#include "ReferenceKernels.h"
#include "openmm/internal/OpenMMContextImpl.h"
#include "SimTKUtilities/SimTKOpenMMRealType.h"
using namespace OpenMM;
......@@ -39,6 +40,7 @@ using namespace OpenMM;
ReferencePlatform::ReferencePlatform() {
ReferenceKernelFactory* factory = new ReferenceKernelFactory();
registerKernelFactory(InitializeForcesKernel::Name(), factory);
registerKernelFactory(UpdateTimeKernel::Name(), factory);
registerKernelFactory(CalcHarmonicBondForceKernel::Name(), factory);
registerKernelFactory(CalcHarmonicAngleForceKernel::Name(), factory);
registerKernelFactory(CalcPeriodicTorsionForceKernel::Name(), factory);
......@@ -61,3 +63,12 @@ bool ReferencePlatform::supportsDoublePrecision() const {
const StreamFactory& ReferencePlatform::getDefaultStreamFactory() const {
return defaultStreamFactory;
}
void ReferencePlatform::contextCreated(OpenMMContextImpl& context) const {
context.setPlatformData(new PlatformData());
}
void ReferencePlatform::contextDestroyed(OpenMMContextImpl& context) const {
PlatformData* data = reinterpret_cast<PlatformData*>(context.getPlatformData());
delete data;
}
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