00001 /* _______ __
00002 / ___/ / ___ __ _ / / ___
00003 / /__/ _ \/ _ \/ V \/ _ \/ _ \
00004 \___/_//_/\___/_/_/_/_.__/\___/
00005 */
00006 // CHOMBO Copyright (c) 2000-2004, The Regents of the University of
00007 // California, through Lawrence Berkeley National Laboratory (subject to
00008 // receipt of any required approvals from U.S. Dept. of Energy). All
00009 // rights reserved.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are met:
00013 //
00014 // (1) Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 // (2) Redistributions in binary form must reproduce the above copyright
00017 // notice, this list of conditions and the following disclaimer in the
00018 // documentation and/or other materials provided with the distribution.
00019 // (3) Neither the name of Lawrence Berkeley National Laboratory, U.S.
00020 // Dept. of Energy nor the names of its contributors may be used to endorse
00021 // or promote products derived from this software without specific prior
00022 // written permission.
00023 //
00024 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
00026 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
00027 // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
00028 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00029 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00030 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035 //
00036 // You are under no obligation whatsoever to provide any bug fixes,
00037 // patches, or upgrades to the features, functionality or performance of
00038 // the source code ("Enhancements") to anyone; however, if you choose to
00039 // make your Enhancements available either publicly, or directly to
00040 // Lawrence Berkeley National Laboratory, without imposing a separate
00041 // written license agreement for such Enhancements, then you hereby grant
00042 // the following license: a non-exclusive, royalty-free perpetual license
00043 // to install, use, modify, prepare derivative works, incorporate into
00044 // other computer software, distribute, and sublicense such Enhancements or
00045 // derivative works thereof, in binary and source code form.
00046 //
00047 // TRADEMARKS. Product and company names mentioned herein may be the
00048 // trademarks of their respective owners. Any rights not expressly granted
00049 // herein are reserved.
00050 //
00051
00052 #ifndef _PIECEWISELINEARFILLPATCH_H_
00053 #define _PIECEWISELINEARFILLPATCH_H_
00054
00055 #include <iostream>
00056 #include <fstream>
00057 #include "REAL.H"
00058 #include "Box.H"
00059 #include "FArrayBox.H"
00060 #include "LevelData.H"
00061 #include "IntVectSet.H"
00062 #include "ProblemDomain.H"
00063
00065
00163 class PiecewiseLinearFillPatch
00164 {
00165 public:
00167
00170 PiecewiseLinearFillPatch();
00171
00173
00176 ~PiecewiseLinearFillPatch();
00177
00179
00190 PiecewiseLinearFillPatch(const DisjointBoxLayout& a_fine_domain,
00191 const DisjointBoxLayout& a_coarse_domain,
00192 int a_num_comps,
00193 const Box& a_crse_problem_domain,
00194 int a_ref_ratio,
00195 int a_interp_radius
00196 );
00197
00199
00210 PiecewiseLinearFillPatch(const DisjointBoxLayout& a_fine_domain,
00211 const DisjointBoxLayout& a_coarse_domain,
00212 int a_num_comps,
00213 const ProblemDomain& a_crse_problem_domain,
00214 int a_ref_ratio,
00215 int a_interp_radius
00216 );
00217
00219
00235 void
00236 define(const DisjointBoxLayout& a_fine_domain,
00237 const DisjointBoxLayout& a_coarse_domain,
00238 int a_num_comps,
00239 const Box& a_crse_problem_domain,
00240 int a_ref_ratio,
00241 int a_interp_radius
00242 );
00243
00245
00261 void
00262 define(const DisjointBoxLayout& a_fine_domain,
00263 const DisjointBoxLayout& a_coarse_domain,
00264 int a_num_comps,
00265 const ProblemDomain& a_crse_problem_domain,
00266 int a_ref_ratio,
00267 int a_interp_radius
00268 );
00269
00271
00278 bool
00279 isDefined() const;
00280
00282
00307 void
00308 fillInterp(LevelData<FArrayBox>& a_fine_data,
00309 const LevelData<FArrayBox>& a_old_coarse_data,
00310 const LevelData<FArrayBox>& a_new_coarse_data,
00311 Real a_time_interp_coef,
00312 int a_src_comp,
00313 int a_dest_comp,
00314 int a_num_comp
00315 );
00316
00317 // debugging utilities
00318 void
00319 printIntVectSets() const;
00320
00321
00322 protected:
00323 // copy coarse data to coarsened fine work array and interpolate to
00324 // fine time level
00325 void
00326 timeInterp(const LevelData<FArrayBox>& a_old_coarse_data,
00327 const LevelData<FArrayBox>& a_new_coarse_data,
00328 Real a_time_interp_coef,
00329 int a_src_comp,
00330 int a_dest_comp,
00331 int a_num_comp
00332 );
00333
00334 // fill the fine interpolation sites piecewise-constantly
00335 void
00336 fillConstantInterp(LevelData<FArrayBox>& a_fine_data,
00337 int a_src_comp,
00338 int a_dest_comp,
00339 int a_num_comp
00340 )
00341 const;
00342
00343 // compute slopes in specified direction
00344 void
00345 computeSlopes(int a_src_comp,
00346 int a_num_comp);
00347
00348 // increment the fine interpolation sites with linear term for the
00349 // specified coordinate direction
00350 void
00351 incrementLinearInterp(LevelData<FArrayBox>& a_fine_data,
00352 int a_src_comp,
00353 int a_dest_comp,
00354 int a_num_comp)
00355 const;
00356
00357
00358 protected:
00359 bool m_is_defined;
00360 // the radius of the interpolation stencil. e.g. a stencil using
00361 // (i-1,j), (i,j) and (i+1,j) has a radius of 1.
00362 static const int s_stencil_radius;
00363 // refinement ratio
00364 int m_ref_ratio;
00365 // number of layers of fine ghost cells to fill by interpolation.
00366 int m_interp_radius;
00367 // work array for coarse data in grids shaped like the fine level.
00368 LevelData<FArrayBox> m_coarsened_fine_data;
00369 // work array for slopes
00370 LevelData<FArrayBox> m_slopes[3];
00371 // problem domain on the coarse level.
00372 ProblemDomain m_crse_problem_domain;
00373 // per-grid fine locations that you interpolate to.
00374 LayoutData<IntVectSet> m_fine_interp;
00375 // per-grid coarse locations that you interpolate from, by type of
00376 // interpolation in the specified coordinate direction.
00377 LayoutData<IntVectSet> m_coarse_centered_interp[SpaceDim];
00378 LayoutData<IntVectSet> m_coarse_lo_interp[SpaceDim];
00379 LayoutData<IntVectSet> m_coarse_hi_interp[SpaceDim];
00380 };
00381
00382 #endif
1.2.16