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  ///
171  {
176  };
177 
178  /// static variable to set default limiting behavior near domain boundaries
179  /**
180  This allows the user to define the default limiting behavior near
181  domain boundaries.
182  Near non-periodic domain boundaries, there are three options when
183  computing interpolated values, corresponding to the three possible
184  values in the BoundaryLimitType enum:
185  limitSlopes -- normal piecewise-linear interpolation, with the standard
186  vanLeer limiting of slopes to prevent new maxima. This
187  requires that ghost-cell values be set on the coarse data
188  at domain boundaries.
189  noSlopeLimiting -- (default) piecewise-linear interpolation without
190  limiting. This doesn't require coarse-level ghost
191  cells be set, but may introduce new maxima/minima
192  (or break positivity) for non-smooth functions.
193  PCInterp -- piecewise-constant interpolation. Safest bet, since it's
194  max/min-preserving without requiring that ghost cells be set,
195  but also least accurate.
196 
197  The basic idea here is that the user can over-ride the default behavior
198  in favor of what an application demands by resetting the static variable.
199  The default behavior can then be over-ridden for an individual
200  instantiation of the FineInterp class by modifying the member variable
201  m_boundary_limit_type.
202  */
204 
205  /// domain-boundary limiting behavior for this object
206  /** default is to use whatever s_default_boundary_limit_type is at define
207  time, but can be reset by the user at any time.
208  */
210 
211 protected:
212  void
214  const BaseFab<Real>& a_coarse,
215  const Box& a_coarsened_fine_box,
216  int a_ref_ratio)
217  const;
218  void
220  const BaseFab<Real>& a_coarse,
221  const Box& a_coarsened_fine_box,
222  int a_ref_ratio) const;
223 
224 protected:
226  // the refinement ratio
228  // work array for the coarse level data in a domain that is the
229  // outline of the fine level domain on the coarse level
231  // coarse level problem domain
233 };
234 
235 #include "NamespaceFooter.H"
236 #endif
ProblemDomain m_coarse_problem_domain
Definition: FineInterp.H:232
int m_boundary_limit_type
domain-boundary limiting behavior for this object
Definition: FineInterp.H:209
A class to facilitate interaction with physical boundary conditions.
Definition: ProblemDomain.H:141
Definition: FineInterp.H:172
bool is_defined
Definition: FineInterp.H:225
static int s_default_boundary_limit_type
static variable to set default limiting behavior near domain boundaries
Definition: FineInterp.H:203
Definition: FineInterp.H:175
bool isDefined() 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)
void interpGridData(BaseFab< Real > &a_fine, const BaseFab< Real > &a_coarse, const Box &a_coarsened_fine_box, int a_ref_ratio) const
void pwcinterpGridData(BaseFab< Real > &a_fine, const BaseFab< Real > &a_coarse, const Box &a_coarsened_fine_box, int a_ref_ratio) const
BoundaryLimitType
Definition: FineInterp.H:170
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:230
int m_ref_ratio
Definition: FineInterp.H:227
Definition: FineInterp.H:173
Definition: FineInterp.H:174
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.