Simpatico  v1.10
PairSelector.h
1 #ifndef MCMD_PAIR_SELECTOR_H
2 #define MCMD_PAIR_SELECTOR_H
3 
4 #include <util/global.h>
5 #include <iostream>
6 
7 namespace McMd
8 {
9 
10  class Atom;
11 
33  {
34 
35  public:
36 
45  enum PairType{INTRA, INTER, ALL};
46 
50  PairSelector();
51 
57  void setAvoidDoubleCounting(bool avoidDoubleCounting);
58 
65  bool match(const Atom& atom1, const Atom& atom2) const;
66 
70  PairType pairType() const;
71 
75  int atom1TypeId() const;
76 
80  int atom2TypeId() const;
81 
82  #ifdef UTIL_MPI
83 
87  static void commitMpiType();
88 
89  #endif
90 
91  private:
92 
94  PairType pairType_;
95 
97  int atom1TypeId_;
98 
100  int atom2TypeId_;
101 
103  bool avoidDoubleCounting_;
104 
105  //friends:
106 
107  friend std::istream& operator>>(std::istream& in, PairSelector& selector);
108  friend std::ostream& operator<<(std::ostream& out, const PairSelector& selector);
109 
110  template <class Archive> friend
111  void serialize(Archive& ar, PairSelector& selector, const unsigned int version);
112  };
113 
114  /*
115  * Return value of pair type.
116  */
118  { return pairType_; }
119 
120  /*
121  * Return value of type Id for atom 1 (-1 means accept all types).
122  */
123  inline int PairSelector::atom1TypeId() const
124  { return atom1TypeId_; }
125 
126  /*
127  * Return value of type Id for atom 2 (-1 means accept all types).
128  */
129  inline int PairSelector::atom2TypeId() const
130  { return atom2TypeId_; }
131 
132  // Iostream operator declarations
133 
143  std::istream& operator>>(std::istream& in, PairSelector& selector);
144 
154  std::ostream& operator<<(std::ostream& out, const PairSelector& selector);
155 
166  template <class Archive>
167  void serialize(Archive& ar, PairSelector& selector, const unsigned int version)
168  {
169  ar & selector.pairType_;
170  ar & selector.atom1TypeId_;
171  ar & selector.atom2TypeId_;
172  }
173 
181  std::istream& operator>>(std::istream& in, PairSelector::PairType& type);
182 
190  std::ostream& operator<<(std::ostream& out, const PairSelector::PairType& type);
191 
202  template <class Archive>
203  void serialize(Archive& ar, PairSelector::PairType& type, const unsigned int version)
204  { serializeEnum(ar, type, version); }
205 
206 }
207 
208 #ifdef UTIL_MPI
209 #include <util/mpi/MpiTraits.h>
210 
211 namespace Util{
212 
216  template <>
218  {
219  public:
220  static MPI::Datatype type;
221  static bool hasType;
222  };
223 
227  template <>
229  {
230  public:
231  static MPI::Datatype type;
232  static bool hasType;
233  };
234 
235 }
236 #endif
237 
238 #endif
static void commitMpiType()
Commit associated MPI DataType.
friend std::ostream & operator<<(std::ostream &out, const PairSelector &selector)
ostream inserter (<<) for a PairSelector object.
static MPI::Datatype type
MPI Datatype.
Definition: PairSelector.h:220
static bool hasType
Is the MPI type initialized?
Definition: PairSelector.h:221
static bool hasType
Is the MPI type initialized?
Definition: PairSelector.h:232
File containing preprocessor macros for error handling.
bool match(const Atom &atom1, const Atom &atom2) const
Return true if pair of atoms matches the selector policy.
friend void serialize(Archive &ar, PairSelector &selector, const unsigned int version)
Serialize a PairSelector.
Definition: PairSelector.h:167
int atom2TypeId() const
Return value of type Id for atom 2 (-1 means accept all types).
Definition: PairSelector.h:129
A point particle within a Molecule.
Utility classes for scientific computation.
Definition: accumulators.mod:1
PairSelector()
Constructor.
Default MpiTraits class.
Definition: MpiTraits.h:39
friend std::istream & operator>>(std::istream &in, PairSelector &selector)
istream extractor (>>) for a PairSelector object.
void serializeEnum(Archive &ar, T &data, const unsigned int version=0)
Serialize an enumeration value.
Definition: serialize.h:42
Selection rule for pairs of Atoms.
Definition: PairSelector.h:32
void setAvoidDoubleCounting(bool avoidDoubleCounting)
Set policy to avoid double counting (true) or to not avoid (false).
PairType
Type of atom pair, based on identity of parent molecules.
Definition: PairSelector.h:45
Single-processor Monte Carlo (MC) and molecular dynamics (MD).
int atom1TypeId() const
Return value of type Id for atom 1 (-1 means accept all types).
Definition: PairSelector.h:123
static MPI::Datatype type
MPI Datatype.
Definition: PairSelector.h:231
PairType pairType() const
Return value of pair type.
Definition: PairSelector.h:117