OpenMPCD
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
OpenMPCD::CUDA::MPCFluid::Simple Class Reference

Fluid consisting of independent particles. More...

#include <Simple.hpp>

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

Public Member Functions

 Simple (const CUDA::Simulation *const sim, const unsigned int count, const FP streamingTimestep_, RNG &rng_, DeviceMemoryManager *const devMemMgr)
 The constructor. More...
 
virtual ~Simple ()
 The destructor. More...
 
virtual unsigned int getNumberOfLogicalEntities () const
 Returns the number of logical entities in the fluid. More...
 
virtual bool numberOfParticlesPerLogicalEntityIsConstant () const
 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...
 
virtual void stream ()
 Performs a streaming step. More...
 
unsigned int getParticleCount () const
 Returns the number of MPC fluid particles. 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

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...
 

Detailed Description

Fluid consisting of independent particles.

Definition at line 20 of file Simple.hpp.

Constructor & Destructor Documentation

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

The constructor.

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.
virtual OpenMPCD::CUDA::MPCFluid::Simple::~Simple ( )
inlinevirtual

The destructor.

Definition at line 37 of file Simple.hpp.

Member Function Documentation

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

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

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
inherited

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.
const MPCParticlePositionType* OpenMPCD::CUDA::MPCFluid::Base::getDevicePositions ( ) const
inlineinherited

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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

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.
static FP OpenMPCD::CUDA::MPCFluid::Base::getkTViaKineticEnergy ( const MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
inlinestaticprotectedinherited

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.

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

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.
virtual unsigned int OpenMPCD::CUDA::MPCFluid::Simple::getNumberOfLogicalEntities ( ) const
inlinevirtual

Returns the number of logical entities in the fluid.

Implements OpenMPCD::CUDA::MPCFluid::Base.

Definition at line 42 of file Simple.hpp.

virtual unsigned int OpenMPCD::CUDA::MPCFluid::Simple::getNumberOfParticlesPerLogicalEntity ( ) const
inlinevirtual

Returns the number of MPC particles per logical entity.

Exceptions
OpenMPCD::InvalidCallExceptionThrows if !numberOfParticlesPerLogicalEntityIsConstant().

Reimplemented from OpenMPCD::CUDA::MPCFluid::Base.

Definition at line 52 of file Simple.hpp.

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

Returns the number of MPC fluid particles.

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

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

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
inherited

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.
static const Vector3D<MPCParticleVelocityType> OpenMPCD::CUDA::MPCFluid::Base::getTotalMomentum ( const MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
staticprotectedinherited

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.
const RemotelyStoredVector<const MPCParticleVelocityType> OpenMPCD::CUDA::MPCFluid::Base::getVelocity ( const unsigned int  particleID) const
inherited

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.
static void OpenMPCD::CUDA::MPCFluid::Base::globalUnbiasedThermostat ( const FP  kT,
MPCParticleVelocityType *const  velocities,
const unsigned int  particleCount 
)
staticprotectedinherited

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.
void OpenMPCD::CUDA::MPCFluid::Base::initializeVelocitiesOnHost ( ) const
protectedinherited

Initializes the fluid particles velocities in Host memory.

virtual bool OpenMPCD::CUDA::MPCFluid::Simple::numberOfParticlesPerLogicalEntityIsConstant ( ) const
inlinevirtual

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.

Implements OpenMPCD::CUDA::MPCFluid::Base.

Definition at line 47 of file Simple.hpp.

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

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

void OpenMPCD::CUDA::MPCFluid::Base::saveLogicalEntityCentersOfMassToDeviceMemory ( MPCParticlePositionType *const  buffer) const
inherited

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.
void OpenMPCD::CUDA::MPCFluid::Base::setPositionsAndVelocities ( const MPCParticlePositionType *const  positions,
const MPCParticleVelocityType *const  velocities 
)
inherited

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.
virtual void OpenMPCD::CUDA::MPCFluid::Simple::stream ( )
virtual

Performs a streaming step.

Implements OpenMPCD::CUDA::MPCFluid::Base.

void OpenMPCD::CUDA::MPCFluid::Base::writeToSnapshot ( VTFSnapshotFile *const  snapshot) const
inherited

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

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

Device pointer for the MPC particle positions.

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

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

Device pointer for the MPC particle positions.

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

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

The Device memory manager.

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

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

The fluid instrumentation.

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

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

The mass of each MPC particle.

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

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

Host pointer for the MPC particle positions.

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

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

Host pointer for the MPC particle positions.

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

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

The number of fluid particles.

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

RNG OpenMPCD::CUDA::MPCFluid::Base::rng
mutableprotectedinherited

The random number generator.

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

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

The simulation instance.

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

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

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: