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 and fill data for level lev */
31 void update_interpolated_to_time (amrex::Real time, int lev,
32 amrex::MultiFab* mf_lev,
33 const amrex::Vector<amrex::Geometry>& geom,
34 const amrex::Vector<amrex::IntVect>& ref_ratio);
35
36 /** \brief Access interpolated data saved for a specific level */
37 const amrex::MultiFab* get_interpolated_mf (int lev) const;
38 private:
39 /** \brief Read in data from file at time index itime and fill into mf */
40 void read_in_at_time (amrex::MultiFab* mf, int itime);
41
42 /** \brief Build cumulative refinement ratio from level 0 to lev */
43 amrex::IntVect cumulative_ref_ratio (int lev,
44 const amrex::Vector<amrex::IntVect>& ref_ratio) const;
45
46 /// File names to read from
47 amrex::Vector<std::string> file_names;
48 /// Whether each file stores this field as one value per time record
49 amrex::Vector<int> file_is_spatially_uniform;
50 /// Field name in netcdf file
51 std::string field_name;
52 /// Field name for time series in netcdf file
53 std::string time_name;
54 /// Domain
55 amrex::Box domain;
56
57 /// Whether the field we're reading in is 2d
58 bool is2d;
59 /** Whether to save interpolated results in mf_interpolated. If false,
60 * data will be calculated to mf_var */
62
63 /// Time points in netcdf file
64 amrex::Vector<amrex::Real> ocean_times;
65 /// File index to access a particular time
66 amrex::Vector<int> file_for_time;
67 /// Offset to access a particular time within its file
68 amrex::Vector<int> file_itime_offset;
69 /// Time index immediately before the last time interpolated to
71 /// Time in ocean_times immediately before the last time interpolated to
72 amrex::Real time_before;
73 /// Time in ocean_times immediately after the last time interpolated to
74 amrex::Real time_after;
75 /// Whether the time series is a cycle
77 /// If a cycle, what is the cycle length?
78 amrex::Real cycle_length;
79
80 /// Multifab to store data at time_before
81 amrex::MultiFab* mf_before;
82 /// Multifab to store data at time_after
83 amrex::MultiFab* mf_after;
84 /// Multifab storing temporally interpolated data on level 0
85 amrex::MultiFab* mf_interp_lev0;
86 /// Interpolated data on each requested AMR level if save_interpolated=true
87 amrex::Vector<std::unique_ptr<amrex::MultiFab>> mf_interpolated_lev;
88 /** Pointer to REMORA data that corresponds to the variable being interpolated.
89 * Filled by update_interpolated_to_time if save_interpolated==false. Otherwise,
90 * just used for getting box array, nodality, and distribution mapping */
91 amrex::MultiFab* mf_var;
92};
93
94#endif // REMORA_USE_NETCDF
95#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 update_interpolated_to_time(amrex::Real 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 and fill data for level lev.
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.
amrex::MultiFab * mf_interp_lev0
Multifab storing temporally interpolated data on level 0.
amrex::Real time_after
Time in ocean_times immediately after the last time interpolated to.
amrex::Real time_before
Time in ocean_times immediately before the last time interpolated to.
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::Real cycle_length
If a cycle, what is the cycle length?
amrex::MultiFab * mf_before
Multifab to store data at time_before.
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.
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.
amrex::Vector< amrex::Real > ocean_times
Time points in netcdf file.
amrex::MultiFab * mf_var