00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _FINEINTERP_H_ 00012 #define _FINEINTERP_H_ 00013 00014 #include "REAL.H" 00015 #include "LevelData.H" 00016 #include "BaseFab.H" 00017 #include "FArrayBox.H" 00018 #include "ProblemDomain.H" 00019 #include "NamespaceHeader.H" 00020 00021 class DisjointBoxLayout; 00022 00023 /// replaces fine level data with interpolation of coarse level data. 00024 /** 00025 This class replaces data at a fine level of refinement with data 00026 interpolated from a coarser level of refinement. Interpolation is 00027 piecewise bi(tri)linear, with van Leer slopes if there is room for 00028 the stencil, with lower-order slopes if there isn't. See the 00029 design document. 00030 00031 */ 00032 class FineInterp 00033 { 00034 public: 00035 /// 00036 /** 00037 Default constructor. User must subsequently call define(). 00038 */ 00039 FineInterp(); 00040 00041 /// 00042 /** 00043 Destructor. 00044 */ 00045 ~FineInterp(); 00046 00047 /// 00048 /** 00049 Defining constructor. Constructs a valid object. 00050 Equivalent to default construction followed by define(). 00051 00052 {\bf Arguments:}\\ 00053 a_fine_domain (not modified): the fine level domain.\\ 00054 a_numcomps (not modified): the number of components.\\ 00055 a_ref_ratio (not modified): the refinement ratio.\\ 00056 a_fine_problem_domain (not modified): problem domain at the fine level.\\ 00057 00058 */ 00059 FineInterp(const DisjointBoxLayout& a_fine_domain, 00060 const int& a_numcomps, 00061 const int& a_ref_ratio, 00062 const Box& a_fine_problem_domain); 00063 00064 /// 00065 /** 00066 Defining constructor. Constructs a valid object. 00067 Equivalent to default construction followed by define(). 00068 00069 {\bf Arguments:}\\ 00070 a_fine_domain (not modified): the fine level domain.\\ 00071 a_numcomps (not modified): the number of components.\\ 00072 a_ref_ratio (not modified): the refinement ratio.\\ 00073 a_fine_problem_domain (not modified): problem domain at the fine level.\\ 00074 */ 00075 FineInterp(const DisjointBoxLayout& a_fine_domain, 00076 const int& a_numcomps, 00077 const int& a_ref_ratio, 00078 const ProblemDomain& a_fine_problem_domain); 00079 00080 /// 00081 /** 00082 Defines this object. Existing information is overriden. 00083 00084 {\bf Arguments:}\\ 00085 a_fine_domain (not modified): the fine level domain.\\ 00086 a_numcomps (not modified): the number of components.\\ 00087 a_ref_ratio (not modified): the refinement ratio.\\ 00088 a_fine_problem_domain (not modified): problem domain at the fine level.\\ 00089 00090 {\bf This:}\\ 00091 ---This object is modified.--- 00092 00093 */ 00094 void 00095 define(const DisjointBoxLayout& a_fine_domain, // the fine level domain 00096 const int& a_numcomps, // the number of components 00097 const int& a_ref_ratio, // the refinement ratio 00098 const Box& a_fine_problem_domain); // problem domain 00099 00100 /// 00101 /** 00102 Defines this object. Existing information is overriden. 00103 00104 {\bf Arguments:}\\ 00105 a_fine_domain (not modified): the fine level domain.\\ 00106 a_numcomps (not modified): the number of components.\\ 00107 a_ref_ratio (not modified): the refinement ratio.\\ 00108 a_fine_problem_domain (not modified): problem domain at the fine level.\\ 00109 00110 {\bf This:}\\ 00111 ---This object is modified.--- 00112 00113 */ 00114 void 00115 define(const DisjointBoxLayout& a_fine_domain, // the fine level domain 00116 const int& a_numcomps, // the number of components 00117 const int& a_ref_ratio, // the refinement ratio 00118 const ProblemDomain& a_fine_problem_domain); 00119 00120 /// 00121 /** 00122 Returns true if this object was created with the defining 00123 constructor or if define() has been called. 00124 00125 {\bf This:}\\ 00126 This object is not modified. 00127 */ 00128 bool 00129 isDefined() const; 00130 00131 /// 00132 /** 00133 Replaces a_fine_data with data interpolated from a_coarse_data. It 00134 is an error to call if not this->isDefined(). The domain of 00135 a_fine_data should be the same as the fine domain specified in the 00136 most recent call to define(). It is expected that the coarse and 00137 fine level's domains are properly nested. Both a_coarse_data and 00138 a_fine_data should have the same number of components specified in 00139 the most recent call to define(). 00140 00141 {\bf Arguments:}\\ 00142 a_fine_data (modified): fine data. \\ 00143 a_coarse_data (not modified): coarse data. \\ 00144 a_averageFromDest: if true, first average data from a_fine_data down 00145 to the resolution of a_coarse_data, then interp 00146 everything back up -- necessary when the coarse 00147 grids don't cover the fine grid (i.e when flattening 00148 an AMR hierarchy to a single resolution). Default is 00149 false. 00150 00151 00152 {\bf This:}\\ 00153 Well, it's complicated. As far as the user is concerned, this object 00154 is not modified. See the design document if you care for details. 00155 00156 */ 00157 void 00158 interpToFine(LevelData<FArrayBox>& a_fine_data, 00159 const LevelData<FArrayBox>& a_coarse_data, 00160 bool a_averageFromDest=false); 00161 00162 /// Just do piecewise-constant interpolation. 00163 void 00164 pwcinterpToFine(LevelData<FArrayBox>& a_fine_data, 00165 const LevelData<FArrayBox>& a_coarse_data, 00166 bool a_averageFromDest = false); 00167 00168 00169 /// 00170 enum BoundaryLimitType 00171 { 00172 limitSlopes = 0, 00173 noSlopeLimiting, 00174 PCInterp, 00175 NUM_LIMIT_TYPES 00176 }; 00177 00178 /// static variable to set default limiting behavior near domain boundaries 00179 /** 00180 This allows the user to define the default limiting behavior near 00181 domain boundaries. 00182 Near non-periodic domain boundaries, there are three options when 00183 computing interpolated values, corresponding to the three possible 00184 values in the BoundaryLimitType enum: 00185 limitSlopes -- normal piecewise-linear interpolation, with the standard 00186 vanLeer limiting of slopes to prevent new maxima. This 00187 requires that ghost-cell values be set on the coarse data 00188 at domain boundaries. 00189 noSlopeLimiting -- (default) piecewise-linear interpolation without 00190 limiting. This doesn't require coarse-level ghost 00191 cells be set, but may introduce new maxima/minima 00192 (or break positivity) for non-smooth functions. 00193 PCInterp -- piecewise-constant interpolation. Safest bet, since it's 00194 max/min-preserving without requiring that ghost cells be set, 00195 but also least accurate. 00196 00197 The basic idea here is that the user can over-ride the default behavior 00198 in favor of what an application demands by resetting the static variable. 00199 The default behavior can then be over-ridden for an individual 00200 instantiation of the FineInterp class by modifying the member variable 00201 m_boundary_limit_type. 00202 */ 00203 static int s_default_boundary_limit_type; 00204 00205 /// domain-boundary limiting behavior for this object 00206 /** default is to use whatever s_default_boundary_limit_type is at define 00207 time, but can be reset by the user at any time. 00208 */ 00209 int m_boundary_limit_type; 00210 00211 protected: 00212 void 00213 interpGridData(BaseFab<Real>& a_fine, 00214 const BaseFab<Real>& a_coarse, 00215 const Box& a_coarsened_fine_box, 00216 int a_ref_ratio) 00217 const; 00218 void 00219 pwcinterpGridData(BaseFab<Real>& a_fine, 00220 const BaseFab<Real>& a_coarse, 00221 const Box& a_coarsened_fine_box, 00222 int a_ref_ratio) const; 00223 00224 protected: 00225 bool is_defined; 00226 // the refinement ratio 00227 int m_ref_ratio; 00228 // work array for the coarse level data in a domain that is the 00229 // outline of the fine level domain on the coarse level 00230 LevelData<FArrayBox> m_coarsened_fine_data; 00231 // coarse level problem domain 00232 ProblemDomain m_coarse_problem_domain; 00233 }; 00234 00235 #include "NamespaceFooter.H" 00236 #endif