Chombo + EB  3.0
EBFastFR.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 _EBFASTFR_H_
12 #define _EBFASTFR_H_
13 
14 #include "REAL.H"
15 #include "Vector.H"
16 #include "EBCellFAB.H"
17 #include "EBFaceFAB.H"
18 #include "EBCellFactory.H"
19 #include "EBLevelDataOps.H"
20 #include "EBISLayout.H"
21 #include "EBISBox.H"
22 #include "IntVectSet.H"
23 #include "CFStencil.H"
24 #include "LoHiSide.H"
25 #include "LevelData.H"
26 #include "EBLevelGrid.H"
27 #include "LayoutData.H"
28 #include "LevelFluxRegister.H"
29 #include "NamespaceHeader.H"
30 class EBIndexSpace;
31 
32 ///EBFastFR-A class to encapsulate a levels worth of flux registers.
33 /**
34  A EBFastFR handles all the data choreography
35  necessary to create a levels worth of flux registers.
36  This only does the elliptic flux register stuff for now (no interacting with
37  redistribution, no RZ, no regular and regular separate).
38 */
39 class EBFastFR
40 {
41 public:
42  static bool s_verbose;
43  ///
44  /**
45  Default constructor. Leaves object undefined.
46  */
47  EBFastFR();
48 
49  ///
50  /**
51  Full constructor. Calls the define function which creates
52  a levels worth of flux registers.
53  */
54  EBFastFR(const EBLevelGrid& a_eblgFine,
55  const EBLevelGrid& a_eblgCoar,
56  const int& a_nref,
57  const int& a_nvar);
58 
59  ///
60  virtual ~EBFastFR();
61 
62  ///
63  /**
64  Full define function. Creates a levels worth of flux registers.
65  */
66  virtual void
67  define(const EBLevelGrid& a_eblgFine,
68  const EBLevelGrid& a_eblgCoar,
69  const int& a_nref,
70  const int& a_nvar);
71 
72  ///
73  /**
74  Initialize values of registers to zero.
75  */
76  virtual void
77  setToZero();
78 
79 
80  ///
81  /**
82  The irregular part of this is just
83  register = input flux (instead of increment)
84  To avoid double-counting.
85  */
86  virtual void
87  incrementCoarseBoth(const EBFaceFAB& a_coarseFlux,
88  const Real& a_scale,
89  const DataIndex& a_coarseDataIndex,
90  const Interval& a_variables,
91  const int& a_dir,
92  const Side::LoHiSide& a_sd);
93 
94 
95  ///
96  virtual void
97  incrementFineBoth(const EBFaceFAB& a_fineFlux,
98  const Real& a_scale,
99  const DataIndex& a_fineDataIndex,
100  const Interval& a_variables,
101  const int& a_dir,
102  const Side::LoHiSide& a_sd);
103 
104  void
105  compareFineSparse(const EBFaceFAB& a_fluxOld,
106  const EBFaceFAB& a_fluxNew,
107  const DataIndex& a_fineDatInd,
108  const int& a_dir,
109  const Side::LoHiSide& a_sd);
110 
111  ///to support baseiffab approach
112  virtual void
113  incrementFineSparse(const EBFaceFAB& a_fineFlux,
114  const Real& a_scale,
115  const DataIndex& a_fineDatInd,
116  const Interval& a_variables,
117  const int& a_dir,
118  const Side::LoHiSide& a_sd,
119  bool a_doingFineRegular);
120 
121  ///
122  virtual void reflux(LevelData<EBCellFAB>& a_uCoarse,
123  const Interval& a_variables,
124  const Real& a_scale,
125  bool a_multByKappaOneMinusKappa = false);
126 
127  ///
128  virtual void reflux(LevelData<EBCellFAB>& a_uCoarse,
129  const Interval& a_solutionvariables,
130  const Interval& a_fluxvariables,
131  const Real& a_scale,
132  bool a_multByKappaOneMinusKappa = false)
133  {
134  CH_assert(a_fluxvariables.size() == a_solutionvariables.size());
137  EBLevelDataOps::setToZero(diffCoar);
138  reflux(diffCoar, a_fluxvariables, a_scale, a_multByKappaOneMinusKappa);
139  for (DataIterator dit = m_eblgCoar.getDBL().dataIterator(); dit.ok(); ++dit)
140  {
141  int isrc = a_fluxvariables.begin();
142  int inco = a_fluxvariables.size();
143  int idst = a_solutionvariables.begin();
144  a_uCoarse[dit()].plus(diffCoar[dit()], isrc, idst, inco);
145  }
146  }
147 
148  ///
149  /**
150  Increments mass array with left-over mass
151  from reflux divergence. this is to test this pig.
152  Ordinarily this mass would go into redistribution. this
153  is used in the test suite to check whether a constant
154  flux refluxed and then unrefluxed (this function) ends up
155  with a constant solution.
156  Correction at each cell = (1-kappa)refluxCorrection.
157  */
159  const Interval& a_variables,
160  const Real& a_scale);
161 
162  ///
163  bool isDefined() const;
164 
165  static int index(int a_dir, Side::LoHiSide a_side);
166 
167  void incrementFineIrreg(const EBFaceFAB& a_fineFlux,
168  const Real& a_newScale,
169  const DataIndex& a_fineDatInd,
170  const Interval& a_variables,
171  const int& a_dir,
172  const Side::LoHiSide& a_sd);
173 
174  ///
175  /**
176  The irregular part of this is just
177  register = input flux (instead of increment)
178  To avoid double-counting.
179  The side argument is ignored.
180  */
181  void incrementCoarIrreg(const EBFaceFAB& a_coarFlux,
182  const Real& a_scale,
183  const DataIndex& a_coarDatInd,
184  const Interval& a_variables,
185  const int& a_dir,
186  const Side::LoHiSide& a_sd);
187 
188  void incrementFineRegul(const EBFaceFAB& a_fineFlux,
189  const Real& a_newScale,
190  const DataIndex& a_fineDatInd,
191  const Interval& a_variables,
192  const int& a_dir,
193  const Side::LoHiSide& a_sd);
194 
195  void incrementCoarRegul(const EBFaceFAB& a_coarFlux,
196  const Real& a_scale,
197  const DataIndex& a_coarDatInd,
198  const Interval& a_variables,
199  const int& a_dir,
200  const Side::LoHiSide& a_sd);
201 
202  bool hasEBCF() const
203  {
204  return m_hasEBCF;
205  }
206 
207  ///undefines object
208  void clear();
209 
210  ///
211  /**
212  Gets the set of vofs to fill a flux for on a particular side
213  and direction that correspond to an EB/CF interface. You still
214  need to fill all the other fluxes at the interface but you do not
215  have to do all the fancy interpolation to face centroids
216  that is needed at these key points since all the other C/F points
217  are treated as regular anyway.
218  Do not use this unless you really know what you are doing. Really.
219  Yes this breaks encapsulation but we do some pretty ugly things
220  for performance reasons, do we not?
221  */
223  const int& a_idir,
224  const Side::LoHiSide& a_sd)
225  {
226  int iloc = index(a_idir, a_sd);
227  return (m_vofiCoar[iloc])[a_dit];
228  }
229 
230  ///
231  /**
232  Gets the set of vofs to fill a flux for on a particular side
233  and direction that correspond to an EB/CF interface. You still
234  need to fill all the other fluxes at the interface but you do not
235  have to do all the fancy interpolation to face centroids
236  that is needed at these key points since all the other C/F points
237  are treated as regular anyway.
238  Do not use this unless you really know what you are doing. Really.
239  Yes this breaks encapsulation but we do some pretty ugly things
240  for performance reasons, do we not?
241  */
243  const int& a_idir,
244  const Side::LoHiSide& a_sd)
245  {
246  int iloc = index(a_idir, a_sd);
247  return (m_vofiCoFi[iloc])[a_dit];
248  }
249 
250  ///
251  const EBLevelGrid& getEBLGCoFi() const
252  {
253  return m_eblgCoFi;
254  }
255 
256 protected:
257 
258  void irregSetToZero();
259  void defineSetsAndIterators();
260  void defineBuffers();
261 
262  void cacheOldSolution(const LevelData<EBCellFAB>& a_uCoar,
263  const Interval& a_variables);
264 
266  const Interval& a_variables);
267 
268  void irregReflux(LevelData<EBCellFAB>& a_uCoar,
269  const Interval& a_variables,
270  const Real& a_scale,
271  bool a_multByKappaOneMinusKappa = false);
272 
274  LevelData<EBCellFAB>& a_fluxDiff,
275  const Interval & a_variables,
276  const Real & a_newScale,
277  bool a_multByOneMinusKappa,
278  bool a_multByKappaOneMinusKappa);
279 
280 
283 
284  void setDefaultValues();
288 
289  int m_refRat;
290  int m_nComp;
291 
292  //nrefdmo is the number of fine faces per coar face
293  //this is intrinsically dimension-dependent
295  bool m_hasEBCF;
296 
297 
298  bool computeHasEBCF();
303 
305 
306  //need to save stuff
307  //so we can do this in two stages.
309 
310  //fine fluxes*fine areas/nref^d-1
314 private:
315  //for all the usual reasons,
316  //there is no copy constructor for this class
317  //and there is no operator= for this class
318  //(there is no rule six).
319  void operator= (const EBFastFR& out)
320  {
321  MayDay::Error("invalid operator");
322  }
323  EBFastFR(const EBFastFR& out)
324  {
325  MayDay::Error("invalid operator");
326  }
327 };
328 #include "NamespaceFooter.H"
329 #endif
void incrementDensityArray(LevelData< EBCellFAB > &a_coarMass, const Interval &a_variables, const Real &a_scale)
EBFastFR-A class to encapsulate a levels worth of flux registers.
Definition: EBFastFR.H:39
LevelFluxRegister * m_levelFluxReg
Definition: EBFastFR.H:281
EBISLayout getEBISL() const
Definition: EBLevelGrid.H:93
void irregReflux(LevelData< EBCellFAB > &a_uCoar, const Interval &a_variables, const Real &a_scale, bool a_multByKappaOneMinusKappa=false)
#define CH_assert(cond)
Definition: CHArray.H:37
Definition: EBIndexSpace.H:260
EBLevelGrid m_eblgFine
Definition: EBFastFR.H:285
int m_nComp
Definition: EBFastFR.H:290
void irregSetToZero()
static int index(int a_dir, Side::LoHiSide a_side)
one dimensional dynamic array
Definition: Vector.H:52
int size() const
Definition: Interval.H:64
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:137
int begin() const
Definition: Interval.H:86
LevelData< EBCellFAB > m_delUCoFi
Definition: EBFastFR.H:311
Real m_nrefdmo
Definition: EBFastFR.H:294
Copier m_reverseCopier
Definition: EBFastFR.H:304
Factory class to produce EBCellFABs.
Definition: EBCellFactory.H:29
Definition: EBLevelGrid.H:30
bool computeHasEBCF()
virtual ~EBFastFR()
DisjointBoxLayout getDBL() const
Definition: EBLevelGrid.H:86
virtual bool ok() const
return true if this iterator is still in its Layout
Definition: LayoutIterator.H:110
Definition: DataIterator.H:140
Definition: EBFaceFAB.H:28
virtual void define(const EBLevelGrid &a_eblgFine, const EBLevelGrid &a_eblgCoar, const int &a_nref, const int &a_nvar)
virtual void incrementFineSparse(const EBFaceFAB &a_fineFlux, const Real &a_scale, const DataIndex &a_fineDatInd, const Interval &a_variables, const int &a_dir, const Side::LoHiSide &a_sd, bool a_doingFineRegular)
to support baseiffab approach
void restoreOldSolution(LevelData< EBCellFAB > &a_uCoar, const Interval &a_variables)
bool isDefined() const
const int SpaceDim
Definition: SPACE.H:39
void defineBuffers()
void compareFineSparse(const EBFaceFAB &a_fluxOld, const EBFaceFAB &a_fluxNew, const DataIndex &a_fineDatInd, const int &a_dir, const Side::LoHiSide &a_sd)
LayoutData< VoFIterator > m_vofiCoFi[2 *SpaceDim]
Definition: EBFastFR.H:299
LayoutData< Vector< VoFIterator > > m_vofiCoar[2 *SpaceDim]
Definition: EBFastFR.H:302
bool m_isDefined
Definition: EBFastFR.H:282
static bool s_verbose
Definition: EBFastFR.H:42
Structure for passing component ranges in code.
Definition: Interval.H:23
virtual void incrementCoarseBoth(const EBFaceFAB &a_coarseFlux, const Real &a_scale, const DataIndex &a_coarseDataIndex, const Interval &a_variables, const int &a_dir, const Side::LoHiSide &a_sd)
virtual void incrementFineBoth(const EBFaceFAB &a_fineFlux, const Real &a_scale, const DataIndex &a_fineDataIndex, const Interval &a_variables, const int &a_dir, const Side::LoHiSide &a_sd)
LevelData< EBCellFAB > m_delUDiff
Definition: EBFastFR.H:313
static void setToZero(LevelData< EBCellFAB > &a_result)
double Real
Definition: REAL.H:33
virtual void setToZero()
void incrementFineRegul(const EBFaceFAB &a_fineFlux, const Real &a_newScale, const DataIndex &a_fineDatInd, const Interval &a_variables, const int &a_dir, const Side::LoHiSide &a_sd)
EBLevelGrid m_eblgCoFi
Definition: EBFastFR.H:287
void incrementCoarRegul(const EBFaceFAB &a_coarFlux, const Real &a_scale, const DataIndex &a_coarDatInd, const Interval &a_variables, const int &a_dir, const Side::LoHiSide &a_sd)
LoHiSide
Definition: LoHiSide.H:27
void defineSetsAndIterators()
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.
const EBLevelGrid & getEBLGCoFi() const
Definition: EBFastFR.H:251
LevelFluxRegister-A class to encapsulate a levels worth of flux registers.
Definition: LevelFluxRegister.H:29
static const IntVect Zero
Definition: IntVect.H:627
LevelData< EBCellFAB > m_saveCoar
Definition: EBFastFR.H:308
VoFIterator & getVoFItCoFi(const DataIndex &a_dit, const int &a_idir, const Side::LoHiSide &a_sd)
Definition: EBFastFR.H:242
bool hasEBCF() const
Definition: EBFastFR.H:202
Definition: DataIndex.H:112
Iterator for all vofs within an IntVectSet and an Ebgraph.
Definition: VoFIterator.H:27
EBLevelGrid m_eblgCoar
Definition: EBFastFR.H:286
void clear()
undefines object
bool m_hasEBCF
Definition: EBFastFR.H:295
int m_refRat
Definition: EBFastFR.H:289
void incrementByRefluxDivergence(LevelData< EBCellFAB > &a_uCoar, LevelData< EBCellFAB > &a_fluxDiff, const Interval &a_variables, const Real &a_newScale, bool a_multByOneMinusKappa, bool a_multByKappaOneMinusKappa)
LayoutData< IntVectSet > m_setsCoFi[2 *SpaceDim]
Definition: EBFastFR.H:300
void incrementFineIrreg(const EBFaceFAB &a_fineFlux, const Real &a_newScale, const DataIndex &a_fineDatInd, const Interval &a_variables, const int &a_dir, const Side::LoHiSide &a_sd)
DataIterator dataIterator() const
Parallel iterator.
void cacheOldSolution(const LevelData< EBCellFAB > &a_uCoar, const Interval &a_variables)
void operator=(const EBFastFR &out)
Definition: EBFastFR.H:319
virtual void reflux(LevelData< EBCellFAB > &a_uCoarse, const Interval &a_variables, const Real &a_scale, bool a_multByKappaOneMinusKappa=false)
LayoutData< Vector< IntVectSet > > m_setsCoar[2 *SpaceDim]
Definition: EBFastFR.H:301
void setDefaultValues()
void incrementCoarIrreg(const EBFaceFAB &a_coarFlux, const Real &a_scale, const DataIndex &a_coarDatInd, const Interval &a_variables, const int &a_dir, const Side::LoHiSide &a_sd)
virtual void reflux(LevelData< EBCellFAB > &a_uCoarse, const Interval &a_solutionvariables, const Interval &a_fluxvariables, const Real &a_scale, bool a_multByKappaOneMinusKappa=false)
Definition: EBFastFR.H:128
Vector< VoFIterator > & getVoFItCoar(const DataIndex &a_dit, const int &a_idir, const Side::LoHiSide &a_sd)
Definition: EBFastFR.H:222
LevelData< EBCellFAB > m_delUCoar
Definition: EBFastFR.H:312
EBFastFR(const EBFastFR &out)
Definition: EBFastFR.H:323