Class mgrid::NcWriter
Incremental writer for a gridded solution file (netCDF-4). More...
#include <netcdf_writer.hpp>
Public Functions
| Type | Name |
|---|---|
| NcWriter (const std::string & path, int nx, int nz, double hx, double hz) Opens path (replacing any existing file) and writes thex /z axis coordinate variables. |
|
| NcWriter (const NcWriter &) = delete |
|
| void | add_attribute (const std::string & name, double value) Adds a scalar double global attribute. |
| void | add_variable (const std::string & name, const Field2D & field) Adds a 2-D double variable over (x ,z ) and writes it. |
| NcWriter & | operator= (const NcWriter &) = delete |
| ~NcWriter () Flushes and closes the file. |
Detailed Description
Construction opens the target path (replacing any existing file), defines the x/z dimensions and fills the 1-D axis coordinate variables. Callers then add 2-D field variables with add_variable() and scalar globals with add_attribute(); the file is flushed and closed when the writer is destroyed.
Public Functions Documentation
function NcWriter [1/2]
Opens path (replacing any existing file) and writes thex /z axis coordinate variables.
mgrid::NcWriter::NcWriter (
const std::string & path,
int nx,
int nz,
double hx,
double hz
)
Parameters:
pathfull output path (the caller has already appended.nc).nxnumber of grid points in x (rows); becomes dimx.nznumber of grid points in z (columns); becomes dimz.hxgrid spacing in x; axis var"x"is filled withi * hx.hzgrid spacing in z; axis var"z"is filled withj * hz.
Exception:
propagatesthe underlying netCDF-C++ exception (astd::exception) on any failure.
function NcWriter [2/2]
mgrid::NcWriter::NcWriter (
const NcWriter &
) = delete
function add_attribute
Adds a scalar double global attribute.
void mgrid::NcWriter::add_attribute (
const std::string & name,
double value
)
Parameters:
nameattribute name.valueattribute value.
Exception:
propagatesthe underlying netCDF-C++ exception on failure.
function add_variable
Adds a 2-D double variable over (x ,z ) and writes it.
void mgrid::NcWriter::add_variable (
const std::string & name,
const Field2D & field
)
Parameters:
namevariable name.fieldvalues, row-major;field.data()is written verbatim.
Exception:
propagatesthe underlying netCDF-C++ exception on failure.
function operator=
NcWriter & mgrid::NcWriter::operator= (
const NcWriter &
) = delete
function ~NcWriter
Flushes and closes the file.
mgrid::NcWriter::~NcWriter ()
The documentation for this class was generated from the following file include/multigrid/netcdf_writer.hpp