#include <NetCdf.h>
|
| | NetCdf (std::string i_path, t_real i_dxy, t_idx i_nx, t_idx i_ny, t_idx i_stride, t_real const *i_bathymetry, t_idx i_k) |
| |
| | NetCdf (Append, std::string i_path, t_real i_dxy, t_idx i_nx, t_idx i_ny, t_idx i_stride, t_idx i_k) |
| |
| | ~NetCdf () |
| |
| | NetCdf (NetCdf const &)=delete |
| |
| NetCdf & | operator= (NetCdf const &)=delete |
| |
| void | writeTimeStep (t_real i_simTime, t_real const *i_h, t_real const *i_hu, t_real const *i_hv) |
| |
| std::size_t | records () const |
| |
| void | writeCheckpoint (std::string i_path, t_real const *i_h, t_real const *i_hu, t_real const *i_hv, t_real const *i_bathymetry, t_real i_simTime, t_idx i_timeStep, t_real i_dt) |
| |
◆ NetCdf() [1/3]
Creates a fresh netCDF file at i_path (overwriting any existing file), defines time/y/x dimensions, the coordinate variables and the time-independent bathymetry, and writes them once. Cell centres are at ((ix + 0.5) * dxy, (iy + 0.5) * dxy) so the values align with the convention used by io::Csv.
- Parameters
-
| i_path | output file path. |
| i_dxy | uniform cell width/height (m). |
| i_nx | number of interior cells in x-direction. |
| i_ny | number of interior cells in y-direction. |
| i_stride | row stride of the data arrays passed to writeTimeStep(). |
| i_bathymetry | bathymetry values at the interior origin (length stride * ny). Optional: nullptr writes a zero-filled bathymetry variable. |
| i_k | coarse-output factor: each k x k block of interior cells is averaged into one output cell, yielding a ceil(nx/k) x ceil(ny/k) grid. Pass 1 for full-resolution output. |
◆ NetCdf() [2/3]
Opens an existing output file (written by the create constructor) for appending: looks up the time/height/momentum variable ids and positions the next record after the last one already present, so a resumed run continues the same solution.nc instead of overwriting it. The grid geometry (full-resolution nx/ny, stride, dxy) and the coarse factor must match the original run.
- Parameters
-
| i_path | existing output file to append to. |
| i_dxy | uniform cell width/height (m). |
| i_nx | number of interior cells in x-direction. |
| i_ny | number of interior cells in y-direction. |
| i_stride | row stride of the data arrays passed to writeTimeStep(). |
| i_k | coarse-output factor used by the original run. |
◆ ~NetCdf()
| tsunami_lab::io::NetCdf::~NetCdf |
( |
| ) |
|
Closes the netCDF file (if open). Errors during close are reported on stderr but not thrown — destructors must not throw.
◆ NetCdf() [3/3]
| tsunami_lab::io::NetCdf::NetCdf |
( |
NetCdf const & | | ) |
|
|
delete |
◆ hasCheckpoint()
| bool tsunami_lab::io::NetCdf::hasCheckpoint |
( |
std::string | i_path | ) |
|
|
static |
True if i_path names a readable checkpoint file (never throws).
◆ operator=()
| NetCdf & tsunami_lab::io::NetCdf::operator= |
( |
NetCdf const & | | ) |
|
|
delete |
◆ read()
Reads a netCDF file with coordinate variables x, y and a 2d data variable z. Both (y, x) and (x, y) dim layouts of z are accepted; the result is always returned in canonical (y, x) row-major order.
- Parameters
-
| i_path | path to the input file. |
- Returns
- the parsed Grid.
◆ readCheckpoint()
Reads a checkpoint written by writeCheckpoint(), returning the four fields plus the simulation time, step counter and constant dt. Throws if the file cannot be opened or is incomplete.
- Parameters
-
| i_path | path to the checkpoint file. |
- Returns
- the recovered restart state.
◆ records()
| std::size_t tsunami_lab::io::NetCdf::records |
( |
| ) |
const |
|
inline |
Number of records written so far (mainly for tests).
◆ writeCheckpoint()
| void tsunami_lab::io::NetCdf::writeCheckpoint |
( |
std::string | i_path, |
|
|
t_real const * | i_h, |
|
|
t_real const * | i_hu, |
|
|
t_real const * | i_hv, |
|
|
t_real const * | i_bathymetry, |
|
|
t_real | i_simTime, |
|
|
t_idx | i_timeStep, |
|
|
t_real | i_dt ) |
Writes a full, self-contained restart checkpoint to i_path: the four fields (height, momentum_x, momentum_y, bathymetry) at full resolution plus the x/y coordinate variables and the scalar metadata needed to resume the run identically (simulation time, time-step counter and the constant time step dt). The file is created, fully written and closed in one call, so a reader always sees a complete checkpoint.
- Parameters
-
| i_path | output path for the checkpoint file. |
| i_h | water heights at the interior origin. |
| i_hu | x-momenta at the interior origin. |
| i_hv | y-momenta at the interior origin. |
| i_bathymetry | bathymetry at the interior origin. |
| i_simTime | current simulation time (seconds). |
| i_timeStep | current time-step counter. |
| i_dt | constant time step of the run (seconds). |
◆ writeTimeStep()
| void tsunami_lab::io::NetCdf::writeTimeStep |
( |
t_real | i_simTime, |
|
|
t_real const * | i_h, |
|
|
t_real const * | i_hu, |
|
|
t_real const * | i_hv ) |
Appends one record to the unlimited time dimension. Each of i_h, i_hu, i_hv must point at the interior origin of an array with the row stride passed to the constructor.
- Parameters
-
| i_simTime | current simulation time (seconds). |
| i_h | water heights at the interior origin. |
| i_hu | x-momenta at the interior origin. |
| i_hv | y-momenta at the interior origin. |
The documentation for this class was generated from the following files: