Chombo + EB  3.2
ReductionCopier.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _REDUCTIONCOPIER_H_
12 #define _REDUCTIONCOPIER_H_
13 
14 #include "DisjointBoxLayout.H"
15 #include "Pool.H"
16 #include "Vector.H"
17 #include "ProblemDomain.H"
18 #include "Copier.H"
19 #include "NamespaceHeader.H"
20 
21 /// Specialized copier for doing reductions in dimensionality
22 /**
23  This is a specialized Copier designed to copy from a multi-dimensional
24  DisjointBoxLayout to a smaller-dimensional one by copying all of the
25  data in the transverse direction to the destination boxLayout. It is
26  assumed that this will be used with a different sort of operator (like
27  a summation operator, for example), since a straight copy operation
28  wouldn't make much sense. Anyway, this just defines the intersection
29  regions; what you do with them is your problem.
30 
31  Note also that both the Spreading and Reduction Copiers ignore periodicity,
32  since it can lead to unintended side-effects and multiple-counting of data.
33  The way to handle periodicity is to do an exchange on the source data before
34  calling the copyTo which does the reduction.
35 */
36 
37 class ReductionCopier : public Copier
38 {
39 public:
40 
41  ///null constructor, copy constructor and operator= can be compiler defined.
43  {}
44 
45  ///
46  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
47  int a_transverseDir, bool a_exchange = false);
48 
49  /// this constructor contains support for periodic BC's
50  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
51  const ProblemDomain& a_domain,
52  int a_transverseDir,
53  bool a_exchange = false);
54 
55  /// Copier to copy data into the valid and invalid regions of a_dest from a_level
56  ReductionCopier(const DisjointBoxLayout& a_level,
57  const BoxLayout& a_dest,
58  const IntVect& a_destGhost,
59  int a_transverseDir,
60  bool a_exchange = false);
61 
62  /// Copier to copy data into the valid and invalid regions of a_dest from a_level with support for periodic BCs
63  ReductionCopier(const DisjointBoxLayout& a_level,
64  const BoxLayout& a_dest,
65  const ProblemDomain& a_domain,
66  const IntVect& a_destGhost,
67  int a_transverseDir,
68  bool a_exchange = false);
69 
70  ///
71  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
72  const Vector<int>& a_transverseDir, bool a_exchange = false);
73 
74  /// this constructor contains support for periodic BC's
75  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
76  const ProblemDomain& a_domain,
77  const Vector<int>& a_transverseDir,
78  bool a_exchange = false);
79 
80  /// Copier to copy data into the valid and invalid regions of a_dest from a_level
81  ReductionCopier(const DisjointBoxLayout& a_level,
82  const BoxLayout& a_dest,
83  const IntVect& a_destGhost,
84  const Vector<int>& a_transverseDir,
85  bool a_exchange = false);
86 
87  /// Copier to copy data into the valid and invalid regions of a_dest from a_level with support for periodic BCs
88  ReductionCopier(const DisjointBoxLayout& a_level,
89  const BoxLayout& a_dest,
90  const ProblemDomain& a_domain,
91  const IntVect& a_destGhost,
92  const Vector<int>& a_transverseDir,
93  bool a_exchange = false);
94 
95  ///
96  virtual ~ReductionCopier();
97 
98  ///
99  virtual void define(const DisjointBoxLayout& a_level,
100  const BoxLayout& a_dest,
101  int a_transverseDir,
102  bool a_exchange = false);
103 
104  /// contains support for periodic BCs
105  virtual void define(const DisjointBoxLayout& a_level,
106  const BoxLayout& a_dest,
107  const ProblemDomain& a_domain,
108  int a_transverseDir,
109  bool a_exchange = false);
110 
111  ///
112  virtual void define(const DisjointBoxLayout& a_level,
113  const BoxLayout& a_dest,
114  const IntVect& a_destGhost,
115  int a_transverseDir,
116  bool a_exchange = false);
117 
118  /// contains support for periodic BCs
119  virtual void define(const BoxLayout& a_level,
120  const BoxLayout& a_dest,
121  const ProblemDomain& a_domain,
122  const IntVect& a_destGhost,
123  int a_transverseDir,
124  bool a_exchange = false);
125 
126  ///
127  virtual void define(const DisjointBoxLayout& a_level,
128  const BoxLayout& a_dest,
129  const Vector<int>& a_transverseDir,
130  bool a_exchange = false);
131 
132  /// contains support for periodic BCs
133  virtual void define(const DisjointBoxLayout& a_level,
134  const BoxLayout& a_dest,
135  const ProblemDomain& a_domain,
136  const Vector<int>& a_transverseDir,
137  bool a_exchange = false);
138 
139  ///
140  virtual void define(const DisjointBoxLayout& a_level,
141  const BoxLayout& a_dest,
142  const IntVect& a_destGhost,
143  const Vector<int>& a_transverseDir,
144  bool a_exchange = false);
145 
146  /// contains support for periodic BCs
147  virtual void define(const BoxLayout& a_level,
148  const BoxLayout& a_dest,
149  const ProblemDomain& a_domain,
150  const IntVect& a_destGhost,
151  const Vector<int>& a_transverseDir,
152  bool a_exchange = false);
153 
154  /// reverse the direction of copy for an already-defined ReductionCopier
155  /**
156  This function simply replaces the from data with the to-data for
157  the already-defined copy operation.
158  For now, this function heads right into a MayDay::Error, since what
159  you probably want is to use a SpreadingCopier rather than a reversed
160  ReductionCopier
161  */
162  void reverse();
163 
164  /// check that this Copier object corresponds to these two BoxLayouts.
165  bool check(const DisjointBoxLayout& from, const BoxLayout& to) const;
166 
167  int print() const;
168 
169 
170 protected:
171 
172  friend class CopyIterator;
173 
174  friend void dumpmemoryatexit();
175 
176 private:
177 
178  // no really good reason to keep this, except for completeness...
180 
181 };
182 
183 //===========================================================================
184 // end of public interface for ReductionCopier.
185 //===========================================================================
186 
187 #include "NamespaceFooter.H"
188 
189 #endif
bool check(const DisjointBoxLayout &from, const BoxLayout &to) const
check that this Copier object corresponds to these two BoxLayouts.
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
A not-necessarily-disjoint collective of boxes.
Definition: BoxLayout.H:145
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:145
ReductionCopier()
null constructor, copy constructor and operator= can be compiler defined.
Definition: ReductionCopier.H:42
int print() const
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
virtual void define(const DisjointBoxLayout &a_level, const BoxLayout &a_dest, int a_transverseDir, bool a_exchange=false)
friend void dumpmemoryatexit()
Vector< int > m_transverseDir
Definition: ReductionCopier.H:179
void reverse()
reverse the direction of copy for an already-defined ReductionCopier
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
virtual ~ReductionCopier()
Specialized copier for doing reductions in dimensionality.
Definition: ReductionCopier.H:37
Definition: Copier.H:375