Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_Amr.H
Go to the documentation of this file.
1
2#ifndef AMREX_Amr_H_
3#define AMREX_Amr_H_
4#include <AMReX_Config.H>
5
6#include <AMReX_Box.H>
7#include <AMReX_Geometry.H>
8#include <AMReX_BoxArray.H>
9#include <AMReX_Array.H>
10#include <AMReX_Vector.H>
11#include <AMReX_BCRec.H>
12#include <AMReX_AmrCore.H>
13
19#include <iosfwd>
20#include <list>
21#include <memory>
22
23namespace amrex {
24
25class AmrLevel;
26class LevelBld;
27#if defined(AMREX_USE_SENSEI_INSITU) && !defined(AMREX_NO_SENSEI_AMR_INST)
28class AmrInSituBridge;
29#endif
30
39class Amr
40 : public AmrCore
41{
42 using BoundaryPointList = std::multimap< std::pair<int, int>, double >;
43
44public:
50 Amr (LevelBld* a_levelbld /* One must pass LevelBld* as an argument now*/);
51
61 Amr (const RealBox* rb, int max_level_in, const Vector<int>& n_cell_in, int coord,
62 LevelBld* a_levelbld /* One must pass LevelBld* as an argument now*/);
63
65 Amr (const Amr& rhs) = delete;
67 Amr (Amr&& rhs) = delete;
69 Amr& operator= (const Amr& rhs) = delete;
71 Amr& operator= (Amr&& rhs) = delete;
72
79 void InitAmr ();
80
82 ~Amr () override;
83
90 virtual void init (Real strt_time, Real stop_time);
91
100 void InitializeInit (Real strt_time, Real stop_time,
101 const BoxArray* lev0_grids = nullptr, const Vector<int>* pmap = nullptr);
102
104 void FinalizeInit (Real strt_time, Real stop_time);
105
107 void setDtLevel (const Vector<Real>& dt_lev) noexcept;
108
110 void setDtLevel (Real dt, int lev) noexcept;
111
113 void setDtMin (const Vector<Real>& dt_min_in) noexcept;
114
116 void setNCycle (const Vector<int>& ns) noexcept;
117
119 int subCycle () const noexcept { return sub_cycle; }
120
122 const std::string& subcyclingMode() const noexcept { return subcycling_mode; }
123
128 int level_being_advanced () const noexcept { return which_level_being_advanced; }
130 Real cumTime () const noexcept { return cumtime; }
132 void setCumTime (Real t) noexcept { cumtime = t; }
134 Real startTime () const noexcept { return start_time; }
136 void setStartTime (Real t) noexcept { start_time = t; }
138 Real dtLevel (int level) const noexcept { return dt_level[level]; }
140 Real dtMin (int level) const noexcept { return dt_min[level]; }
142 const Vector<Real>& dtLevel () const noexcept { return dt_level; }
144 int nCycle (int level) const noexcept { return n_cycle[level]; }
146 int levelSteps (int lev) const noexcept { return level_steps[lev]; }
153 void setLevelSteps (int lev, int n) noexcept { level_steps[lev] = n; }
155 int levelCount (int lev) const noexcept { return level_count[lev]; }
162 void setLevelCount (int lev, int n) noexcept { level_count[lev] = n; }
164 static bool RegridOnRestart () noexcept;
166 int regridInt (int lev) const noexcept { return regrid_int[lev]; }
168 int checkInt () const noexcept { return check_int; }
170 Real checkPer() const noexcept { return check_per; }
172 int plotInt () const noexcept { return plot_int; }
174 Real plotPer () const noexcept { return plot_per; }
176 Real plotLogPer () const noexcept { return plot_log_per; }
178 int plotMaxLevel () const noexcept { return plot_max_level; }
180 int smallplotInt () const noexcept { return small_plot_int; }
182 Real smallplotPer () const noexcept { return small_plot_per; }
184 Real smallplotLogPer () const noexcept { return small_plot_log_per; }
190 static const std::list<std::string>& statePlotVars () noexcept { return state_plot_vars; }
192 static const std::list<std::string>& stateSmallPlotVars () noexcept { return state_small_plot_vars; }
198 static bool isStatePlotVar (const std::string& name);
204 static bool isStateSmallPlotVar (const std::string& name);
210 static void addStatePlotVar (const std::string& name);
216 static void addStateSmallPlotVar (const std::string& name);
222 static void deleteStatePlotVar (const std::string& name);
224 static void clearStatePlotVarList ();
226 static void clearStateSmallPlotVarList ();
228 static void fillStatePlotVarList ();
230 static void fillStateSmallPlotVarList ();
232 static bool Plot_Files_Output ();
241 static const std::list<std::string>& derivePlotVars () noexcept { return derive_plot_vars; }
248 static const std::list<std::string>& deriveSmallPlotVars () noexcept { return derive_small_plot_vars; }
254 static bool isDerivePlotVar (const std::string& name) noexcept;
260 static bool isDeriveSmallPlotVar (const std::string& name) noexcept;
266 static void addDerivePlotVar (const std::string& name);
272 static void addDeriveSmallPlotVar (const std::string& name);
278 static void deleteDerivePlotVar (const std::string& name);
284 static void deleteDeriveSmallPlotVar (const std::string& name);
286 static void clearDerivePlotVarList ();
288 static void clearDeriveSmallPlotVarList ();
290 static void fillDerivePlotVarList ();
292 static void fillDeriveSmallPlotVarList ();
293
295 static void setComputeNewDtOnRegrid (bool flag) { compute_new_dt_on_regrid = flag; }
296
298 static void Initialize ();
300 static void Finalize ();
306 AmrLevel& getLevel (int lev) noexcept { return *amr_level[lev]; }
310 Long cellCount () noexcept;
312 Long cellCount (int lev) noexcept;
314 int numGrids () noexcept;
316 int numGrids (int lev) noexcept;
318 int okToContinue () noexcept;
326 void regrid (int lbase,
327 Real time,
328 bool initial = false) override;
335 void RegridOnly (Real time, bool do_io = true);
341 bool okToRegrid (int level) noexcept;
347 static const BoxArray& initialBa (int level) noexcept
348 { BL_ASSERT(level-1 < initial_ba.size()); return initial_ba[level-1]; }
350 static int initialBaLevels () noexcept { return static_cast<int>(initial_ba.size()); }
356 virtual void coarseTimeStep (Real stop_time);
357
364 Real coarseTimeStepDt (Real stop_time);
374 std::unique_ptr<MultiFab> derive (const std::string& name,
375 Real time,
376 int lev,
377 int ngrow);
386 void derive (const std::string& name,
387 Real time,
388 const Vector<MultiFab*>& mf,
389 int dcomp);
398 Vector<std::unique_ptr<MultiFab>> derive (const std::string& name,
399 amrex::Real time,
400 int ngrow);
402 const std::string& theRestartFile () const noexcept { return restart_chkfile; }
404 const std::string& theRestartPlotFile () const noexcept { return restart_pltfile; }
410 std::ostream& DataLog (int i);
412 std::string DataLogName (int i) const noexcept { return datalogname[i]; }
414 int NumDataLogs () noexcept;
429 static Real computeOptimalSubcycling (int n,
430 int* best,
431 const Real* dt_max,
432 const Real* est_work,
433 const int* cycle_max);
434
436
439 virtual void writePlotFile ();
441 int stepOfLastPlotFile () const noexcept {return last_plotfile;}
445 virtual void writeSmallPlotFile ();
447 int stepOfLastSmallPlotFile () const noexcept {return last_smallplotfile;}
449
452 virtual void checkPoint ();
454 int stepOfLastCheckPoint () const noexcept {return last_checkpoint;}
455
457 static const Vector<BoxArray>& getInitialBA() noexcept;
458
470 void setBoundaryGeometry(BoundaryPointList& IntersectLoX,
471 BoundaryPointList& IntersectHiX,
472 BoundaryPointList& IntersectLoY,
473 BoundaryPointList& IntersectHiY) noexcept
474 {
475 intersect_lox = IntersectLoX;
476 intersect_hix = IntersectHiX;
477 intersect_loy = IntersectLoY;
478 intersect_hiy = IntersectHiY;
479 }
480
494 void setBoundaryGeometry(BoundaryPointList& IntersectLoX,
495 BoundaryPointList& IntersectHiX,
496 BoundaryPointList& IntersectLoY,
497 BoundaryPointList& IntersectHiY,
498 BoundaryPointList& IntersectLoZ,
499 BoundaryPointList& IntersectHiZ) noexcept
500 {
501 intersect_lox = IntersectLoX;
502 intersect_hix = IntersectHiX;
503 intersect_loy = IntersectLoY;
504 intersect_hiy = IntersectHiY;
505 intersect_loz = IntersectLoZ;
506 intersect_hiz = IntersectHiZ;
507 }
508
510 BoundaryPointList& getIntersectLoX() noexcept
511 {
512 return intersect_lox;
513 }
515 BoundaryPointList& getIntersectHiX() noexcept
516 {
517 return intersect_hix;
518 }
520 BoundaryPointList& getIntersectLoY() noexcept
521 {
522 return intersect_loy;
523 }
525 BoundaryPointList& getIntersectHiY() noexcept
526 {
527 return intersect_hiy;
528 }
530 BoundaryPointList& getIntersectLoZ() noexcept
531 {
532 return intersect_loz;
533 }
535 BoundaryPointList& getIntersectHiZ() noexcept
536 {
537 return intersect_hiz;
538 }
539
540#ifdef AMREX_PARTICLES
546 void RedistributeParticles ();
547#endif
548
555 void InstallNewDistributionMap (int lev, const DistributionMapping& newdm);
556
558 static bool UsingPrecreateDirectories () noexcept;
559
560protected:
561
570 void initialInit (Real strt_time, Real stop_time,
571 const BoxArray* lev0_grids = nullptr, const Vector<int>* pmap = nullptr);
572#ifndef AMREX_NO_PROBINIT
574 void readProbinFile (int& init);
575#endif
577 void checkInput ();
579 void restart (const std::string& filename);
581 void defBaseLevel (Real strt_time, const BoxArray* lev0_grids = nullptr, const Vector<int>* pmap = nullptr);
583 void bldFineLevels (Real strt_time);
585 virtual void regrid_level_0_on_restart ();
594 void grid_places (int lbase,
595 Real time,
596 int& new_finest,
597 Vector<BoxArray>& new_grids);
598
604 DistributionMapping makeLoadBalanceDistributionMap (int lev, Real time, const BoxArray& ba) const;
610 void LoadBalanceLevel0 (Real time);
611
620 void ErrorEst (int lev, TagBoxArray& tags, Real time, int ngrow) override;
622 BoxArray GetAreaNotToTag (int lev) override;
630 void ManualTagsPlacement (int lev, TagBoxArray& tags, const Vector<IntVect>& bf_lev) override;
631
641 virtual void timeStep (int level,
642 Real time,
643 int iteration,
644 int niter,
645 Real stop_time);
646
647 // pure virtual function in AmrCore
648 void MakeNewLevelFromScratch (int /*lev*/, Real /*time*/, const BoxArray& /*ba*/, const DistributionMapping& /*dm*/) override
649 { amrex::Abort("How did we get here!"); }
650 void MakeNewLevelFromCoarse (int /*lev*/, Real /*time*/, const BoxArray& /*ba*/, const DistributionMapping& /*dm*/) override
651 { amrex::Abort("How did we get here!"); }
652 void RemakeLevel (int /*lev*/, Real /*time*/, const BoxArray& /*ba*/, const DistributionMapping& /*dm*/) override
653 { amrex::Abort("How did we get here!"); }
654 void ClearLevel (int /*lev*/) override
655 { amrex::Abort("How did we get here!"); }
656
658 bool checkPointNow () noexcept;
660 bool writePlotNow () noexcept;
662 bool writeSmallPlotNow () noexcept;
663
671 void printGridInfo (std::ostream& os,
672 int min_lev,
673 int max_lev);
674
676 void setRecordGridInfo (const std::string& filename);
677
679 void setRecordRunInfo (const std::string& filename);
680
682 void setRecordRunInfoTerse (const std::string& filename);
683
685 void setRecordDataInfo (int i, const std::string& filename);
686
688 void initSubcycle();
690 void initPltAndChk();
691
693 static int initInSitu();
695 int updateInSitu();
697 static int finalizeInSitu();
698
699 //
700 // The data ...
701 //
702 std::string regrid_grids_file;
703 std::string initial_grids_file;
704 Vector<std::unique_ptr<AmrLevel> > amr_level;
705 Real cumtime = std::numeric_limits<Real>::lowest();
706 Real start_time = std::numeric_limits<Real>::lowest();
711 std::string subcycling_mode;
717 std::string check_file_root;
730 std::string plot_file_root;
732
734
738 std::ofstream gridlog;
739 std::ofstream runlog;
740 std::ofstream runlog_terse;
741 Vector<std::unique_ptr<std::fstream> > datalog;
742 Vector<std::string> datalogname;
744 std::string restart_chkfile;
745 std::string restart_pltfile;
746#ifndef AMREX_NO_PROBINIT
747 std::string probin_file;
748#endif
755
757
758 //
759 // The static data ...
760 //
761 static std::list<std::string> state_plot_vars;
762 static std::list<std::string> state_small_plot_vars;
763 static std::list<std::string> derive_plot_vars;
764 static std::list<std::string> derive_small_plot_vars;
765 static bool first_plotfile;
771
772#if defined(AMREX_USE_SENSEI_INSITU) && !defined(AMREX_NO_SENSEI_AMR_INST)
773 static AmrInSituBridge *insitu_bridge;
774#endif
775
776public:
777 BoundaryPointList intersect_lox;
778 BoundaryPointList intersect_loy;
779 BoundaryPointList intersect_loz;
780 BoundaryPointList intersect_hix;
781 BoundaryPointList intersect_hiy;
782 BoundaryPointList intersect_hiz;
783
785
786private:
787 void writePlotFileDoit (std::string const& pltfile, bool regular);
788};
789
790}
791
792#endif /*_Amr_H_*/
Base class for AMR applications that manages mesh hierarchy but not state data.
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
Provide basic functionalities to set up an AMR hierarchy.
Definition AMReX_AmrCore.H:31
Virtual base class for managing individual levels. AmrLevel functions both as a container for state d...
Definition AMReX_AmrLevel.H:44
Manage hierarchy of levels for time-dependent AMR computations.
Definition AMReX_Amr.H:41
Real smallplotPer() const noexcept
Time between plot files.
Definition AMReX_Amr.H:182
std::string check_file_root
Root name of checkpoint file.
Definition AMReX_Amr.H:717
virtual void init(Real strt_time, Real stop_time)
Initialize hierarchy state (grid creation, initial conditions, etc.).
Definition AMReX_Amr.cpp:1170
std::string probin_file
Definition AMReX_Amr.H:747
virtual void writeSmallPlotFile()
Write the reduced “small plot” file (subset of variables/levels) to disk.
Definition AMReX_Amr.cpp:930
bool bUserStopRequest
Definition AMReX_Amr.H:756
BoundaryPointList & getIntersectHiX() noexcept
Definition AMReX_Amr.H:515
void RemakeLevel(int, Real, const BoxArray &, const DistributionMapping &) override
Remake an existing level using provided metadata and refill from old data.
Definition AMReX_Amr.H:652
static void clearDeriveSmallPlotVarList()
Clear the list of derived quantities written to small plot files.
Definition AMReX_Amr.cpp:736
static const std::list< std::string > & deriveSmallPlotVars() noexcept
List of derived quantities included when writing small plot files.
Definition AMReX_Amr.H:248
static void fillDerivePlotVarList()
Fill the list of derive_plot_vars with all derived quantities.
Definition AMReX_Amr.cpp:700
Vector< int > n_cycle
Definition AMReX_Amr.H:710
void checkInput()
Check for valid input.
Definition AMReX_Amr.cpp:1092
DistributionMapping makeLoadBalanceDistributionMap(int lev, Real time, const BoxArray &ba) const
Build a DistributionMapping for level lev at time time using grid layout ba.
Definition AMReX_Amr.cpp:2811
void setNCycle(const Vector< int > &ns) noexcept
Provide the number of time subcycles per level via ns.
Definition AMReX_Amr.cpp:851
Vector< int > level_count
Definition AMReX_Amr.H:709
Vector< Real > dt_level
Timestep at this level.
Definition AMReX_Amr.H:707
static const Vector< BoxArray > & getInitialBA() noexcept
Definition AMReX_Amr.cpp:3439
void setLevelSteps(int lev, int n) noexcept
Override the recorded time-step count for level lev.
Definition AMReX_Amr.H:153
int file_name_digits
How many digits to use in the plotfile and checkpoint names.
Definition AMReX_Amr.H:728
static const BoxArray & initialBa(int level) noexcept
Return the user-specified BoxArray that initializes level level (1-based).
Definition AMReX_Amr.H:347
static void deleteDerivePlotVar(const std::string &name)
Remove name from the full derived list.
Definition AMReX_Amr.cpp:758
int sub_cycle
Definition AMReX_Amr.H:743
const Vector< Real > & dtLevel() const noexcept
Vector of time steps (dt) for all levels.
Definition AMReX_Amr.H:142
void initPltAndChk()
Initialize plot/checkpoint cadence, names, and counters from inputs.
Definition AMReX_Amr.cpp:3278
int plot_max_level
Maximum AMR level to write to a plotfile.
Definition AMReX_Amr.H:723
int stream_max_tries
Definition AMReX_Amr.H:751
int NumDataLogs() noexcept
Definition AMReX_Amr.cpp:164
int stepOfLastSmallPlotFile() const noexcept
Return the AMR step index associated with the most recent small plot file.
Definition AMReX_Amr.H:447
virtual void timeStep(int level, Real time, int iteration, int niter, Real stop_time)
Do a single time step on level level.
Definition AMReX_Amr.cpp:1971
void MakeNewLevelFromCoarse(int, Real, const BoxArray &, const DistributionMapping &) override
Make a new level using provided metadata and populate it from the next coarser level.
Definition AMReX_Amr.H:650
std::string restart_pltfile
Definition AMReX_Amr.H:745
int smallplotInt() const noexcept
Number of time steps between small plot files.
Definition AMReX_Amr.H:180
Vector< std::string > datalogname
Definition AMReX_Amr.H:742
Real coarseTimeStepDt(Real stop_time)
Advance once and report the coarse level dt that was used.
Definition AMReX_Amr.cpp:2138
Vector< int > regrid_int
Interval between regridding.
Definition AMReX_Amr.H:713
void restart(const std::string &filename)
Restart from a checkpoint file named filename.
Definition AMReX_Amr.cpp:1427
int plotMaxLevel() const noexcept
Maximum level index to include when writing plot files.
Definition AMReX_Amr.H:178
Vector< std::unique_ptr< std::fstream > > datalog
Definition AMReX_Amr.H:741
static void clearStatePlotVarList()
Clear the list of state_plot_vars.
Definition AMReX_Amr.cpp:636
int message_int
How often checking messages touched by user, such as "stop_run".
Definition AMReX_Amr.H:729
Vector< int > level_steps
Number of time steps at this level.
Definition AMReX_Amr.H:708
void setRecordGridInfo(const std::string &filename)
Record the log filename filename used when dumping grid info metadata.
Definition AMReX_Amr.cpp:781
AmrLevel & getLevel(int lev) noexcept
Access the AmrLevel object stored at index lev.
Definition AMReX_Amr.H:306
void setDtMin(const Vector< Real > &dt_min_in) noexcept
Override the maximum allowable dt (typically CFL-limited) for each level using dt_min_in.
Definition AMReX_Amr.cpp:176
Real plotLogPer() const noexcept
Spacing in log10(time) of logarithmically spaced plot files.
Definition AMReX_Amr.H:176
std::unique_ptr< MultiFab > derive(const std::string &name, Real time, int lev, int ngrow)
Build a MultiFab containing the derived quantity named name.
Definition AMReX_Amr.cpp:202
static bool compute_new_dt_on_regrid
Definition AMReX_Amr.H:770
BoundaryPointList & getIntersectLoY() noexcept
Definition AMReX_Amr.H:520
static Real computeOptimalSubcycling(int n, int *best, const Real *dt_max, const Real *est_work, const int *cycle_max)
Compute the optimal subcycling pattern. This assumes that anything less than cycle_max[i] is a valid ...
Definition AMReX_Amr.cpp:3386
Vector< Real > dt_min
Definition AMReX_Amr.H:712
static bool isStateSmallPlotVar(const std::string &name)
Return true if name is already registered for small plotfiles.
Definition AMReX_Amr.cpp:615
const std::string & theRestartPlotFile() const noexcept
Name of the restart plotfile.
Definition AMReX_Amr.H:404
Vector< std::unique_ptr< AmrLevel > > amr_level
Vector of levels.
Definition AMReX_Amr.H:704
static Vector< BoxArray > initial_ba
Array of BoxArrays read in to initially define grid hierarchy.
Definition AMReX_Amr.H:767
void printGridInfo(std::ostream &os, int min_lev, int max_lev)
Print per-level grid metadata to os for levels [min_lev, max_lev].
Definition AMReX_Amr.cpp:2939
BoundaryPointList intersect_hiz
Definition AMReX_Amr.H:782
int loadbalance_level0_int
Definition AMReX_Amr.H:753
void InitializeInit(Real strt_time, Real stop_time, const BoxArray *lev0_grids=nullptr, const Vector< int > *pmap=nullptr)
First half of the two-phase initialization used by initialInit().
Definition AMReX_Amr.cpp:1319
static void clearDerivePlotVarList()
Clear the list of derive_plot_vars.
Definition AMReX_Amr.cpp:730
static std::list< std::string > derive_small_plot_vars
Derived Vars to dump to small plotfile.
Definition AMReX_Amr.H:764
BoundaryPointList & getIntersectHiY() noexcept
Definition AMReX_Amr.H:525
static bool isDerivePlotVar(const std::string &name) noexcept
Return true if name is already registered for full derived-output.
Definition AMReX_Amr.cpp:686
std::string small_plot_file_root
Root name of small plotfile.
Definition AMReX_Amr.H:731
static int finalizeInSitu()
Tear down in-situ infrastructure; returns 0 on success.
Definition AMReX_Amr.cpp:592
int nCycle(int level) const noexcept
Number of subcycled time steps taken per coarse step on level level.
Definition AMReX_Amr.H:144
static void addDerivePlotVar(const std::string &name)
Register name as a derived quantity to include in full plotfiles (no-op if already present).
Definition AMReX_Amr.cpp:742
void defBaseLevel(Real strt_time, const BoxArray *lev0_grids=nullptr, const Vector< int > *pmap=nullptr)
Define and initialize the coarsest level using optional level-0 grids lev0_grids and map pmap.
Definition AMReX_Amr.cpp:2565
Real plotPer() const noexcept
Time between plot files.
Definition AMReX_Amr.H:174
virtual void regrid_level_0_on_restart()
Regrid level 0 on restart.
Definition AMReX_Amr.cpp:2877
static void clearStateSmallPlotVarList()
Clear the list of variables written to small plot files.
Definition AMReX_Amr.cpp:656
int loadbalance_with_workestimates
Definition AMReX_Amr.H:752
int stepOfLastPlotFile() const noexcept
Return the AMR step index associated with the most recent plot file.
Definition AMReX_Amr.H:441
int small_plot_int
How often small plotfile (# of time steps)
Definition AMReX_Amr.H:724
void RegridOnly(Real time, bool do_io=true)
Regrid the hierarchy at physical time time without advancing any levels.
Definition AMReX_Amr.cpp:1936
BoundaryPointList & getIntersectLoX() noexcept
Definition AMReX_Amr.H:510
static std::list< std::string > state_small_plot_vars
State Vars to dump to small plotfile.
Definition AMReX_Amr.H:762
BoundaryPointList intersect_loy
Definition AMReX_Amr.H:778
Amr(Amr &&rhs)=delete
Amr instances are not movable; they rely on pointers registered with static callbacks.
const std::string & theRestartFile() const noexcept
Name of the most recent restart checkpoint file.
Definition AMReX_Amr.H:402
static std::list< std::string > state_plot_vars
State Vars to dump to plotfile.
Definition AMReX_Amr.H:761
std::ofstream runlog_terse
Definition AMReX_Amr.H:740
static bool isDeriveSmallPlotVar(const std::string &name) noexcept
Return true if name is already registered for small derived-output.
Definition AMReX_Amr.cpp:693
int plotInt() const noexcept
Number of time steps between plot files.
Definition AMReX_Amr.H:172
int regridInt(int lev) const noexcept
Interval (in steps) between regrids on level lev.
Definition AMReX_Amr.H:166
std::string plot_file_root
Root name of plotfile.
Definition AMReX_Amr.H:730
void setStartTime(Real t) noexcept
Set the recorded start time to t.
Definition AMReX_Amr.H:136
Vector< std::unique_ptr< AmrLevel > > & getAmrLevels() noexcept
Return the container of level objects (index 0..finest).
Definition AMReX_Amr.cpp:184
Real startTime() const noexcept
Physical time this simulation started.
Definition AMReX_Amr.H:134
int which_level_being_advanced
Only >=0 if we are in Amr::timeStep(level,...)
Definition AMReX_Amr.H:733
std::string subcycling_mode
Type of subcycling to use.
Definition AMReX_Amr.H:711
BoundaryPointList intersect_lox
Definition AMReX_Amr.H:777
static void setComputeNewDtOnRegrid(bool flag)
Toggle whether new time steps are recomputed immediately after each regrid (flag=true recomputes).
Definition AMReX_Amr.H:295
std::ostream & DataLog(int i)
Return the i th datalog stream (opened lazily) for writing diagnostics.
Definition AMReX_Amr.cpp:158
bool writeSmallPlotNow() noexcept
Whether to emit a small plot file on this step.
Definition AMReX_Amr.cpp:2492
void RedistributeParticles()
Trigger a particle redistribution pass across all levels.
Definition AMReX_Amr.cpp:3446
static std::list< std::string > derive_plot_vars
Derived Vars to dump to plotfile.
Definition AMReX_Amr.H:763
void ErrorEst(int lev, TagBoxArray &tags, Real time, int ngrow) override
Default error-estimation driver; forwards to the levelbld-defined callbacks.
Definition AMReX_Amr.cpp:3086
int levelSteps(int lev) const noexcept
Number of time steps completed so far on level lev.
Definition AMReX_Amr.H:146
BoundaryPointList & getIntersectLoZ() noexcept
Definition AMReX_Amr.H:530
void setCumTime(Real t) noexcept
Set the accumulated physical time to t.
Definition AMReX_Amr.H:132
int stepOfLastCheckPoint() const noexcept
Return the AMR step index associated with the most recent checkpoint.
Definition AMReX_Amr.H:454
Amr(const Amr &rhs)=delete
Amr owns global driver state—disable copying to avoid duplicate hierarchies.
BoundaryPointList & getIntersectHiZ() noexcept
Definition AMReX_Amr.H:535
int updateInSitu()
Drive any per-step in-situ actions; returns 0 on success.
Definition AMReX_Amr.cpp:579
int last_plotfile
Step number of previous plotfile.
Definition AMReX_Amr.H:718
~Amr() override
The destructor.
Definition AMReX_Amr.cpp:773
void ClearLevel(int) override
Delete level lev data structures owned by the derived class.
Definition AMReX_Amr.H:654
static bool isStatePlotVar(const std::string &name)
Return true if name is already registered for full plotfiles.
Definition AMReX_Amr.cpp:608
int plot_int
How often plotfile (# of time steps)
Definition AMReX_Amr.H:720
std::ofstream gridlog
Definition AMReX_Amr.H:738
void grid_places(int lbase, Real time, int &new_finest, Vector< BoxArray > &new_grids)
Define new grid locations (called from regrid) and store them in new_grids.
Definition AMReX_Amr.cpp:2985
void setRecordRunInfo(const std::string &filename)
Record the log filename filename used when writing detailed run information.
Definition AMReX_Amr.cpp:795
void setBoundaryGeometry(BoundaryPointList &IntersectLoX, BoundaryPointList &IntersectHiX, BoundaryPointList &IntersectLoY, BoundaryPointList &IntersectHiY) noexcept
Specialized version: register intersection points for faces orthogonal to X/Y.
Definition AMReX_Amr.H:470
void InitAmr()
Initialize Amr-wide defaults and parse the amr.* ParmParse options.
Definition AMReX_Amr.cpp:277
int okToContinue() noexcept
Definition AMReX_Amr.cpp:879
void readProbinFile(int &init)
Read the probin file, updating the flag init that tracks initialization iterations.
Definition AMReX_Amr.cpp:1209
static int initInSitu()
Set up in-situ analysis hooks; returns 0 on success.
Definition AMReX_Amr.cpp:565
bool abort_on_stream_retry_failure
Definition AMReX_Amr.H:750
LevelBld * levelbld
Definition AMReX_Amr.H:749
static void deleteDeriveSmallPlotVar(const std::string &name)
Remove name from the small derived list.
Definition AMReX_Amr.cpp:766
Real cumtime
Physical time variable.
Definition AMReX_Amr.H:705
void ManualTagsPlacement(int lev, TagBoxArray &tags, const Vector< IntVect > &bf_lev) override
Allow derived classes to override tagging manually on level lev.
Definition AMReX_Amr.cpp:3098
void regrid(int lbase, Real time, bool initial=false) override
Rebuild grid hierarchy finer than lbase.
Definition AMReX_Amr.cpp:2626
Real check_per
How often checkpoint (units of time).
Definition AMReX_Amr.H:716
static int initialBaLevels() noexcept
Definition AMReX_Amr.H:350
Real checkPer() const noexcept
Time between checkpoint files.
Definition AMReX_Amr.H:170
static void Initialize()
Initialize global, Amr-wide static state (e.g., ParmParse defaults, logs).
Definition AMReX_Amr.cpp:106
static void fillStatePlotVarList()
Fill the list of state_plot_vars with all of the state quantities.
Definition AMReX_Amr.cpp:622
BoundaryPointList intersect_hix
Definition AMReX_Amr.H:780
static bool Plot_Files_Output()
Write out plotfiles (True/False)?
Definition AMReX_Amr.cpp:155
Real small_plot_per
How often small plotfile (in units of time)
Definition AMReX_Amr.H:725
std::string regrid_grids_file
Grids file that will bypass regridding.
Definition AMReX_Amr.H:702
Amr & operator=(const Amr &rhs)=delete
Copy assignment is likewise disabled.
int check_int
How often checkpoint (# time steps).
Definition AMReX_Amr.H:715
Real dtLevel(int level) const noexcept
Time step currently stored for level level.
Definition AMReX_Amr.H:138
static const std::list< std::string > & stateSmallPlotVars() noexcept
List of state variables written to the reduced “small” plot files.
Definition AMReX_Amr.H:192
static void fillDeriveSmallPlotVarList()
Populate derive_small_plot_vars with every registered derived quantity.
Definition AMReX_Amr.cpp:715
static bool first_smallplotfile
Definition AMReX_Amr.H:784
bool checkPointNow() noexcept
Whether checkpoint criteria are satisfied on this step.
Definition AMReX_Amr.cpp:2371
std::string initial_grids_file
Grids file that will bypass regridding only at initialization.
Definition AMReX_Amr.H:703
const std::string & subcyclingMode() const noexcept
How are we subcycling?
Definition AMReX_Amr.H:122
void setRecordDataInfo(int i, const std::string &filename)
Configure the i th datalog stream to mirror file filename.
Definition AMReX_Amr.cpp:823
Long cellCount() noexcept
Definition AMReX_Amr.cpp:859
void LoadBalanceLevel0(Real time)
Compute and install a new distribution map for level 0.
Definition AMReX_Amr.cpp:2855
int record_run_info_terse
Definition AMReX_Amr.H:737
virtual void coarseTimeStep(Real stop_time)
Advance the hierarchy by one coarse step.
Definition AMReX_Amr.cpp:2145
static void deleteStatePlotVar(const std::string &name)
Remove name from the full-plot list if present.
Definition AMReX_Amr.cpp:678
Real small_plot_log_per
How often small plotfile (in units of log10(time))
Definition AMReX_Amr.H:726
void bldFineLevels(Real strt_time)
Define and initialize refined levels at simulation time strt_time.
Definition AMReX_Amr.cpp:3104
std::ofstream runlog
Definition AMReX_Amr.H:739
int record_grid_info
Definition AMReX_Amr.H:735
std::string restart_chkfile
Definition AMReX_Amr.H:744
Real plot_log_per
How often plotfile (in units of log10(time))
Definition AMReX_Amr.H:722
int checkInt() const noexcept
Number of time steps between checkpoint files.
Definition AMReX_Amr.H:168
static void addStatePlotVar(const std::string &name)
Register name as a state variable to include in full plotfiles (no-op if already present).
Definition AMReX_Amr.cpp:662
int last_smallplotfile
Step number of previous small plotfile.
Definition AMReX_Amr.H:719
void InstallNewDistributionMap(int lev, const DistributionMapping &newdm)
Replace the distribution map on level lev with newdm and update metadata.
Definition AMReX_Amr.cpp:2864
bool writePlotNow() noexcept
Whether to write a plotfile now.
Definition AMReX_Amr.cpp:2419
void setLevelCount(int lev, int n) noexcept
Set the current cycle count for level lev.
Definition AMReX_Amr.H:162
void initSubcycle()
Parse ParmParse state and initialize subcycling-related arrays/flags.
Definition AMReX_Amr.cpp:3176
BoundaryPointList intersect_loz
Definition AMReX_Amr.H:779
static const std::list< std::string > & statePlotVars() noexcept
The names of state variables to output in the plotfile. They can be set using the amr....
Definition AMReX_Amr.H:190
std::string DataLogName(int i) const noexcept
The filename backing the i th datalog stream.
Definition AMReX_Amr.H:412
bool write_plotfile_with_checkpoint
Write out a plotfile whenever we checkpoint.
Definition AMReX_Amr.H:727
void FinalizeInit(Real strt_time, Real stop_time)
Second half of initial initialization; pairs with InitializeInit() using times strt_time and stop_tim...
Definition AMReX_Amr.cpp:1351
static void fillStateSmallPlotVarList()
Populate state_small_plot_vars with every state quantity registered on AmrLevel 0.
Definition AMReX_Amr.cpp:642
Real dtMin(int level) const noexcept
Max time step (typically physics-limited) for level level.
Definition AMReX_Amr.H:140
static Vector< BoxArray > regrid_ba
Array of BoxArrays read in to externally define grid hierarchy at each regrid.
Definition AMReX_Amr.H:769
int levelCount(int lev) const noexcept
Which cycle number are we on for level lev?
Definition AMReX_Amr.H:155
static bool RegridOnRestart() noexcept
Whether to regrid right after restart.
Definition AMReX_Amr.cpp:170
BoundaryPointList intersect_hiy
Definition AMReX_Amr.H:781
int numGrids() noexcept
Definition AMReX_Amr.cpp:869
int record_run_info
Definition AMReX_Amr.H:736
Real start_time
Physical time this simulation started.
Definition AMReX_Amr.H:706
Real loadbalance_max_fac
Definition AMReX_Amr.H:754
static void Finalize()
Release global Amr static resources allocated by Initialize().
Definition AMReX_Amr.cpp:142
static void addStateSmallPlotVar(const std::string &name)
Append name to the small-plot variable list if not already present.
Definition AMReX_Amr.cpp:670
void setBoundaryGeometry(BoundaryPointList &IntersectLoX, BoundaryPointList &IntersectHiX, BoundaryPointList &IntersectLoY, BoundaryPointList &IntersectHiY, BoundaryPointList &IntersectLoZ, BoundaryPointList &IntersectHiZ) noexcept
General version: register intersections for all Cartesian faces.
Definition AMReX_Amr.H:494
Real cumTime() const noexcept
Physical time (time advanced so far).
Definition AMReX_Amr.H:130
int subCycle() const noexcept
Subcycle in time?
Definition AMReX_Amr.H:119
void setDtLevel(const Vector< Real > &dt_lev) noexcept
Set per-level time steps to the values in dt_lev.
Definition AMReX_Amr.cpp:837
void setRecordRunInfoTerse(const std::string &filename)
Record the log filename filename used for terse run information.
Definition AMReX_Amr.cpp:809
Real smallplotLogPer() const noexcept
Spacing in log10(time) of logarithmically spaced small plot files.
Definition AMReX_Amr.H:184
void MakeNewLevelFromScratch(int, Real, const BoxArray &, const DistributionMapping &) override
Create and fill a new level from scratch.
Definition AMReX_Amr.H:648
int last_checkpoint
Step number of previous checkpoint.
Definition AMReX_Amr.H:714
static const std::list< std::string > & derivePlotVars() noexcept
The names of derived variables to output in the plotfile. They can be set using the amr....
Definition AMReX_Amr.H:241
bool okToRegrid(int level) noexcept
Return true if level level is permitted to regrid on this step.
Definition AMReX_Amr.cpp:3376
Real plot_per
How often plotfile (in units of time)
Definition AMReX_Amr.H:721
static bool UsingPrecreateDirectories() noexcept
Whether plot/checkpoint writers pre-create directories (helps avoid races on some filesystems).
Definition AMReX_Amr.cpp:100
int level_being_advanced() const noexcept
What is "level" in Amr::timeStep? This is only relevant if we are still in Amr::timeStep; it is set b...
Definition AMReX_Amr.H:128
static bool first_plotfile
Definition AMReX_Amr.H:765
void initialInit(Real strt_time, Real stop_time, const BoxArray *lev0_grids=nullptr, const Vector< int > *pmap=nullptr)
Initialize the grid hierarchy (called by Amr::init()).
Definition AMReX_Amr.cpp:1301
static void addDeriveSmallPlotVar(const std::string &name)
Append name to the small-plot derived list if not already present.
Definition AMReX_Amr.cpp:750
BoxArray GetAreaNotToTag(int lev) override
Return cached regions that must not be tagged on level lev.
Definition AMReX_Amr.cpp:3092
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:564
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:43
Builds problem-specific AmrLevels.
Definition AMReX_LevelBld.H:27
A Box with real dimensions.
Definition AMReX_RealBox.H:28
An array of TagBoxes.
Definition AMReX_TagBox.H:151
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:28
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:79
amrex_long Long
Definition AMReX_INT.H:30
virtual void writePlotFile()
Write a full-resolution plot file to disk using the current hierarchy state.
Definition AMReX_Amr.cpp:892
virtual void checkPoint()
Write current state into a chk* checkpoint directory.
Definition AMReX_Amr.cpp:1751
Definition AMReX_Amr.cpp:50
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:241