Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

AMR.H

Go to the documentation of this file.
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 _AMR_H_
00053 #define _AMR_H_
00054 
00055 #include <iostream>
00056 #include <string>
00057 #include <ctime>
00058 
00059 #include "REAL.H"
00060 #include "Vector.H"
00061 #include "AMRLevel.H"
00062 #include "AMRLevelFactory.H"
00063 #include "BRMeshRefine.H"
00064 #include "ProblemDomain.H"
00065 #include "Box.H"
00066 #include "CH_HDF5.H"
00067 
00069 
00090 class AMR
00091 {
00092 public:
00094 
00098   AMR();
00099 
00101 
00104   ~AMR();
00105 
00107 
00127   void define(int                          a_max_level,
00128               const Vector<int>&           a_ref_ratios,
00129               const Box&                   a_prob_domain,
00130               const AMRLevelFactory* const a_amrLevelFact);
00131 
00133 
00153   void define(int                          a_max_level,
00154               const Vector<int>&           a_ref_ratios,
00155               const ProblemDomain&         a_prob_domain,
00156               const AMRLevelFactory* const a_amrLevelFact);
00157 
00159 
00163   bool isDefined() const;
00164 
00166 
00170   bool isSetUp() const;
00171 
00172 #ifdef HDF5
00173 
00174 
00180   void setupForRestart(HDF5Handle& a_handle);
00181 #endif
00182 
00184 
00190   void setupForNewAMRRun();
00191 
00197   void setupForFixedHierarchyRun(const Vector<Vector<Box> >& a_amr_grids,
00198                                  int                         a_proper_nest = 1);
00199 
00201 
00206   void conclude() const;
00207 
00209 
00213   void run(Real a_max_time, int a_max_step);
00214 
00216 
00221   void plotPrefix(const std::string& a_plotfile_prefix);
00222 
00224 
00229   void checkpointPrefix(const std::string& a_checkpointfile_prefix);
00230 
00232 
00236   void plotInterval(int a_plot_interval);
00237 
00239 
00243   void checkpointInterval(int a_checkpoint_interval);
00244 
00246 
00250   void maxGridSize(int a_max_grid_size);
00251 
00253 
00258   void maxBaseGridSize(int a_max_base_grid_size);
00259 
00261 
00266   void dtToleranceFactor(Real a_dt_tolerance_factor);
00267 
00269 
00273   void fillRatio(Real a_fillRat);
00274 
00276 
00280   void blockFactor(int a_blockFactor);
00281 
00283 
00287   void gridBufferSize(int a_grid_buffer_size);
00288 
00290 
00293   int maxGridSize() const;
00294 
00296 
00299   int maxBaseGridSize() const;
00300 
00302 
00313   void verbosity (int a_verbosity);
00314 
00316 
00320   void regridIntervals(const Vector<int>& a_regridIntervals);
00321 
00323 
00332   int verbosity () const;
00333 
00335 
00336   void maxDtGrow(Real a_dtGrowFactor);
00337 
00339 
00344   void timeEps(Real a_timeEps);
00345 
00347 
00348   Real maxDtGrow() const;
00349 
00351 
00354   Real timeEps() const;
00355 
00357 
00358   void fixedDt(Real a_dt);
00359 
00361 
00362   Real fixedDt() const;
00363 
00365 
00368   Vector<AMRLevel*> getAMRLevels();
00369 
00371 
00374   Real getCurrentTime() const;
00375 
00376 
00377 protected:
00378   // advance by dt on this level and all finer levels and return the
00379   // number of steps left - given the number of steps left on entry.
00380   int timeStep(int a_level, int a_stepsLeft, bool a_coarseTimeBoundary);
00381 
00382   //intenal use only
00383   void clearMemory();
00384 
00385   // make new grids.
00386   void regrid(int a_base_level);
00387 
00388   // make initial grids.
00389   // not an accurate name, since there are no grids to re.
00390   void initialGrid();
00391 
00392   void writePlotFile() const;
00393 
00394   void writeCheckpointFile() const;
00395 
00396   // computes maximum stable time step given the maximum stable time
00397   // step on the individual levels.
00398   void assignDt();
00399 
00400   // whether regridding should be done now.
00401   bool needToRegrid(int a_level, int a_numStepsLeft) const;
00402 
00403   void makeBaseLevelMesh (Vector<Box>& a_grids) const;
00404 
00405   void setDefaultValues();
00406 
00407   int  m_blockFactor;
00408   Real m_fillRatio;
00409   int  m_max_level;
00410   int  m_finest_level_old;
00411   int  m_finest_level;
00412   int  m_checkpoint_interval;
00413   int  m_plot_interval;
00414   int  m_max_grid_size;
00415   int  m_max_base_grid_size;
00416   Real m_dt_tolerance_factor;
00417   Real m_fixedDt;
00418 
00419   bool              m_isDefined;
00420   bool              m_isSetUp;
00421   Vector<AMRLevel*> m_amrlevels;
00422   Vector<int>       m_ref_ratios;
00423   Vector<int>       m_reduction_factor;
00424   Vector<int>       m_regrid_intervals;
00425 
00426   Real         m_dt_base;
00427   // New (maximum) dt
00428   Vector<Real> m_dt_new;
00429   // Current dt
00430   Vector<Real> m_dt_cur;
00431   Real         m_maxDtGrow;
00432   Real         m_time_eps;
00433 
00434   BRMeshRefine m_mesh_refine;
00435   bool         m_use_meshrefine;
00436 
00437   Vector<Vector<Box> > m_amr_grids;
00438 
00439   int m_cur_step;
00440   int m_restart_step;
00441   int m_lastcheck_step;
00442 
00443   Real         m_cur_time;
00444   Vector<int>  m_steps_since_regrid;
00445   Vector<long> m_cell_updates;
00446 
00447   std::string m_plotfile_prefix;
00448   std::string m_checkpointfile_prefix;
00449 
00450   int m_verbosity;
00451 };
00452 
00453 #endif

Generated on Wed Jan 19 17:51:21 2005 for Chombo&INSwithParticles by doxygen1.2.16