OpenMPCD
|
Base class for MPC fluids. More...
#include <Base.hpp>
Public Member Functions | |
virtual | ~Base () |
The destructor. More... | |
unsigned int | getParticleCount () const |
Returns the number of MPC fluid particles. More... | |
virtual unsigned int | getNumberOfLogicalEntities () const =0 |
Returns the number of logical entities in the fluid. More... | |
virtual bool | numberOfParticlesPerLogicalEntityIsConstant () const =0 |
Returns whether all logical entities consist of the same number of MPC particles. More... | |
virtual unsigned int | getNumberOfParticlesPerLogicalEntity () const |
Returns the number of MPC particles per logical entity. More... | |
void | fetchFromDevice () const |
Copies the MPC fluid particles from the CUDA Device to the Host. More... | |
const RemotelyStoredVector< const MPCParticlePositionType > | getPosition (const unsigned int particleID) const |
Returns a MPC fluid particle's position vector. More... | |
const RemotelyStoredVector< const MPCParticleVelocityType > | getVelocity (const unsigned int particleID) const |
Returns a MPC fluid particle's velocity vector. More... | |
void | setPositionsAndVelocities (const MPCParticlePositionType *const positions, const MPCParticleVelocityType *const velocities) |
Sets the positions and velocities of the particles on the Device. More... | |
const MPCParticlePositionType * | getDevicePositions () const |
Returns a const pointer to the MPC fluid positions on the Device. More... | |
MPCParticlePositionType * | getDevicePositions () |
Returns a pointer to the MPC fluid positions on the Device. More... | |
MPCParticleVelocityType * | getDeviceVelocities () |
Returns a pointer to the MPC fluid velocities on the Device. More... | |
const MPCParticleVelocityType * | getDeviceVelocities () const |
Returns a const pointer to the MPC fluid velocities on the Device. More... | |
MPCParticlePositionType * | getHostPositions () |
Returns a pointer to the MPC fluid positions on the Host. More... | |
MPCParticleVelocityType * | getHostVelocities () |
Returns a pointer to the MPC fluid velocities on the Host. More... | |
Instrumentation::Base & | getInstrumentation () const |
Returns the fluid instrumentation. More... | |
void | writeToSnapshot (VTFSnapshotFile *const snapshot) const |
Writes the particle positions and velocities to the given snapshot file. More... | |
void | findMatchingParticlesOnHost (bool(*func)(const RemotelyStoredVector< const MPCParticlePositionType > &, const RemotelyStoredVector< const MPCParticleVelocityType > &), std::vector< unsigned int > *const matches, unsigned int *const matchCount) const |
Computes, on the Host, which MPC particles match the criterion represented by func . More... | |
void | saveLogicalEntityCentersOfMassToDeviceMemory (MPCParticlePositionType *const buffer) const |
Computes the center of mass for each logical entity, and saves their coordinates in the given Device buffer. More... | |
Static Public Member Functions | |
static unsigned int | getParticleMass () |
Returns the MPC fluid particle mass. More... | |
Protected Member Functions | |
Base (const CUDA::Simulation *const sim, const unsigned int count, const FP streamingTimestep_, RNG &rng_, DeviceMemoryManager *const devMemMgr) | |
The constructor. More... | |
virtual void | stream ()=0 |
Performs a streaming step. More... | |
void | pushToDevice () |
Copies the MPC fluid particles from the Host to the CUDA Device. More... | |
void | initializeVelocitiesOnHost () const |
Initializes the fluid particles velocities in Host memory. More... | |
Static Protected Member Functions | |
static void | globalUnbiasedThermostat (const FP kT, MPCParticleVelocityType *const velocities, const unsigned int particleCount) |
Scales all MPC fluid particle velocities so that the global temperature matches the given target. More... | |
static const Vector3D< MPCParticleVelocityType > | getTotalMomentum (const MPCParticleVelocityType *const velocities, const unsigned int particleCount) |
Returns the total momentum of the given MPC fluid particles. More... | |
static const Vector3D< MPCParticleVelocityType > | getMeanMomentum (const MPCParticleVelocityType *const velocities, const unsigned int particleCount) |
Returns the mean momentum of the given MPC fluid particles. More... | |
static FP | getKineticEnergy (const MPCParticleVelocityType *const velocities, const unsigned int particleCount) |
Returns the total kinetic energy of the MPC fluid. More... | |
static FP | getkTViaKineticEnergy (const MPCParticleVelocityType *const velocities, const unsigned int particleCount) |
Returns the product of Boltzmann's constant with the MPC fluid temperature, as measured by the total kinetic energy of the MPC fluid. More... | |
Protected Attributes | |
const CUDA::Simulation *const | simulation |
The simulation instance. More... | |
DeviceMemoryManager *const | deviceMemoryManager |
The Device memory manager. More... | |
Instrumentation::Base * | instrumentation |
The fluid instrumentation. More... | |
RNG | rng |
The random number generator. More... | |
MPCParticlePositionType * | mpcParticlePositions |
Host pointer for the MPC particle positions. More... | |
MPCParticleVelocityType * | mpcParticleVelocities |
Host pointer for the MPC particle positions. More... | |
MPCParticlePositionType * | d_mpcParticlePositions |
Device pointer for the MPC particle positions. More... | |
MPCParticleVelocityType * | d_mpcParticleVelocities |
Device pointer for the MPC particle positions. More... | |
const unsigned int | numberOfParticles |
The number of fluid particles. More... | |
const FP | streamingTimestep |
The timestep for a streaming step. More... | |
Static Protected Attributes | |
static const unsigned int | mpcParticleMass = 1 |
The mass of each MPC particle. More... | |
Friends | |
class | CUDA::Simulation |
Base class for MPC fluids.
The MPC fluid consists of a certain number of logical entities, each of which consists of one or more MPC particles.
Examples of logical entities include linear polymers, ring polymers, and dendrimers. The MPC particles (i.e. the fundamental objects that MPC is concerned with) that would make up those logical entities would typically couple to each other via interaction potentials that depend on the kind of MPC fluid at hand.
Definition at line 40 of file CUDA/MPCFluid/Base.hpp.
|
protected |
The constructor.
This constructor neither initializes the fluid state on Host or Device, nor does it synchronize Host and Device.
[in] | sim | The simulation instance. |
[in] | count | The number of fluid particles. |
[in] | streamingTimestep_ | The timestep for a streaming step. |
[in] | rng_ | A random number generator to seed this instance's RNG with. |
[in] | devMemMgr | The Device memory manager. |
|
virtual |
The destructor.
void OpenMPCD::CUDA::MPCFluid::Base::fetchFromDevice | ( | ) | const |
void OpenMPCD::CUDA::MPCFluid::Base::findMatchingParticlesOnHost | ( | bool(*)(const RemotelyStoredVector< const MPCParticlePositionType > &, const RemotelyStoredVector< const MPCParticleVelocityType > &) | func, |
std::vector< unsigned int > *const | matches, | ||
unsigned int *const | matchCount | ||
) | const |
Computes, on the Host, which MPC particles match the criterion represented by func
.
fetchFromDevice
was called. [in] | func | Iff this function returns true, the MPC particles are considered to satisfy the criterion. The first argument is the particle's position, the second its velocity. |
[out] | matches | Will hold the IDs of the particles that satisfied the criterion; may be nullptr if not needed. |
[out] | matchCount | Will hold the number of particles that satisfied the criterion; may be nullptr if not needed. |
|
inline |
Returns a pointer to the MPC fluid positions on the Device.
Definition at line 169 of file CUDA/MPCFluid/Base.hpp.
|
inline |
Returns a const pointer to the MPC fluid positions on the Device.
Definition at line 161 of file CUDA/MPCFluid/Base.hpp.
|
inline |
Returns a pointer to the MPC fluid velocities on the Device.
Definition at line 177 of file CUDA/MPCFluid/Base.hpp.
|
inline |
Returns a const pointer to the MPC fluid velocities on the Device.
Definition at line 185 of file CUDA/MPCFluid/Base.hpp.
|
inline |
Returns a pointer to the MPC fluid positions on the Host.
Definition at line 193 of file CUDA/MPCFluid/Base.hpp.
|
inline |
Returns a pointer to the MPC fluid velocities on the Host.
Definition at line 201 of file CUDA/MPCFluid/Base.hpp.
|
inline |
Returns the fluid instrumentation.
NULLPointerException | If OPENMPCD_DEBUG is defined, throws if instrumentation is a NULL pointer. |
Definition at line 210 of file CUDA/MPCFluid/Base.hpp.
|
staticprotected |
Returns the total kinetic energy of the MPC fluid.
[in] | velocities | The velocities of the MPC fluid particles on the Host. |
[in] | particleCount | The number of MPC fluid particles. |
|
inlinestaticprotected |
Returns the product of Boltzmann's constant with the MPC fluid temperature, as measured by the total kinetic energy of the MPC fluid.
[in] | velocities | The velocities of the MPC fluid particles on the Host. |
[in] | particleCount | The number of MPC fluid particles. |
Definition at line 335 of file CUDA/MPCFluid/Base.hpp.
|
staticprotected |
Returns the mean momentum of the given MPC fluid particles.
[in] | velocities | The velocities of the MPC fluid particles on the Host. |
[in] | particleCount | The number of MPC fluid particles. |
|
pure virtual |
Returns the number of logical entities in the fluid.
Implemented in OpenMPCD::CUDA::MPCFluid::GaussianDumbbells, OpenMPCD::CUDA::MPCFluid::HarmonicTrimers, OpenMPCD::CUDA::MPCFluid::GaussianChains, OpenMPCD::CUDA::MPCFluid::GaussianRods, and OpenMPCD::CUDA::MPCFluid::Simple.
|
virtual |
Returns the number of MPC particles per logical entity.
OpenMPCD::InvalidCallException | Throws if !numberOfParticlesPerLogicalEntityIsConstant() . |
Reimplemented in OpenMPCD::CUDA::MPCFluid::GaussianDumbbells, OpenMPCD::CUDA::MPCFluid::HarmonicTrimers, OpenMPCD::CUDA::MPCFluid::GaussianChains, OpenMPCD::CUDA::MPCFluid::GaussianRods, and OpenMPCD::CUDA::MPCFluid::Simple.
|
inline |
Returns the number of MPC fluid particles.
Definition at line 72 of file CUDA/MPCFluid/Base.hpp.
|
inlinestatic |
Returns the MPC fluid particle mass.
Definition at line 80 of file CUDA/MPCFluid/Base.hpp.
const RemotelyStoredVector<const MPCParticlePositionType> OpenMPCD::CUDA::MPCFluid::Base::getPosition | ( | const unsigned int | particleID | ) | const |
Returns a MPC fluid particle's position vector.
OutOfBoundsException | If OPENMPCD_DEBUG is defined, throws if particleID >= getMPCParticleCount() |
[in] | particleID | The particle ID. |
|
staticprotected |
Returns the total momentum of the given MPC fluid particles.
[in] | velocities | The velocities of the MPC fluid particles on the Host. |
[in] | particleCount | The number of MPC fluid particles. |
const RemotelyStoredVector<const MPCParticleVelocityType> OpenMPCD::CUDA::MPCFluid::Base::getVelocity | ( | const unsigned int | particleID | ) | const |
Returns a MPC fluid particle's velocity vector.
OutOfBoundsException | If OPENMPCD_DEBUG is defined, throws if particleID >= getMPCParticleCount() |
[in] | particleID | The particle ID. |
|
staticprotected |
Scales all MPC fluid particle velocities so that the global temperature matches the given target.
[in] | kT | The target temperature, multiplied by Boltzmann's constant. |
[in,out] | velocities | The MPC fluid particle velocities on the Host. |
[in] | particleCount | The number of MPC fluid particles. |
|
protected |
Initializes the fluid particles velocities in Host memory.
|
pure virtual |
Returns whether all logical entities consist of the same number of MPC particles.
The value of this function will remain unchanged for the lifetime of the instance.
Implemented in OpenMPCD::CUDA::MPCFluid::GaussianDumbbells, OpenMPCD::CUDA::MPCFluid::HarmonicTrimers, OpenMPCD::CUDA::MPCFluid::GaussianChains, OpenMPCD::CUDA::MPCFluid::GaussianRods, and OpenMPCD::CUDA::MPCFluid::Simple.
|
protected |
void OpenMPCD::CUDA::MPCFluid::Base::saveLogicalEntityCentersOfMassToDeviceMemory | ( | MPCParticlePositionType *const | buffer | ) | const |
Computes the center of mass for each logical entity, and saves their coordinates in the given Device buffer.
The computation is performed with the data as it currently exists on the Device.
OpenMPCD::NULLPointerException | Throws if buffer == nullptr . * |
[out] | buffer | The device buffer to save the coordinates to. It must be able to hold at least 3 * getNumberOfLogicalEntities() elements. The first element in the buffer will be the x coordinate of the center of mass of the first logical entity, followed by the y and z coordinates. After that, the second entity's coordinates follow, and so on. |
void OpenMPCD::CUDA::MPCFluid::Base::setPositionsAndVelocities | ( | const MPCParticlePositionType *const | positions, |
const MPCParticleVelocityType *const | velocities | ||
) |
Sets the positions and velocities of the particles on the Device.
OpenMPCD::NULLPointerException | If OPENMPCD_DEBUG is defined, throws if positions == nullptr or velocities == nullptr . |
[in] | positions | An array holding 3 * getParticleCount() values on the Host; first, the x , y , and z coordinates of the first atom, then those of the second, etc. |
[in] | velocities | An array holding 3 * getParticleCount() values on the Host; first, the x , y , and z velocities of the first atom, then those of the second, etc. |
|
protectedpure virtual |
Performs a streaming step.
Implemented in OpenMPCD::CUDA::MPCFluid::GaussianDumbbells, OpenMPCD::CUDA::MPCFluid::HarmonicTrimers, OpenMPCD::CUDA::MPCFluid::GaussianChains, OpenMPCD::CUDA::MPCFluid::GaussianRods, and OpenMPCD::CUDA::MPCFluid::Simple.
void OpenMPCD::CUDA::MPCFluid::Base::writeToSnapshot | ( | VTFSnapshotFile *const | snapshot | ) | const |
Writes the particle positions and velocities to the given snapshot file.
This function will call fetchFromDevice
, and write the current Device data to the given snapshot file.
OpenMPCD::NULLPointerException | Throws if snapshot == nullptr . |
OpenMPCD::InvalidArgumentException | Throws if the number of atoms declared in the snapshot does not match the number of particles in this instance. |
OpenMPCD::InvalidArgumentException | Throws if the given snapshot is not in write mode. |
[in,out] | snapshot | The snapshot file. |
|
protected |
Device pointer for the MPC particle positions.
Definition at line 363 of file CUDA/MPCFluid/Base.hpp.
|
protected |
Device pointer for the MPC particle positions.
Definition at line 364 of file CUDA/MPCFluid/Base.hpp.
|
protected |
The Device memory manager.
Definition at line 354 of file CUDA/MPCFluid/Base.hpp.
|
protected |
The fluid instrumentation.
Definition at line 356 of file CUDA/MPCFluid/Base.hpp.
|
staticprotected |
The mass of each MPC particle.
Definition at line 351 of file CUDA/MPCFluid/Base.hpp.
|
mutableprotected |
Host pointer for the MPC particle positions.
Definition at line 360 of file CUDA/MPCFluid/Base.hpp.
|
mutableprotected |
Host pointer for the MPC particle positions.
Definition at line 361 of file CUDA/MPCFluid/Base.hpp.
|
protected |
The number of fluid particles.
Definition at line 366 of file CUDA/MPCFluid/Base.hpp.
|
mutableprotected |
The random number generator.
Definition at line 358 of file CUDA/MPCFluid/Base.hpp.
|
protected |
The simulation instance.
Definition at line 353 of file CUDA/MPCFluid/Base.hpp.
|
protected |
The timestep for a streaming step.
Definition at line 368 of file CUDA/MPCFluid/Base.hpp.