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