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 _PIECEWISELINEARFILLPATCHFACE_H_ 00012 #define _PIECEWISELINEARFILLPATCHFACE_H_ 00013 00014 #include <iostream> 00015 #include <fstream> 00016 #include "REAL.H" 00017 #include "Box.H" 00018 #include "FArrayBox.H" 00019 #include "FluxBox.H" 00020 #include "LevelData.H" 00021 #include "DisjointBoxLayout.H" 00022 #include "IntVectSet.H" 00023 #include "ProblemDomain.H" 00024 00025 #include "NamespaceHeader.H" 00026 00027 /// Fills ghost cells by linear interpolation in space and time 00028 00029 /** 00030 Fills some fine level ghost "faces" by piecewise linear interpolation 00031 from the coarse level. 00032 00033 This class fills the first a_interp_radius layers of fine level 00034 ghost cells that are not part of other fine level grids. It uses 00035 piecewise linear interpolation from the coarse level. The slopes 00036 are computed using van leer limiting if there is enough room for 00037 the stencil. It drops order and uses first-order one-sided 00038 differences otherwise. 00039 00040 00041 */ 00042 00043 class PiecewiseLinearFillPatchFace 00044 { 00045 public: 00046 /// 00047 /** 00048 Default constructor. User must subsequently call define(). 00049 */ 00050 PiecewiseLinearFillPatchFace(); 00051 00052 /// 00053 /** 00054 Destructor. 00055 */ 00056 ~PiecewiseLinearFillPatchFace(); 00057 00058 /// 00059 /** 00060 Defining constructor. 00061 00062 {\bf Arguments:}\\ 00063 a_fine_domain (not modified): domain of fine level. \\ 00064 a_coarse_domain (not modified): domain of coarse level. \\ 00065 a_num_comps (not modified): number of components of state vector. \\ 00066 a_crse_problem_domain (not modified): problem domain on the coarse level.\\ 00067 a_ref_ratio (not modified): refinement ratio. \\ 00068 a_interp_radius (not modified): number of layers of fine ghost cells to fill by interpolation. \\ 00069 */ 00070 PiecewiseLinearFillPatchFace(const DisjointBoxLayout& a_fine_domain, 00071 const DisjointBoxLayout& a_coarse_domain, 00072 int a_num_comps, 00073 const Box& a_crse_problem_domain, 00074 int a_ref_ratio, 00075 int a_interp_radius 00076 ); 00077 00078 00079 /// 00080 /** 00081 Defining constructor. 00082 00083 {\bf Arguments:}\\ 00084 a_fine_domain (not modified): domain of fine level. \\ 00085 a_coarse_domain (not modified): domain of coarse level. \\ 00086 a_num_comps (not modified): number of components of state vector. \\ 00087 a_crse_problem_domain (not modified): problem domain on the coarse level.\\ 00088 a_ref_ratio (not modified): refinement ratio. \\ 00089 a_interp_radius (not modified): number of layers of fine ghost cells to fill by interpolation. \\ 00090 */ 00091 PiecewiseLinearFillPatchFace(const DisjointBoxLayout& a_fine_domain, 00092 const DisjointBoxLayout& a_coarse_domain, 00093 int a_num_comps, 00094 const ProblemDomain& a_crse_problem_domain, 00095 int a_ref_ratio, 00096 int a_interp_radius 00097 ); 00098 00099 /// 00100 /** 00101 Defines this object. The user may call define() once and call 00102 fillInterp() multiple times with different valid data sets. 00103 00104 {\bf Arguments:}\\ 00105 a_fine_domain (not modified): domain of fine level. \\ 00106 a_coarse_domain (not modified): domain of coarse level. \\ 00107 a_num_comps (not modified): number of components of state vector. \\ 00108 a_crse_problem_domain (not modified): problem domain on the coarse level.\\ 00109 a_ref_ratio (not modified): refinement ratio. \\ 00110 a_interp_radius (not modified): number of layers of fine ghost cells to fill by interpolation. \\ 00111 00112 {\bf This:}\\ 00113 ---This object is modified.--- 00114 00115 */ 00116 void 00117 define(const DisjointBoxLayout& a_fine_domain, 00118 const DisjointBoxLayout& a_coarse_domain, 00119 int a_num_comps, 00120 const Box& a_crse_problem_domain, 00121 int a_ref_ratio, 00122 int a_interp_radius 00123 ); 00124 00125 00126 /// 00127 /** 00128 Defines this object. The user may call define() once and call 00129 fillInterp() multiple times with different valid data sets. 00130 00131 {\bf Arguments:}\\ 00132 a_fine_domain (not modified): domain of fine level. \\ 00133 a_coarse_domain (not modified): domain of coarse level. \\ 00134 a_num_comps (not modified): number of components of state vector. \\ 00135 a_crse_problem_domain (not modified): problem domain on the coarse level.\\ 00136 a_ref_ratio (not modified): refinement ratio. \\ 00137 a_interp_radius (not modified): number of layers of fine ghost cells to fill by interpolation. \\ 00138 00139 {\bf This:}\\ 00140 ---This object is modified.--- 00141 00142 */ 00143 void 00144 define(const DisjointBoxLayout& a_fine_domain, 00145 const DisjointBoxLayout& a_coarse_domain, 00146 int a_num_comps, 00147 const ProblemDomain& a_crse_problem_domain, 00148 int a_ref_ratio, 00149 int a_interp_radius 00150 ); 00151 00152 /// 00153 /** 00154 Returns true if this object was created with the defining 00155 constructor or if define() has been called. 00156 00157 {\bf This:}\\ 00158 This object is not modified. 00159 */ 00160 bool 00161 isDefined() const; 00162 00163 /// 00164 /** 00165 This is an adaptation of the Cell-centered PiecewiseLinearFillPatch 00166 class for face-centered data. 00167 00168 00169 Fills the first m_interp_radius layers of fine ghost cells by 00170 interpolation from the coarse level. It is an error to call if not 00171 this->isDefined(). The range components to interpolate must be 00172 specified. The corresponding components on the coarse and fine 00173 levels may be different. It is required that a_fine_data's domain 00174 is the same as was specified in the most recent call to define(). 00175 It is expected that the coarse and fine level's domains are 00176 properly nested. 00177 00178 {\bf Arguments:}\\ 00179 a_fine_data (modified): fine-level data being interpolated to.\\ 00180 a_old_coarse_data (not modified): coarse level source data at the old time.\\ 00181 a_new_coarse_data (not modified): coarse level source data at the new time.\\ 00182 a_time_interp_coef (not modified): time interpolation coefficient, in the range [0:1]. 0=old time, 1=new time.\\ 00183 a_src_comp (not modifed): starting coarse data component.\\ 00184 a_dest_comp (not modifed): starting fine data component.\\ 00185 a_num_comp (not modified): number of data components to be 00186 interpolated. 00187 00188 {\bf This:}\\ 00189 Well, it's complicated. As far as the user is concerned, this object 00190 is not modified. See the design document if you care for details. 00191 00192 */ 00193 void 00194 fillInterp(LevelData<FluxBox>& a_fine_data, 00195 const LevelData<FluxBox>& a_old_coarse_data, 00196 const LevelData<FluxBox>& a_new_coarse_data, 00197 Real a_time_interp_coef, 00198 int a_src_comp, 00199 int a_dest_comp, 00200 int a_num_comp 00201 ); 00202 00203 // debugging utilities 00204 void 00205 printIntVectSets() const; 00206 00207 00208 protected: 00209 // copy coarse data to coarsened fine work array and interpolate to 00210 // fine time level 00211 void 00212 timeInterp(LevelData<FluxBox>& m_coarsened_fine_data, 00213 const LevelData<FluxBox>& a_old_coarse_data, 00214 const LevelData<FluxBox>& a_new_coarse_data, 00215 Real a_time_interp_coef, 00216 int a_src_comp, 00217 int a_dest_comp, 00218 int a_num_comp 00219 ); 00220 00221 00222 // fill the fine interpolation sites piecewise-constantly 00223 void 00224 fillConstantInterp(LevelData<FluxBox>& a_fine_data, 00225 const LevelData<FluxBox>& m_coarsened_fine_data, 00226 int a_src_comp, 00227 int a_dest_comp, 00228 int a_num_comp 00229 ) 00230 const; 00231 00232 // compute slopes in specified direction 00233 void 00234 computeSlopes(FArrayBox& slope_fab, 00235 const FArrayBox& data_fab, 00236 const IntVectSet& local_centered_interp, 00237 const IntVectSet& local_lo_interp, 00238 const IntVectSet& local_hi_interp, 00239 int a_dir, 00240 int a_src_comp, 00241 int a_num_comp) const; 00242 00243 // // compute slopes in specified direction 00244 // void 00245 // computeSlopes(int a_dir, 00246 // int a_src_comp, 00247 // int a_num_comp); 00248 00249 00250 // increment the fine interpolation sites with linear term for the 00251 // specified coordinate direction 00252 void 00253 incrementLinearInterpTangential(LevelData<FluxBox>& a_fine_data, 00254 const LevelData<FluxBox>& m_coarsened_fine_data, 00255 int a_dir, 00256 int a_src_comp, 00257 int a_dest_comp, 00258 int a_num_comp) 00259 const; 00260 00261 00262 // now do the fine interpolation normal to the face directions 00263 void 00264 incrementLinearInterpNormal(LevelData<FluxBox>& a_fine_data, 00265 int a_src_comp, 00266 int a_dest_comp, 00267 int a_num_comp) 00268 const; 00269 00270 00271 00272 00273 protected: 00274 bool m_is_defined; 00275 // the radius of the interpolation stencil. e.g. a stencil using 00276 // (i-1,j), (i,j) and (i+1,j) has a radius of 1. 00277 static const int s_stencil_radius; 00278 // refinement ratio 00279 int m_ref_ratio; 00280 // number of layers of fine ghost cells to fill by interpolation. 00281 int m_interp_radius; 00282 // // work array for coarse data in grids shaped like the fine level. 00283 // LevelData<FluxBox> m_coarsened_fine_data; 00284 // // work array for slopes 00285 // LevelData<FluxBox> m_slopes; 00286 // (FM added) coarse slope/ghost/coarsened_fine_domain 00287 IntVect m_coarse_slope, m_coarse_ghost; 00288 DisjointBoxLayout m_coarsened_fine_domain; 00289 // problem domain on the coarse level. 00290 ProblemDomain m_crse_problem_domain; 00291 // per-grid fine locations that you interpolate to. 00292 LayoutData<IntVectSet> m_fine_interp[SpaceDim]; 00293 // per-grid coarse locations that you interpolate from, by type of 00294 // interpolation in the specified coordinate direction. 00295 // note that there are two subscripts here -- first one 00296 // refers to direction of slopes, second to direction of face 00297 LayoutData<IntVectSet> m_coarse_centered_interp[SpaceDim][SpaceDim]; 00298 LayoutData<IntVectSet> m_coarse_lo_interp[SpaceDim][SpaceDim]; 00299 LayoutData<IntVectSet> m_coarse_hi_interp[SpaceDim][SpaceDim]; 00300 }; 00301 00302 #include "NamespaceFooter.H" 00303 00304 #endif 00305 00306