Chombo + EB + MF  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  /// face sum op requires that destGhost -> destGhost + Unit; this helps cell-centerd box calculus work for face-centered data
46  ReductionCopier(const bool & a_usingFaceSumOp ,
47  const DisjointBoxLayout& a_sourceLayout ,
48  const BoxLayout & a_destLayout ,
49  const ProblemDomain & a_domain ,
50  const IntVect & a_destGhost ,
51  const IntVect & a_reduceDir ,
52  bool a_exchange = false);
53  ///
54  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
55  int a_transverseDir, bool a_exchange = false);
56 
57  /// this constructor contains support for periodic BC's
58  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
59  const ProblemDomain& a_domain,
60  int a_transverseDir,
61  bool a_exchange = false);
62 
63  /// Copier to copy data into the valid and invalid regions of a_dest from a_level
64  ReductionCopier(const DisjointBoxLayout& a_level,
65  const BoxLayout& a_dest,
66  const IntVect& a_destGhost,
67  int a_transverseDir,
68  bool a_exchange = false);
69 
70  /// Copier to copy data into the valid and invalid regions of a_dest from a_level with support for periodic BCs
71  ReductionCopier(const DisjointBoxLayout& a_level,
72  const BoxLayout& a_dest,
73  const ProblemDomain& a_domain,
74  const IntVect& a_destGhost,
75  int a_transverseDir,
76  bool a_exchange = false);
77 
78  ///
79  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
80  const Vector<int>& a_transverseDir, bool a_exchange = false);
81 
82  /// this constructor contains support for periodic BC's
83  ReductionCopier(const DisjointBoxLayout& a_level, const BoxLayout& a_dest,
84  const ProblemDomain& a_domain,
85  const Vector<int>& a_transverseDir,
86  bool a_exchange = false);
87 
88  /// Copier to copy data into the valid and invalid regions of a_dest from a_level
89  ReductionCopier(const DisjointBoxLayout& a_level,
90  const BoxLayout& a_dest,
91  const IntVect& a_destGhost,
92  const Vector<int>& a_transverseDir,
93  bool a_exchange = false);
94 
95  /// Copier to copy data into the valid and invalid regions of a_dest from a_level with support for periodic BCs
96  ReductionCopier(const DisjointBoxLayout& a_level,
97  const BoxLayout& a_dest,
98  const ProblemDomain& a_domain,
99  const IntVect& a_destGhost,
100  const Vector<int>& a_transverseDir,
101  bool a_exchange = false);
102 
103  ///
104  virtual ~ReductionCopier();
105 
106  ///
107  virtual void define(const bool & a_usingFaceSumOp ,
108  const DisjointBoxLayout & a_sourceLayout ,
109  const BoxLayout & a_destLayout ,
110  const ProblemDomain & a_domain ,
111  const IntVect & a_ghostVect ,
112  const Vector<int> & a_reduceDir ,
113  bool a_exchange = false);
114 
115  virtual void setMotionItems(const int & a_itemProcID,
116  const Box & a_fromBox ,
117  const Box & a_toBox ,
118  const bool & a_firstLoop ,
119  const DataIndex & a_fromdi ,
120  const DataIndex & a_todi ,
121  const bool & a_exchange = false);
122 
123  // utility function for the define
124  virtual void nestedDILoops(const bool & a_firstLoop ,
125  const BoxLayout & a_sourceLayout ,
126  const BoxLayout & a_destLayout ,
127  const IntVect & a_ghostVect ,
128  const Box & a_domainBox ,
129  vector<DataIndex> & a_outerLoop ,
130  vector<DataIndex> & a_innerLoop ,
131  const Vector<int> & a_reduceLo ,
132  const Vector<int> & a_reduceHi ,
133  bool a_exchange = false);
134 
135  ///
136  virtual void define(const DisjointBoxLayout& a_level,
137  const BoxLayout& a_dest,
138  int a_transverseDir,
139  bool a_exchange = false);
140 
141  /// contains support for periodic BCs
142  virtual void define(const DisjointBoxLayout& a_level,
143  const BoxLayout& a_dest,
144  const ProblemDomain& a_domain,
145  int a_transverseDir,
146  bool a_exchange = false);
147 
148  ///
149  virtual void define(const DisjointBoxLayout& a_level,
150  const BoxLayout& a_dest,
151  const IntVect& a_destGhost,
152  int a_transverseDir,
153  bool a_exchange = false);
154 
155  /// contains support for periodic BCs
156  virtual void define(const BoxLayout& a_level,
157  const BoxLayout& a_dest,
158  const ProblemDomain& a_domain,
159  const IntVect& a_destGhost,
160  int a_transverseDir,
161  bool a_exchange = false);
162 
163  ///
164  virtual void define(const DisjointBoxLayout& a_level,
165  const BoxLayout& a_dest,
166  const Vector<int>& a_transverseDir,
167  bool a_exchange = false);
168 
169  /// contains support for periodic BCs
170  virtual void define(const DisjointBoxLayout& a_level,
171  const BoxLayout& a_dest,
172  const ProblemDomain& a_domain,
173  const Vector<int>& a_transverseDir,
174  bool a_exchange = false);
175 
176  ///
177  virtual void define(const DisjointBoxLayout& a_level,
178  const BoxLayout& a_dest,
179  const IntVect& a_destGhost,
180  const Vector<int>& a_transverseDir,
181  bool a_exchange = false);
182 
183  /// contains support for periodic BCs
184  virtual void define(const BoxLayout& a_level,
185  const BoxLayout& a_dest,
186  const ProblemDomain& a_domain,
187  const IntVect& a_destGhost,
188  const Vector<int>& a_transverseDir,
189  bool a_exchange = false);
190 
191  /// reverse the direction of copy for an already-defined ReductionCopier
192  /**
193  This function simply replaces the from data with the to-data for
194  the already-defined copy operation.
195  For now, this function heads right into a MayDay::Error, since what
196  you probably want is to use a SpreadingCopier rather than a reversed
197  ReductionCopier
198  */
199  void reverse();
200 
201  /// check that this Copier object corresponds to these two BoxLayouts.
202  bool check(const DisjointBoxLayout& from, const BoxLayout& to) const;
203 
204  int print() const;
205 
206 
207 protected:
208 
209  friend class CopyIterator;
210 
211  friend void dumpmemoryatexit();
212 
213 private:
214 
215  // no really good reason to keep this, except for completeness...
218 };
219 
220 //===========================================================================
221 // end of public interface for ReductionCopier.
222 //===========================================================================
223 
224 #include "NamespaceFooter.H"
225 
226 #endif
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:152
int print() const
Vector< int > m_reduceDir
Definition: ReductionCopier.H:217
ReductionCopier()
null constructor, copy constructor and operator= can be compiler defined.
Definition: ReductionCopier.H:42
virtual void define(const bool &a_usingFaceSumOp, const DisjointBoxLayout &a_sourceLayout, const BoxLayout &a_destLayout, const ProblemDomain &a_domain, const IntVect &a_ghostVect, const Vector< int > &a_reduceDir, bool a_exchange=false)
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
friend void dumpmemoryatexit()
Vector< int > m_transverseDir
Definition: ReductionCopier.H:216
void reverse()
reverse the direction of copy for an already-defined ReductionCopier
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
bool check(const DisjointBoxLayout &from, const BoxLayout &to) const
check that this Copier object corresponds to these two BoxLayouts.
Definition: DataIndex.H:114
virtual void nestedDILoops(const bool &a_firstLoop, const BoxLayout &a_sourceLayout, const BoxLayout &a_destLayout, const IntVect &a_ghostVect, const Box &a_domainBox, vector< DataIndex > &a_outerLoop, vector< DataIndex > &a_innerLoop, const Vector< int > &a_reduceLo, const Vector< int > &a_reduceHi, bool a_exchange=false)
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:402
virtual void setMotionItems(const int &a_itemProcID, const Box &a_fromBox, const Box &a_toBox, const bool &a_firstLoop, const DataIndex &a_fromdi, const DataIndex &a_todi, const bool &a_exchange=false)