Context Class Reference

A Context stores the complete state of a simulation. More...

#include <Context.h>

List of all members.

Public Member Functions

 Context (System &system, Integrator &integrator)
 Construct a new Context in which to run a simulation.
 Context (System &system, Integrator &integrator, Platform &platform)
 Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used to perform calculations.
 Context (System &system, Integrator &integrator, Platform &platform, const std::map< std::string, std::string > &properties)
 Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used to perform calculations and the values of platform-specific properties.
 ~Context ()
const SystemgetSystem () const
 Get System being simulated in this context.
SystemgetSystem ()
 Get System being simulated in this context.
const IntegratorgetIntegrator () const
 Get Integrator being used to by this context.
IntegratorgetIntegrator ()
 Get Integrator being used to by this context.
const PlatformgetPlatform () const
 Get the Platform being used for calculations.
PlatformgetPlatform ()
 Get the Platform being used for calculations.
State getState (int types) const
 Get a State object recording the current state information stored in this context.
void setTime (double time)
 Set the current time of the simulation (in picoseconds).
void setPositions (const std::vector< Vec3 > &positions)
 Set the positions of all particles in the System (measured in nm).
void setVelocities (const std::vector< Vec3 > &velocities)
 Set the velocities of all particles in the System (measured in nm/picosecond).
double getParameter (const std::string &name)
 Get the value of an adjustable parameter defined by a Force object in the System.
void setParameter (const std::string &name, double value)
 Set the value of an adjustable parameter defined by a Force object in the System.
void reinitialize ()
 When a Context is created, it may cache information about the System being simulated and the Force objects contained in it.

Friends

class Platform

Detailed Description

A Context stores the complete state of a simulation.

More specifically, it includes:

You can retrieve a snapshot of the current state at any time by calling getState(). This allows you to record the state of the simulation at various points, either for analysis or for checkpointing. getState() can also be used to retrieve the current forces on each particle and the current energy of the System.


Constructor & Destructor Documentation

Context ( System system,
Integrator integrator 
)

Construct a new Context in which to run a simulation.

Parameters:
system the System which will be simulated
integrator the Integrator which will be used to simulate the System
Context ( System system,
Integrator integrator,
Platform platform 
)

Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used to perform calculations.

Parameters:
system the System which will be simulated
integrator the Integrator which will be used to simulate the System
platform the Platform to use for calculations
Context ( System system,
Integrator integrator,
Platform platform,
const std::map< std::string, std::string > &  properties 
)

Construct a new Context in which to run a simulation, explicitly specifying what Platform should be used to perform calculations and the values of platform-specific properties.

Parameters:
system the System which will be simulated
integrator the Integrator which will be used to simulate the System
platform the Platform to use for calculations
properties a set of values for platform-specific properties. Keys are the property names.
~Context (  ) 

Member Function Documentation

Integrator& getIntegrator (  ) 

Get Integrator being used to by this context.

const Integrator& getIntegrator (  )  const

Get Integrator being used to by this context.

double getParameter ( const std::string &  name  ) 

Get the value of an adjustable parameter defined by a Force object in the System.

Parameters:
name the name of the parameter to get
Platform& getPlatform (  ) 

Get the Platform being used for calculations.

const Platform& getPlatform (  )  const

Get the Platform being used for calculations.

State getState ( int  types  )  const

Get a State object recording the current state information stored in this context.

Parameters:
types the set of data types which should be stored in the State object. This should be a union of DataType values, e.g. (State::Positions | State::Velocities).
System& getSystem (  ) 

Get System being simulated in this context.

const System& getSystem (  )  const

Get System being simulated in this context.

void reinitialize (  ) 

When a Context is created, it may cache information about the System being simulated and the Force objects contained in it.

This means that, if the System or Forces are then modified, the Context might not see all of the changes. Call reinitialize() to force the Context to rebuild its internal representation of the System and pick up any changes that have been made.

This is an expensive operation, so you should try to avoid calling it too frequently.

void setParameter ( const std::string &  name,
double  value 
)

Set the value of an adjustable parameter defined by a Force object in the System.

Parameters:
name the name of the parameter to set
value the value of the parameter
void setPositions ( const std::vector< Vec3 > &  positions  ) 

Set the positions of all particles in the System (measured in nm).

Parameters:
positions a vector whose length equals the number of particles in the System. The i'th element contains the position of the i'th particle.
void setTime ( double  time  ) 

Set the current time of the simulation (in picoseconds).

void setVelocities ( const std::vector< Vec3 > &  velocities  ) 

Set the velocities of all particles in the System (measured in nm/picosecond).

Parameters:
velocities a vector whose length equals the number of particles in the System. The i'th element contains the velocity of the i'th particle.

Friends And Related Function Documentation

friend class Platform [friend]

The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2