Chombo + EB + MF  3.2
ReductionOps.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 _REDUCTIONOPS_H_
12 #define _REDUCTIONOPS_H_
13 
14 #include "BoxLayoutData.H"
15 #include "FArrayBox.H"
16 #include "FluxBox.H"
17 
18 #include "NamespaceHeader.H"
19 
21 /// Class to do summing operation in the context of CopyTo
22 /**
23  This class will perform a summing operation of the data in src
24  in the summingDir direction(s), multiplying by the scale, and placing
25  the sum in the corresponding location in dest
26 */
27 
28 class SumOp : public LDOperator<FArrayBox>
29 {
30 public:
33  SumOp();
34 
35  // single-direction
36  SumOp(int a_summingDir);
37 
38  // allows for a multidimensional reduction
39  SumOp(const Vector<int>& a_summingDir);
40 
41  virtual void linearOut(const FArrayBox& arg, void* buf, const Box& R,
42  const Interval& comps) const;
43 
44  virtual void linearIn(FArrayBox& arg, void* buf, const Box& R,
45  const Interval& comps) const;
46  void op(FArrayBox& dest,
47  const Box& RegionFrom,
48  const Interval& Cdest,
49  const Box& RegionTo,
50  const FArrayBox& src,
51  const Interval& Csrc) const;
52 
53 };
54 
55 // (DFM 11/13/08) as currently implemented, FaceSumOp doesn't
56 // do the right thing for multiple adjoining grids -- it will
57 // double-count overlying faces where boxes adjoin. Since we don't
58 // actually need the face-centered summing operator at the moment,
59 // take the cowardly path of just commenting it out to revisit if it
60 // becomes a needed member of the Chombo family
61 
62 
63 class FaceSumOp: public LDOperator<FluxBox>
64 {
65 public:
66 
67  FaceSumOp();
68 
69  // The projection directions are stored in an IntVect: a 1 value denotes summing in that direction. A zero value denotes no summng in that direction
70  FaceSumOp(const IntVect& a_summingDir);
71  FaceSumOp(const int & a_summingDir);
72 
73  virtual ~FaceSumOp()
74  {
75  }
76 
77  void setReductionDir (const IntVect& a_sumDir);
78  void setScale(const Real& a_scale );
79 
80  void op(FluxBox & dataTo ,
81  const Box & RegionFrom ,
82  const Interval& Cdest ,
83  const Box & RegionTo ,
84  const FluxBox & src ,
85  const Interval& Csrc ) const;
86 
87  virtual void linearIn(FluxBox & a_arg ,
88  void* a_buf ,
89  const Box & a_R ,
90  const Interval& a_comps) const;
91 
92 
93  virtual void linearOut(const FluxBox & a_arg ,
94  void* a_buf ,
95  const Box & a_R ,
96  const Interval& a_comps) const;
97 
98  int size(const FluxBox & a_fluxBox,
99  const Box & a_bx ,
100  const Interval& a_comps ) const;
101 
102  // reduce a source Intvect or a source box
103  virtual IntVect project(const IntVect & a_iv ) const ;
104  virtual Box project (const Box & a_box) const;
105 
106  // expand a destination box
107  virtual Box inject (const Box & a_box)const ;
108 
109  virtual void setDestBox (const Box & a_destDom )const ;
110  virtual void setSourceBox (const Box & a_sourceDom )const ;
111 
112  virtual Box getDestinationBox() const ;
113  virtual Box getSourceBox () const ;
114 
115  virtual void setProjectionDirections(const IntVect & a_directions)const;
116  virtual IntVect getProjectionDirections(const IntVect & a_directions)const;
117 
118 
119 public:
121 
122  // one in an entry indicates reduction in that direction; 0 or anything else indicates no reduction
124 
125  // used in op
126  mutable Box m_destBox ;
127  mutable Box m_sourceBox;
128 
129 };
130 
131 /// Class to do spreading operation in the context of CopyTo
132 /**
133  This class will perform a spreading operation of the data in src
134  along the summingDir direction(s), multiplying by the scale, and placing
135  the src values in the corresponding locations in dest.
136 */
137 
138 class SpreadingOp : public LDOperator<FArrayBox>
139 {
140 public:
143  SpreadingOp();
144 
145  // single spreading direction
146  SpreadingOp(int a_spreadingDir);
147 
148  SpreadingOp(const Vector<int>& a_spreadingDir);
149 
150  virtual void linearIn(FArrayBox& arg, void* buf, const Box& R,
151  const Interval& comps) const;
152  void op(FArrayBox& dest,
153  const Box& RegionFrom,
154  const Interval& Cdest,
155  const Box& RegionTo,
156  const FArrayBox& src,
157  const Interval& Csrc) const;
158 
159  void applyOp(FArrayBox& dest,
160  const Box& RegionFrom,
161  const Interval& Cdest,
162  const Box& RegionTo,
163  const FArrayBox& src,
164  const Interval& Csrc,
165  Real a_scale) const;
166 
167 };
168 
169 /// Class to do spreading operation in the context of CopyTo
170 /**
171  This class will perform a spreading operation of the data in src
172  along the summingDir direction(s), multiplying by the scale, and placing
173  the src values in the corresponding locations in dest.
174 */
175 
176 class FaceSpreadingOp : public LDOperator<FluxBox>
177 {
178 public:
181  FaceSpreadingOp();
182 
183  // single spreading direction
184  FaceSpreadingOp(int a_spreadingDir);
185 
186  // allows for multiple directions
187  FaceSpreadingOp(const Vector<int>& a_spreadingDir);
188 
189  virtual void linearIn(FluxBox& arg, void* buf, const Box& R,
190  const Interval& comps) const;
191  void op(FluxBox& dest,
192  const Box& RegionFrom,
193  const Interval& Cdest,
194  const Box& RegionTo,
195  const FluxBox& src,
196  const Interval& Csrc) const;
197 
198  void applyOp(FluxBox& dest,
199  const Box& RegionFrom,
200  const Interval& Cdest,
201  const Box& RegionTo,
202  const FluxBox& src,
203  const Interval& Csrc,
204  Real a_scale) const;
205 
206 };
207 
208 #include "NamespaceFooter.H"
209 
210 #endif
Definition: ReductionOps.H:63
virtual void linearIn(FArrayBox &arg, void *buf, const Box &R, const Interval &comps) const
Vector< int > m_spreadingDir
Definition: ReductionOps.H:142
Vector< int > m_spreadingDir
Definition: ReductionOps.H:180
Vector< int > m_summingDir
Definition: ReductionOps.H:32
void op(FArrayBox &dest, const Box &RegionFrom, const Interval &Cdest, const Box &RegionTo, const FArrayBox &src, const Interval &Csrc) const
Real scale
Definition: ReductionOps.H:141
Class to do spreading operation in the context of CopyTo.
Definition: ReductionOps.H:138
void computeFaceReductionWeights(LevelData< FluxBox > &a_weights)
A FArrayBox-like container for face-centered fluxes.
Definition: FluxBox.H:22
virtual int size(const FArrayBox &arg, const Box &b, const Interval &comps) const
Definition: BoxLayoutData.H:180
Structure for passing component ranges in code.
Definition: Interval.H:23
double Real
Definition: REAL.H:33
Real scale
Definition: ReductionOps.H:31
Real m_scale
Definition: ReductionOps.H:120
IntVect m_projectionDirections
Definition: ReductionOps.H:123
virtual ~FaceSumOp()
Definition: ReductionOps.H:73
Box m_sourceBox
Definition: ReductionOps.H:127
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: FArrayBox.H:45
Class to do summing operation in the context of CopyTo.
Definition: ReductionOps.H:28
Box m_destBox
Definition: ReductionOps.H:126
Definition: BoxLayoutData.H:173
Real scale
Definition: ReductionOps.H:179
virtual void linearOut(const FArrayBox &arg, void *buf, const Box &R, const Interval &comps) const
Class to do spreading operation in the context of CopyTo.
Definition: ReductionOps.H:176