Chombo + EB + MF  3.2
MFCellFAB.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 _MFCELLFAB_H_
12 #define _MFCELLFAB_H_
13 
14 #include "EBCellFAB.H"
15 #include "BoxLayoutData.H"
16 #include "EBISLayout.H"
17 #include "Vector.H"
18 #include "DisjointBoxLayout.H"
19 #include "MFIndexSpace.H"
20 #include "NamespaceHeader.H"
21 
22 class MFCellFAB
23 {
24 public:
26  {
27  }
28 
29  virtual ~MFCellFAB();
30 
31  MFCellFAB(const Vector<EBISBox>& a_phaseGraphs,
32  const Box& a_region, const Vector<int>& a_nVar);
33 
34  void
35  setVal(Vector<Real> a_value);
36 
37  void setVal(const Real& a_value);
38 
39  void setVal(Real a_val, const Box& a_region, int startcomp,int ncomp);
40 
41  ///
42  int nComp(int a_phase) const
43  {
44  return (*m_phase[a_phase]).nComp();
45  }
46 
47  ///
48  int numPhases() const
49  {
50  return m_phase.size();
51  }
52 
53  ///
54  const Box& box() const
55  {
56  return m_box;
57  }
58 
59  EBCellFAB& getPhase(int a_phase)
60  {
61  return (*m_phase[a_phase]);
62  }
63  const EBCellFAB& getPhase(int a_phase) const
64  {
65  return (*m_phase[a_phase]);
66  }
67  EBCellFAB* getPhasePtr(int a_phase)
68  {
69  return m_phase[a_phase];
70  }
71 
72  ///
73  void copy(const Box& RegionFrom,
74  const Interval& destInt,
75  const Box& RegionTo,
76  const MFCellFAB& source,
77  const Interval& srcInt);
78 
79  static int preAllocatable()
80  {
81  return 1;
82  }
83 
84  ///
85  int size(const Box& R, const Interval& comps) const ;
86  ///
87  void linearOut(void* buf, const Box& R, const Interval& comps) const ;
88 
89  ///
90  void linearIn(void* buf, const Box& R, const Interval& comps);
91 
92  ///invalid but necessary for leveldata to compile
93  MFCellFAB(const Box& a_region, int a_nVar)
94  {
95  MayDay::Error("invalid constructor called for baseebcellfab");
96  }
97  ///
98  /**
99  Negate the values in all locations
100  */
102  {
103  this->mult(-1);
104  return *this;
105  }
106 
107  ///
108  /**
109  Both fabs need the same ebisBox and region.
110  */
111  MFCellFAB& operator+=(const MFCellFAB& a_mffab);
112 
113  ///
114  /**
115  Both fabs need the same ebisBox and region.
116  */
117  MFCellFAB& plus(const MFCellFAB& a_ebfab,
118  int a_srccomp,
119  int a_destcomp,
120  int a_numcomp);
121 
122 
123  MFCellFAB& plus(const MFCellFAB& a_src,
124  const Box& a_srcbox,
125  const Box& a_destbox,
126  const Real& a_scale,
127  int a_srccomp,
128  int a_destcomp,
129  int a_numcomp);
130  ///
131  /**
132  Both fabs need the same ebisBox and region.
133  */
134  MFCellFAB& operator-=(const MFCellFAB& a_mffab);
135 
136  ///
137  /**
138  Both fabs need the same ebisBox and region.
139  */
140  MFCellFAB& minus(const MFCellFAB& a_ebfab,
141  int a_srccomp,
142  int a_destcomp,
143  int a_numcomp);
144 
145 
146  ///
147  /**
148  Both fabs need the same ebisBox and region.
149  */
150  MFCellFAB& operator*=(const MFCellFAB& a_mffab);
151 
152  ///
153  /**
154  Both fabs need the same ebisBox and region.
155  */
156  MFCellFAB& mult(const MFCellFAB& a_ebfab,
157  int a_srccomp,
158  int a_destcomp,
159  int a_numcomp);
160 
161 
162  ///
163  /**
164  Both fabs need the same ebisBox and region.
165  */
166  MFCellFAB& operator/=(const MFCellFAB& a_mffab);
167 
168 
169  ///
170  /**
171  Both fabs need the same ebisBox and region.
172  */
173  MFCellFAB& divide(const MFCellFAB& a_ebfab,
174  int a_srccomp,
175  int a_destcomp,
176  int a_numcomp);
177 
178 
179  ///
180  /**
181  Both fabs need the same ebisBox and region.
182  */
183  MFCellFAB& operator+=(const Real& a_scalar);
184 
185  ///
186  /**
187  Both fabs need the same ebisBox and region.
188  */
189  MFCellFAB& operator-=(const Real& a_scalar);
190 
191  ///
192  /**
193  Both fabs need the same ebisBox and region.
194  */
195  MFCellFAB& operator*=(const Real& a_scalar);
196 
197  ///
198  /**
199  Both fabs need the same ebisBox and region.
200  */
201  MFCellFAB& mult(Real a_scalar);
202 
203  ///
204  /**
205  Both fabs need the same ebisBox and region.
206  */
207  MFCellFAB& operator/=(const Real& a_scalar);
208 
209  ///
210  /**
211  Current FAB += a_src FAB * a_scalar. Both fabs need the same ebisBox
212  and region.
213  */
214  MFCellFAB& plus(const MFCellFAB& a_src,
215  Real a_scalar);
216 
217 
218  MFCellFAB& copy(const MFCellFAB& a_src);
219 
220  /// (Not implemented) Returns the Lp-norm of this MFCellFAB
221  /**
222  (Not implemented) Returns the Lp-norm of this MFCellFAB using components
223  (a_comp : a_comp + a_numcomp - 1). a_power < 0 -> ERROR.
224  a_power = 0 -> infinity norm (max norm).
225  a_power = 1 -> L1-norm
226  a_power > 1 -> Lp-norm
227  */
228  virtual Real norm(int a_power,
229  int a_comp,
230  int a_numComp) const;
231 
232  /// (Not implemented) Returns the Lp-norm of this MFCellFAB within a region
233  /**
234  (Not implemented) Returns the Lp-norm of this MFCellFAB using components
235  (a_comp : a_comp + a_numcomp - 1) and within the a_subbox. a_power < 0
236  -> ERROR.
237  a_power = 0 -> infinity norm (max norm).
238  a_power = 1 -> L1-norm
239  a_power > 1 -> Lp-norm
240  */
241  virtual Real norm(const Box& a_subbox,
242  int a_power,
243  int a_comp,
244  int a_numComp) const;
245 
246  /// (Not implemented) Returns a sum of powers of a subset of this MFCellFAB
247  /**
248  (Not implemented) Returns a sum of powers of a subset of this MFCellFAB,
249  specifically components a_comp to a_comp+a_numcomp-1 within a_subbox.
250  a_power >= 2 only.
251 
252  */
253  virtual Real sumPow(const Box& a_subbox,
254  int a_power,
255  int a_comp,
256  int a_numComp) const;
257 
258  /// (Not implemented) Return the dot product of this MFCellFAB with another
259  /**
260  (Not implemented) Return the dot product of this MFCellFAB and "ebfab2"
261  over their overlap region and all components.
262  */
263  Real dotProduct(const MFCellFAB& ebfab2) const;
264 
265  Real dotProduct(const MFCellFAB& ebfab2, const Box& a_box) const;
266 
267 private:
268 
269  void operator=(const MFCellFAB& rhs); //unimplemented
270 
273 
274 };
275 
276 /// Factory class to produce MFCellFABs.
277 /**
278  Factory class to produce MFCellFABs.
279  This is needed for LevelData construction.
280  */
282  : public DataFactory<MFCellFAB>
283 {
284 public:
285 
286  MFCellFactory(Vector<EBISLayout>& a_ebis, const Vector<int>& a_ncomp);
287 
288  MFCellFactory(const MFIndexSpace& a_mf, const DisjointBoxLayout& a_dbl,
289  const Box& a_domain, const Vector<int>& a_ncomps,
290  int ghost);
291 
292  void define(Vector<EBISLayout>& a_ebis, const Vector<int>& a_ncomp);
293 
294  virtual ~MFCellFactory();
295  /// factory function.
296  /**
297  Creates a new mfcellfab object
298  and returns a pointer to it. Responsibility
299  for calling operator 'delete' on this pointer is passed to the user.
300  */
301  virtual MFCellFAB* create(const Box& a_box, int a_ncompsIgnored,
302  const DataIndex& a_dit) const;
303 
304  const EBISLayout& getEBISLayout(int phase) const
305  {
306  return m_ebis[phase];
307  }
308 
309 private:
310 
313 
314 };
315 
316 #include "NamespaceFooter.H"
317 #endif
const EBCellFAB & getPhase(int a_phase) const
Definition: MFCellFAB.H:63
MFCellFAB & mult(const MFCellFAB &a_ebfab, int a_srccomp, int a_destcomp, int a_numcomp)
Definition: MFCellFAB.H:22
virtual ~MFCellFAB()
Definition: MFIndexSpace.H:17
void setVal(Vector< Real > a_value)
MFCellFAB & operator*=(const MFCellFAB &a_mffab)
MFCellFAB & plus(const MFCellFAB &a_ebfab, int a_srccomp, int a_destcomp, int a_numcomp)
one dimensional dynamic array
Definition: Vector.H:53
const Box & box() const
Definition: MFCellFAB.H:54
virtual Real norm(int a_power, int a_comp, int a_numComp) const
(Not implemented) Returns the Lp-norm of this MFCellFAB
Factory class to produce MFCellFABs.
Definition: MFCellFAB.H:281
MFCellFAB & operator/=(const MFCellFAB &a_mffab)
Box m_box
Definition: MFCellFAB.H:272
int size(const Box &R, const Interval &comps) const
Vector< int > m_ncomp
Definition: MFCellFAB.H:312
EBCellFAB * getPhasePtr(int a_phase)
Definition: MFCellFAB.H:67
Vector< EBCellFAB * > m_phase
Definition: MFCellFAB.H:271
Structure for passing component ranges in code.
Definition: Interval.H:23
MFCellFAB(const Box &a_region, int a_nVar)
invalid but necessary for leveldata to compile
Definition: MFCellFAB.H:93
Definition: EBCellFAB.H:29
double Real
Definition: REAL.H:33
int nComp(int a_phase) const
Definition: MFCellFAB.H:42
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
void linearOut(void *buf, const Box &R, const Interval &comps) const
size_t size() const
Definition: Vector.H:192
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.
MFCellFAB & minus(const MFCellFAB &a_ebfab, int a_srccomp, int a_destcomp, int a_numcomp)
virtual Real sumPow(const Box &a_subbox, int a_power, int a_comp, int a_numComp) const
(Not implemented) Returns a sum of powers of a subset of this MFCellFAB
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
void linearIn(void *buf, const Box &R, const Interval &comps)
Vector< EBISLayout > m_ebis
Definition: MFCellFAB.H:311
Definition: DataIndex.H:114
MFCellFAB & operator+=(const MFCellFAB &a_mffab)
MFCellFAB()
Definition: MFCellFAB.H:25
void operator=(const MFCellFAB &rhs)
EBCellFAB & getPhase(int a_phase)
Definition: MFCellFAB.H:59
Factory object to data members of a BoxLayoutData container.
Definition: BoxLayoutData.H:30
int numPhases() const
Definition: MFCellFAB.H:48
Definition: EBISLayout.H:39
MFCellFAB & negate(void)
Definition: MFCellFAB.H:101
MFCellFAB & operator-=(const MFCellFAB &a_mffab)
Real dotProduct(const MFCellFAB &ebfab2) const
(Not implemented) Return the dot product of this MFCellFAB with another
static int preAllocatable()
Definition: MFCellFAB.H:79
MFCellFAB & divide(const MFCellFAB &a_ebfab, int a_srccomp, int a_destcomp, int a_numcomp)
const EBISLayout & getEBISLayout(int phase) const
Definition: MFCellFAB.H:304
void copy(const Box &RegionFrom, const Interval &destInt, const Box &RegionTo, const MFCellFAB &source, const Interval &srcInt)