ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_ReadBndryPlanes.H
Go to the documentation of this file.
1 #ifndef ERF_BOUNDARYPLANE_H
2 #define ERF_BOUNDARYPLANE_H
3 
4 #include "AMReX_Gpu.H"
5 #include "AMReX_AmrCore.H"
6 #include <AMReX_BndryRegister.H>
7 #include "ERF_IndexDefines.H"
8 #include "ERF_DataStruct.H"
9 
10 using PlaneVector = amrex::Vector<amrex::FArrayBox>;
11 
12 /** Collection of data structures and operations for reading data
13  *
14  * This class contains the inlet data structures and operations to
15  * read and interpolate inflow data.
16  */
18 {
19 
20 public:
21  explicit ReadBndryPlanes (const amrex::Geometry& geom,
22  const amrex::Real& rdOcp_in);
23 
24  void define_level_data (int lev);
25 
26  void read_time_file ();
27 
28  void read_input_files (amrex::Real time,
29  amrex::Real dt,
30  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>, AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals);
31 
32  void read_file (int idx,
33  amrex::Vector<std::unique_ptr<PlaneVector>>& data_to_fill,
34  amrex::Array<amrex::Array<amrex::Real, AMREX_SPACEDIM*2>, AMREX_SPACEDIM+NBCVAR_max> m_bc_extdir_vals);
35 
36  // Return the pointer to PlaneVectors at time "time"
37  amrex::Vector<std::unique_ptr<PlaneVector>>& interp_in_time (const amrex::Real& time);
38 
39  [[nodiscard]] amrex::Real tinterp() const { return m_tinterp; }
40 
41  [[nodiscard]] int ingested_velocity() const {return is_velocity_read;}
42  [[nodiscard]] int ingested_theta() const {return (is_temperature_read || is_theta_read);}
43  [[nodiscard]] int ingested_density() const {return is_density_read;}
44  [[nodiscard]] int ingested_scalar() const {return is_scalar_read;}
45  [[nodiscard]] int ingested_q1() const {return is_q1_read;}
46  [[nodiscard]] int ingested_q2() const {return is_q2_read;}
47  [[nodiscard]] int ingested_KE() const {return is_KE_read;}
48 
49 private:
50 
51  //! The times for which we currently have data
52  amrex::Real m_tn;
53  amrex::Real m_tnp1;
54  amrex::Real m_tnp2;
55 
56  //! Data at time m_tn
57  amrex::Vector<std::unique_ptr<PlaneVector>> m_data_n;
58 
59  //! Data at time m_tnp1
60  amrex::Vector<std::unique_ptr<PlaneVector>> m_data_np1;
61 
62  //! Data at time m_tnp2
63  amrex::Vector<std::unique_ptr<PlaneVector>> m_data_np2;
64 
65  //! Data interpolated to the time requested
66  amrex::Vector<std::unique_ptr<PlaneVector>> m_data_interp;
67 
68  //! Time for plane at interpolation
69  amrex::Real m_tinterp{-1.0};
70 
71  //! Geometry at level 0
72  amrex::Geometry m_geom;
73 
74  //! File name for IO
75  std::string m_filename{""};
76 
77  //! File name for file holding timesteps and times
78  std::string m_time_file{""};
79 
80  //! The timesteps / times that we read from time.dat
81  amrex::Vector<amrex::Real> m_in_times;
82  amrex::Vector<int> m_in_timesteps;
83 
84  //! Variables to be read in
85  amrex::Vector<std::string> m_var_names;
86 
87  //! controls extents on native bndry output
88  const int m_in_rad = 1;
89  const int m_out_rad = 1;
90  const int m_extent_rad = 0;
91 
92  //! R_d/c_p is needed for reading boundary files
93  const amrex::Real m_rdOcp;
94 
103 
105 };
106 
107 #endif /* ERF_BOUNDARYPLANE_H */
#define NBCVAR_max
Definition: ERF_IndexDefines.H:29
amrex::Vector< amrex::FArrayBox > PlaneVector
Definition: ERF_NCWpsFile.H:13
Definition: ERF_ReadBndryPlanes.H:18
int ingested_q1() const
Definition: ERF_ReadBndryPlanes.H:45
int is_velocity_read
Definition: ERF_ReadBndryPlanes.H:95
ReadBndryPlanes(const amrex::Geometry &geom, const amrex::Real &rdOcp_in)
Definition: ERF_ReadBndryPlanes.cpp:140
void define_level_data(int lev)
Definition: ERF_ReadBndryPlanes.cpp:43
int is_q2_read
Definition: ERF_ReadBndryPlanes.H:101
amrex::Vector< std::unique_ptr< PlaneVector > > & interp_in_time(const amrex::Real &time)
Definition: ERF_ReadBndryPlanes.cpp:84
void read_input_files(amrex::Real time, amrex::Real dt, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals)
Definition: ERF_ReadBndryPlanes.cpp:266
int is_theta_read
Definition: ERF_ReadBndryPlanes.H:98
std::string m_filename
File name for IO.
Definition: ERF_ReadBndryPlanes.H:75
amrex::Real m_tinterp
Time for plane at interpolation.
Definition: ERF_ReadBndryPlanes.H:69
int is_temperature_read
Definition: ERF_ReadBndryPlanes.H:97
amrex::Real m_tnp1
Definition: ERF_ReadBndryPlanes.H:53
int is_density_read
Definition: ERF_ReadBndryPlanes.H:96
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_np2
Data at time m_tnp2.
Definition: ERF_ReadBndryPlanes.H:63
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_interp
Data interpolated to the time requested.
Definition: ERF_ReadBndryPlanes.H:66
int ingested_scalar() const
Definition: ERF_ReadBndryPlanes.H:44
int last_file_read
Definition: ERF_ReadBndryPlanes.H:104
amrex::Real tinterp() const
Definition: ERF_ReadBndryPlanes.H:39
int is_KE_read
Definition: ERF_ReadBndryPlanes.H:102
amrex::Vector< int > m_in_timesteps
Definition: ERF_ReadBndryPlanes.H:82
const amrex::Real m_rdOcp
R_d/c_p is needed for reading boundary files.
Definition: ERF_ReadBndryPlanes.H:93
std::string m_time_file
File name for file holding timesteps and times.
Definition: ERF_ReadBndryPlanes.H:78
const int m_in_rad
controls extents on native bndry output
Definition: ERF_ReadBndryPlanes.H:88
int ingested_KE() const
Definition: ERF_ReadBndryPlanes.H:47
int ingested_velocity() const
Definition: ERF_ReadBndryPlanes.H:41
amrex::Vector< std::string > m_var_names
Variables to be read in.
Definition: ERF_ReadBndryPlanes.H:85
int is_scalar_read
Definition: ERF_ReadBndryPlanes.H:99
int is_q1_read
Definition: ERF_ReadBndryPlanes.H:100
int ingested_density() const
Definition: ERF_ReadBndryPlanes.H:43
int ingested_q2() const
Definition: ERF_ReadBndryPlanes.H:46
int ingested_theta() const
Definition: ERF_ReadBndryPlanes.H:42
void read_time_file()
Definition: ERF_ReadBndryPlanes.cpp:196
amrex::Real m_tnp2
Definition: ERF_ReadBndryPlanes.H:54
const int m_out_rad
Definition: ERF_ReadBndryPlanes.H:89
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_n
Data at time m_tn.
Definition: ERF_ReadBndryPlanes.H:57
amrex::Real m_tn
The times for which we currently have data.
Definition: ERF_ReadBndryPlanes.H:52
amrex::Vector< amrex::Real > m_in_times
The timesteps / times that we read from time.dat.
Definition: ERF_ReadBndryPlanes.H:81
const int m_extent_rad
Definition: ERF_ReadBndryPlanes.H:90
amrex::Vector< std::unique_ptr< PlaneVector > > m_data_np1
Data at time m_tnp1.
Definition: ERF_ReadBndryPlanes.H:60
amrex::Geometry m_geom
Geometry at level 0.
Definition: ERF_ReadBndryPlanes.H:72
void read_file(int idx, amrex::Vector< std::unique_ptr< PlaneVector >> &data_to_fill, amrex::Array< amrex::Array< amrex::Real, AMREX_SPACEDIM *2 >, AMREX_SPACEDIM+NBCVAR_max > m_bc_extdir_vals)
Definition: ERF_ReadBndryPlanes.cpp:340