Chombo + EB  3.0
EBCoarsen.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 _EBCOARSEN_H_
12 #define _EBCOARSEN_H_
13 
14 #include "REAL.H"
15 #include "FArrayBox.H"
16 #include "LevelData.H"
17 #include "EBLevelGrid.H"
18 #include "EBCellFAB.H"
19 #include "Interval.H"
20 #include "VoFIterator.H"
21 #include "NamespaceHeader.H"
22 class EBIndexSpace;
23 class VoFStencil;
24 
25 /// replaces coarse level data with a coarsening of fine level data.
26 /**
27  This class replaces data at a coarse level of refinement with a
28  coarsening of data at a finer level of refinement, in areas where fine
29  data is present. Coarse level data is not modified where fine
30  level data is not present.
31  */
32 class EBCoarsen
33 {
34 public:
35  ///
36  /**
37  Default constructor. User must subsequently call define().
38  */
39  EBCoarsen();
40 
41  ///
42  ~EBCoarsen();
43 
44  ///
45  /**
46  Defining constructor. Constructs a valid object.
47  Equivalent to default construction followed by define().
48 
49  {\bf Arguments:}\\
50  eblgFine, eblgCoar: The fine and coarse layouts
51  of the data.\\
52  nref: The refinement ratio between the two levels. \\
53  nvar: The number of variables contained in the data
54  at each VoF.
55  */
56  EBCoarsen(const EBLevelGrid& eblgFine,
57  const EBLevelGrid& eblgCoar,
58  const int& nref,
59  const int& nvar);
60 
61  ///
62  /**
63  Defines this object. Existing information is overriden.
64 
65  {\bf Arguments:}\\
66  eblgFine, eblgCoar: The fine and coarse layouts
67  of the data.\\
68  nref: The refinement ratio between the two levels. \\
69  nvar: The number of variables contained in the data
70  at each VoF.
71  */
72  void define(const EBLevelGrid& eblgFine,
73  const EBLevelGrid& eblgCoar,
74  const int& nref,
75  const int& nvar);
76 
77  ///
78  /**
79  Returns true if this object was created with the defining
80  constructor or if define() has been called.
81  */
82  bool isDefined() const;
83 
84  ///
85  /**
86  Replaces a_coarse_data with the coarsening of a_fine_data within the
87  coarsening of the domain of the fine level. This is different from
88  averaging in that we are trying to approximate the coarse value at
89  the cell center. (averaging approximates the average over the cell)
90  Elsewhere, the
91  coarse data is unchanged. It is an error to call if not
92  this->isDefined(). The domain of a_fine_data should be
93  the same as the fine domain specified in the most recent call to
94  define(). It is expected that the coarse and fine level's
95  domains are properly nested. Both a_coarse_data and a_fine_data
96  should have the same number of components specified in the most
97  recent call to define().
98  a_fine_data needs pre-filled ghost cells of size 1 ONLY IF refRat<4
99 
100  {\bf Arguments:}\\
101  coarData: The data over the coarse layout.\\
102  fineData: The data over the fine layout. \\
103  Fine and coarse data must
104  have the same number of variables.\\
105  variables: The variables to coarsen. Those not
106  in this range will be left alone. This range of variables
107  must be in both the coarse and fine data.
108  */
109  void
110  coarsenFine(LevelData<EBCellFAB>& a_coarData,
111  const LevelData<EBCellFAB>& a_fineData,
112  const Interval& a_variables);
113 protected:
114  void defineStencil(const LayoutData<IntVectSet>& a_cfivs);
115 
116  void coarsenIrreg(EBCellFAB& a_coar,
117  const EBCellFAB& a_fine,
118  const DataIndex& a_dit,
119  const Interval& a_variables);
120 
121  void checkStencil(VoFStencil& a_stencil,
122  const Real& a_sum) const;
123 
124  bool getVofsSideDir(Vector<VolIndex>& a_vofList,
125  const VolIndex& a_vof,
126  const IntVectSet& a_cfivs,
127  const EBISBox& a_ebisBox,
128  const int& a_dir,
129  const Side::LoHiSide& a_side,
130  const int& a_stepSize) const;
131 
132  void addWeight(VoFStencil& a_stencil,
133  const Vector<VolIndex>& a_vofList,
134  const Real& a_weight,
135  const bool& a_hasVof) const;
136 
137  void getCoarsenVoFStencil(VoFStencil& a_stencil,
138  const EBISBox& a_ebisBoxCoar,
139  const EBISBox& a_ebisBoxFine,
140  const VolIndex& a_vofCoar,
141  const DataIndex& a_datInd,
142  const IntVectSet& a_cfivs);
143 
144  void coarsenFAB(EBCellFAB& a_coar,
145  const EBCellFAB& a_fine,
146  const DataIndex& a_datInd,
147  const Interval& a_variables);
148 
149  void
151 
153 
159 
162 
165 
166  int m_refRat;
167  int m_nComp;
169 
172 
173 private:
174  //disallowed for all the usual reasons
175  EBCoarsen(const EBCoarsen& ebcin)
176  {
177  MayDay::Error("ebca 2 invalid operator");
178  }
179  void operator=(const EBCoarsen& fabin)
180  {
181  MayDay::Error("ebca 3 invalid operator");
182  }
183 
184 };
185 
186 #include "NamespaceFooter.H"
187 #endif
bool isDefined() const
A reference-counting handle class.
Definition: RefCountedPtr.H:66
An irregular domain on an integer lattice.
Definition: IntVectSet.H:44
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:130
void coarsenIrreg(EBCellFAB &a_coar, const EBCellFAB &a_fine, const DataIndex &a_dit, const Interval &a_variables)
Definition: EBIndexSpace.H:260
ProblemDomain m_domainCoar
Definition: EBCoarsen.H:157
EBCoarsen(const EBCoarsen &ebcin)
Definition: EBCoarsen.H:175
RefCountedPtr< LayoutData< IntVectSet > > m_cfivsPtr
Definition: EBCoarsen.H:164
Definition: EBISBox.H:46
Definition: EBLevelGrid.H:30
void checkStencil(VoFStencil &a_stencil, const Real &a_sum) const
bool getVofsSideDir(Vector< VolIndex > &a_vofList, const VolIndex &a_vof, const IntVectSet &a_cfivs, const EBISBox &a_ebisBox, const int &a_dir, const Side::LoHiSide &a_side, const int &a_stepSize) const
void define(const EBLevelGrid &eblgFine, const EBLevelGrid &eblgCoar, const int &nref, const int &nvar)
DisjointBoxLayout m_gridsFine
Definition: EBCoarsen.H:155
int m_nComp
Definition: EBCoarsen.H:167
void addWeight(VoFStencil &a_stencil, const Vector< VolIndex > &a_vofList, const Real &a_weight, const bool &a_hasVof) const
VoF-centered stencil.
Definition: Stencils.H:59
bool m_isDefined
Definition: EBCoarsen.H:152
void coarsenFAB(EBCellFAB &a_coar, const EBCellFAB &a_fine, const DataIndex &a_datInd, const Interval &a_variables)
Structure for passing component ranges in code.
Definition: Interval.H:23
Definition: EBCellFAB.H:29
int m_refRat
Definition: EBCoarsen.H:166
double Real
Definition: REAL.H:33
LayoutData< VoFIterator > m_vofIt
Definition: EBCoarsen.H:171
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
LoHiSide
Definition: LoHiSide.H:27
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.
EBISLayout m_coarsenedFineEBISL
Definition: EBCoarsen.H:163
EBISLayout m_ebislCoar
Definition: EBCoarsen.H:160
void defineStencil(const LayoutData< IntVectSet > &a_cfivs)
Definition: DataIndex.H:112
void getCoarsenVoFStencil(VoFStencil &a_stencil, const EBISBox &a_ebisBoxCoar, const EBISBox &a_ebisBoxFine, const VolIndex &a_vofCoar, const DataIndex &a_datInd, const IntVectSet &a_cfivs)
replaces coarse level data with a coarsening of fine level data.
Definition: EBCoarsen.H:32
Volume of Fluid Index.
Definition: VolIndex.H:31
void operator=(const EBCoarsen &fabin)
Definition: EBCoarsen.H:179
Definition: EBISLayout.H:39
EBISLayout m_ebislFine
Definition: EBCoarsen.H:161
LevelData< EBCellFAB > m_coarsenedFineData
Definition: EBCoarsen.H:168
DisjointBoxLayout m_gridsCoar
Definition: EBCoarsen.H:154
DisjointBoxLayout m_coarsenedFineGrids
Definition: EBCoarsen.H:156
ProblemDomain m_domainFine
Definition: EBCoarsen.H:158
void setDefaultValues()
void coarsenFine(LevelData< EBCellFAB > &a_coarData, const LevelData< EBCellFAB > &a_fineData, const Interval &a_variables)
LayoutData< BaseIVFAB< VoFStencil > > m_coarsenStencil
Definition: EBCoarsen.H:170