Chombo + EB + MF  3.2
NodeCoarseAverage.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 _NODECOARSEAVERAGE_H_
12 #define _NODECOARSEAVERAGE_H_
13 
14 #include "REAL.H"
15 #include "BaseFab.H"
16 #include "IntVectSet.H"
17 #include "NodeFArrayBox.H"
18 #include "LevelData.H"
19 #include "DisjointBoxLayout.H"
20 #include "BitSet.H"
21 #include "NamespaceHeader.H"
22 
23 /// Replaces coarse-level data with an average of fine-level data
24 
26 /**
27  This class replaces data at a coarse level of refinement with an
28  average of data at a finer level of refinement, in areas where fine
29  data is present. Coarse-level data is not modified where fine-level
30  data is not present.
31  */
32 {
33 public:
34 
35  /**
36  \name Constructors, destructor and defines
37  */
38  /*@{*/
39 
40  ///
41  /** Default constructor. User must subsequently call define().
42  */
44 
45  ///
46  /** Defining constructor. Calls define() function with
47  identical arguments.
48  */
49  NodeCoarseAverage(const DisjointBoxLayout& a_gridsFine,
50  const DisjointBoxLayout& a_gridsCoarse,
51  int a_numcomps,
52  int a_refRatio,
53  const ProblemDomain& a_domainFine);
54 
55  ///
56  /** Defining constructor. Calls define() function with
57  identical arguments.
58  */
59  NodeCoarseAverage(const DisjointBoxLayout& a_gridsFine,
60  const DisjointBoxLayout& a_gridsCoarse,
61  int a_numcomps,
62  int a_refRatio,
63  const Box& a_domainFine);
64 
65  ///
66  /** Defining constructor. Calls define() function with
67  identical arguments.
68  */
69  NodeCoarseAverage(const DisjointBoxLayout& a_gridsCoarse,
70  int a_numcomps,
71  int a_refRatio,
72  const ProblemDomain& a_domainFine);
73 
74  ///
75  /** Defining constructor. Calls define() function with
76  identical arguments.
77  */
78  NodeCoarseAverage(const DisjointBoxLayout& a_gridsCoarse,
79  int a_numcomps,
80  int a_refRatio,
81  const Box& a_domainFine);
82 
83  ///
84  /** Destructor.
85  */
87 
88  ///
89  /** Defines this object. Existing information is overriden.
90  */
91  void define(/// CELL-centered grids at the fine level
92  const DisjointBoxLayout& a_gridsFine,
93  /// CELL-centered grids at the coarse level
94  const DisjointBoxLayout& a_gridsCoarse,
95  /// number of components of data
96  int a_numcomps,
97  /// refinement ratio between the two levels
98  int a_refRatio,
99  /// CELL-centered physical domain at the fine level
100  const ProblemDomain& a_domainFine);
101 
102  ///
103  /** Defines this object. Existing information is overriden.
104  */
105  void define(/// CELL-centered grids at the fine level
106  const DisjointBoxLayout& a_gridsFine,
107  /// CELL-centered grids at the coarse level
108  const DisjointBoxLayout& a_gridsCoarse,
109  /// number of components of data
110  int a_numcomps,
111  /// refinement ratio between the two levels
112  int a_refRatio,
113  /// CELL-centered physical domain at the fine level
114  const Box& a_domainFine);
115 
116 
117  ///
118  /** Defines this object. Existing information is overriden.
119  Fine grids are refinements of coarse grids.
120  */
121  void define(/// CELL-centered grids at the coarse level
122  const DisjointBoxLayout& a_gridsCoarse,
123  /// number of components of data
124  int a_numcomps,
125  /// refinement ratio between the two levels
126  int a_refRatio,
127  /// CELL-centered physical domain at the fine level
128  const ProblemDomain& a_domainFine);
129 
130  ///
131  /** Defines this object. Existing information is overriden.
132  Fine grids are refinements of coarse grids.
133  */
134  void define(/// CELL-centered grids at the coarse level
135  const DisjointBoxLayout& a_gridsCoarse,
136  /// number of components of data
137  int a_numcomps,
138  /// refinement ratio between the two levels
139  int a_refRatio,
140  /// CELL-centered physical domain at the fine level
141  const Box& a_domainFine);
142 
143  /*@}*/
144 
145  /**
146  \name Access functions
147  */
148  /*@{*/
149 
150  ///
151  /** Returns <tt>true</tt> if this object was created with the defining
152  constructor or if define() has been called.
153  */
154  bool isDefined() const;
155 
156  ///
157  /** Set whether the solver gives output while solving.
158  Default is <tt>true</tt>.
159  */
160  void setVerbose( bool a_verbose );
161 
162 
163  /*@}*/
164 
165  /**
166  \name Data modification functions
167  */
168  /*@{*/
169 
170  ///
171  /** Replaces coarse data with the average of nearby cells' fine data
172  on the interior nodes of the coarsened fine-level domain.
173  Elsewhere, the coarse data is unchanged.
174 
175  It is an error to call if not this->isDefined().
176 
177  The domain of <i>a_fine</i> should be the same as <i>a_gridsFine</i>
178  specified in the most recent call to define().
179 
180  It is expected that the coarse and fine levels'
181  domains are properly nested. Both <i>a_coarse</i> and <i>a_fine</i>
182  should have the same number of components specified in
183  the most recent call to define().
184 
185  The fine data is modified only in exchange().
186  A work array is also modified.
187  */
188  // this method would like to be const, but the work array is changed.
189  // this suggests that the work array should not be persistent.
190  void averageToCoarse(/// coarse data
191  LevelData<NodeFArrayBox>& a_coarse,
192  /// fine data, modified in exchange()
193  LevelData<NodeFArrayBox>& a_fine);
194 
195  /*@}*/
196 
197 protected:
198 
199  /** has this NodeCoarseAverage object been defined yet?
200  */
202 
203  /** flag for verbose output
204  */
205  bool m_verbose;
206 
207  /** the refinement ratio between the two levels
208  */
210 
211  /** the number of components of data, used in work array
212  */
214 
215  /** CELL-centered physical domain at the coarser level
216  */
218 
219  /** box with indices from -<i>m_refRatio</i>/2 to +<i>m_refRatio</i>/2
220  in all directions
221  */
223 
224  /** weights for coarsening
225  */
227 
228  /** are the fine grids merely refined versions of the coarse grids?
229  */
231 
232  /** CELL-centered grids at the finer level, coarsened by <i>m_refRatio</i>
233  */
235 
236  /** work array for the coarsening of the fine data, based on the layout
237  <i>m_coarsenedGrids</i> */
239 
240  /** interior boundary nodes of coarsened finer-level grids,
241  distributed among the coarser-level grids */
243 
244  /** whether each section of <i>m_IVSVsame</i> is a complete box
245  */
247 
248  /** interior boundary nodes of coarsened finer-level grids,
249  distributed among the same grids */
251 };
252 
253 #include "NamespaceFooter.H"
254 #endif
void define(const DisjointBoxLayout &a_gridsFine, const DisjointBoxLayout &a_gridsCoarse, int a_numcomps, int a_refRatio, const ProblemDomain &a_domainFine)
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
LayoutData< BitSet > m_IVSVfull
Definition: NodeCoarseAverage.H:246
Data that maintains a one-to-one mapping of T to the boxes in a BoxLayout.
Definition: BoxLayout.H:26
bool is_defined
Definition: NodeCoarseAverage.H:201
bool m_verbose
Definition: NodeCoarseAverage.H:205
FArrayBox m_weights
Definition: NodeCoarseAverage.H:226
void setVerbose(bool a_verbose)
DisjointBoxLayout m_coarsenedGrids
Definition: NodeCoarseAverage.H:234
void averageToCoarse(LevelData< NodeFArrayBox > &a_coarse, LevelData< NodeFArrayBox > &a_fine)
ProblemDomain m_domainCoarse
Definition: NodeCoarseAverage.H:217
int m_numcomps
Definition: NodeCoarseAverage.H:213
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
int m_refRatio
Definition: NodeCoarseAverage.H:209
bool m_sameGrids
Definition: NodeCoarseAverage.H:230
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:469
LevelData< NodeFArrayBox > m_coarsenedFine
Definition: NodeCoarseAverage.H:238
Definition: FArrayBox.H:45
Box m_refbox
Definition: NodeCoarseAverage.H:222
LayoutData< Vector< IntVectSet > > m_IVSV
Definition: NodeCoarseAverage.H:242
Replaces coarse-level data with an average of fine-level data.
Definition: NodeCoarseAverage.H:25
LayoutData< Vector< IntVectSet > > m_IVSVsame
Definition: NodeCoarseAverage.H:250
bool isDefined() const