Alsvinn  0.5.3
The fast FVM simulator with UQ support
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
alsfvm::io::NetCDFWriter Class Reference

#include <alsfvm/io/NetCDFWriter.hpp>

Inheritance diagram for alsfvm::io::NetCDFWriter:
alsfvm::io::Writer alsfvm::io::NetCDFMPIWriter

Public Member Functions

 NetCDFWriter (const std::string &basefileName)
 
virtual ~NetCDFWriter ()
 
virtual void write (const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation) override
 
- Public Member Functions inherited from alsfvm::io::Writer
virtual ~Writer ()
 
virtual void finalize (const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation)
 This method should be called at the end of the simulation. More...
 
void addAttributes (const std::string &nameOfAttributes, const boost::property_tree::ptree &attributes)
 

Protected Member Functions

void writeToFile (netcdf_raw_ptr file, const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation)
 
std::array< netcdf_raw_ptr, 3 > createDimensions (netcdf_raw_ptr basegroup, const volume::Volume &volume)
 
void writeMemory (netcdf_raw_ptr baseGroup, netcdf_raw_ptr dataset, const volume::Volume &volume, size_t memoryIndex)
 
void writeVolume (netcdf_raw_ptr baseGroup, const volume::Volume &volume, std::array< netcdf_raw_ptr, 3 > dimensions)
 
std::pair< netcdf_raw_ptr, netcdf_raw_ptrmakeDataset (netcdf_raw_ptr baseGroup, const volume::Volume &volume, size_t memoryIndex, std::array< netcdf_raw_ptr, 3 > dimensions)
 
std::string getFilename ()
 
void addFileInformation (netcdf_raw_ptr file)
 Writes basic Alsvinn info to file. More...
 

Protected Attributes

size_t snapshotNumber {0}
 
const std::string basefileName
 
- Protected Attributes inherited from alsfvm::io::Writer
std::map< std::string, boost::property_tree::ptree > attributesMap
 

Additional Inherited Members

- Static Public Member Functions inherited from alsfvm::io::Writer
static std::string getClassName ()
 

Detailed Description

The netcdf writer writes to the netcdf format. This is the recommended writer to use

Note
can easily be read by the netcdf python package, see http://www.hydro.washington.edu/~jhamman/hydro-logic/blog/2013/10/12/plot-netcdf-data/

Constructor & Destructor Documentation

◆ NetCDFWriter()

alsfvm::io::NetCDFWriter::NetCDFWriter ( const std::string &  basefileName)

Creates a new instance of the NetCDFWriter

Parameters
basefileNamethe base filename to use. Resulting filenames will be of the form basefileName_<timestep>.nc

◆ ~NetCDFWriter()

virtual alsfvm::io::NetCDFWriter::~NetCDFWriter ( )
inlinevirtual

Since we inherit from this class, this is the safest option (the destructor is anyway empty)

Member Function Documentation

◆ addFileInformation()

void alsfvm::io::NetCDFWriter::addFileInformation ( netcdf_raw_ptr  file)
protected

Writes basic Alsvinn info to file.

◆ createDimensions()

std::array< netcdf_raw_ptr, 3 > alsfvm::io::NetCDFWriter::createDimensions ( netcdf_raw_ptr  basegroup,
const volume::Volume volume 
)
protected

Creates the dimensions

Note
Can only be called once per file!
Parameters
basegroupthe file pointer to write to
volumewill use this to get the dimensions

◆ getFilename()

std::string alsfvm::io::NetCDFWriter::getFilename ( )
protected

Creates the next filename and increments snapshot number

Note
should only be called once per write!

◆ makeDataset()

std::pair< netcdf_raw_ptr, netcdf_raw_ptr > alsfvm::io::NetCDFWriter::makeDataset ( netcdf_raw_ptr  baseGroup,
const volume::Volume volume,
size_t  memoryIndex,
std::array< netcdf_raw_ptr, 3 >  dimensions 
)
protected

Creates or opens a dataset for the given volume and memory index

Parameters
baseGroupthe file/group to create the dimensions in
volumethe volume to extract the size information from
memoryIndexthe given memoryIndex (used for the name)
dimensionsthe already created dimensions
Returns
a touple where the first member is the file/group id, and the second the dataset

◆ write()

void alsfvm::io::NetCDFWriter::write ( const volume::Volume conservedVariables,
const grid::Grid grid,
const simulator::TimestepInformation timestepInformation 
)
overridevirtual

Write the volume to file This will create a variable for each volume

There will be no additioanl grid information written, this is implicit in the netcdf format

Implements alsfvm::io::Writer.

Reimplemented in alsfvm::io::NetCDFMPIWriter.

◆ writeMemory()

void alsfvm::io::NetCDFWriter::writeMemory ( netcdf_raw_ptr  baseGroup,
netcdf_raw_ptr  dataset,
const volume::Volume volume,
size_t  memoryIndex 
)
protected

Writes the memory to the given memory dataset

Parameters
baseGroupthe file pointer (or group pointer)
datasetthe dataset to write to
volumethe volume to extract the memory from (we need this to get the sizes)
memoryIndexthe memoryIndex of the volume

◆ writeToFile()

void alsfvm::io::NetCDFWriter::writeToFile ( netcdf_raw_ptr  file,
const volume::Volume conservedVariables,
const grid::Grid grid,
const simulator::TimestepInformation timestepInformation 
)
protected

Writes to the opened file @note Assumes the file is in define mode

Parameters
filethe filepointer
conservedVariablesthe conservedVariables to write
gridthe underlying grid
timestepInformationthe current timestep information

◆ writeVolume()

void alsfvm::io::NetCDFWriter::writeVolume ( netcdf_raw_ptr  baseGroup,
const volume::Volume volume,
std::array< netcdf_raw_ptr, 3 >  dimensions 
)
protected

Writes the volume to file

Parameters
baseGroupthe baseGroup to write to
volumethe given volume
dimensionsalready created dimensions

Member Data Documentation

◆ basefileName

const std::string alsfvm::io::NetCDFWriter::basefileName
protected

◆ snapshotNumber

size_t alsfvm::io::NetCDFWriter::snapshotNumber {0}
protected

The documentation for this class was generated from the following files: