ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_WriteBndryPlanes.H
Go to the documentation of this file.
1 /**
2  * \file ERF_WriteBndryPlanes.H
3  */
4 #ifndef ERF_WRITEBNDRYPLANES_H
5 #define ERF_WRITEBNDRYPLANES_H
6 
7 #include "AMReX_Gpu.H"
8 #include "AMReX_AmrCore.H"
9 #include <AMReX_BndryRegister.H>
10 
11 
12 /** Interface for writing boundary planes
13  *
14  * This class performs the necessary file operations to write boundary planes
15  *
16  */
18 {
19 public:
20  explicit WriteBndryPlanes (amrex::Vector<amrex::BoxArray>& grids,
21  amrex::Vector<amrex::Geometry>& geom);
22 
23  void write_planes (int t_step, double time,
24  amrex::Vector<amrex::Vector<amrex::MultiFab>>& vars_new,
25  bool is_moist);
26 
27  /** Decide which rows of time.dat a run starting at step start_step (at time start_time,
28  * with start_time the absolute time written in time.dat) continues from: a restart keeps
29  * the rows the run before it wrote up to that step, a fresh start keeps none. The file is
30  * rewritten only when the run writes its first plane, so a run that stops before then
31  * leaves it as it was. Returns whether the kept rows end with a plane at start_step itself.
32  */
33  bool start_series (int start_step, double start_time, bool restarting);
34 
35  //! Level the planes are taken from
36  static int get_bndry_lev () { return bndry_lev; }
37 
38  /** How many leading rows of a time.dat with these steps and times a run starting at
39  * start_step and start_time keeps: on a restart the rows up to and including the restart
40  * that increase in step and time and are not later than the restart; on a fresh start none.
41  */
42  static int rows_to_keep (const amrex::Vector<int>& steps, const amrex::Vector<double>& times,
43  int start_step, double start_time, bool restarting);
44 
45 private:
46 
47  //! IO output box region
48  amrex::Box target_box;
49 
50  //! Geometry objects for all levels
51  amrex::Vector<amrex::Geometry>& m_geom;
52 
53  //! File name for IO
54  std::string m_filename{""};
55 
56  //! File name for Native time file
57  std::string m_time_file{""};
58 
59  //! Variables for IO
60  amrex::Vector<std::string> m_var_names;
61 
62  //! Rows of time.dat the run continues from, written back before its first plane (I/O rank)
63  amrex::Vector<std::string> m_kept_rows;
64 
65  //! Whether time.dat still has to be rewritten to m_kept_rows (I/O rank)
66  bool m_rewrite_time_file = false;
67 
68  //! Timestep and times to be stored in time.dat
69  amrex::Vector<double> m_in_times;
70  amrex::Vector<int> m_in_timesteps;
71 
72  // This defaults to level 0, but if we can fit the whole target_box
73  // inside a higher level, we will use the finest data possible
74  static int bndry_lev;
75 
76  //! controls extents on native bndry output
77  int m_in_rad = 1;
78  const int m_out_rad = 1;
79  const int m_extent_rad = 0;
80 };
81 
82 #endif /* ERF_BOUNDARYPLANE_H */
Definition: ERF_WriteBndryPlanes.H:18
amrex::Vector< amrex::Geometry > & m_geom
Geometry objects for all levels.
Definition: ERF_WriteBndryPlanes.H:51
void write_planes(int t_step, double time, amrex::Vector< amrex::Vector< amrex::MultiFab >> &vars_new, bool is_moist)
Definition: ERF_WriteBndryPlanes.cpp:262
int m_in_rad
controls extents on native bndry output
Definition: ERF_WriteBndryPlanes.H:77
static int bndry_lev
Definition: ERF_WriteBndryPlanes.H:74
static int rows_to_keep(const amrex::Vector< int > &steps, const amrex::Vector< double > &times, int start_step, double start_time, bool restarting)
Definition: ERF_WriteBndryPlanes.cpp:155
const int m_out_rad
Definition: ERF_WriteBndryPlanes.H:78
const int m_extent_rad
Definition: ERF_WriteBndryPlanes.H:79
WriteBndryPlanes(amrex::Vector< amrex::BoxArray > &grids, amrex::Vector< amrex::Geometry > &geom)
Definition: ERF_WriteBndryPlanes.cpp:65
amrex::Box target_box
IO output box region.
Definition: ERF_WriteBndryPlanes.H:48
amrex::Vector< int > m_in_timesteps
Definition: ERF_WriteBndryPlanes.H:70
amrex::Vector< std::string > m_var_names
Variables for IO.
Definition: ERF_WriteBndryPlanes.H:60
std::string m_time_file
File name for Native time file.
Definition: ERF_WriteBndryPlanes.H:57
static int get_bndry_lev()
Level the planes are taken from.
Definition: ERF_WriteBndryPlanes.H:36
std::string m_filename
File name for IO.
Definition: ERF_WriteBndryPlanes.H:54
bool start_series(int start_step, double start_time, bool restarting)
Definition: ERF_WriteBndryPlanes.cpp:184
bool m_rewrite_time_file
Whether time.dat still has to be rewritten to m_kept_rows (I/O rank)
Definition: ERF_WriteBndryPlanes.H:66
amrex::Vector< double > m_in_times
Timestep and times to be stored in time.dat.
Definition: ERF_WriteBndryPlanes.H:69
amrex::Vector< std::string > m_kept_rows
Rows of time.dat the run continues from, written back before its first plane (I/O rank)
Definition: ERF_WriteBndryPlanes.H:63