Simpatico  v1.10
List of all members | Static Public Member Functions | Friends
DdMd::Atom Class Reference

Detailed Description

A point particle in an MD simulation.

An Atom has:

An Atom may only be constructed as an element of an AtomArray. The Atom constructor is private, to prevent instantiation of an indivual Atom, but is accessible by the AtomArray class via a a friend declaration.

The interface of the Atom class provides access to each Atom data field through an accessor function, as if all were true C++ class data members. In fact, some of the above are "pseudo-members" that are stored in separate arrays. All arrays that store atom data are private members of the associated AtomArray, all of which use the same indexing scheme to identify atoms. Each Atom object has a pointer to its parent AtomArray and its array index, in private members. The public accessor method for each pseudo-member simply retrieves the required array element for this atom.

In the current implementation, the position, force, atom type id, and isGhost flag are stored in true member variables of an Atom object, while the velocity, mask, plan, id (the global atom index), and AtomContext (if any) are all pseudo-members stored in separate arrays. See documentation of the private member localId_ and other comments in the Atom.h file for further implementation details.

Definition at line 64 of file ddMd/chemistry/Atom.h.

#include <Atom.h>

Public Member Functions

Mutators
Atomoperator= (Atom const &other)
 Assignment. More...
 
void clear ()
 Reset integer members to initial null values. More...
 
void setId (int Id)
 Set unique global id for this Atom. More...
 
void setTypeId (int Id)
 Set the atom type index. More...
 
void setIsGhost (bool isGhost)
 Mark as ghost or local atom for this processor. More...
 
Accessors (return non-const references)
Vectorposition ()
 Get position Vector by reference. More...
 
Vectorvelocity ()
 Get velocity Vector by reference. More...
 
Vectorforce ()
 Get force Vector by reference. More...
 
Maskmask ()
 Get the associated Mask by reference. More...
 
Planplan ()
 Get communication plan by reference. More...
 
AtomContextcontext ()
 Get the AtomContext struct by non-const reference. More...
 
unsigned int & groups ()
 Get groups bit field by non-const reference. More...
 
Accessors (return by value or const references).
int id () const
 Get unique global index for this atom. More...
 
int typeId () const
 Get atom type index. More...
 
bool isGhost () const
 Is this atom a ghost? More...
 
const Vectorposition () const
 Get the position Vector (const reference). More...
 
const Vectorvelocity () const
 Get the velocity Vector (const reference). More...
 
const Vectorforce () const
 Get the force Vector (const reference). More...
 
const Maskmask () const
 Get the associated Mask by const reference. More...
 
const Planplan () const
 Get communication plan by const reference. More...
 
const AtomContextcontext () const
 Get the AtomContext struct by const reference. More...
 
unsigned int groups () const
 Get bit field of groups to which this atom belongs. More...
 
Pack and Unpack Methods (Interprocessor Communication)
void packAtom (Buffer &buffer)
 Pack an Atom into a send buffer, for exchange of ownership. More...
 
void unpackAtom (Buffer &buffer)
 Unpack an atom from a recv buffer and receive ownership. More...
 
void packGhost (Buffer &buffer)
 Pack a ghost Atom into a send buffer. More...
 
void unpackGhost (Buffer &buffer)
 Unpack a ghost Atom from a recv buffer. More...
 
void packUpdate (Buffer &buffer)
 Pack updated ghost position into send buffer. More...
 
void unpackUpdate (Buffer &buffer)
 Unpack updated ghost position from recv buffer. More...
 
void packForce (Buffer &buffer)
 Pack update of ghost Atom force into send buffer. More...
 
void unpackForce (Buffer &buffer)
 Unpack updated position of ghost Atom from recv buffer. More...
 
void copyLocalGhost (Atom const &sendAtom)
 Copies data from local atom to update this ghost atom. More...
 
void copyLocalUpdate (Atom const &sendAtom)
 Copies position of local atom to update this ghost atom. More...
 

Static Public Member Functions

static void setHasAtomContext (bool hasAtomContext)
 Enable (true) or disable (false) use of AtomContext data. More...
 
static bool hasAtomContext ()
 Is AtomContext data enabled? More...
 
static int packedAtomSize ()
 Return max size of an atom packed for exchange, in bytes. More...
 
static int packedGhostSize ()
 Return size of ghost atom packed for communication, in bytes. More...
 

Friends

class Util::Memory
 

Member Function Documentation

void DdMd::Atom::setHasAtomContext ( bool  hasAtomContext)
static

Enable (true) or disable (false) use of AtomContext data.

Parameters
hasAtomContextnew value for hasAtomContext static bool flag.

Definition at line 29 of file ddMd/chemistry/Atom.cpp.

Referenced by DdMd::Simulation::loadParameters(), and DdMd::Simulation::readParameters().

bool DdMd::Atom::hasAtomContext ( )
inlinestatic
int DdMd::Atom::packedAtomSize ( )
static

Return max size of an atom packed for exchange, in bytes.

Definition at line 149 of file ddMd/chemistry/Atom.cpp.

Referenced by DdMd::Buffer::isInitialized().

int DdMd::Atom::packedGhostSize ( )
static

Return size of ghost atom packed for communication, in bytes.

Definition at line 204 of file ddMd/chemistry/Atom.cpp.

Referenced by DdMd::Buffer::isInitialized().

Atom & DdMd::Atom::operator= ( Atom const &  other)

Assignment.

Definition at line 49 of file ddMd/chemistry/Atom.cpp.

References context(), groups(), id(), isGhost(), mask(), plan(), and velocity().

void DdMd::Atom::clear ( )

Reset integer members to initial null values.

Definition at line 69 of file ddMd/chemistry/Atom.cpp.

Referenced by DdMd::AtomDistributor::newAtomPtr(), DdMd::AtomStorage::newAtomPtr(), and DdMd::AtomStorage::newGhostPtr().

void DdMd::Atom::setId ( int  Id)
inline

Set unique global id for this Atom.

This id must be unique among all atoms on all processors, and must be less than totalAtomCapacity of the AtomStorage.

Parameters
Idunique atom id.

Definition at line 551 of file ddMd/chemistry/Atom.h.

Referenced by DdMd::AtomStorage::addAtom(), DdMd::AtomStorage::addGhost(), DdMd::Exchanger::exchange(), DdMd::SerializeConfigIo::loadConfig(), DdMd::DdMdConfigIo::readConfig(), DdMd::LammpsConfigIo::readConfig(), and DdMd::DdMdOrderedConfigIo::readConfig().

void DdMd::Atom::setTypeId ( int  Id)
inline

Set the atom type index.

Parameters
Idinteger index that identifies atom type

Definition at line 433 of file ddMd/chemistry/Atom.h.

Referenced by DdMd::Exchanger::exchange(), DdMd::SerializeConfigIo::loadConfig(), DdMd::DdMdConfigIo::readConfig(), DdMd::LammpsConfigIo::readConfig(), and DdMd::DdMdOrderedConfigIo::readConfig().

void DdMd::Atom::setIsGhost ( bool  isGhost)
inline

Mark as ghost or local atom for this processor.

Parameters
isGhosttrue if this is a ghost, or false if local.

Definition at line 439 of file ddMd/chemistry/Atom.h.

Referenced by DdMd::AtomStorage::addNewAtom(), DdMd::AtomStorage::addNewGhost(), and DdMd::AtomStorage::newGhostPtr().

Vector & DdMd::Atom::position ( )
inline

Get position Vector by reference.

Definition at line 468 of file ddMd/chemistry/Atom.h.

Referenced by DdMd::AtomDistributor::addAtom(), DdMd::AtomMap::addLocal(), DdMd::BondTensorAutoCorr::computeData(), DdMd::AnglePotentialImpl< Interaction >::computeEnergy(), DdMd::BondPotentialImpl< Interaction >::computeEnergy(), DdMd::DihedralPotentialImpl< Interaction >::computeEnergy(), DdMd::PairPotentialImpl< Interaction >::computeEnergy(), DdMd::AnglePotentialImpl< Interaction >::computeForces(), DdMd::BondPotentialImpl< Interaction >::computeForces(), DdMd::DihedralPotentialImpl< Interaction >::computeForces(), DdMd::BondPotentialImpl< Interaction >::computeForcesAndStress(), DdMd::PairPotentialImpl< Interaction >::computeForcesAndStress(), DdMd::PairPotentialImpl< Interaction >::computePairEnergies(), DdMd::AnglePotentialImpl< Interaction >::computeStress(), DdMd::BondPotentialImpl< Interaction >::computeStress(), DdMd::DihedralPotentialImpl< Interaction >::computeStress(), DdMd::PairPotentialImpl< Interaction >::computeStress(), copyLocalGhost(), copyLocalUpdate(), DdMd::Exchanger::exchange(), DdMd::SerializeConfigIo::loadConfig(), DdMd::GroupStorage< N >::markSpanningGroups(), DdMd::PairPotential::nPair(), DdMd::CellList::placeAtom(), DdMd::DdMdConfigIo::readConfig(), DdMd::LammpsConfigIo::readConfig(), DdMd::DdMdOrderedConfigIo::readConfig(), DdMd::AtomDistributor::receive(), DdMd::SerializeConfigIo::saveConfig(), DdMd::Exchanger::update(), DdMd::DdMdConfigIo::writeConfig(), DdMd::LammpsConfigIo::writeConfig(), DdMd::DdMdOrderedConfigIo::writeConfig(), DdMd::LammpsDumpWriter::writeFrame(), DdMd::DdMdTrajectoryWriter::writeFrame(), and DdMd::DdMdGroupTrajectoryWriter::writeFrame().

Vector & DdMd::Atom::velocity ( )
inline
Vector & DdMd::Atom::force ( )
inline
Mask & DdMd::Atom::mask ( )
inline

Get the associated Mask by reference.

Definition at line 521 of file ddMd/chemistry/Atom.h.

Referenced by operator=(), and DdMd::ConfigIo::setAtomMasks().

Plan & DdMd::Atom::plan ( )
inline
AtomContext & DdMd::Atom::context ( )
inline

Get the AtomContext struct by non-const reference.

Throws and Exception if atom context data is disabled.

A DdMd::AtomContext struct contains public members speciesId, moleculeId and atomId that identify the species of molecule to which this atom belongs, the index of the molecule within it species, and the index of the atom with the molecule.

Definition at line 557 of file ddMd/chemistry/Atom.h.

References UTIL_THROW.

Referenced by copyLocalGhost(), DdMd::SerializeConfigIo::loadConfig(), operator=(), DdMd::DdMdConfigIo::readConfig(), DdMd::DdMdOrderedConfigIo::readConfig(), DdMd::SerializeConfigIo::saveConfig(), DdMd::DdMdConfigIo::writeConfig(), and DdMd::DdMdOrderedConfigIo::writeConfig().

unsigned int & DdMd::Atom::groups ( )
inline

Get groups bit field by non-const reference.

The unsigned int groups is used as a bit field in which bit number i (with i=0 the least signficant bit), is set true/1 if this atom belongs to group i, and is false/0 if this atom of not belong to group i. By default, all bits are clear.

Individual bits may be set, unset and queried using an instance of class Util::Bit.

Definition at line 579 of file ddMd/chemistry/Atom.h.

Referenced by DdMd::SerializeConfigIo::loadConfig(), operator=(), DdMd::SerializeConfigIo::saveConfig(), DdMd::DdMdGroupTrajectoryWriter::writeFrame(), and DdMd::DdMdGroupTrajectoryWriter::writeHeader().

int DdMd::Atom::id ( ) const
inline
int DdMd::Atom::typeId ( ) const
inline
bool DdMd::Atom::isGhost ( ) const
inline
Vector const & DdMd::Atom::position ( ) const
inline

Get the position Vector (const reference).

Definition at line 474 of file ddMd/chemistry/Atom.h.

Vector const & DdMd::Atom::velocity ( ) const
inline

Get the velocity Vector (const reference).

Definition at line 515 of file ddMd/chemistry/Atom.h.

Vector const & DdMd::Atom::force ( ) const
inline

Get the force Vector (const reference).

Definition at line 486 of file ddMd/chemistry/Atom.h.

Mask const & DdMd::Atom::mask ( ) const
inline

Get the associated Mask by const reference.

Definition at line 527 of file ddMd/chemistry/Atom.h.

Plan const & DdMd::Atom::plan ( ) const
inline

Get communication plan by const reference.

Definition at line 539 of file ddMd/chemistry/Atom.h.

AtomContext const & DdMd::Atom::context ( ) const
inline

Get the AtomContext struct by const reference.

Throws an Exception if atom context data is disabled.

See also
AtomContext& context() non-const accessor for

Definition at line 568 of file ddMd/chemistry/Atom.h.

References UTIL_THROW.

unsigned int DdMd::Atom::groups ( ) const
inline

Get bit field of groups to which this atom belongs.

See also
Atom::groups() non-const accessor.

Definition at line 585 of file ddMd/chemistry/Atom.h.

void DdMd::Atom::packAtom ( Buffer buffer)

Pack an Atom into a send buffer, for exchange of ownership.

Packs required data, increments buffer sendSize counter.

Parameters
buffercommunication buffer

Definition at line 88 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::incrementSendSize(), and DdMd::Buffer::pack().

Referenced by DdMd::AtomDistributor::addAtom(), DdMd::AtomDistributor::newAtomPtr(), and DdMd::AtomDistributor::send().

void DdMd::Atom::unpackAtom ( Buffer buffer)

Unpack an atom from a recv buffer and receive ownership.

Parameters
buffercommunication buffer

Definition at line 114 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::decrementRecvSize(), and DdMd::Buffer::unpack().

Referenced by DdMd::Exchanger::exchange(), and DdMd::AtomDistributor::receive().

void DdMd::Atom::packGhost ( Buffer buffer)

Pack a ghost Atom into a send buffer.

Packs required data, increments buffer sendSize counter.

Parameters
buffercommunication buffer

Definition at line 168 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::incrementSendSize(), and DdMd::Buffer::pack().

Referenced by DdMd::Exchanger::exchange().

void DdMd::Atom::unpackGhost ( Buffer buffer)

Unpack a ghost Atom from a recv buffer.

Unpacks required data, decrements buffer recvSize counter.

Parameters
buffercommunication buffer

Definition at line 184 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::decrementRecvSize(), and DdMd::Buffer::unpack().

Referenced by DdMd::Exchanger::exchange().

void DdMd::Atom::packUpdate ( Buffer buffer)

Pack updated ghost position into send buffer.

Packs position Vector, increments buffer sendSize counter.

Parameters
buffercommunication buffer

Definition at line 221 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::incrementSendSize(), and DdMd::Buffer::pack().

Referenced by DdMd::Exchanger::update().

void DdMd::Atom::unpackUpdate ( Buffer buffer)

Unpack updated ghost position from recv buffer.

Unpacks position Vector, decrements buffer recvSize counter.

Parameters
buffercommunication buffer

Definition at line 230 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::decrementRecvSize(), and DdMd::Buffer::unpack().

Referenced by DdMd::Exchanger::update().

void DdMd::Atom::packForce ( Buffer buffer)

Pack update of ghost Atom force into send buffer.

Packs force Vector, increments buffer sendSize counter.

Parameters
buffercommunication buffer

Definition at line 241 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::incrementSendSize(), and DdMd::Buffer::pack().

Referenced by DdMd::Exchanger::reverseUpdate().

void DdMd::Atom::unpackForce ( Buffer buffer)

Unpack updated position of ghost Atom from recv buffer.

Reads force from buffer and increments the atomic force (rather than overwriting), then decrements recvSize counter.

Parameters
buffercommunication buffer

Definition at line 250 of file ddMd/chemistry/Atom.cpp.

References DdMd::Buffer::decrementRecvSize(), and DdMd::Buffer::unpack().

Referenced by DdMd::Exchanger::reverseUpdate().

void DdMd::Atom::copyLocalGhost ( Atom const &  sendAtom)

Copies data from local atom to update this ghost atom.

Parameters
sendAtomLocal atom to be copied to this atom.

Definition at line 262 of file ddMd/chemistry/Atom.cpp.

References context(), DdMd::Plan::flags(), id(), plan(), position(), and typeId().

Referenced by DdMd::Exchanger::exchange().

void DdMd::Atom::copyLocalUpdate ( Atom const &  sendAtom)

Copies position of local atom to update this ghost atom.

Parameters
sendAtomLocal atom to be copied to update this atom.

Definition at line 276 of file ddMd/chemistry/Atom.cpp.

References position().

Referenced by DdMd::Exchanger::update().


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