Chombo + EB  3.2
FineInterp.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 _FINEINTERP_H_
12 #define _FINEINTERP_H_
13 
14 #include "REAL.H"
15 #include "LevelData.H"
16 #include "BaseFab.H"
17 #include "FArrayBox.H"
18 #include "ProblemDomain.H"
19 #include "NamespaceHeader.H"
20 
21 class DisjointBoxLayout;
22 
23 /// replaces fine level data with interpolation of coarse level data.
24 /**
25  This class replaces data at a fine level of refinement with data
26  interpolated from a coarser level of refinement. Interpolation is
27  piecewise bi(tri)linear, with van Leer slopes if there is room for
28  the stencil, with lower-order slopes if there isn't. See the
29  design document.
30 
31  */
33 {
34 public:
35  ///
36  /**
37  Default constructor. User must subsequently call define().
38  */
39  FineInterp();
40 
41  ///
42  /**
43  Destructor.
44  */
45  ~FineInterp();
46 
47  ///
48  /**
49  Defining constructor. Constructs a valid object.
50  Equivalent to default construction followed by define().
51 
52  {\bf Arguments:}\\
53  a_fine_domain (not modified): the fine level domain.\\
54  a_numcomps (not modified): the number of components.\\
55  a_ref_ratio (not modified): the refinement ratio.\\
56  a_fine_problem_domain (not modified): problem domain at the fine level.\\
57 
58  */
59  FineInterp(const DisjointBoxLayout& a_fine_domain,
60  const int& a_numcomps,
61  const int& a_ref_ratio,
62  const Box& a_fine_problem_domain);
63 
64  ///
65  /**
66  Defining constructor. Constructs a valid object.
67  Equivalent to default construction followed by define().
68 
69  {\bf Arguments:}\\
70  a_fine_domain (not modified): the fine level domain.\\
71  a_numcomps (not modified): the number of components.\\
72  a_ref_ratio (not modified): the refinement ratio.\\
73  a_fine_problem_domain (not modified): problem domain at the fine level.\\
74  */
75  FineInterp(const DisjointBoxLayout& a_fine_domain,
76  const int& a_numcomps,
77  const int& a_ref_ratio,
78  const ProblemDomain& a_fine_problem_domain);
79 
80  ///
81  /**
82  Defines this object. Existing information is overriden.
83 
84  {\bf Arguments:}\\
85  a_fine_domain (not modified): the fine level domain.\\
86  a_numcomps (not modified): the number of components.\\
87  a_ref_ratio (not modified): the refinement ratio.\\
88  a_fine_problem_domain (not modified): problem domain at the fine level.\\
89 
90  {\bf This:}\\
91  ---This object is modified.---
92 
93  */
94  void
95  define(const DisjointBoxLayout& a_fine_domain, // the fine level domain
96  const int& a_numcomps, // the number of components
97  const int& a_ref_ratio, // the refinement ratio
98  const Box& a_fine_problem_domain); // problem domain
99 
100  ///
101  /**
102  Defines this object. Existing information is overriden.
103 
104  {\bf Arguments:}\\
105  a_fine_domain (not modified): the fine level domain.\\
106  a_numcomps (not modified): the number of components.\\
107  a_ref_ratio (not modified): the refinement ratio.\\
108  a_fine_problem_domain (not modified): problem domain at the fine level.\\
109 
110  {\bf This:}\\
111  ---This object is modified.---
112 
113  */
114  void
115  define(const DisjointBoxLayout& a_fine_domain, // the fine level domain
116  const int& a_numcomps, // the number of components
117  const int& a_ref_ratio, // the refinement ratio
118  const ProblemDomain& a_fine_problem_domain);
119 
120  ///
121  /**
122  Returns true if this object was created with the defining
123  constructor or if define() has been called.
124 
125  {\bf This:}\\
126  This object is not modified.
127  */
128  bool
129  isDefined() const;
130 
131  ///
132  /**
133  Replaces a_fine_data with data interpolated from a_coarse_data. It
134  is an error to call if not this->isDefined(). The domain of
135  a_fine_data should be the same as the fine domain specified in the
136  most recent call to define(). It is expected that the coarse and
137  fine level's domains are properly nested. Both a_coarse_data and
138  a_fine_data should have the same number of components specified in
139  the most recent call to define().
140 
141  {\bf Arguments:}\\
142  a_fine_data (modified): fine data. \\
143  a_coarse_data (not modified): coarse data. \\
144  a_averageFromDest: if true, first average data from a_fine_data down
145  to the resolution of a_coarse_data, then interp
146  everything back up -- necessary when the coarse
147  grids don't cover the fine grid (i.e when flattening
148  an AMR hierarchy to a single resolution). Default is
149  false.
150 
151 
152  {\bf This:}\\
153  Well, it's complicated. As far as the user is concerned, this object
154  is not modified. See the design document if you care for details.
155 
156  */
157  void
158  interpToFine(LevelData<FArrayBox>& a_fine_data,
159  const LevelData<FArrayBox>& a_coarse_data,
160  bool a_averageFromDest=false);
161 
162  /// Just do piecewise-constant interpolation.
163  void
165  const LevelData<FArrayBox>& a_coarse_data,
166  bool a_averageFromDest = false);
167 
168 
169  /// enumeration of the different ways we can handle interpolation near domain boundaries
170  /**
171  limitSlopes -- turns on slope limiting in all directions near physical domain boundaries. This requires that ghost cell values be set to reasonable values
172  noSlopeLimiting -- turns off slope limiting near domain boundaries. This can produce new max/min values if you're unlucky.
173  PCInterp -- fall back to piecewise-constant interpolation near boundaries. This is safe, since you won't step out of bounds or create new max/min, but has lower accuracy
174  limitTangentialOnly -- limit slopes tangential to domain boundaries, fall back to Piecewise-constant interpolation (set slopes to 0) in the normal direction
175  */
176 
178  {
184  };
185 
186  /// static variable to set default limiting behavior near domain boundaries
187  /**
188  This allows the user to define the default limiting behavior near
189  domain boundaries.
190  Near non-periodic domain boundaries, there are four options when
191  computing interpolated values, corresponding to the four possible
192  values in the BoundaryLimitType enum:
193  limitSlopes -- normal piecewise-linear interpolation, with the standard
194  vanLeer limiting of slopes to prevent new maxima. This
195  requires that ghost-cell values be set on the coarse data
196  at domain boundaries.
197  noSlopeLimiting -- (default) piecewise-linear interpolation without
198  limiting. This doesn't require coarse-level ghost
199  cells be set, but may introduce new maxima/minima
200  (or break positivity) for non-smooth functions.
201  PCInterp -- piecewise-constant interpolation. Safest bet, since it's
202  max/min-preserving without requiring that ghost cells be set,
203  but also least accurate.
204 
205  limitTangentialOnly -- limit slopes in the coordinate directions
206  tangential to the boundary, while not limiting
207  in the normal direction. This is useful when you
208  don't have reasonable ghost-cell values but
209  still need limiting.
210 
211  The basic idea here is that the user can over-ride the default behavior
212  in favor of what an application demands by resetting the static variable.
213  The default behavior can then be over-ridden for an individual
214  instantiation of the FineInterp class by modifying the member variable
215  m_boundary_limit_type.
216  */
218 
219  /// domain-boundary limiting behavior for this object
220  /** default is to use whatever s_default_boundary_limit_type is at define
221  time, but can be reset by the user at any time.
222  */
224 
225 protected:
226  void
228  const BaseFab<Real>& a_coarse,
229  const Box& a_coarsened_fine_box,
230  int a_ref_ratio)
231  const;
232  void
234  const BaseFab<Real>& a_coarse,
235  const Box& a_coarsened_fine_box,
236  int a_ref_ratio) const;
237 
238 protected:
240  // the refinement ratio
242  // work array for the coarse level data in a domain that is the
243  // outline of the fine level domain on the coarse level
245  // coarse level problem domain
247 };
248 
249 #include "NamespaceFooter.H"
250 #endif
ProblemDomain m_coarse_problem_domain
Definition: FineInterp.H:246
int m_boundary_limit_type
domain-boundary limiting behavior for this object
Definition: FineInterp.H:223
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
Definition: FineInterp.H:182
Definition: FineInterp.H:179
bool is_defined
Definition: FineInterp.H:239
static int s_default_boundary_limit_type
static variable to set default limiting behavior near domain boundaries
Definition: FineInterp.H:217
Definition: FineInterp.H:183
void interpGridData(BaseFab< Real > &a_fine, const BaseFab< Real > &a_coarse, const Box &a_coarsened_fine_box, int a_ref_ratio) const
replaces fine level data with interpolation of coarse level data.
Definition: FineInterp.H:32
void define(const DisjointBoxLayout &a_fine_domain, const int &a_numcomps, const int &a_ref_ratio, const Box &a_fine_problem_domain)
BoundaryLimitType
enumeration of the different ways we can handle interpolation near domain boundaries ...
Definition: FineInterp.H:177
A BoxLayout that has a concept of disjointedness.
Definition: DisjointBoxLayout.H:30
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
LevelData< FArrayBox > m_coarsened_fine_data
Definition: FineInterp.H:244
bool isDefined() const
int m_ref_ratio
Definition: FineInterp.H:241
Definition: FineInterp.H:180
Definition: FineInterp.H:181
void pwcinterpGridData(BaseFab< Real > &a_fine, const BaseFab< Real > &a_coarse, const Box &a_coarsened_fine_box, int a_ref_ratio) const
void interpToFine(LevelData< FArrayBox > &a_fine_data, const LevelData< FArrayBox > &a_coarse_data, bool a_averageFromDest=false)
void pwcinterpToFine(LevelData< FArrayBox > &a_fine_data, const LevelData< FArrayBox > &a_coarse_data, bool a_averageFromDest=false)
Just do piecewise-constant interpolation.