Chombo + EB  3.0
LevelFluxRegisterEdge.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 _LEVELFLUXREGISTEREDGE_H_
12 #define _LEVELFLUXREGISTEREDGE_H_
13 
14 #include "REAL.H"
15 #include "Vector.H"
16 #include "FluxBox.H"
17 #include "EdgeDataBox.H"
18 #include "IntVectSet.H"
19 #include "CFStencil.H"
20 #include "LoHiSide.H"
21 #include "LevelData.H"
22 #include "LayoutData.H"
23 
24 #include "NamespaceHeader.H"
25 
26 ///LevelFluxRegisterEdge -- Flux register for constrained-transport applications
27 /**
28  A LevelFluxRegisterEdge manages the coarse-fine fixup for a face-centered
29  field which is defined as a curl of an edge-centered field, performing
30  the "reflux-curl" operation described in Balsara(2001) to preserve the
31  divergence-free magnetic field in the presence of coarse-fine interfaces.
32 
33  This class performs a reflux-curl of edge-centered fluxes to correct a
34  face-centered field. This is in contrast to the regular LevelFluxRegister
35  class, which performs a reflux-divergence of face-centered fluxes to
36  correct a cell-centered field.
37  */
39 {
40 public:
41 
42  ///
43  /**
44  Default constructor. Creates an uninitialized LevelFluxRegisterEdge.
45  */
47 
48  ///
49  /**
50  Full constructor. Calls the define function which creates
51  a levels worth of flux registers.
52  */
54  const DisjointBoxLayout& a_dbl,
55  const DisjointBoxLayout& a_dblCoarse,
56  const Box& a_dProblem,
57  int a_nRefine,
58  int a_nComp);
59 
60  ///
61  /**
62  Full constructor. Calls the define function which creates
63  a levels worth of flux registers.
64  */
66  const DisjointBoxLayout& a_dbl,
67  const DisjointBoxLayout& a_dblCoarse,
68  const ProblemDomain& a_dProblem,
69  int a_nRefine,
70  int a_nComp);
71 
72  ///
74 
75  ///
76  /**
77  Full define function. Creates a levels worth of flux registers.
78  The values in the flux registers are still undefined, however.
79  To zero the fluxregisters, you must call setToZero().
80  */
81  void define(
82  const DisjointBoxLayout& a_dbl,
83  const DisjointBoxLayout& a_dblCoarse,
84  const Box& a_dProblem,
85  int a_nRefine,
86  int a_nComp);
87 
88 
89  ///
90  /**
91  Full define function. Creates a levels worth of flux registers.
92  The values in the flux registers are still undefined, however.
93  To zero the fluxregisters, you must call setToZero().
94  */
95  void define(
96  const DisjointBoxLayout& a_dbl,
97  const DisjointBoxLayout& a_dblCoarse,
98  const ProblemDomain& a_dProblem,
99  int a_nRefine,
100  int a_nComp);
101 
102 ///
103 /**
104  Modifies this LevelFluxRegisterEdge so that it is returned to the
105  uninitialized state. User must now call the full define() before
106  using it.
107 
108 */
109  void
110  undefine();
111 
112  ///
113  /**
114  Initialize values of registers to zero.
115  */
116  void setToZero();
117 
118  ///
119  /**
120  increments the register with data from coarseFlux, multiplied by scale.
121  coarseFlux must contain the edge-centered (in 3d, node centered in
122  2d) coarse fluxes in the dir direction
123  for the grid m_coarseLayout[coarseDataIndex].
124  By convention, only the low side flux is used to
125  avoid double-counting at coarse-fine interfaces.
126  This operation is local.
127  */
128  void incrementCoarse(
129  FArrayBox& a_coarseFlux,
130  Real a_scale,
131  const DataIndex& a_coarseDataIndex,
132  const Interval& a_srcInterval,
133  const Interval& a_dstInterval);
134 
135  ///
136  /**
137  increments the register with data from fineFlux (which is edge-centered
138  in 3d, node-centered in 2d), multiplied by scale, for all coarse-fine
139  face directions associated with the grid box m_fineLayout[fineDataIndex]
140  This operation is local.
141  */
142  void incrementFine(
143  FArrayBox& a_fineFlux,
144  Real a_scale,
145  const DataIndex& a_fineDataIndex,
146  const Interval& a_srcInterval,
147  const Interval& a_dstInterval);
148 
149 
150  ///
151  /**
152  increments the register with data from fineFlux (which is edge-centered
153  in 3d, node-centered in 2d), multiplied by scale.
154  a_dir is the normal of the coarse-fine interface, and a_sd determines
155  whether we're looking at the high-side or the low-side
156  for the grid box m_fineLayout[fineDataIndex]
157  This operation is local.
158  */
159  void incrementFine(
160  FArrayBox& a_fineFlux,
161  Real a_scale,
162  const DataIndex& a_fineDataIndex,
163  const Interval& a_srcInterval,
164  const Interval& a_dstInterval,
165  int a_dir,
166  Side::LoHiSide a_sd);
167 
168  ///
169  /**
170  increments uCoarse with the reflux "CURL" of the
171  contents of the flux register.
172  Note that there is no srccomp etc crap here.
173  this is done for all components so uCoarse has
174  to have the same number of components as input nComp.
175  This operation is global and blocking.
176  */
177  void refluxCurl(
178  LevelData<FluxBox>& a_uCoarse,
179  Real a_scale);
180 
181  ///
182  /**
183  has full define function been called? return true if so.
184  */
185  bool isDefined() const;
186 
187  //write the contents of all the registers
188  void dump();
189 
190  //spew the contents of all the low coar registers
191  void dumpLoCoar(int idir);
192 
193  //spew the contents of all the high coar registers
194  void dumpHiCoar(int idir);
195 
196  //spew the contents of all the low fine registers
197  void dumpLoFine(int idir);
198 
199  //spew the contents of all the high fine registers
200  void dumpHiFine(int idir);
201 protected:
202 
203  static int index(int dir, Side::LoHiSide side);
204 
205  static int getRegComp(const int& faceDir, const int& edgeDir);
206 
207  //internal use only
208  void setDefaultValues();
209 
210  // both fabCoarse and fabFine have FluxBoxes that are
211  // defined in the coarse index space. fabCoarse
212  // can ONLY be indexed into by the DataIndex stored in
213  // coarToCoarMap. fabFine is indexed by the same indexing
214  // used in the fine DisjointBoxLayout.
217 
218  // in an attempt to speed things up in the periodic case especially,
219  // precompute copiers used to copy from fabFine to coarse-level-indexed
220  // fabs
222 
223  /**: reflux locations -- need SpaceDim of these to account
224  for the different face directions, which explains the extra
225  Vector */
228 
230 
231  ///number of components in register
232  int m_nComp;
233 
234  ///refinement ratio between levels
236 
237  /// domain at the coarse grid resolution
239 
240 private:
241 
242  ///there is no operator= for this class
243  void operator= (const LevelFluxRegisterEdge&);
244  ///there is no copy constructor for this class
246 };
247 
248 #include "NamespaceFooter.H"
249 
250 #endif
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
Data that maintains a one-to-one mapping of T to the boxes in a BoxLayout.
Definition: LayoutData.H:46
int m_nComp
number of components in register
Definition: LevelFluxRegisterEdge.H:232
LevelData< FluxBox > m_fabFine[SpaceDim *2]
Definition: LevelFluxRegisterEdge.H:216
ProblemDomain m_domainCoarse
domain at the coarse grid resolution
Definition: LevelFluxRegisterEdge.H:238
const int SpaceDim
Definition: SPACE.H:39
bool isDefined() const
LayoutData< Vector< Vector< IntVectSet > > > m_refluxLocations[SpaceDim *2]
Definition: LevelFluxRegisterEdge.H:226
LayoutData< Vector< DataIndex > > m_coarToCoarMap[SpaceDim *2]
Definition: LevelFluxRegisterEdge.H:227
void operator=(const LevelFluxRegisterEdge &)
there is no operator= for this class
Structure for passing component ranges in code.
Definition: Interval.H:23
double Real
Definition: REAL.H:33
LevelFluxRegisterEdge – Flux register for constrained-transport applications.
Definition: LevelFluxRegisterEdge.H:38
Vector< Copier > m_crseCopiers
Definition: LevelFluxRegisterEdge.H:221
bool m_isDefined
Definition: LevelFluxRegisterEdge.H:229
LevelData< EdgeDataBox > m_regCoarse
Definition: LevelFluxRegisterEdge.H:215
void dumpLoCoar(int idir)
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
LoHiSide
Definition: LoHiSide.H:27
void refluxCurl(LevelData< FluxBox > &a_uCoarse, Real a_scale)
static int getRegComp(const int &faceDir, const int &edgeDir)
void incrementFine(FArrayBox &a_fineFlux, Real a_scale, const DataIndex &a_fineDataIndex, const Interval &a_srcInterval, const Interval &a_dstInterval)
void dumpHiFine(int idir)
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
void define(const DisjointBoxLayout &a_dbl, const DisjointBoxLayout &a_dblCoarse, const Box &a_dProblem, int a_nRefine, int a_nComp)
Definition: DataIndex.H:112
void incrementCoarse(FArrayBox &a_coarseFlux, Real a_scale, const DataIndex &a_coarseDataIndex, const Interval &a_srcInterval, const Interval &a_dstInterval)
Definition: FArrayBox.H:44
int m_nRefine
refinement ratio between levels
Definition: LevelFluxRegisterEdge.H:235
static int index(int dir, Side::LoHiSide side)
void dumpHiCoar(int idir)
void dumpLoFine(int idir)