Chombo + EB  3.0
CoarseAverage.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 _COARSEAVERAGE_H_
12 #define _COARSEAVERAGE_H_
13 
14 #include "REAL.H"
15 #include "BaseFab.H"
16 #include "FArrayBox.H"
17 #include "LevelData.H"
18 #include "NamespaceHeader.H"
19 
20 class DisjointBoxLayout;
21 
22 /// replaces coarse level data with an average of fine level data.
23 /**
24  This class replaces data at a coarse level of refinement with an
25  average of data at a finer level of refinement, in areas where fine
26  data is present. Coarse level data is not modified where fine
27  level data is not present.
28 
29  */
31 {
32 public:
33 
34  ///
35  /**
36  Default constructor. User must subsequently call define().
37  */
38  CoarseAverage();
39 
40  ///
41  /**
42  Destructor.
43  */
45 
46  ///
47  /**
48  Defining constructor. Constructs a valid object.
49  Equivalent to default construction followed by define().
50 
51  {\bf Arguments:}\\
52  a_fine_domain (not modified): the fine level domain.\\
53  a_numcomps (not modified): the number of components.\\
54  a_ref_ratio (not modified): the refinement ratio. \\
55 
56  */
57  CoarseAverage(const DisjointBoxLayout& a_fine_domain,
58  int a_numcomps,
59  int a_ref_ratio);
60 
61  ///
62  /**
63  Defining constructor. Constructs a valid object.
64  Equivalent to default construction followed by define().
65  This version takes the coarser level as well, results in
66  a faster averaging operation, since Copier can be pre-constructed.
67 
68  {\bf Arguments:}\\
69  a_fine_domain (not modified): the fine level domain.\\
70  a_crse_domain (not modified): the crse level domain.\\
71  a_numcomps (not modified): the number of components.\\
72  a_ref_ratio (not modified): the refinement ratio.\\
73  a_ghostVect (not modified): radius of ghost cells around coarse grids to be filled (normally none)\
74 
75 
76  */
77  CoarseAverage(const DisjointBoxLayout& a_fine_domain,
78  const DisjointBoxLayout& a_crse_domain,
79  int a_numcomps,
80  int a_ref_ratio,
81  IntVect a_ghostVect = IntVect::Zero);
82 
83  ///
84  /**
85  Defines this object. Existing information is overriden.
86 
87  {\bf Arguments:}\\
88  a_fine_domain (not modified): the fine level domain.\\
89  a_numcomps (not modified): the number of components.\\
90  a_ref_ratio (not modified): the refinement ratio.\\
91 
92  {\bf This:}\\
93  ---This object is modified.---
94 
95  */
96  void
97  define(const DisjointBoxLayout& a_fine_domain, // the fine level domain
98  int a_numcomps, // the number of components
99  int a_ref_ratio); // the refinement ratio
100 
101 
102  ///
103  /**
104  Defines this object. Existing information is overriden.
105  This version takes the coarser-level grids as well, which
106  allows for a faster averaging operation, since the Copier
107  can be pre-defined
108 
109  {\bf Arguments:}\\
110  a_fine_domain (not modified): the fine level domain.\\
111  a_crse_domain (not modified): the coarse level domain.\\
112  a_numcomps (not modified): the number of components.\\
113  a_ref_ratio (not modified): the refinement ratio.\\
114  a_ghostVect (not modified): radius of ghost cells around coarse grids to be filled (normally none)\
115 
116  {\bf This:}\\
117  ---This object is modified.---
118 
119  */
120  void
121  define(const DisjointBoxLayout& a_fine_domain, // the fine level domain
122  const DisjointBoxLayout& a_crse_domain, // the crse level domain
123  int a_numcomps, // the number of components
124  int a_ref_ratio, // the refinement ratio
125  IntVect a_ghostVect = IntVect::Zero); // coarse-level ghost cells to be filled.
126 
127  ///
128  /**
129  Returns true if this object was created with the defining
130  constructor or if define() has been called.
131 
132  {\bf This:}\\
133  This object is not modified.
134  */
135  bool
136  isDefined() const;
137 
138  ///
139  /**
140  Replaces a_coarse_data with the average of a_fine_data within the
141  coarsening of the domain of the fine level. Elsewhere, the
142  coarse data is unchanged. It is an error to call if not
143  this->isDefined(). The domain of a_fine_data should be
144  the same as the fine domain specified in the most recent call to
145  define(). It is expected that the coarse and fine level's
146  domains are properly nested. Both a_coarse_data and a_fine_data
147  should have the same number of components specified in the most
148  recent call to define().
149 
150  {\bf Arguments:}\\
151  a_coarse_data (modified): coarse data. \\
152  a_fine_data (not modified): fine data. \\
153 
154  {\bf This:}\\
155  Well, it's complicated. As far as the user is concerned, this object
156  is not modified. See the design document if you care for details.
157 
158  */
159  // this method would like to be const, but the work array is changed.
160  // this suggests that the work array should not be persistent.
161  void
162  averageToCoarse(LevelData<FArrayBox>& a_coarse_data,
163  const LevelData<FArrayBox>& a_fine_data);
164 
165 
166  /// similar to averageToCoarse, except does a harmonic average
167  void
169  const LevelData<FArrayBox>& a_fine_data);
170 
171 
172  ///
174  {
178  };
179 
180 
181 protected:
182 
183 
184  /** utility function called by both averageToCoarse
185  and averageToCoarseHarmonic (to avoid code duplication)
186  */
187  void
188  computeAverages(LevelData<FArrayBox>& a_coarse_data,
189  const LevelData<FArrayBox>& a_fine_data,
190  int a_averageType);
191 
192  void
193  averageGridData(BaseFab<Real>& a_coarse,
194  const BaseFab<Real>& a_fine,
195  int a_ref_ratio,
196  int a_averageType)
197  const;
198 
199 protected:
201 
202  // the refinement ratio
204  // work array for the coarsening of the fine data, of the same "shape"
205  // as the fine data.
207 
208  // has a copier been defined to transfer data to coarse-grid layout?
210 
211  // cached copier to handle transfer to coarse-grid layout.
213 };
214 
215 #include "NamespaceFooter.H"
216 #endif
averageType
Definition: CoarseAverage.H:173
replaces coarse level data with an average of fine level data.
Definition: CoarseAverage.H:30
Definition: CoarseAverage.H:175
Definition: CoarseAverage.H:176
void averageToCoarseHarmonic(LevelData< FArrayBox > &a_coarse_data, const LevelData< FArrayBox > &a_fine_data)
similar to averageToCoarse, except does a harmonic average
A strange but true thing to make copying from one boxlayoutdata to another fast.
Definition: Copier.H:137
void define(const DisjointBoxLayout &a_fine_domain, int a_numcomps, int a_ref_ratio)
int m_ref_ratio
Definition: CoarseAverage.H:203
bool is_defined
Definition: CoarseAverage.H:200
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:31
LevelData< FArrayBox > m_coarsened_fine_data
Definition: CoarseAverage.H:206
static const IntVect Zero
Definition: IntVect.H:627
bool isDefined() const
void computeAverages(LevelData< FArrayBox > &a_coarse_data, const LevelData< FArrayBox > &a_fine_data, int a_averageType)
Copier m_copier
Definition: CoarseAverage.H:212
void averageGridData(BaseFab< Real > &a_coarse, const BaseFab< Real > &a_fine, int a_ref_ratio, int a_averageType) const
bool m_is_copier_defined
Definition: CoarseAverage.H:209
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
Definition: CoarseAverage.H:177
void averageToCoarse(LevelData< FArrayBox > &a_coarse_data, const LevelData< FArrayBox > &a_fine_data)