Simpatico  v1.10
Plan.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 <util/space/Dimension.h>
9 #include "Plan.h"
10 
11 namespace DdMd
12 {
13 
14  unsigned int Plan::GMask[3][2] = { {0x0001, 0x0002}, {0x0004, 0x0008}, {0x0010, 0x0020} };
15  unsigned int Plan::EMask[3][2] = { {0x0100, 0x0200}, {0x0400, 0x0800}, {0x1000, 0x2000} };
16 
17  using namespace Util;
18 
19  /*
20  * Input a Plan from an istream, as a pair of 0s and ones
21  */
22  std::istream& operator>>(std::istream& in, Plan &plan)
23  {
24  std::string string;
25  int i, j, k;
26 
27  in >> string;
28  k = 0;
29  for (i=0; i < Dimension; ++i) {
30  for (j=0; j < 2; ++j) {
31  if (string[k] == '1') {
32  plan.setExchange(i, j);
33  } else if (string[k] == '0') {
34  plan.clearExchange(i, j);
35  }
36  ++k;
37  }
38  }
39 
40  in >> string;
41  k = 0;
42  for (int i=0; i < Dimension; ++i) {
43  for (int j=0; j < 2; ++j) {
44  if (string[k] == '1') {
45  plan.setGhost(i, j);
46  } else if (string[k] == '0') {
47  plan.clearGhost(i, j);
48  }
49  }
50  ++k;
51  }
52  return in;
53  }
54 
55  /*
56  * Output a Plan to an ostream, without line breaks.
57  */
58  std::ostream& operator<<(std::ostream& out, const Plan &plan)
59  {
60  int i, j;
61  for (i = 0; i < Dimension; ++i) {
62  for (j = 0; j < 2; ++j) {
63  if (plan.exchange(i, j)) {
64  out << '1';
65  } else {
66  out << '0';
67  }
68  }
69  }
70  out << " ";
71  for (i=0; i < Dimension; ++i) {
72  for (j=0; j < 2; ++j) {
73  if (plan.ghost(i, j)) {
74  out << '1';
75  } else {
76  out << '0';
77  }
78  }
79  }
80  return out;
81  }
82 
83 }
void setGhost(int i, int j)
Set ghost flag for direction i, j (set true).
Definition: Plan.h:83
const int Dimension
Dimensionality of space.
Definition: Dimension.h:19
std::istream & operator>>(std::istream &in, AtomType &atomType)
istream extractor (>>) for an AtomType.
bool exchange(int i, int j) const
Get bool exchange flag for direction i, j.
Definition: Plan.h:113
bool ghost(int i, int j) const
Get ghost flag for direction i, j.
Definition: Plan.h:122
Parallel domain decomposition (DD) MD simulation.
void setExchange(int i, int j)
Set exchange flag for direction i, j (set true).
Definition: Plan.h:65
Utility classes for scientific computation.
Definition: accumulators.mod:1
void clearExchange(int i, int j)
Clear exchange flag for direction i, j (set false).
Definition: Plan.h:74
void clearGhost(int i, int j)
Clear ghost flag for direction i, j (set false).
Definition: Plan.h:92
Communication plan.
Definition: Plan.h:45
std::ostream & operator<<(std::ostream &out, const AtomType &atomType)
ostream inserter (<<) for an AtomType.