Simpatico
v1.10
|
Associative container for finding atoms identified by integer id.
#include <AtomMap.h>
Public Member Functions | |
AtomMap () | |
Constructor. More... | |
~AtomMap () | |
Destructor. More... | |
void | allocate (int totalAtomCapacity) |
Set parameters, allocate memory and initialize. More... | |
void | addLocal (Atom *ptr) |
Add local atom. More... | |
void | removeLocal (Atom *ptr) |
Remove a specific Atom. More... | |
void | addGhost (Atom *ptr) |
Add ghost atom. More... | |
void | removeGhost (Atom *ptr) |
Remove a ghost Atom. More... | |
void | clearGhosts (const ArraySet< Atom > &ghostSet) |
Clear all ghosts from this map. More... | |
Accessors | |
Atom * | find (int atomId) const |
Return pointer to Atom with specified id. More... | |
int | nLocal () const |
Return the number of local atoms. More... | |
int | nGhostDistinct () const |
Return the number of ghosts with distinct ids. More... | |
int | nGhost () const |
Return the number of ghosts, including images. More... | |
template<int N> | |
int | findGroupLocalAtoms (Group< N > &group) const |
Set handles to local atoms in a Group<N> object. More... | |
template<int N> | |
int | findGroupGhostAtoms (Group< N > &group) const |
Set handles to ghost atoms in a Group<N> object. More... | |
bool | isValid () const |
Check validity of this AtomMap. More... | |
DdMd::AtomMap::AtomMap | ( | ) |
Constructor.
Definition at line 23 of file AtomMap.cpp.
DdMd::AtomMap::~AtomMap | ( | ) |
Destructor.
Definition at line 34 of file AtomMap.cpp.
void DdMd::AtomMap::allocate | ( | int | totalAtomCapacity | ) |
Set parameters, allocate memory and initialize.
Call this or (read|load)Parameters to initialize, but not both.
totalAtomCapacity | max number of atoms on all processors. |
Definition at line 40 of file AtomMap.cpp.
References UTIL_THROW.
Referenced by DdMd::AtomStorage::save().
void DdMd::AtomMap::addLocal | ( | Atom * | ptr | ) |
Add local atom.
ptr | Pointer to new Atom. |
Definition at line 57 of file AtomMap.cpp.
References Util::Log::file(), DdMd::Atom::id(), DdMd::Atom::position(), and UTIL_THROW.
Referenced by DdMd::AtomStorage::addNewAtom().
void DdMd::AtomMap::removeLocal | ( | Atom * | ptr | ) |
Remove a specific Atom.
Exception | if atom is not present. |
ptr | Pointer to Atom to be removed. |
Definition at line 83 of file AtomMap.cpp.
References Util::Log::file(), DdMd::Atom::id(), and UTIL_THROW.
Referenced by DdMd::AtomStorage::clearAtoms(), and DdMd::AtomStorage::removeAtom().
void DdMd::AtomMap::addGhost | ( | Atom * | ptr | ) |
Add ghost atom.
ptr | Pointer to new Atom. |
Definition at line 120 of file AtomMap.cpp.
References DdMd::Atom::id(), and UTIL_THROW.
Referenced by DdMd::AtomStorage::addNewGhost().
void DdMd::AtomMap::removeGhost | ( | Atom * | ptr | ) |
Remove a ghost Atom.
This function throws an exception if no atom with this id is present, but not if it does not match this pointer.
ptr | Pointer to Atom to be removed. |
Definition at line 139 of file AtomMap.cpp.
References DdMd::Atom::id(), and UTIL_THROW.
Referenced by DdMd::AtomStorage::removeGhost().
Clear all ghosts from this map.
ghostSet | Set containing all ghosts on this processor. |
Definition at line 185 of file AtomMap.cpp.
References Util::PArray< Data >::begin(), Util::ConstPArrayIterator< Data >::get(), nGhost(), Util::ConstPArrayIterator< Data >::notEnd(), Util::PArray< Data >::size(), and UTIL_THROW.
Referenced by DdMd::AtomStorage::clearGhosts().
|
inline |
Return pointer to Atom with specified id.
This function returns a pointer to an Atom with the specified id if it is present, or returns a null pointer otherwise.
atomId | integer index of atom |
Definition at line 230 of file AtomMap.h.
Referenced by DdMd::GroupStorage< N >::isValid(), DdMd::AtomStorage::isValid(), DdMd::GroupStorage< N >::markGhosts(), and DdMd::ConfigIo::setAtomMasks().
|
inline |
Return the number of local atoms.
Definition at line 236 of file AtomMap.h.
Referenced by DdMd::AtomStorage::clearAtoms().
|
inline |
Return the number of ghosts with distinct ids.
Definition at line 242 of file AtomMap.h.
Referenced by DdMd::AtomStorage::clearGhosts().
|
inline |
Return the number of ghosts, including images.
Definition at line 248 of file AtomMap.h.
Referenced by clearGhosts(), DdMd::AtomStorage::clearGhosts(), and DdMd::AtomStorage::isValid().
int DdMd::AtomMap::findGroupLocalAtoms | ( | Group< N > & | group | ) | const |
Set handles to local atoms in a Group<N> object.
On entry, group is a Group<N> object for which the atom ids for all N atoms in the Group have been set to valid values, in the range 0 <= atomId < totalAtomCapacity, but in which some or all pointers have not been set. The AtomMap may not contain any ghosts.
On exit, pointers are set correctly for all local atoms that exist in this AtomMap, or set to null for absent atoms. All old pointer values are overwritten.
group | Group<N> object with known atom ids. |
Definition at line 257 of file AtomMap.h.
References DdMd::Group< N >::atomId(), DdMd::Group< N >::clearAtomPtr(), DdMd::Atom::id(), DdMd::Atom::isGhost(), and DdMd::Group< N >::setAtomPtr().
Referenced by DdMd::GroupDistributor< N >::add(), DdMd::GroupDistributor< N >::receive(), and DdMd::GroupStorage< N >::unpack().
int DdMd::AtomMap::findGroupGhostAtoms | ( | Group< N > & | group | ) | const |
Set handles to ghost atoms in a Group<N> object.
On entry, group is a Group<N> object for which the atom ids for all N atoms in the Group have been set to valid values, in the range 0 <= atomId < totalAtomCapacity, and in which all pointers to local atoms have been set, but in which no pointers to ghosts have been set. This function may only be called after all pointers have been set for all local atoms and after this AtomMap contains all ghost atoms.
On exit, pointers are set for all ghost atoms present in this AtomMap.
group | Group<N> object with known atom ids. |
Definition at line 279 of file AtomMap.h.
References DdMd::Group< N >::atomId(), DdMd::Group< N >::atomPtr(), DdMd::Group< N >::clearAtomPtr(), DdMd::Atom::id(), DdMd::Atom::isGhost(), and DdMd::Group< N >::setAtomPtr().
Referenced by DdMd::GroupStorage< N >::findGhosts().
bool DdMd::AtomMap::isValid | ( | ) | const |
Check validity of this AtomMap.
Returns true if all is ok, or throws an Exception.
Definition at line 215 of file AtomMap.cpp.
References Util::Log::file(), DdMd::Atom::id(), and UTIL_THROW.
Referenced by DdMd::AtomStorage::isValid().