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