Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class 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 #ifdef CH_USE_TIMER
00068 #include "CH_Timer.H"
00069 #endif
00070 
00072 
00093 class AMR
00094 {
00095 public:
00097 
00101   AMR();
00102 
00104 
00107   ~AMR();
00108 
00110 
00130   void define(int                          a_max_level,
00131               const Vector<int>&           a_ref_ratios,
00132               const Box&                   a_prob_domain,
00133               const AMRLevelFactory* const a_amrLevelFact);
00134 
00136 
00156   void define(int                          a_max_level,
00157               const Vector<int>&           a_ref_ratios,
00158               const ProblemDomain&         a_prob_domain,
00159               const AMRLevelFactory* const a_amrLevelFact);
00160 
00162 
00166   bool isDefined() const;
00167 
00169 
00173   bool isSetUp() const;
00174 
00175 #ifdef CH_USE_HDF5
00176 
00177 
00183   void setupForRestart(HDF5Handle& a_handle);
00184 #endif
00185 
00187 
00193   void setupForNewAMRRun();
00194 
00200   void setupForFixedHierarchyRun(const Vector<Vector<Box> >& a_amr_grids,
00201                                  int                         a_proper_nest = 1);
00202 
00204 
00209   void conclude() const;
00210 
00212 
00216   void run(Real a_max_time, int a_max_step);
00217 
00219 
00224   void plotPrefix(const std::string& a_plotfile_prefix);
00225 
00227 
00232   void checkpointPrefix(const std::string& a_checkpointfile_prefix);
00233 
00235 
00239   void plotInterval(int a_plot_interval);
00240 
00242 
00246   void checkpointInterval(int a_checkpoint_interval);
00247 
00249 
00253   void maxGridSize(int a_max_grid_size);
00254 
00256 
00261   void maxBaseGridSize(int a_max_base_grid_size);
00262 
00264 
00269   void dtToleranceFactor(Real a_dt_tolerance_factor);
00270 
00272 
00276   void fillRatio(Real a_fillRat);
00277 
00279 
00283   void blockFactor(int a_blockFactor);
00284 
00286 
00290   void gridBufferSize(int a_grid_buffer_size);
00291 
00293 
00296   int maxGridSize() const;
00297 
00299 
00302   int maxBaseGridSize() const;
00303 
00305 
00316   void verbosity (int a_verbosity);
00317 
00319 
00323   void regridIntervals(const Vector<int>& a_regridIntervals);
00324 
00326 
00335   int verbosity () const;
00336 
00338 
00339   void maxDtGrow(Real a_dtGrowFactor);
00340 
00342 
00347   void timeEps(Real a_timeEps);
00348 
00350 
00351   Real maxDtGrow() const;
00352 
00354 
00357   Real timeEps() const;
00358 
00360 
00361   void fixedDt(Real a_dt);
00362 
00364 
00365   Real fixedDt() const;
00366 
00368 
00371   Vector<AMRLevel*> getAMRLevels();
00372 
00374 
00380   void initialTime(Real a_initialTime);
00381 
00383 
00386   Real getCurrentTime() const;
00387 
00388 #ifdef CH_USE_TIMER
00389 
00390 
00393   Chombo::Timer * timer(Chombo::Timer *a_timer = NULL );
00394 #endif
00395 
00396 protected:
00397   // advance by dt on this level and all finer levels and return the
00398   // number of steps left - given the number of steps left on entry.
00399   int timeStep(int a_level, int a_stepsLeft, bool a_coarseTimeBoundary);
00400 
00401   //intenal use only
00402   void clearMemory();
00403 
00404   // make new grids.
00405   void regrid(int a_base_level);
00406 
00407   // make initial grids.
00408   // not an accurate name, since there are no grids to re.
00409   void initialGrid();
00410 
00411   void writePlotFile() const;
00412 
00413   void writeCheckpointFile() const;
00414 
00415   // computes maximum stable time step given the maximum stable time
00416   // step on the individual levels.
00417   void assignDt();
00418 
00419   // whether regridding should be done now.
00420   bool needToRegrid(int a_level, int a_numStepsLeft) const;
00421 
00422   void makeBaseLevelMesh (Vector<Box>& a_grids) const;
00423 
00424   void setDefaultValues();
00425 
00426   int  m_blockFactor;
00427   Real m_fillRatio;
00428   int  m_max_level;
00429   int  m_finest_level_old;
00430   int  m_finest_level;
00431   int  m_checkpoint_interval;
00432   int  m_plot_interval;
00433   int  m_max_grid_size;
00434   int  m_max_base_grid_size;
00435   Real m_dt_tolerance_factor;
00436   Real m_fixedDt;
00437 
00438   bool              m_isDefined;
00439   bool              m_isSetUp;
00440   Vector<AMRLevel*> m_amrlevels;
00441   Vector<int>       m_ref_ratios;
00442   Vector<int>       m_reduction_factor;
00443   Vector<int>       m_regrid_intervals;
00444 
00445   Real         m_dt_base;
00446   // New (maximum) dt
00447   Vector<Real> m_dt_new;
00448   // Current dt
00449   Vector<Real> m_dt_cur;
00450   Real         m_maxDtGrow;
00451   Real         m_time_eps;
00452 
00453   BRMeshRefine m_mesh_refine;
00454   bool         m_use_meshrefine;
00455 
00456   Vector<Vector<Box> > m_amr_grids;
00457 
00458   int m_cur_step;
00459   int m_restart_step;
00460   int m_lastcheck_step;
00461 
00462   Real         m_cur_time;
00463   Vector<int>  m_steps_since_regrid;
00464   Vector<long> m_cell_updates;
00465 
00466   std::string m_plotfile_prefix;
00467   std::string m_checkpointfile_prefix;
00468 
00469   int m_verbosity;
00470 #ifdef CH_USE_TIMER
00471   Chombo::Timer *m_timer;  //assumes the application manages the memory
00472 #endif
00473 };
00474 
00475 #endif

Generated on Wed Oct 5 13:52:08 2005 for Chombo&AMRSelfGravity by  doxygen 1.4.1