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 ();
238 static const std::list<std::string>& derivePlotVars () noexcept { return derive_plot_vars; }
240 static const std::list<std::string>& deriveSmallPlotVars () noexcept { return derive_small_plot_vars; }
246 static bool isDerivePlotVar (const std::string& name) noexcept;
252 static bool isDeriveSmallPlotVar (const std::string& name) noexcept;
258 static void addDerivePlotVar (const std::string& name);
264 static void addDeriveSmallPlotVar (const std::string& name);
270 static void deleteDerivePlotVar (const std::string& name);
276 static void deleteDeriveSmallPlotVar (const std::string& name);
278 static void clearDerivePlotVarList ();
280 static void clearDeriveSmallPlotVarList ();
282 static void fillDerivePlotVarList ();
284 static void fillDeriveSmallPlotVarList ();
285
287 static void setComputeNewDtOnRegrid (bool flag) { compute_new_dt_on_regrid = flag; }
288
290 static void Initialize ();
292 static void Finalize ();
298 AmrLevel& getLevel (int lev) noexcept { return *amr_level[lev]; }
302 Long cellCount () noexcept;
304 Long cellCount (int lev) noexcept;
306 int numGrids () noexcept;
308 int numGrids (int lev) noexcept;
310 int okToContinue () noexcept;
318 void regrid (int lbase,
319 Real time,
320 bool initial = false) override;
327 void RegridOnly (Real time, bool do_io = true);
333 bool okToRegrid (int level) noexcept;
339 static const BoxArray& initialBa (int level) noexcept
340 { BL_ASSERT(level-1 < initial_ba.size()); return initial_ba[level-1]; }
342 static int initialBaLevels () noexcept { return static_cast<int>(initial_ba.size()); }
348 virtual void coarseTimeStep (Real stop_time);
349
356 Real coarseTimeStepDt (Real stop_time);
366 std::unique_ptr<MultiFab> derive (const std::string& name,
367 Real time,
368 int lev,
369 int ngrow);
378 void derive (const std::string& name,
379 Real time,
380 const Vector<MultiFab*>& mf,
381 int dcomp);
390 Vector<std::unique_ptr<MultiFab>> derive (const std::string& name,
391 amrex::Real time,
392 int ngrow);
394 const std::string& theRestartFile () const noexcept { return restart_chkfile; }
396 const std::string& theRestartPlotFile () const noexcept { return restart_pltfile; }
402 std::ostream& DataLog (int i);
404 std::string DataLogName (int i) const noexcept { return datalogname[i]; }
406 int NumDataLogs () noexcept;
421 static Real computeOptimalSubcycling (int n,
422 int* best,
423 const Real* dt_max,
424 const Real* est_work,
425 const int* cycle_max);
426
428
431 virtual void writePlotFile ();
433 int stepOfLastPlotFile () const noexcept {return last_plotfile;}
437 virtual void writeSmallPlotFile ();
439 int stepOfLastSmallPlotFile () const noexcept {return last_smallplotfile;}
441
444 virtual void checkPoint ();
446 int stepOfLastCheckPoint () const noexcept {return last_checkpoint;}
447
449 static const Vector<BoxArray>& getInitialBA() noexcept;
450
462 void setBoundaryGeometry(BoundaryPointList& IntersectLoX,
463 BoundaryPointList& IntersectHiX,
464 BoundaryPointList& IntersectLoY,
465 BoundaryPointList& IntersectHiY) noexcept
466 {
467 intersect_lox = IntersectLoX;
468 intersect_hix = IntersectHiX;
469 intersect_loy = IntersectLoY;
470 intersect_hiy = IntersectHiY;
471 }
472
486 void setBoundaryGeometry(BoundaryPointList& IntersectLoX,
487 BoundaryPointList& IntersectHiX,
488 BoundaryPointList& IntersectLoY,
489 BoundaryPointList& IntersectHiY,
490 BoundaryPointList& IntersectLoZ,
491 BoundaryPointList& IntersectHiZ) noexcept
492 {
493 intersect_lox = IntersectLoX;
494 intersect_hix = IntersectHiX;
495 intersect_loy = IntersectLoY;
496 intersect_hiy = IntersectHiY;
497 intersect_loz = IntersectLoZ;
498 intersect_hiz = IntersectHiZ;
499 }
500
502 BoundaryPointList& getIntersectLoX() noexcept
503 {
504 return intersect_lox;
505 }
507 BoundaryPointList& getIntersectHiX() noexcept
508 {
509 return intersect_hix;
510 }
512 BoundaryPointList& getIntersectLoY() noexcept
513 {
514 return intersect_loy;
515 }
517 BoundaryPointList& getIntersectHiY() noexcept
518 {
519 return intersect_hiy;
520 }
522 BoundaryPointList& getIntersectLoZ() noexcept
523 {
524 return intersect_loz;
525 }
527 BoundaryPointList& getIntersectHiZ() noexcept
528 {
529 return intersect_hiz;
530 }
531
532#ifdef AMREX_PARTICLES
538 void RedistributeParticles ();
539#endif
540
547 void InstallNewDistributionMap (int lev, const DistributionMapping& newdm);
548
550 static bool UsingPrecreateDirectories () noexcept;
551
552protected:
553
562 void initialInit (Real strt_time, Real stop_time,
563 const BoxArray* lev0_grids = nullptr, const Vector<int>* pmap = nullptr);
564#ifndef AMREX_NO_PROBINIT
566 void readProbinFile (int& init);
567#endif
569 void checkInput ();
571 void restart (const std::string& filename);
573 void defBaseLevel (Real strt_time, const BoxArray* lev0_grids = nullptr, const Vector<int>* pmap = nullptr);
575 void bldFineLevels (Real strt_time);
577 virtual void regrid_level_0_on_restart ();
586 void grid_places (int lbase,
587 Real time,
588 int& new_finest,
589 Vector<BoxArray>& new_grids);
590
596 DistributionMapping makeLoadBalanceDistributionMap (int lev, Real time, const BoxArray& ba) const;
602 void LoadBalanceLevel0 (Real time);
603
612 void ErrorEst (int lev, TagBoxArray& tags, Real time, int ngrow) override;
614 BoxArray GetAreaNotToTag (int lev) override;
622 void ManualTagsPlacement (int lev, TagBoxArray& tags, const Vector<IntVect>& bf_lev) override;
623
633 virtual void timeStep (int level,
634 Real time,
635 int iteration,
636 int niter,
637 Real stop_time);
638
639 // pure virtual function in AmrCore
640 void MakeNewLevelFromScratch (int /*lev*/, Real /*time*/, const BoxArray& /*ba*/, const DistributionMapping& /*dm*/) override
641 { amrex::Abort("How did we get here!"); }
642 void MakeNewLevelFromCoarse (int /*lev*/, Real /*time*/, const BoxArray& /*ba*/, const DistributionMapping& /*dm*/) override
643 { amrex::Abort("How did we get here!"); }
644 void RemakeLevel (int /*lev*/, Real /*time*/, const BoxArray& /*ba*/, const DistributionMapping& /*dm*/) override
645 { amrex::Abort("How did we get here!"); }
646 void ClearLevel (int /*lev*/) override
647 { amrex::Abort("How did we get here!"); }
648
650 bool checkPointNow () noexcept;
652 bool writePlotNow () noexcept;
654 bool writeSmallPlotNow () noexcept;
655
663 void printGridInfo (std::ostream& os,
664 int min_lev,
665 int max_lev);
666
668 void setRecordGridInfo (const std::string& filename);
669
671 void setRecordRunInfo (const std::string& filename);
672
674 void setRecordRunInfoTerse (const std::string& filename);
675
677 void setRecordDataInfo (int i, const std::string& filename);
678
680 void initSubcycle();
682 void initPltAndChk();
683
685 static int initInSitu();
687 int updateInSitu();
689 static int finalizeInSitu();
690
691 //
692 // The data ...
693 //
694 std::string regrid_grids_file;
695 std::string initial_grids_file;
696 Vector<std::unique_ptr<AmrLevel> > amr_level;
697 Real cumtime = std::numeric_limits<Real>::lowest();
698 Real start_time = std::numeric_limits<Real>::lowest();
703 std::string subcycling_mode;
709 std::string check_file_root;
722 std::string plot_file_root;
724
726
730 std::ofstream gridlog;
731 std::ofstream runlog;
732 std::ofstream runlog_terse;
733 Vector<std::unique_ptr<std::fstream> > datalog;
734 Vector<std::string> datalogname;
736 std::string restart_chkfile;
737 std::string restart_pltfile;
738#ifndef AMREX_NO_PROBINIT
739 std::string probin_file;
740#endif
747
749
750 //
751 // The static data ...
752 //
753 static std::list<std::string> state_plot_vars;
754 static std::list<std::string> state_small_plot_vars;
755 static std::list<std::string> derive_plot_vars;
756 static std::list<std::string> derive_small_plot_vars;
757 static bool first_plotfile;
763
764#if defined(AMREX_USE_SENSEI_INSITU) && !defined(AMREX_NO_SENSEI_AMR_INST)
765 static AmrInSituBridge *insitu_bridge;
766#endif
767
768public:
769 BoundaryPointList intersect_lox;
770 BoundaryPointList intersect_loy;
771 BoundaryPointList intersect_loz;
772 BoundaryPointList intersect_hix;
773 BoundaryPointList intersect_hiy;
774 BoundaryPointList intersect_hiz;
775
777
778private:
779 void writePlotFileDoit (std::string const& pltfile, bool regular);
780};
781
782}
783
784#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:709
virtual void init(Real strt_time, Real stop_time)
Initialize hierarchy state (grid creation, initial conditions, etc.).
Definition AMReX_Amr.cpp:1160
std::string probin_file
Definition AMReX_Amr.H:739
virtual void writeSmallPlotFile()
Write the reduced “small plot” file (subset of variables/levels) to disk.
Definition AMReX_Amr.cpp:920
bool bUserStopRequest
Definition AMReX_Amr.H:748
BoundaryPointList & getIntersectHiX() noexcept
Definition AMReX_Amr.H:507
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:644
static void clearDeriveSmallPlotVarList()
Clear the list of derived quantities written to small plot files.
Definition AMReX_Amr.cpp:726
static const std::list< std::string > & deriveSmallPlotVars() noexcept
List of derived quantities included when writing small plot files.
Definition AMReX_Amr.H:240
static void fillDerivePlotVarList()
Fill the list of derive_plot_vars with all derived quantities.
Definition AMReX_Amr.cpp:690
Vector< int > n_cycle
Definition AMReX_Amr.H:702
void checkInput()
Check for valid input.
Definition AMReX_Amr.cpp:1082
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:2801
void setNCycle(const Vector< int > &ns) noexcept
Provide the number of time subcycles per level via ns.
Definition AMReX_Amr.cpp:841
Vector< int > level_count
Definition AMReX_Amr.H:701
Vector< Real > dt_level
Timestep at this level.
Definition AMReX_Amr.H:699
static const Vector< BoxArray > & getInitialBA() noexcept
Definition AMReX_Amr.cpp:3429
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:720
static const BoxArray & initialBa(int level) noexcept
Return the user-specified BoxArray that initializes level level (1-based).
Definition AMReX_Amr.H:339
static void deleteDerivePlotVar(const std::string &name)
Remove name from the full derived list.
Definition AMReX_Amr.cpp:748
int sub_cycle
Definition AMReX_Amr.H:735
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:3268
int plot_max_level
Maximum AMR level to write to a plotfile.
Definition AMReX_Amr.H:715
int stream_max_tries
Definition AMReX_Amr.H:743
int NumDataLogs() noexcept
Definition AMReX_Amr.cpp:162
int stepOfLastSmallPlotFile() const noexcept
Return the AMR step index associated with the most recent small plot file.
Definition AMReX_Amr.H:439
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:1961
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:642
std::string restart_pltfile
Definition AMReX_Amr.H:737
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:734
Real coarseTimeStepDt(Real stop_time)
Advance once and report the coarse level dt that was used.
Definition AMReX_Amr.cpp:2128
Vector< int > regrid_int
Interval between regridding.
Definition AMReX_Amr.H:705
void restart(const std::string &filename)
Restart from a checkpoint file named filename.
Definition AMReX_Amr.cpp:1417
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:733
static void clearStatePlotVarList()
Clear the list of state_plot_vars.
Definition AMReX_Amr.cpp:626
int message_int
How often checking messages touched by user, such as "stop_run".
Definition AMReX_Amr.H:721
Vector< int > level_steps
Number of time steps at this level.
Definition AMReX_Amr.H:700
void setRecordGridInfo(const std::string &filename)
Record the log filename filename used when dumping grid info metadata.
Definition AMReX_Amr.cpp:771
AmrLevel & getLevel(int lev) noexcept
Access the AmrLevel object stored at index lev.
Definition AMReX_Amr.H:298
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:174
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:200
static bool compute_new_dt_on_regrid
Definition AMReX_Amr.H:762
BoundaryPointList & getIntersectLoY() noexcept
Definition AMReX_Amr.H:512
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:3376
Vector< Real > dt_min
Definition AMReX_Amr.H:704
static bool isStateSmallPlotVar(const std::string &name)
Return true if name is already registered for small plotfiles.
Definition AMReX_Amr.cpp:605
const std::string & theRestartPlotFile() const noexcept
Name of the restart plotfile.
Definition AMReX_Amr.H:396
Vector< std::unique_ptr< AmrLevel > > amr_level
Vector of levels.
Definition AMReX_Amr.H:696
static Vector< BoxArray > initial_ba
Array of BoxArrays read in to initially define grid hierarchy.
Definition AMReX_Amr.H:759
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:2929
BoundaryPointList intersect_hiz
Definition AMReX_Amr.H:774
int loadbalance_level0_int
Definition AMReX_Amr.H:745
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:1309
static void clearDerivePlotVarList()
Clear the list of derive_plot_vars.
Definition AMReX_Amr.cpp:720
static std::list< std::string > derive_small_plot_vars
Derived Vars to dump to small plotfile.
Definition AMReX_Amr.H:756
BoundaryPointList & getIntersectHiY() noexcept
Definition AMReX_Amr.H:517
static bool isDerivePlotVar(const std::string &name) noexcept
Return true if name is already registered for full derived-output.
Definition AMReX_Amr.cpp:676
std::string small_plot_file_root
Root name of small plotfile.
Definition AMReX_Amr.H:723
static int finalizeInSitu()
Tear down in-situ infrastructure; returns 0 on success.
Definition AMReX_Amr.cpp:582
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:732
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:2555
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:2867
static void clearStateSmallPlotVarList()
Clear the list of variables written to small plot files.
Definition AMReX_Amr.cpp:646
int loadbalance_with_workestimates
Definition AMReX_Amr.H:744
int stepOfLastPlotFile() const noexcept
Return the AMR step index associated with the most recent plot file.
Definition AMReX_Amr.H:433
int small_plot_int
How often small plotfile (# of time steps)
Definition AMReX_Amr.H:716
void RegridOnly(Real time, bool do_io=true)
Regrid the hierarchy at physical time time without advancing any levels.
Definition AMReX_Amr.cpp:1926
BoundaryPointList & getIntersectLoX() noexcept
Definition AMReX_Amr.H:502
static std::list< std::string > state_small_plot_vars
State Vars to dump to small plotfile.
Definition AMReX_Amr.H:754
BoundaryPointList intersect_loy
Definition AMReX_Amr.H:770
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:394
static std::list< std::string > state_plot_vars
State Vars to dump to plotfile.
Definition AMReX_Amr.H:753
std::ofstream runlog_terse
Definition AMReX_Amr.H:732
static bool isDeriveSmallPlotVar(const std::string &name) noexcept
Return true if name is already registered for small derived-output.
Definition AMReX_Amr.cpp:683
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:722
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:182
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:725
std::string subcycling_mode
Type of subcycling to use.
Definition AMReX_Amr.H:703
BoundaryPointList intersect_lox
Definition AMReX_Amr.H:769
static void setComputeNewDtOnRegrid(bool flag)
Toggle whether new time steps are recomputed immediately after each regrid (flag=true recomputes).
Definition AMReX_Amr.H:287
std::ostream & DataLog(int i)
Return the i th datalog stream (opened lazily) for writing diagnostics.
Definition AMReX_Amr.cpp:156
bool writeSmallPlotNow() noexcept
Whether to emit a small plot file on this step.
Definition AMReX_Amr.cpp:2482
void RedistributeParticles()
Trigger a particle redistribution pass across all levels.
Definition AMReX_Amr.cpp:3436
static std::list< std::string > derive_plot_vars
Derived Vars to dump to plotfile.
Definition AMReX_Amr.H:755
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:3076
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:522
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:446
Amr(const Amr &rhs)=delete
Amr owns global driver state—disable copying to avoid duplicate hierarchies.
BoundaryPointList & getIntersectHiZ() noexcept
Definition AMReX_Amr.H:527
int updateInSitu()
Drive any per-step in-situ actions; returns 0 on success.
Definition AMReX_Amr.cpp:569
int last_plotfile
Step number of previous plotfile.
Definition AMReX_Amr.H:710
~Amr() override
The destructor.
Definition AMReX_Amr.cpp:763
void ClearLevel(int) override
Delete level lev data structures owned by the derived class.
Definition AMReX_Amr.H:646
static bool isStatePlotVar(const std::string &name)
Return true if name is already registered for full plotfiles.
Definition AMReX_Amr.cpp:598
int plot_int
How often plotfile (# of time steps)
Definition AMReX_Amr.H:712
std::ofstream gridlog
Definition AMReX_Amr.H:730
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:2975
void setRecordRunInfo(const std::string &filename)
Record the log filename filename used when writing detailed run information.
Definition AMReX_Amr.cpp:785
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:462
void InitAmr()
Initialize Amr-wide defaults and parse the amr.* ParmParse options.
Definition AMReX_Amr.cpp:267
int okToContinue() noexcept
Definition AMReX_Amr.cpp:869
void readProbinFile(int &init)
Read the probin file, updating the flag init that tracks initialization iterations.
Definition AMReX_Amr.cpp:1199
static int initInSitu()
Set up in-situ analysis hooks; returns 0 on success.
Definition AMReX_Amr.cpp:555
bool abort_on_stream_retry_failure
Definition AMReX_Amr.H:742
LevelBld * levelbld
Definition AMReX_Amr.H:741
static void deleteDeriveSmallPlotVar(const std::string &name)
Remove name from the small derived list.
Definition AMReX_Amr.cpp:756
Real cumtime
Physical time variable.
Definition AMReX_Amr.H:697
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:3088
void regrid(int lbase, Real time, bool initial=false) override
Rebuild grid hierarchy finer than lbase.
Definition AMReX_Amr.cpp:2616
Real check_per
How often checkpoint (units of time).
Definition AMReX_Amr.H:708
static int initialBaLevels() noexcept
Definition AMReX_Amr.H:342
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:105
static void fillStatePlotVarList()
Fill the list of state_plot_vars with all of the state quantities.
Definition AMReX_Amr.cpp:612
BoundaryPointList intersect_hix
Definition AMReX_Amr.H:772
static bool Plot_Files_Output()
Write out plotfiles (True/False)?
Definition AMReX_Amr.cpp:153
Real small_plot_per
How often small plotfile (in units of time)
Definition AMReX_Amr.H:717
std::string regrid_grids_file
Grids file that will bypass regridding.
Definition AMReX_Amr.H:694
Amr & operator=(const Amr &rhs)=delete
Copy assignment is likewise disabled.
int check_int
How often checkpoint (# time steps).
Definition AMReX_Amr.H:707
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:705
static bool first_smallplotfile
Definition AMReX_Amr.H:776
bool checkPointNow() noexcept
Whether checkpoint criteria are satisfied on this step.
Definition AMReX_Amr.cpp:2361
std::string initial_grids_file
Grids file that will bypass regridding only at initialization.
Definition AMReX_Amr.H:695
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:813
Long cellCount() noexcept
Definition AMReX_Amr.cpp:849
void LoadBalanceLevel0(Real time)
Compute and install a new distribution map for level 0.
Definition AMReX_Amr.cpp:2845
int record_run_info_terse
Definition AMReX_Amr.H:729
virtual void coarseTimeStep(Real stop_time)
Advance the hierarchy by one coarse step.
Definition AMReX_Amr.cpp:2135
static void deleteStatePlotVar(const std::string &name)
Remove name from the full-plot list if present.
Definition AMReX_Amr.cpp:668
Real small_plot_log_per
How often small plotfile (in units of log10(time))
Definition AMReX_Amr.H:718
void bldFineLevels(Real strt_time)
Define and initialize refined levels at simulation time strt_time.
Definition AMReX_Amr.cpp:3094
std::ofstream runlog
Definition AMReX_Amr.H:731
int record_grid_info
Definition AMReX_Amr.H:727
std::string restart_chkfile
Definition AMReX_Amr.H:736
Real plot_log_per
How often plotfile (in units of log10(time))
Definition AMReX_Amr.H:714
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:652
int last_smallplotfile
Step number of previous small plotfile.
Definition AMReX_Amr.H:711
void InstallNewDistributionMap(int lev, const DistributionMapping &newdm)
Replace the distribution map on level lev with newdm and update metadata.
Definition AMReX_Amr.cpp:2854
bool writePlotNow() noexcept
Whether to write a plotfile now.
Definition AMReX_Amr.cpp:2409
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:3166
BoundaryPointList intersect_loz
Definition AMReX_Amr.H:771
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:404
bool write_plotfile_with_checkpoint
Write out a plotfile whenever we checkpoint.
Definition AMReX_Amr.H:719
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:1341
static void fillStateSmallPlotVarList()
Populate state_small_plot_vars with every state quantity registered on AmrLevel 0.
Definition AMReX_Amr.cpp:632
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:761
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:168
BoundaryPointList intersect_hiy
Definition AMReX_Amr.H:773
int numGrids() noexcept
Definition AMReX_Amr.cpp:859
int record_run_info
Definition AMReX_Amr.H:728
Real start_time
Physical time this simulation started.
Definition AMReX_Amr.H:698
Real loadbalance_max_fac
Definition AMReX_Amr.H:746
static void Finalize()
Release global Amr static resources allocated by Initialize().
Definition AMReX_Amr.cpp:141
static void addStateSmallPlotVar(const std::string &name)
Append name to the small-plot variable list if not already present.
Definition AMReX_Amr.cpp:660
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:486
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:827
void setRecordRunInfoTerse(const std::string &filename)
Record the log filename filename used for terse run information.
Definition AMReX_Amr.cpp:799
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:640
int last_checkpoint
Step number of previous checkpoint.
Definition AMReX_Amr.H:706
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:238
bool okToRegrid(int level) noexcept
Return true if level level is permitted to regrid on this step.
Definition AMReX_Amr.cpp:3366
Real plot_per
How often plotfile (in units of time)
Definition AMReX_Amr.H:713
static bool UsingPrecreateDirectories() noexcept
Whether plot/checkpoint writers pre-create directories (helps avoid races on some filesystems).
Definition AMReX_Amr.cpp:99
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:757
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:1291
static void addDeriveSmallPlotVar(const std::string &name)
Append name to the small-plot derived list if not already present.
Definition AMReX_Amr.cpp:740
BoxArray GetAreaNotToTag(int lev) override
Return cached regions that must not be tagged on level lev.
Definition AMReX_Amr.cpp:3082
A collection of Boxes stored in an Array.
Definition AMReX_BoxArray.H:568
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:882
virtual void checkPoint()
Write current state into a chk* checkpoint directory.
Definition AMReX_Amr.cpp:1741
Definition AMReX_Amr.cpp:49
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition AMReX.cpp:240