Chombo + EB  3.2
IrregFAB.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 _IRREGFAB_H_
12 #define _IRREGFAB_H_
13 
14 #include <cmath>
15 #include <cstdlib>
16 #include "SPACE.H"
17 #include "Vector.H"
18 #include "IntVectSet.H"
19 #include "VolIndex.H"
20 #include "BaseIndex.H"
21 #include "BaseFab.H"
22 #include "BaseIVFAB.H"
23 #include "EBGraph.H"
24 #include "NamespaceHeader.H"
25 
26 
27 
28 ///
29 /**
30  This is a data holder which holds data over the irregular
31  cells in a box.
32 */
33 class IrregFAB: public BaseIVFAB<Real>
34 {
35 public:
36  ///
37  /**
38  Default constructor. Constructs an uninitialized IVFAB. You must
39  subsequently call {\bf define} before using this IVFAB.
40  */
41  IrregFAB();
42 
43  ///
44  /**
45  Defining constructor. Specifies the irregular domain as the
46  irregular cells within the region
47  and the number of data components per VoF. The irregular domain
48  must lie completely within the EBGraph. The
49  contents are uninitialized. Calls full define function.
50  */
51  IrregFAB(const Box& a_region,
52  const EBGraph& a_ebgraph,
53  const int& a_nvarin);
54 
55 
56  ///
57  virtual ~IrregFAB();
58 
59  ///
60  /**
61  Full define function. Specifies the irregular domain as the
62  irregular cells within the regionand the
63  number of data components per VoF. The irregular domain
64  must lie completely within the EBGraph. The contents
65  are uninitialized. If it has previously been defined, the old definition
66  data is overwritten and lost.
67  */
68  virtual void define(const Box& a_region,
69  const EBGraph& a_ebgraph,
70  const int& a_nvarin);
71 
72 
73  ///invalid but necessary for leveldata to compile
74  IrregFAB(const Box& a_region, int a_nVar)
75  {
76  MayDay::Error("invalid constructor called for baseebcellfab");
77  }
78 
79  /// some stuff to do arithmetic
80  class arithOp
81  {
82  public:
83  virtual void func(Real& dstVal, const Real& srcVal) = 0;
84  };
85 
86  /// operator for +=
87  class additionOp: public arithOp
88  {
89  void func(Real& a_dstVal, const Real& a_srcVal)
90  {
91  a_dstVal += a_srcVal;
92  }
93  };
94 
95  /// operator for -=
96  class subtractionOp: public arithOp
97  {
98  void func(Real& a_dstVal, const Real& a_srcVal)
99  {
100  a_dstVal -= a_srcVal;
101  }
102  };
103 
104  /// operator for *=
105  class multiplicationOp: public arithOp
106  {
107  void func(Real& a_dstVal, const Real& a_srcVal)
108  {
109  a_dstVal *= a_srcVal;
110  }
111  };
112 
113  /// operator for /=
114  class divisionOp: public arithOp
115  {
116  void func(Real& a_dstVal, const Real& a_srcVal)
117  {
118  a_dstVal /= a_srcVal;
119  }
120  };
121 
122  ///apply any operator pointwise for two fabs.
123  IrregFAB& applyOp(const Real& a_srcVal,
124  int a_srccomp,
125  int a_destcomp,
126  int a_numcomp,
127  IrregFAB::arithOp& a_op);
128 
129  ///apply any operator pointwise with input real number
130  IrregFAB& applyOp(const IrregFAB& a_srcVal,
131  const Box& a_region,
132  int a_srccomp,
133  int a_destcomp,
134  int a_numcomp,
135  IrregFAB::arithOp& a_op);
136 
137  ///
138  /**
139  done over intersection of src, dst
140  Both fabs need the same ncomp
141  */
142  IrregFAB& operator+=(const IrregFAB& a_ebfab);
143 
144  ///
145  /**
146  done over intersection of src, dst
147  Both fabs need the same ncomp
148  */
149  IrregFAB& operator+=(const Real& a_ebfab);
150 
151 
152  ///
153  /**
154  done over intersection of src, dst
155  Both fabs need the same ncomp
156  */
157  IrregFAB& operator-=(const IrregFAB& a_ebfab);
158 
159  ///
160  /**
161  */
162  IrregFAB& operator-=(const Real& a_ebfab);
163 
164  ///
165  /**
166  done over intersection of src, dst
167  Both fabs need the same ncomp
168  */
169  IrregFAB& operator*=(const IrregFAB& a_IrregFAB);
170 
171  ///
172  /**
173  */
174  IrregFAB& operator*=(const Real& a_ebfab);
175 
176  ///
177  /**
178  done over intersection of src, dst
179  Both fabs need the same ncomp
180  */
181  IrregFAB& operator/=(const IrregFAB& a_ebfab);
182 
183  ///
184  /**
185  */
186  IrregFAB& operator/=(const Real& a_ebfab);
187 
188 
189  ///more flexible versions of stuff
190 
191  ///
192  IrregFAB& plus(const IrregFAB& a_src,
193  int a_srccomp,
194  int a_destcomp,
195  int a_numcomp);
196 
197  ///
198  IrregFAB& plus(const Real& a_src,
199  int a_srccomp,
200  int a_destcomp,
201  int a_numcomp);
202 
203  ///
204  IrregFAB& plus(const IrregFAB& a_src,
205  const Box& a_region,
206  int a_srccomp,
207  int a_destcomp,
208  int a_numcomp);
209 
210  ///
211  IrregFAB& minus(const IrregFAB& a_src,
212  int a_srccomp,
213  int a_destcomp,
214  int a_numcomp);
215 
216  ///
217  IrregFAB& minus(const Real& a_src,
218  int a_srccomp,
219  int a_destcomp,
220  int a_numcomp);
221 
222  ///
223  IrregFAB& mult(const Real& a_src,
224  int a_srccomp,
225  int a_destcomp,
226  int a_numcomp);
227  ///
228  IrregFAB& divide(const Real& a_src,
229  int a_srccomp,
230  int a_destcomp,
231  int a_numcomp);
232 
233  ///
234  IrregFAB& minus(const IrregFAB& a_src,
235  const Box& a_region,
236  int a_srccomp,
237  int a_destcomp,
238  int a_numcomp);
239 
240 
241  ///
242  IrregFAB& mult(const IrregFAB& a_src,
243  int a_srccomp,
244  int a_destcomp,
245  int a_numcomp);
246 
247  ///
248  IrregFAB& mult(const IrregFAB& a_src,
249  const Box& a_region,
250  int a_srccomp,
251  int a_destcomp,
252  int a_numcomp);
253 
254  ///
255  IrregFAB& divide(const IrregFAB& a_src,
256  int a_srccomp,
257  int a_destcomp,
258  int a_numcomp);
259 
260  ///
261  IrregFAB& divide(const IrregFAB& a_src,
262  const Box& a_region,
263  int a_srccomp,
264  int a_destcomp,
265  int a_numcomp);
266 protected:
268 
269 private:
270 
271  //disallowed for all the usual reasons
272  void operator= (const IrregFAB& a_input)
273  {
274  MayDay::Error("IrregFAB operator = not defined");
275  }
276  IrregFAB(const IrregFAB& a_input)
277  {
278  MayDay::Error("invalid operator");
279  }
280 };
281 
282 #include "NamespaceFooter.H"
283 #endif
Definition: IrregFAB.H:33
operator for -=
Definition: IrregFAB.H:96
IrregFAB(const Box &a_region, int a_nVar)
invalid but necessary for leveldata to compile
Definition: IrregFAB.H:74
virtual void func(Real &dstVal, const Real &srcVal)=0
IrregFAB & divide(const Real &a_src, int a_srccomp, int a_destcomp, int a_numcomp)
Geometric description within a box.
Definition: EBGraph.H:427
operator for +=
Definition: IrregFAB.H:87
virtual void define(const Box &a_region, const EBGraph &a_ebgraph, const int &a_nvarin)
void func(Real &a_dstVal, const Real &a_srcVal)
Definition: IrregFAB.H:107
IrregFAB & minus(const IrregFAB &a_src, int a_srccomp, int a_destcomp, int a_numcomp)
virtual ~IrregFAB()
IrregFAB & operator-=(const IrregFAB &a_ebfab)
Box m_region
Definition: IrregFAB.H:267
IrregFAB & operator+=(const IrregFAB &a_ebfab)
IrregFAB & mult(const Real &a_src, int a_srccomp, int a_destcomp, int a_numcomp)
some stuff to do arithmetic
Definition: IrregFAB.H:80
double Real
Definition: REAL.H:33
void func(Real &a_dstVal, const Real &a_srcVal)
Definition: IrregFAB.H:89
operator for /=
Definition: IrregFAB.H:114
IrregFAB & operator/=(const IrregFAB &a_ebfab)
static void Error(const char *const a_msg=m_nullString, int m_exitCode=CH_DEFAULT_ERROR_CODE)
Print out message to cerr and exit with the specified exit code.
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
IrregFAB & plus(const IrregFAB &a_src, int a_srccomp, int a_destcomp, int a_numcomp)
more flexible versions of stuff
IrregFAB & applyOp(const Real &a_srcVal, int a_srccomp, int a_destcomp, int a_numcomp, IrregFAB::arithOp &a_op)
apply any operator pointwise for two fabs.
void func(Real &a_dstVal, const Real &a_srcVal)
Definition: IrregFAB.H:98
void func(Real &a_dstVal, const Real &a_srcVal)
Definition: IrregFAB.H:116
IrregFAB(const IrregFAB &a_input)
Definition: IrregFAB.H:276
void operator=(const IrregFAB &a_input)
Definition: IrregFAB.H:272
operator for *=
Definition: IrregFAB.H:105
IrregFAB & operator*=(const IrregFAB &a_IrregFAB)
Definition: BaseIVFAB.H:32