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 */
21 NCTimeSeriesBoundary (int a_lev,
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, reading in data as necessary */
34 void update_interpolated_to_time (amrex::Real time);
35
36 /// FArrayBox to store data at inteprolated time at xlo boundary */
37 amrex::FArrayBox xlo_dat_interp;
38
39 /// FArrayBox to store data at inteprolated time at ylo boundary */
40 amrex::FArrayBox ylo_dat_interp;
41
42 /// FArrayBox to store data at inteprolated time at xhi boundary */
43 amrex::FArrayBox xhi_dat_interp;
44
45 /// FArrayBox to store data at inteprolated time at yhi boundary */
46 amrex::FArrayBox yhi_dat_interp;
47
48 /// Refinement ratios relative to level 0
49 int m_rx; int m_ry;
50
51 /** \brief spatially interpolate boundary fabs from level 0 data (read in) to current level */
52 void interp_fab (amrex::FArrayBox& dat_crse,
53 amrex::FArrayBox& dat_fine);
54
55 private:
56 /** \brief Read in data from file at time index itime and fill into mf */
57 void read_in_at_time (amrex::FArrayBox& fab_xlo,
58 amrex::FArrayBox& fab_xhi,
59 amrex::FArrayBox& fab_ylo,
60 amrex::FArrayBox& fab_yhi,
61 int itime);
62
63 /// File name to read from
64 amrex::Vector<std::string> file_names;
65 /// Field name in netcdf file
66 std::string field_name;
67 /// Variable names that will be read from file
68 amrex::Vector<std::string> nc_var_names;
69 /// Field name for time series in netcdf file
70 std::string time_name;
71 /// Domain
72 amrex::Box domain;
73 /// Index type for field to fill
74 amrex::IntVect index_type;
75
76 /// Level at which we are holding the boundary data
77 int m_lev;
78
79 /// Geometry at all levels
80 amrex::Vector<amrex::Geometry> m_geom;
81
82 /// Whether the field we're reading in is 2d
83 bool is2d;
84
85 /// Time points in netcdf file
86 amrex::Vector<amrex::Real> bry_times;
87 /// File index to access a particular time
88 amrex::Vector<int> file_for_time;
89 /// Offset to access a particular time within its file
90 amrex::Vector<int> file_itime_offset;
91 /// Time index immediately before the last time interpolated to
93 /// Time in ocean_times immediately before the last time interpolated to
94 amrex::Real time_before;
95 /// Time in ocean_times immediately after the last time interpolated to
96 amrex::Real time_after;
97
98 /// FArrayBox to store data at time_before at xlo boundary
99 amrex::FArrayBox xlo_dat_before;
100 /// FArrayBox to store data at time_after at xlo boundary
101 amrex::FArrayBox xlo_dat_after;
102
103 /// FArrayBox to store data at time_before at ylo boundary
104 amrex::FArrayBox ylo_dat_before;
105 /// FArrayBox to store data at time_after at ylo boundary
106 amrex::FArrayBox ylo_dat_after;
107
108 /// FArrayBox to store data at time_before at xhi boundary
109 amrex::FArrayBox xhi_dat_before;
110 /// FArrayBox to store data at time_after at xhi boundary
111 amrex::FArrayBox xhi_dat_after;
112
113 /// FArrayBox to store data at time_before at yhi boundary
114 amrex::FArrayBox yhi_dat_before;
115 /// FArrayBox to store data at time_after at yhi boundary
116 amrex::FArrayBox yhi_dat_after;
117
118 /// Array over boundaries indicating whether we need physical data for this variable
119 amrex::GpuArray<bool, AMREX_SPACEDIM*2> var_need_data;
120};
121
122#endif // REMORA_USE_NETCDF
123#endif //_REMORA_NCTIMESERIESBOUNDARY_H_
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::Real time_before
Time in ocean_times immediately before the last time interpolated to.
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 *‍/.
amrex::Vector< amrex::Real > bry_times
Time points in netcdf file.
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.
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.
void update_interpolated_to_time(amrex::Real time)
Calculate interpolated values at time, reading in data as necessary.
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::Real time_after
Time in ocean_times immediately after the last time interpolated to.
amrex::Vector< int > file_for_time
File index to access a particular time.