Chombo + EB  3.0
LevelFluxRegister.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 _LEVELFLUXREGISTER_H_
12 #define _LEVELFLUXREGISTER_H_
13 
14 #include "REAL.H"
15 #include "Vector.H"
16 #include "FArrayBox.H"
17 #include "IntVectSet.H"
18 #include "LoHiSide.H"
19 #include "LevelData.H"
20 #include "LayoutData.H"
21 #include "ProblemDomain.H"
22 #include "NamespaceHeader.H"
23 
24 ///LevelFluxRegister-A class to encapsulate a levels worth of flux registers.
25 /**
26  A LevelFluxRegister handles all the data choreography
27  necessary to create a levels worth of flux registers.
28 */
30 {
31 protected:
32 
33  /// Define status
35  {
37  FluxRegDefined = (1 << 0), // Indicates define() was called
38  FluxRegFineDefined = (1 << 1), // m_fineFlux was defined
39  FluxRegCoarseDefined = (1 << 2), // m_coarFlux was defined
40  FluxRegAllDefined = (1 << 3) - 1 // Everything
41  };
42 
43 public:
44  static bool s_verbose;
45  ///
46  /**
47  Default constructor. Creates an uninitialized levelfluxregister.
48  */
50 
51  ///
52  /**
53  Full constructor. Calls the define function which creates
54  a levels worth of flux registers. a_dProblem is fine-level
55  domain.
56 
57  If a_scaleFineFluxes is true (default then all fine fluxes are
58  scaled by 1/a_nRefine^(SpaceDim-1). Otherwise, no scaling is done.
59  */
61  const DisjointBoxLayout& a_dblCoarse,
62  const ProblemDomain& a_dProblem,
63  int a_nRefine,
64  int a_nComp,
65  bool a_scaleFineFluxes = true);
66 
67  /// This is an old style constructor - do not use if at all possible.
68  /**
69  Full constructor. Calls the define function which creates
70  a levels worth of flux registers. a_dProblem is fine-level
71  domain.
72 
73  If a_scaleFineFluxes is true (default then all fine fluxes are
74  scaled by 1/a_nRefine^(SpaceDim-1). Otherwise, no scaling is done.
75  */
77  const DisjointBoxLayout& a_dblCoarse,
78  const Box& a_dProblem,
79  int a_nRefine,
80  int a_nComp,
81  bool a_scaleFineFluxes = true);
82 
83  ///
84  virtual ~LevelFluxRegister();
85 
86  ///
87  /**
88  Full define function. Creates a levels worth of flux registers.
89  The values in the flux registers are still undefined, however.
90  To zero the fluxregisters, you must call setToZero(). a_dProblem
91  is fine-level domain. This method may be overridden by a subclass.
92 
93  If a_scaleFineFluxes is true then all fine fluxes are
94  scaled by 1/a_nRefine^(SpaceDim-1). Otherwise, no scaling is done.
95  */
96  virtual void define(const DisjointBoxLayout& a_dbl,
97  const DisjointBoxLayout& a_dblCoarse,
98  const ProblemDomain& a_dProblem,
99  int a_nRefine,
100  int a_nComp,
101  bool a_scaleFineFluxes);
102 
103  ///
104  /**
105  This define function calls the above define(), setting a_scaleFineFluxes to true.
106  */
107  void define(const DisjointBoxLayout& a_dbl,
108  const DisjointBoxLayout& a_dblCoarse,
109  const ProblemDomain& a_dProblem,
110  int a_nRefine,
111  int a_nComp);
112 
113  /// This is an old style define - do not use if at all possible.
114  /**
115  Full define function. Creates a levels worth of flux registers.
116  The values in the flux registers are still undefined, however.
117  To zero the fluxregisters, you must call setToZero(). a_dProblem
118  is fine-level domain.
119 
120  If a_scaleFineFluxes is true (default then all fine fluxes are
121  scaled by 1/a_nRefine^(SpaceDim-1). Otherwise, no scaling is done.
122  */
123  void define(const DisjointBoxLayout& a_dbl,
124  const DisjointBoxLayout& a_dblCoarse,
125  const Box& a_dProblem,
126  int a_nRefine,
127  int a_nComp,
128  bool a_scaleFineFluxes = true);
129 
130  ///
131  /**
132  Modifies this LevelFluxRegister so that it is returned to the
133  uninitialized state. User must now call the full define() before
134  using it.
135 
136  */
137  void
138  undefine();
139 
140  ///
141  /**
142  Initialize values of registers to zero.
143  */
144  void setToZero();
145 
146  ///
147  /**
148  increments the register with data from coarseFlux, multiplied by scale.
149  coarseFlux must contain the coarse fluxes in the dir direction
150  for the grid m_coarseLayout[coarseDataIndex]. This operation is local.
151  Increment coarse does register += -sign(side)*incrScale*coarseFlux
152  for both Lo and Hi "side".
153  */
154  void incrementCoarse(
155  const FArrayBox& a_coarseFlux,
156  Real a_scale,
157  const DataIndex& a_coarseDataIndex,
158  const Interval& a_srcInterval,
159  const Interval& a_dstInterval,
160  int a_dir);
161 
162  ///
163  /**
164  This method implements the register's coarse increment on a single side.
165  It may be overridden by a subclass.
166  */
167  virtual void incrementCoarse(
168  const FArrayBox& a_coarseFlux,
169  Real a_scale,
170  const DataIndex& a_coarseDataIndex,
171  const Interval& a_srcInterval,
172  const Interval& a_dstInterval,
173  int a_dir,
174  Side::LoHiSide a_sd);
175 
176  ///
177  /**
178  increments the register with data from fineFlux, multiplied by scale.
179  fineFlux must contain the coarse fluxes in the dir direction for the
180  grid m_fineLayout[fineDataIndex]. This operation is local.
181  Increment fine does register += sign(side)*incrScale*Ave(fineFlux)
182  for both Lo and Hi "side".
183  */
184  void incrementFine(
185  const FArrayBox& a_fineFlux,
186  Real a_scale,
187  const DataIndex& a_fineDataIndex,
188  const Interval& a_srcInterval,
189  const Interval& a_dstInterval,
190  int a_dir);
191 
192  ///
193  /**
194  This method implements the register's fine increment on one side.
195  It may be overridden by a subclass.
196  */
197  virtual void incrementFine(
198  const FArrayBox& a_fineFlux,
199  Real a_scale,
200  const DataIndex& a_fineDataIndex,
201  const Interval& a_srcInterval,
202  const Interval& a_dstInterval,
203  int a_dir,
204  Side::LoHiSide a_sd);
205 
206  ///
207  /**
208  increments uCoarse with the reflux divergence of the
209  contents of the flux register.
210  Note that there is no srccomp etc crap here.
211  this is done for all components so uCoarse has
212  to have the same number of components as input nComp.
213  This operation is global and blocking.
214 
215  Reflux does cellValue -= refluxScale*registerContents
216  */
217  void reflux(
218  LevelData<FArrayBox>& a_uCoarse,
219  Real a_scale);
220 
221  ///
222  /**
223  Interface for multiblock algorithms where, if an interval
224  of the components represents a vector, it must be specially
225  handled. If called from a singleblock code, the vector
226  interval is just ignored.
227  */
228  virtual void reflux(
229  LevelData<FArrayBox>& a_uCoarse,
230  const Interval& a_coarseVectorIntv,
231  Real a_scale);
232 
233  ///
234  /**
235  increments uCoarse with the reflux divergence of the
236  contents of the flux register. This can be overridden by
237  a subclass. This operation is global and blocking.
238  Reflux does cellValue -= refluxScale*registerContents
239  */
240  virtual void reflux(
241  LevelData<FArrayBox>& a_uCoarse,
242  const Interval& a_coarse_interval,
243  const Interval& a_flux_interval,
244  Real a_scale);
245 
246  ///same as above with a variable scale multiplied in
247  void reflux(
248  LevelData<FArrayBox>& a_uCoarse,
249  Real a_scale,
250  const Interval& a_coarseInterv,
251  const Interval& a_fluxInterval,
252  const LevelData<FArrayBox>& a_beta);
253 
254 
255  bool hasCF(const DataIndex& a_fineDataIndex, Side::LoHiSide) const;
256  bool hasCF(const DataIndex& a_coarseIndex) const;
257 
258  ///
259  /**
260  has full define function been called? return true if so.
261  */
262  bool isDefined() const;
263 
264  bool isAllDefined() const;
265 
266  ///
267  void poutCoarseRegisters() const;
268 
269  ///
270  void poutFineRegisters() const;
271 
273  {
274  CH_assert(isDefined());
275  int index = a_idir + a_sd*CH_SPACEDIM;
276  return m_coarseLocations[index];
277  }
278 
280  {
281  return m_reverseCopier;
282  }
283 
284 protected:
285 
286  // both of these are defined in the coarse index space,
287  // but, m_coarFlux uses the coarse grid layout, and
288  // m_fineFlux uses the fine grid layout.
291 
292  //LayoutData<IntVectSet> m_coarseLocations[CH_SPACEDIM*2];
294 
296 
298 
300 
302 
304 
305 private:
306 
307  ///there is no operator= for this class
308  void operator= (const LevelFluxRegister&);
309  ///there is no copy constructor for this class
311 };
312 #include "NamespaceFooter.H"
313 #endif
void poutFineRegisters() const
Definition: LevelFluxRegister.H:36
#define CH_SPACEDIM
Definition: SPACE.H:52
#define CH_assert(cond)
Definition: CHArray.H:37
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
static bool s_verbose
Definition: LevelFluxRegister.H:44
bool m_scaleFineFluxes
Definition: LevelFluxRegister.H:301
Data that maintains a one-to-one mapping of T to the boxes in a BoxLayout.
Definition: LayoutData.H:46
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:137
FluxRegDefineStatus
Define status.
Definition: LevelFluxRegister.H:34
void poutCoarseRegisters() const
Definition: LevelFluxRegister.H:39
int m_isDefined
Definition: LevelFluxRegister.H:297
Definition: LevelFluxRegister.H:37
bool hasCF(const DataIndex &a_fineDataIndex, Side::LoHiSide) const
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual ~LevelFluxRegister()
LayoutData< Vector< Box > > & getCoarseLocations(int a_idir, Side::LoHiSide a_sd)
Definition: LevelFluxRegister.H:272
LayoutData< Vector< Box > > m_coarseLocations[CH_SPACEDIM *2]
Definition: LevelFluxRegister.H:293
double Real
Definition: REAL.H:33
Copier m_reverseCopier
Definition: LevelFluxRegister.H:303
int m_nRefine
Definition: LevelFluxRegister.H:299
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
LoHiSide
Definition: LoHiSide.H:27
void incrementCoarse(const FArrayBox &a_coarseFlux, Real a_scale, const DataIndex &a_coarseDataIndex, const Interval &a_srcInterval, const Interval &a_dstInterval, int a_dir)
LevelData< FArrayBox > m_fineFlux
Definition: LevelFluxRegister.H:290
LevelFluxRegister-A class to encapsulate a levels worth of flux registers.
Definition: LevelFluxRegister.H:29
Definition: LevelFluxRegister.H:40
void reflux(LevelData< FArrayBox > &a_uCoarse, Real a_scale)
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
Definition: DataIndex.H:112
Definition: FArrayBox.H:44
LevelData< FArrayBox > m_coarFlux
Definition: LevelFluxRegister.H:289
ProblemDomain m_domain
Definition: LevelFluxRegister.H:295
void incrementFine(const FArrayBox &a_fineFlux, Real a_scale, const DataIndex &a_fineDataIndex, const Interval &a_srcInterval, const Interval &a_dstInterval, int a_dir)
void operator=(const LevelFluxRegister &)
there is no operator= for this class
Copier & getReverseCopier()
Definition: LevelFluxRegister.H:279
virtual void define(const DisjointBoxLayout &a_dbl, const DisjointBoxLayout &a_dblCoarse, const ProblemDomain &a_dProblem, int a_nRefine, int a_nComp, bool a_scaleFineFluxes)
bool isAllDefined() const
bool isDefined() const
Definition: LevelFluxRegister.H:38