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