REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_NCTimeSeries.H
Go to the documentation of this file.
1#ifndef _REMORA_NCTIMESEIRES_H_
2#define _REMORA_NCTIMESEIRES_H_
3
4#ifdef REMORA_USE_NETCDF
5
6#include <string>
7#include <memory>
8
9#include <AMReX_AmrCore.H>
10
11/** \brief A class to hold and interpolate time series data read from a NetCDF file
12 *
13 * The class only ever holds the two time steps necessary to interpoplate to the current
14 * simulation time.
15 */
17{
18 public:
19 /** \brief Constructor */
20 NCTimeSeries (const amrex::Vector<std::string>& a_file_names,
21 const std::string a_field_name,
22 const std::string a_time_name,
23 const amrex::Box& a_domain,
24 amrex::MultiFab* a_mf_var,
25 bool a_is2d, bool a_save_interpolated);
26
27 /** \brief Read in time array from file and allocate data arrays */
28 void Initialize ();
29
30 /** \brief Calculate interpolated values at time, in seconds on the model clock,
31 * and fill data for level lev */
32 void update_interpolated_to_time (double time, int lev,
33 amrex::MultiFab* mf_lev,
34 const amrex::Vector<amrex::Geometry>& geom,
35 const amrex::Vector<amrex::IntVect>& ref_ratio);
36
37 /** \brief Access interpolated data saved for a specific level */
38 const amrex::MultiFab* get_interpolated_mf (int lev) const;
39 private:
40 /** \brief Read in data from file at time index itime and fill into mf */
41 void read_in_at_time (amrex::MultiFab* mf, int itime);
42
43 /** \brief Build cumulative refinement ratio from level 0 to lev */
44 amrex::IntVect cumulative_ref_ratio (int lev,
45 const amrex::Vector<amrex::IntVect>& ref_ratio) const;
46
47 /// File names to read from
48 amrex::Vector<std::string> file_names;
49 /// Whether each file stores this field as one value per time record
50 amrex::Vector<int> file_is_spatially_uniform;
51 /// Field name in netcdf file
52 std::string field_name;
53 /// Field name for time series in netcdf file
54 std::string time_name;
55 /// Domain
56 amrex::Box domain;
57
58 /// Whether the field we're reading in is 2d
59 bool is2d;
60 /** Whether to save interpolated results in mf_interpolated. If false,
61 * data will be calculated to mf_var */
63
64 /// Time points in netcdf file, in seconds on the model clock. Double, like
65 /// every time on the model clock: see REMORA::t_new.
66 amrex::Vector<double> ocean_times;
67 /// File index to access a particular time
68 amrex::Vector<int> file_for_time;
69 /// Offset to access a particular time within its file
70 amrex::Vector<int> file_itime_offset;
71 /// Time index immediately before the last time interpolated to
73 /// Time in ocean_times immediately before the last time interpolated to
75 /// Time in ocean_times immediately after the last time interpolated to
76 double time_after;
77 /// Whether the time series is a cycle
79 /// If a cycle, what is the cycle length?
81
82 /// Multifab to store data at time_before
83 amrex::MultiFab* mf_before;
84 /// Multifab to store data at time_after
85 amrex::MultiFab* mf_after;
86 /// Multifab storing temporally interpolated data on level 0
87 amrex::MultiFab* mf_interp_lev0;
88 /// Interpolated data on each requested AMR level if save_interpolated=true
89 amrex::Vector<std::unique_ptr<amrex::MultiFab>> mf_interpolated_lev;
90
91 /** Level of the most recent update. One series serves every level, and under
92 * subcycling the levels ask for different times, so a saved buffer is only current
93 * for the level that last updated it. Callers update immediately before reading;
94 * this records enough to catch a caller that stops doing so. */
96 /** Pointer to REMORA data that corresponds to the variable being interpolated.
97 * Filled by update_interpolated_to_time if save_interpolated==false. Otherwise,
98 * just used for getting box array, nodality, and distribution mapping */
99 amrex::MultiFab* mf_var;
100};
101
102#endif // REMORA_USE_NETCDF
103#endif //_REMORA_NCTIMESEIRES_H_
mf_h setVal(geomdata.ProbHi(2))
A class to hold and interpolate time series data read from a NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > mf_interpolated_lev
Interpolated data on each requested AMR level if save_interpolated=true.
bool is2d
Whether the field we're reading in is 2d.
void read_in_at_time(amrex::MultiFab *mf, int itime)
Read in data from file at time index itime and fill into mf.
amrex::Vector< int > file_itime_offset
Offset to access a particular time within its file.
double time_before
Time in ocean_times immediately before the last time interpolated to.
amrex::MultiFab * mf_interp_lev0
Multifab storing temporally interpolated data on level 0.
bool is_cycle
Whether the time series is a cycle.
amrex::Box domain
Domain.
void Initialize()
Read in time array from file and allocate data arrays.
amrex::Vector< int > file_is_spatially_uniform
Whether each file stores this field as one value per time record.
amrex::MultiFab * mf_before
Multifab to store data at time_before.
amrex::Vector< double > ocean_times
int i_time_before
Time index immediately before the last time interpolated to.
std::string field_name
Field name in netcdf file.
amrex::IntVect cumulative_ref_ratio(int lev, const amrex::Vector< amrex::IntVect > &ref_ratio) const
Build cumulative refinement ratio from level 0 to lev.
amrex::Vector< std::string > file_names
File names to read from.
amrex::MultiFab * mf_after
Multifab to store data at time_after.
double cycle_length
If a cycle, what is the cycle length?
std::string time_name
Field name for time series in netcdf file.
amrex::Vector< int > file_for_time
File index to access a particular time.
const amrex::MultiFab * get_interpolated_mf(int lev) const
Access interpolated data saved for a specific level.
void update_interpolated_to_time(double time, int lev, amrex::MultiFab *mf_lev, const amrex::Vector< amrex::Geometry > &geom, const amrex::Vector< amrex::IntVect > &ref_ratio)
Calculate interpolated values at time, in seconds on the model clock, and fill data for level lev.
amrex::MultiFab * mf_var
double time_after
Time in ocean_times immediately after the last time interpolated to.