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 (const amrex::Vector<std::string>& a_file_name,
22 const std::string a_field_name,
23 const std::string a_time_name,
24 const amrex::Box& a_domain,
25 const amrex::IntVect a_index_type,
26 const amrex::GpuArray<bool, AMREX_SPACEDIM*2>* a_var_need_data,
27 bool a_is2d);
28
29 /** \brief Read in time array from file and allocate data arrays */
30 void Initialize ();
31
32 /** \brief Calculate interpolated values at time, reading in data as necessary */
33 void update_interpolated_to_time (amrex::Real time);
34
35 /// FArrayBox to store data at inteprolated time at xlo boundary */
36 amrex::FArrayBox xlo_dat_interp;
37
38 /// FArrayBox to store data at inteprolated time at ylo boundary */
39 amrex::FArrayBox ylo_dat_interp;
40
41 /// FArrayBox to store data at inteprolated time at xhi boundary */
42 amrex::FArrayBox xhi_dat_interp;
43
44 /// FArrayBox to store data at inteprolated time at yhi boundary */
45 amrex::FArrayBox yhi_dat_interp;
46
47 private:
48 /** \brief Read in data from file at time index itime and fill into mf */
49 void read_in_at_time (amrex::FArrayBox& fab_xlo,
50 amrex::FArrayBox& fab_xhi,
51 amrex::FArrayBox& fab_ylo,
52 amrex::FArrayBox& fab_yhi,
53 int itime);
54
55 /// File name to read from
56 amrex::Vector<std::string> file_names;
57 /// Field name in netcdf file
58 std::string field_name;
59 /// Variable names that will be read from file
60 amrex::Vector<std::string> nc_var_names;
61 /// Field name for time series in netcdf file
62 std::string time_name;
63 /// Domain
64 amrex::Box domain;
65 /// Index type for field to fill
66 amrex::IntVect index_type;
67
68 /// Whether the field we're reading in is 2d
69 bool is2d;
70
71 /// Time points in netcdf file
72 amrex::Vector<amrex::Real> bry_times;
73 /// File index to access a particular time
74 amrex::Vector<int> file_for_time;
75 /// Offset to access a particular time within its file
76 amrex::Vector<int> file_itime_offset;
77 /// Time index immediately before the last time interpolated to
79 /// Time in ocean_times immediately before the last time interpolated to
80 amrex::Real time_before;
81 /// Time in ocean_times immediately after the last time interpolated to
82 amrex::Real time_after;
83
84 /// FArrayBox to store data at time_before at xlo boundary
85 amrex::FArrayBox xlo_dat_before;
86 /// FArrayBox to store data at time_after at xlo boundary
87 amrex::FArrayBox xlo_dat_after;
88
89 /// FArrayBox to store data at time_before at ylo boundary
90 amrex::FArrayBox ylo_dat_before;
91 /// FArrayBox to store data at time_after at ylo boundary
92 amrex::FArrayBox ylo_dat_after;
93
94 /// FArrayBox to store data at time_before at xhi boundary
95 amrex::FArrayBox xhi_dat_before;
96 /// FArrayBox to store data at time_after at xhi boundary
97 amrex::FArrayBox xhi_dat_after;
98
99 /// FArrayBox to store data at time_before at yhi boundary
100 amrex::FArrayBox yhi_dat_before;
101 /// FArrayBox to store data at time_after at yhi boundary
102 amrex::FArrayBox yhi_dat_after;
103
104 /// Array over boundaries indicating whether we need physical data for this variable
105 amrex::GpuArray<bool, AMREX_SPACEDIM*2> var_need_data;
106};
107
108#endif // REMORA_USE_NETCDF
109#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.
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::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.
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.