Chombo + EB  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  FaceSumOp(const int& a_summingDir);
69 
70  virtual ~FaceSumOp()
71  {
72  }
73 
74  void setDir (const int& a_sumDir);
75  void setScale(const Real& a_scale );
76 
77  void op(FluxBox & dataTo ,
78  const Box & RegionFrom ,
79  const Interval& Cdest ,
80  const Box & RegionTo ,
81  const FluxBox & src ,
82  const Interval& Csrc ) const;
83 
84 
85 
86  virtual void linearIn(FluxBox & a_arg ,
87  void* a_buf ,
88  const Box & a_R ,
89  const Interval& a_comps) const;
90 
91 
92  virtual void linearOut(const FluxBox & a_arg ,
93  void* a_buf ,
94  const Box & a_R ,
95  const Interval& a_comps) const;
96 
97  int size(const FluxBox & a_fluxBox,
98  const Box & a_bx ,
99  const Interval& a_comps ) const;
100 
101 
104 
105 };
106 
107 /// Class to do spreading operation in the context of CopyTo
108 /**
109  This class will perform a spreading operation of the data in src
110  along the summingDir direction(s), multiplying by the scale, and placing
111  the src values in the corresponding locations in dest.
112 */
113 
114 class SpreadingOp : public LDOperator<FArrayBox>
115 {
116 public:
119  SpreadingOp();
120 
121  // single spreading direction
122  SpreadingOp(int a_spreadingDir);
123 
124  SpreadingOp(const Vector<int>& a_spreadingDir);
125 
126  virtual void linearIn(FArrayBox& arg, void* buf, const Box& R,
127  const Interval& comps) const;
128  void op(FArrayBox& dest,
129  const Box& RegionFrom,
130  const Interval& Cdest,
131  const Box& RegionTo,
132  const FArrayBox& src,
133  const Interval& Csrc) const;
134 
135  void applyOp(FArrayBox& dest,
136  const Box& RegionFrom,
137  const Interval& Cdest,
138  const Box& RegionTo,
139  const FArrayBox& src,
140  const Interval& Csrc,
141  Real a_scale) const;
142 
143 };
144 
145 /// Class to do spreading operation in the context of CopyTo
146 /**
147  This class will perform a spreading operation of the data in src
148  along the summingDir direction(s), multiplying by the scale, and placing
149  the src values in the corresponding locations in dest.
150 */
151 
152 class FaceSpreadingOp : public LDOperator<FluxBox>
153 {
154 public:
157  FaceSpreadingOp();
158 
159  // single spreading direction
160  FaceSpreadingOp(int a_spreadingDir);
161 
162  // allows for multiple directions
163  FaceSpreadingOp(const Vector<int>& a_spreadingDir);
164 
165  virtual void linearIn(FluxBox& arg, void* buf, const Box& R,
166  const Interval& comps) const;
167  void op(FluxBox& dest,
168  const Box& RegionFrom,
169  const Interval& Cdest,
170  const Box& RegionTo,
171  const FluxBox& src,
172  const Interval& Csrc) const;
173 
174  void applyOp(FluxBox& dest,
175  const Box& RegionFrom,
176  const Interval& Cdest,
177  const Box& RegionTo,
178  const FluxBox& src,
179  const Interval& Csrc,
180  Real a_scale) const;
181 
182 };
183 
184 #include "NamespaceFooter.H"
185 
186 #endif
Definition: ReductionOps.H:63
virtual void linearIn(FArrayBox &arg, void *buf, const Box &R, const Interval &comps) const
int m_summingDir
Definition: ReductionOps.H:103
Vector< int > m_spreadingDir
Definition: ReductionOps.H:118
Vector< int > m_spreadingDir
Definition: ReductionOps.H:156
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:117
Class to do spreading operation in the context of CopyTo.
Definition: ReductionOps.H:114
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:102
virtual ~FaceSumOp()
Definition: ReductionOps.H:70
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
Definition: FArrayBox.H:45
Class to do summing operation in the context of CopyTo.
Definition: ReductionOps.H:28
Definition: BoxLayoutData.H:173
Real scale
Definition: ReductionOps.H:155
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:152