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  /** How many leading rows of a time.dat with these steps and times a run starting at
36  * start_step and start_time keeps: on a restart the rows up to and including the restart
37  * that increase in step and time and are not later than the restart; on a fresh start none.
38  */
39  static int rows_to_keep (const amrex::Vector<int>& steps, const amrex::Vector<double>& times,
40  int start_step, double start_time, bool restarting);
41 
42 private:
43 
44  //! IO output box region
45  amrex::Box target_box;
46 
47  //! Geometry objects for all levels
48  amrex::Vector<amrex::Geometry>& m_geom;
49 
50  //! File name for IO
51  std::string m_filename{""};
52 
53  //! File name for Native time file
54  std::string m_time_file{""};
55 
56  //! Variables for IO
57  amrex::Vector<std::string> m_var_names;
58 
59  //! Rows of time.dat the run continues from, written back before its first plane (I/O rank)
60  amrex::Vector<std::string> m_kept_rows;
61 
62  //! Whether time.dat still has to be rewritten to m_kept_rows (I/O rank)
63  bool m_rewrite_time_file = false;
64 
65  //! Timestep and times to be stored in time.dat
66  amrex::Vector<double> m_in_times;
67  amrex::Vector<int> m_in_timesteps;
68 
69  // This defaults to level 0, but if we can fit the whole target_box
70  // inside a higher level, we will use the finest data possible
71  static int bndry_lev;
72 
73  //! controls extents on native bndry output
74  int m_in_rad = 1;
75  const int m_out_rad = 1;
76  const int m_extent_rad = 0;
77 };
78 
79 #endif /* ERF_BOUNDARYPLANE_H */
Definition: ERF_WriteBndryPlanes.H:18
amrex::Vector< amrex::Geometry > & m_geom
Geometry objects for all levels.
Definition: ERF_WriteBndryPlanes.H:48
void write_planes(int t_step, double time, amrex::Vector< amrex::Vector< amrex::MultiFab >> &vars_new, bool is_moist)
Definition: ERF_WriteBndryPlanes.cpp:259
int m_in_rad
controls extents on native bndry output
Definition: ERF_WriteBndryPlanes.H:74
static int bndry_lev
Definition: ERF_WriteBndryPlanes.H:71
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:152
const int m_out_rad
Definition: ERF_WriteBndryPlanes.H:75
const int m_extent_rad
Definition: ERF_WriteBndryPlanes.H:76
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:45
amrex::Vector< int > m_in_timesteps
Definition: ERF_WriteBndryPlanes.H:67
amrex::Vector< std::string > m_var_names
Variables for IO.
Definition: ERF_WriteBndryPlanes.H:57
std::string m_time_file
File name for Native time file.
Definition: ERF_WriteBndryPlanes.H:54
std::string m_filename
File name for IO.
Definition: ERF_WriteBndryPlanes.H:51
bool start_series(int start_step, double start_time, bool restarting)
Definition: ERF_WriteBndryPlanes.cpp:181
bool m_rewrite_time_file
Whether time.dat still has to be rewritten to m_kept_rows (I/O rank)
Definition: ERF_WriteBndryPlanes.H:63
amrex::Vector< double > m_in_times
Timestep and times to be stored in time.dat.
Definition: ERF_WriteBndryPlanes.H:66
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:60