9 #include "PairIterator.h" 10 #include <ddMd/chemistry/Atom.h> 11 #include <util/space/Vector.h> 12 #include <util/format/Int.h> 53 atom1Ptrs_.reserve(atomCapacity_);
54 atom2Ptrs_.reserve(pairCapacity_);
55 first_.
reserve(atomCapacity_ + 1);
91 cutoffSq = cutoff_*cutoff_;
103 cellPtr = cellList.
begin();
105 na = cellPtr->
nAtom();
109 nn = neighbors.
size();
112 for (i = 0; i < na; ++i) {
113 atom1Ptr = neighbors[i];
114 maskPtr = atom1Ptr->maskPtr();
118 for (j = i + 1; j < nn; ++j) {
119 atom2Ptr = neighbors[j];
120 dr.
subtract(atom2Ptr->position(), atom1Ptr->position());
121 if (dr.
square() < cutoffSq && !maskPtr->
isMasked(atom2Ptr->id())) {
122 atom2Ptrs_.append(atom2Ptr->ptr());
129 atom1Ptrs_.append(atom1Ptr->ptr());
130 first_.
append(atom2Ptrs_.size());
141 if (atom1Ptrs_.size()) {
142 if (first_.
size() != atom1Ptrs_.size() + 1) {
145 if (first_[0] != 0) {
146 UTIL_THROW(
"Incorrect first element of first_");
148 if (first_[atom1Ptrs_.size()] != atom2Ptrs_.size()) {
149 UTIL_THROW(
"Incorrect last element of first_");
157 if (atom1Ptrs_.size() > maxNAtomLocal_) {
158 maxNAtomLocal_ = atom1Ptrs_.size();
160 if (atom2Ptrs_.size() > maxNPairLocal_) {
161 maxNPairLocal_ = atom2Ptrs_.size();
170 if (atom1Ptrs_.size()) {
171 iterator.atom1Ptrs_ = &atom1Ptrs_[0];
172 iterator.atom2Ptrs_ = &atom2Ptrs_[0];
173 iterator.first_ = &first_[0];
174 iterator.nAtom1_ = atom1Ptrs_.size();
175 iterator.nAtom2_ = atom2Ptrs_.size();
176 iterator.atom1Id_ = 0;
177 iterator.atom2Id_ = 0;
193 communicator.Allreduce(&maxNAtomLocal_, &maxNAtomGlobal, 1,
195 communicator.Allreduce(&maxNPairLocal_, &maxNPairGlobal, 1,
197 maxNAtom_.
set(maxNAtomGlobal);
198 maxNPair_.
set(maxNPairGlobal);
199 maxNAtomLocal_ = maxNAtomGlobal;
200 maxNPairLocal_ = maxNPairGlobal;
202 maxNAtom_.
set(maxNAtomLocal_);
203 maxNPair_.
set(maxNPairLocal_);
226 out <<
"PairList" << std::endl;
227 out <<
"NPair: max, capacity " 229 <<
Int(pairCapacity_, 10)
231 out <<
"NAtom: max, capacity " 233 <<
Int(atomCapacity_, 10)
const Cell * begin() const
Return pointer to first local cell in linked list.
Set of Atoms for which pair interactions with a parent Atom are "masked".
A cell list used only to identify nearby atom pairs.
int atomCapacity() const
Get the maximum number of primary atoms.
A Vector is a Cartesian vector.
Data for an atom in a CellList.
void append(const Data &data)
Append an element to the end of the sequence.
void clear()
Reset to empty state.
void clearStatistics()
Clear statistical accumulators (call on all processors).
void set(const T &value)
Set the value and mark as set.
void outputStatistics(std::ostream &out)
Output statistics.
void reserve(int capacity)
Reserve memory for specified number of elements.
virtual ~PairList()
Destructor.
int size() const
Return logical size of this array (i.e., current number of elements).
File containing preprocessor macros for error handling.
PairList()
Default constructor.
void begin(PairIterator &iterator) const
Initialize a PairIterator.
Parallel domain decomposition (DD) MD simulation.
bool isMasked(int id) const
True if the atom is in the masked set for the parent Atom.
void clear()
Reset this to empty state.
A fixed capacity (static) contiguous array with a variable logical size.
const T & value() const
Return value (if set).
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
virtual void computeStatistics(MPI::Intracomm &communicator)
Compute statistics (reduce from all processors).
void update()
Update the cell list.
int nAtom() const
Number of atoms in cell.
Utility classes for scientific computation.
Wrapper for an int, for formatted ostream output.
void build(CellList &cellList, bool reverseUpdateFlag=false)
Use a CellList to build a new PairList.
void unset()
Unset the value (mark as unknown).
void allocate(int atomCapacity, int pairCapacity, double cutoff)
Allocate memory and set cutoff.
void getNeighbors(NeighborArray &neighbors, bool reverseUpdateFlag=false) const
Fill an array with pointers to atoms in a cell and neighboring cells.
Vector & subtract(const Vector &v1, const Vector &v2)
Subtract vector v2 from v1.
Iterator for pairs in a PairList.
bool isAllocated() const
Has memory been allocated for this PairList?
int size() const
Return logical size of this array (i.e., number of elements).
double square() const
Return square magnitude of this vector.
const Cell * nextCellPtr() const
Return a pointer to neighbor cell i.
int pairCapacity() const
Get the maximum number of pairs.
A single Cell in a CellList.