REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_NCTimeSeriesBoundary.H
Go to the documentation of this file.
1#ifndef _REMORA_NCTIMESERIESBOUNDARY_H_
2#define _REMORA_NCTIMESERIESBOUNDARY_H_
3
4#ifdef REMORA_USE_NETCDF
5
6#include <string>
7
8#include <AMReX_AmrCore.H>
9
10#include <REMORA.H>
11
12/** \brief A class to hold and interpolate time series data read from a NetCDF file
13 *
14 * The class only ever holds the two time steps necessary to interpoplate to the current
15 * simulation time.
16 */
18{
19 public:
20 /** \brief Constructor */
22 const amrex::Vector<amrex::Geometry> a_geom,
23 const amrex::Vector<std::string>& a_file_name,
24 const std::string a_field_name,
25 const std::string a_time_name,
26 const amrex::IntVect a_index_type,
27 const amrex::GpuArray<bool, AMREX_SPACEDIM*2>& a_var_need_data,
28 bool a_is2d, int rx, int ry);
29
30 /** \brief Read in time array from file and allocate data arrays */
31 void Initialize ();
32
33 /** \brief Calculate interpolated values at time, in seconds on the model clock,
34 * reading in data as necessary */
36
37 /// FArrayBox to store data at inteprolated time at xlo boundary */
38 amrex::FArrayBox xlo_dat_interp;
39
40 /// FArrayBox to store data at inteprolated time at ylo boundary */
41 amrex::FArrayBox ylo_dat_interp;
42
43 /// FArrayBox to store data at inteprolated time at xhi boundary */
44 amrex::FArrayBox xhi_dat_interp;
45
46 /// FArrayBox to store data at inteprolated time at yhi boundary */
47 amrex::FArrayBox yhi_dat_interp;
48
49 /// Refinement ratios relative to level 0
50 int m_rx; int m_ry;
51
52 /** \brief spatially interpolate boundary fabs from level 0 data (read in) to current level */
53 void interp_fab (amrex::FArrayBox& dat_crse,
54 amrex::FArrayBox& dat_fine);
55
56 private:
57 /** \brief Read in data from file at time index itime and fill into mf */
58 void read_in_at_time (amrex::FArrayBox& fab_xlo,
59 amrex::FArrayBox& fab_xhi,
60 amrex::FArrayBox& fab_ylo,
61 amrex::FArrayBox& fab_yhi,
62 int itime);
63
64 /// File name to read from
65 amrex::Vector<std::string> file_names;
66 /// Field name in netcdf file
67 std::string field_name;
68 /// Variable names that will be read from file
69 amrex::Vector<std::string> nc_var_names;
70 /// Field name for time series in netcdf file
71 std::string time_name;
72 /// Domain
73 amrex::Box domain;
74 /// Index type for field to fill
75 amrex::IntVect index_type;
76
77 /// Level at which we are holding the boundary data
78 int m_lev;
79
80 /// Geometry at all levels
81 amrex::Vector<amrex::Geometry> m_geom;
82
83 /// Whether the field we're reading in is 2d
84 bool is2d;
85
86 /// Time points in netcdf file, in seconds on the model clock
87 amrex::Vector<double> bry_times;
88 /// File index to access a particular time
89 amrex::Vector<int> file_for_time;
90 /// Offset to access a particular time within its file
91 amrex::Vector<int> file_itime_offset;
92 /// Time index immediately before the last time interpolated to
94 /// Time in ocean_times immediately before the last time interpolated to
96 /// Time in ocean_times immediately after the last time interpolated to
97 double time_after;
98
99 /// FArrayBox to store data at time_before at xlo boundary
100 amrex::FArrayBox xlo_dat_before;
101 /// FArrayBox to store data at time_after at xlo boundary
102 amrex::FArrayBox xlo_dat_after;
103
104 /// FArrayBox to store data at time_before at ylo boundary
105 amrex::FArrayBox ylo_dat_before;
106 /// FArrayBox to store data at time_after at ylo boundary
107 amrex::FArrayBox ylo_dat_after;
108
109 /// FArrayBox to store data at time_before at xhi boundary
110 amrex::FArrayBox xhi_dat_before;
111 /// FArrayBox to store data at time_after at xhi boundary
112 amrex::FArrayBox xhi_dat_after;
113
114 /// FArrayBox to store data at time_before at yhi boundary
115 amrex::FArrayBox yhi_dat_before;
116 /// FArrayBox to store data at time_after at yhi boundary
117 amrex::FArrayBox yhi_dat_after;
118
119 /// Array over boundaries indicating whether we need physical data for this variable
120 amrex::GpuArray<bool, AMREX_SPACEDIM*2> var_need_data;
121};
122
123#endif // REMORA_USE_NETCDF
124#endif //_REMORA_NCTIMESERIESBOUNDARY_H_
mf_h setVal(geomdata.ProbHi(2))
A class to hold and interpolate time series data read from a NetCDF file.
amrex::FArrayBox yhi_dat_before
FArrayBox to store data at time_before at yhi boundary.
amrex::FArrayBox yhi_dat_after
FArrayBox to store data at time_after at yhi boundary.
amrex::GpuArray< bool, AMREX_SPACEDIM *2 > var_need_data
Array over boundaries indicating whether we need physical data for this variable.
void interp_fab(amrex::FArrayBox &dat_crse, amrex::FArrayBox &dat_fine)
spatially interpolate boundary fabs from level 0 data (read in) to current level
amrex::FArrayBox ylo_dat_before
FArrayBox to store data at time_before at ylo boundary.
amrex::FArrayBox xlo_dat_after
FArrayBox to store data at time_after at xlo boundary.
amrex::Vector< std::string > nc_var_names
Variable names that will be read from file.
amrex::FArrayBox ylo_dat_after
FArrayBox to store data at time_after at ylo boundary.
amrex::Vector< double > bry_times
Time points in netcdf file, in seconds on the model clock.
double time_before
Time in ocean_times immediately before the last time interpolated to.
void update_interpolated_to_time(double time)
Calculate interpolated values at time, in seconds on the model clock, reading in data as necessary.
void Initialize()
Read in time array from file and allocate data arrays.
amrex::FArrayBox yhi_dat_interp
FArrayBox to store data at inteprolated time at yhi boundary *‍/.
amrex::FArrayBox xlo_dat_interp
FArrayBox to store data at inteprolated time at xlo boundary *‍/.
std::string time_name
Field name for time series in netcdf file.
amrex::FArrayBox xhi_dat_interp
FArrayBox to store data at inteprolated time at xhi boundary *‍/.
amrex::IntVect index_type
Index type for field to fill.
double time_after
Time in ocean_times immediately after the last time interpolated to.
int i_time_before
Time index immediately before the last time interpolated to.
std::string field_name
Field name in netcdf file.
amrex::FArrayBox ylo_dat_interp
FArrayBox to store data at inteprolated time at ylo boundary *‍/.
amrex::Vector< amrex::Geometry > m_geom
Geometry at all levels.
amrex::FArrayBox xhi_dat_after
FArrayBox to store data at time_after at xhi boundary.
void read_in_at_time(amrex::FArrayBox &fab_xlo, amrex::FArrayBox &fab_xhi, amrex::FArrayBox &fab_ylo, amrex::FArrayBox &fab_yhi, int itime)
Read in data from file at time index itime and fill into mf.
amrex::Vector< std::string > file_names
File name to read from.
amrex::Vector< int > file_itime_offset
Offset to access a particular time within its file.
amrex::FArrayBox xhi_dat_before
FArrayBox to store data at time_before at xhi boundary.
bool is2d
Whether the field we're reading in is 2d.
int m_lev
Level at which we are holding the boundary data.
int m_rx
Refinement ratios relative to level 0.
amrex::FArrayBox xlo_dat_before
FArrayBox to store data at time_before at xlo boundary.
amrex::Vector< int > file_for_time
File index to access a particular time.