OpenMPCD
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
OpenMPCD::CUDA::MPCFluid::Base Class Referenceabstract

Base class for MPC fluids. More...

#include <Base.hpp>

Inheritance diagram for OpenMPCD::CUDA::MPCFluid::Base:
Inheritance graph
[legend]
Collaboration diagram for OpenMPCD::CUDA::MPCFluid::Base:
Collaboration graph
[legend]

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 MPCParticlePositionTypegetPosition (const unsigned int particleID) const
 Returns a MPC fluid particle's position vector. More...
 
const RemotelyStoredVector< const MPCParticleVelocityTypegetVelocity (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 MPCParticlePositionTypegetDevicePositions () const
 Returns a const pointer to the MPC fluid positions on the Device. More...
 
MPCParticlePositionTypegetDevicePositions ()
 Returns a pointer to the MPC fluid positions on the Device. More...
 
MPCParticleVelocityTypegetDeviceVelocities ()
 Returns a pointer to the MPC fluid velocities on the Device. More...
 
const MPCParticleVelocityTypegetDeviceVelocities () const
 Returns a const pointer to the MPC fluid velocities on the Device. More...
 
MPCParticlePositionTypegetHostPositions ()
 Returns a pointer to the MPC fluid positions on the Host. More...
 
MPCParticleVelocityTypegetHostVelocities ()
 Returns a pointer to the MPC fluid velocities on the Host. More...
 
Instrumentation::BasegetInstrumentation () 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< MPCParticleVelocityTypegetTotalMomentum (const MPCParticleVelocityType *const velocities, const unsigned int particleCount)
 Returns the total momentum of the given MPC fluid particles. More...
 
static const Vector3D< MPCParticleVelocityTypegetMeanMomentum (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::Baseinstrumentation
 The fluid instrumentation. More...
 
RNG rng
 The random number generator. More...
 
MPCParticlePositionTypempcParticlePositions
 Host pointer for the MPC particle positions. More...
 
MPCParticleVelocityTypempcParticleVelocities
 Host pointer for the MPC particle positions. More...
 
MPCParticlePositionTyped_mpcParticlePositions
 Device pointer for the MPC particle positions. More...
 
MPCParticleVelocityTyped_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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Base()

OpenMPCD::CUDA::MPCFluid::Base::Base ( const CUDA::Simulation *const  sim,
const unsigned int  count,
const FP  streamingTimestep_,
RNG rng_,
DeviceMemoryManager *const  devMemMgr 
)
protected

The constructor.

This constructor neither initializes the fluid state on Host or Device, nor does it synchronize Host and Device.

Parameters
[in]simThe simulation instance.
[in]countThe 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]devMemMgrThe Device memory manager.

◆ ~Base()

virtual OpenMPCD::CUDA::MPCFluid::Base::~Base ( )
virtual

The destructor.

Member Function Documentation

◆ fetchFromDevice()

void OpenMPCD::CUDA::MPCFluid::Base::fetchFromDevice ( ) const

Copies the MPC fluid particles from the CUDA Device to the Host.

◆ findMatchingParticlesOnHost()

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.

Warning
This function operates only on the data that were current the last time fetchFromDevice was called.
Parameters
[in]funcIff 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]matchesWill hold the IDs of the particles that satisfied the criterion; may be nullptr if not needed.
[out]matchCountWill hold the number of particles that satisfied the criterion; may be nullptr if not needed.

◆ getDevicePositions() [1/2]

MPCParticlePositionType* OpenMPCD::CUDA::MPCFluid::Base::getDevicePositions ( )
inline

Returns a pointer to the MPC fluid positions on the Device.

Definition at line 169 of file CUDA/MPCFluid/Base.hpp.

◆ getDevicePositions() [2/2]

const MPCParticlePositionType* OpenMPCD::CUDA::MPCFluid::Base::getDevicePositions ( ) const
inline

Returns a const pointer to the MPC fluid positions on the Device.

Definition at line 161 of file CUDA/MPCFluid/Base.hpp.

◆ getDeviceVelocities() [1/2]

MPCParticleVelocityType* OpenMPCD::CUDA::MPCFluid::Base::getDeviceVelocities ( )
inline

Returns a pointer to the MPC fluid velocities on the Device.

Definition at line 177 of file CUDA/MPCFluid/Base.hpp.

◆ getDeviceVelocities() [2/2]

const MPCParticleVelocityType* OpenMPCD::CUDA::MPCFluid::Base::getDeviceVelocities ( ) const
inline

Returns a const pointer to the MPC fluid velocities on the Device.

Definition at line 185 of file CUDA/MPCFluid/Base.hpp.

◆ getHostPositions()

MPCParticlePositionType* OpenMPCD::CUDA::MPCFluid::Base::getHostPositions ( )
inline

Returns a pointer to the MPC fluid positions on the Host.

Definition at line 193 of file CUDA/MPCFluid/Base.hpp.

◆ getHostVelocities()

MPCParticleVelocityType* OpenMPCD::CUDA::MPCFluid::Base::getHostVelocities ( )
inline

Returns a pointer to the MPC fluid velocities on the Host.

Definition at line 201 of file CUDA/MPCFluid/Base.hpp.

◆ getInstrumentation()

Instrumentation::Base& OpenMPCD::CUDA::MPCFluid::Base::getInstrumentation ( ) const
inline

Returns the fluid instrumentation.

Exceptions
NULLPointerExceptionIf OPENMPCD_DEBUG is defined, throws if instrumentation is a NULL pointer.

Definition at line 210 of file CUDA/MPCFluid/Base.hpp.

◆ getKineticEnergy()

static FP OpenMPCD::CUDA::MPCFluid::Base::getKineticEnergy ( const MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
staticprotected

Returns the total kinetic energy of the MPC fluid.

Parameters
[in]velocitiesThe velocities of the MPC fluid particles on the Host.
[in]particleCountThe number of MPC fluid particles.

◆ getkTViaKineticEnergy()

static FP OpenMPCD::CUDA::MPCFluid::Base::getkTViaKineticEnergy ( const MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
inlinestaticprotected

Returns the product of Boltzmann's constant with the MPC fluid temperature, as measured by the total kinetic energy of the MPC fluid.

Parameters
[in]velocitiesThe velocities of the MPC fluid particles on the Host.
[in]particleCountThe number of MPC fluid particles.

Definition at line 335 of file CUDA/MPCFluid/Base.hpp.

◆ getMeanMomentum()

static const Vector3D<MPCParticleVelocityType> OpenMPCD::CUDA::MPCFluid::Base::getMeanMomentum ( const MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
staticprotected

Returns the mean momentum of the given MPC fluid particles.

Parameters
[in]velocitiesThe velocities of the MPC fluid particles on the Host.
[in]particleCountThe number of MPC fluid particles.

◆ getNumberOfLogicalEntities()

virtual unsigned int OpenMPCD::CUDA::MPCFluid::Base::getNumberOfLogicalEntities ( ) const
pure virtual

◆ getNumberOfParticlesPerLogicalEntity()

virtual unsigned int OpenMPCD::CUDA::MPCFluid::Base::getNumberOfParticlesPerLogicalEntity ( ) const
virtual

Returns the number of MPC particles per logical entity.

Exceptions
OpenMPCD::InvalidCallExceptionThrows 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.

◆ getParticleCount()

unsigned int OpenMPCD::CUDA::MPCFluid::Base::getParticleCount ( ) const
inline

Returns the number of MPC fluid particles.

Definition at line 72 of file CUDA/MPCFluid/Base.hpp.

◆ getParticleMass()

static unsigned int OpenMPCD::CUDA::MPCFluid::Base::getParticleMass ( )
inlinestatic

Returns the MPC fluid particle mass.

Definition at line 80 of file CUDA/MPCFluid/Base.hpp.

◆ getPosition()

const RemotelyStoredVector<const MPCParticlePositionType> OpenMPCD::CUDA::MPCFluid::Base::getPosition ( const unsigned int  particleID) const

Returns a MPC fluid particle's position vector.

Warning
This function only returns the position that was current the last time fetchFromDevice was called.
Exceptions
OutOfBoundsExceptionIf OPENMPCD_DEBUG is defined, throws if particleID >= getMPCParticleCount()
Parameters
[in]particleIDThe particle ID.

◆ getTotalMomentum()

static const Vector3D<MPCParticleVelocityType> OpenMPCD::CUDA::MPCFluid::Base::getTotalMomentum ( const MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
staticprotected

Returns the total momentum of the given MPC fluid particles.

Parameters
[in]velocitiesThe velocities of the MPC fluid particles on the Host.
[in]particleCountThe number of MPC fluid particles.

◆ getVelocity()

const RemotelyStoredVector<const MPCParticleVelocityType> OpenMPCD::CUDA::MPCFluid::Base::getVelocity ( const unsigned int  particleID) const

Returns a MPC fluid particle's velocity vector.

Warning
This function only returns the velocity that was current the last time fetchFromDevice was called.
Exceptions
OutOfBoundsExceptionIf OPENMPCD_DEBUG is defined, throws if particleID >= getMPCParticleCount()
Parameters
[in]particleIDThe particle ID.

◆ globalUnbiasedThermostat()

static void OpenMPCD::CUDA::MPCFluid::Base::globalUnbiasedThermostat ( const FP  kT,
MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
staticprotected

Scales all MPC fluid particle velocities so that the global temperature matches the given target.

Parameters
[in]kTThe target temperature, multiplied by Boltzmann's constant.
[in,out]velocitiesThe MPC fluid particle velocities on the Host.
[in]particleCountThe number of MPC fluid particles.

◆ initializeVelocitiesOnHost()

void OpenMPCD::CUDA::MPCFluid::Base::initializeVelocitiesOnHost ( ) const
protected

Initializes the fluid particles velocities in Host memory.

◆ numberOfParticlesPerLogicalEntityIsConstant()

virtual bool OpenMPCD::CUDA::MPCFluid::Base::numberOfParticlesPerLogicalEntityIsConstant ( ) const
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.

◆ pushToDevice()

void OpenMPCD::CUDA::MPCFluid::Base::pushToDevice ( )
protected

Copies the MPC fluid particles from the Host to the CUDA Device.

◆ saveLogicalEntityCentersOfMassToDeviceMemory()

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.

Exceptions
OpenMPCD::NULLPointerExceptionThrows if buffer == nullptr. *
Parameters
[out]bufferThe 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.

◆ setPositionsAndVelocities()

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.

Exceptions
OpenMPCD::NULLPointerExceptionIf OPENMPCD_DEBUG is defined, throws if positions == nullptr or velocities == nullptr.
Parameters
[in]positionsAn 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]velocitiesAn 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.

◆ stream()

virtual void OpenMPCD::CUDA::MPCFluid::Base::stream ( )
protectedpure virtual

◆ writeToSnapshot()

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.

Exceptions
OpenMPCD::NULLPointerExceptionThrows if snapshot == nullptr.
OpenMPCD::InvalidArgumentExceptionThrows if the number of atoms declared in the snapshot does not match the number of particles in this instance.
OpenMPCD::InvalidArgumentExceptionThrows if the given snapshot is not in write mode.
Parameters
[in,out]snapshotThe snapshot file.

Member Data Documentation

◆ d_mpcParticlePositions

MPCParticlePositionType* OpenMPCD::CUDA::MPCFluid::Base::d_mpcParticlePositions
protected

Device pointer for the MPC particle positions.

Definition at line 363 of file CUDA/MPCFluid/Base.hpp.

◆ d_mpcParticleVelocities

MPCParticleVelocityType* OpenMPCD::CUDA::MPCFluid::Base::d_mpcParticleVelocities
protected

Device pointer for the MPC particle positions.

Definition at line 364 of file CUDA/MPCFluid/Base.hpp.

◆ deviceMemoryManager

DeviceMemoryManager* const OpenMPCD::CUDA::MPCFluid::Base::deviceMemoryManager
protected

The Device memory manager.

Definition at line 354 of file CUDA/MPCFluid/Base.hpp.

◆ instrumentation

Instrumentation::Base* OpenMPCD::CUDA::MPCFluid::Base::instrumentation
protected

The fluid instrumentation.

Definition at line 356 of file CUDA/MPCFluid/Base.hpp.

◆ mpcParticleMass

const unsigned int OpenMPCD::CUDA::MPCFluid::Base::mpcParticleMass = 1
staticprotected

The mass of each MPC particle.

Definition at line 351 of file CUDA/MPCFluid/Base.hpp.

◆ mpcParticlePositions

MPCParticlePositionType* OpenMPCD::CUDA::MPCFluid::Base::mpcParticlePositions
mutableprotected

Host pointer for the MPC particle positions.

Definition at line 360 of file CUDA/MPCFluid/Base.hpp.

◆ mpcParticleVelocities

MPCParticleVelocityType* OpenMPCD::CUDA::MPCFluid::Base::mpcParticleVelocities
mutableprotected

Host pointer for the MPC particle positions.

Definition at line 361 of file CUDA/MPCFluid/Base.hpp.

◆ numberOfParticles

const unsigned int OpenMPCD::CUDA::MPCFluid::Base::numberOfParticles
protected

The number of fluid particles.

Definition at line 366 of file CUDA/MPCFluid/Base.hpp.

◆ rng

RNG OpenMPCD::CUDA::MPCFluid::Base::rng
mutableprotected

The random number generator.

Definition at line 358 of file CUDA/MPCFluid/Base.hpp.

◆ simulation

const CUDA::Simulation* const OpenMPCD::CUDA::MPCFluid::Base::simulation
protected

The simulation instance.

Definition at line 353 of file CUDA/MPCFluid/Base.hpp.

◆ streamingTimestep

const FP OpenMPCD::CUDA::MPCFluid::Base::streamingTimestep
protected

The timestep for a streaming step.

Definition at line 368 of file CUDA/MPCFluid/Base.hpp.


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