Simpatico  v1.10
mcMd/chemistry/Mask.cpp
1 /*
2 * Simpatico - Simulation Package for Polymeric and Molecular Liquids
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "Mask.h"
9 #include <util/global.h>
10 
11 namespace McMd
12 {
13 
14  using namespace Util;
15 
16  /*
17  * Constructor.
18  */
20  : size_(0)
21  {
22  for (int i=0; i < Capacity; ++i) {
23  atomPtrs_[i] = 0;
24  }
25  }
26 
27  /*
28  * Clear the mask, i.e., remove all Atoms.
29  */
30  void Mask::clear()
31  {
32  for (int i=0; i < Capacity; ++i) {
33  atomPtrs_[i] = 0;
34  }
35  size_ = 0;
36  }
37 
38  /*
39  * Add an an atom to the mask.
40  */
41  void Mask::append(const Atom& atom)
42  {
43  if (size_ >= Capacity) {
44  UTIL_THROW("Too many masked partners for one Atom");
45  }
46  if (isMasked(atom)) {
47  UTIL_THROW("Attempt to add an atom to a Mask twice");
48  }
49  atomPtrs_[size_] = &atom;
50  ++size_;
51  }
52 
53 }
File containing preprocessor macros for error handling.
bool isMasked(const Atom &atom) const
True if the atom is in the masked set for the target Atom.
#define UTIL_THROW(msg)
Macro for throwing an Exception, reporting function, file and line number.
Definition: global.h:51
Mask()
Constructor.
A point particle within a Molecule.
void clear()
Clear the mask set (remove all atoms).
Utility classes for scientific computation.
Definition: accumulators.mod:1
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
void append(const Atom &atom)
Add an Atom to the masked set.