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
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 NCTimeSeries (const 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 amrex::MultiFab* a_mf_var,
26 bool a_is2d, bool a_save_interpolated);
27
28 /** \brief Read in time array from file and allocate data arrays */
29 void Initialize ();
30
31 /** \brief Calculate interpolated values at time, reading in data as necessary */
32 void update_interpolated_to_time (amrex::Real time);
33
34 /** Container for interpolated data; Only used if save_interpolated == true */
35 amrex::MultiFab* mf_interpolated;
36 private:
37 /** \brief Read in data from file at time index itime and fill into mf */
38 void read_in_at_time (amrex::MultiFab* mf, int itime);
39
40 /// File name to read from
41 std::string file_name;
42 /// Field name in netcdf file
43 std::string field_name;
44 /// Field name for time series in netcdf file
45 std::string time_name;
46 /// Domain
47 amrex::Box domain;
48
49 /// Whether the field we're reading in is 2d
50 bool is2d;
51 /** Whether to save interpolated results in mf_interpolated. If false,
52 * data will be calculated to mf_var */
54
55 /// Time points in netcdf file
56 amrex::Vector<amrex::Real> ocean_times;
57 /// Time index immediately before the last time interpolated to
59 /// Time in ocean_times immediately before the last time interpolated to
60 amrex::Real time_before;
61 /// Time in ocean_times immediately after the last time interpolated to
62 amrex::Real time_after;
63
64 /// Multifab to store data at time_before
65 amrex::MultiFab* mf_before;
66 /// Multifab to store data at time_after
67 amrex::MultiFab* mf_after;
68 /** Pointer to REMORA data that corresponds to the variable being interpolated.
69 * Filled by update_interpolated_to_time if save_interpolated==false. Otherwise,
70 * just used for getting box array, nodality, and distribution mapping */
71 amrex::MultiFab* mf_var;
72};
73
74#endif // REMORA_USE_NETCDF
75#endif //_REMORA_NCTIMESEIRES_H_
A class to hold and interpolate time series data read from a NetCDF file.
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::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.
amrex::Box domain
Domain.
void Initialize()
Read in time array from file and allocate data arrays.
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::MultiFab * mf_after
Multifab to store data at time_after.
amrex::MultiFab * mf_interpolated
std::string time_name
Field name for time series in netcdf file.
std::string file_name
File name to read from.
void update_interpolated_to_time(amrex::Real time)
Calculate interpolated values at time, reading in data as necessary.
amrex::Vector< amrex::Real > ocean_times
Time points in netcdf file.
amrex::MultiFab * mf_var