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

#include <alsfvm/io/NetCDFMPIWriter.hpp>

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

Public Member Functions

 NetCDFMPIWriter (const std::string &basefileName, const std::vector< std::string > &groupNames, size_t groupIndex, bool newFile, MPI_Comm mpiCommunicator, MPI_Info mpiInfo)
 NetCDFMPIWriter constructs a new NetCDFMPIWriter. More...
 
virtual ~NetCDFMPIWriter ()
 We could inherit from this, hence virtual destructor. More...
 
virtual void write (const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation) override
 write writes the data to disk More...
 
- Public Member Functions inherited from alsfvm::io::NetCDFWriter
 NetCDFWriter (const std::string &basefileName)
 
virtual ~NetCDFWriter ()
 
- 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 Types

typedef std::array< netcdf_raw_ptr, 3 > dimension_vector
 

Protected Member Functions

virtual dimension_vector createDimensions (netcdf_raw_ptr basegroup, const grid::Grid &grid, bool newFile)
 
virtual std::vector< netcdf_raw_ptrmakeDataset (netcdf_raw_ptr baseGroup, const volume::Volume &volume, std::array< netcdf_raw_ptr, 3 > dimensions)
 
virtual void writeToFile (netcdf_raw_ptr file, const volume::Volume &conservedVariables, const grid::Grid &grid, const simulator::TimestepInformation &timestepInformation, bool newFile)
 
virtual void writeMemory (netcdf_raw_ptr baseGroup, netcdf_raw_ptr dataset, const volume::Volume &volume, size_t memoryIndex, const grid::Grid &grid)
 
virtual void writeVolume (netcdf_raw_ptr baseGroup, const volume::Volume &volume, std::array< netcdf_raw_ptr, 3 > dimensions, const std::vector< netcdf_raw_ptr > &datasets, const grid::Grid &grid)
 
- Protected Member Functions inherited from alsfvm::io::NetCDFWriter
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...
 

Additional Inherited Members

- Static Public Member Functions inherited from alsfvm::io::Writer
static std::string getClassName ()
 
- Protected Attributes inherited from alsfvm::io::NetCDFWriter
size_t snapshotNumber {0}
 
const std::string basefileName
 
- Protected Attributes inherited from alsfvm::io::Writer
std::map< std::string, boost::property_tree::ptree > attributesMap
 

Detailed Description

Writes to the mpi version of netcdf.

Note
Due to the new mpi of pNetCDF, this can not be combined in any meaningful way with the old NetCDFWriter class, the code is pretty much disjoint.
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/

Member Typedef Documentation

◆ dimension_vector

Constructor & Destructor Documentation

◆ NetCDFMPIWriter()

alsfvm::io::NetCDFMPIWriter::NetCDFMPIWriter ( const std::string &  basefileName,
const std::vector< std::string > &  groupNames,
size_t  groupIndex,
bool  newFile,
MPI_Comm  mpiCommunicator,
MPI_Info  mpiInfo 
)

NetCDFMPIWriter constructs a new NetCDFMPIWriter.

Parameters
basefileNamethe basefilename to use (this could be eg. "some_simulation".
groupNamesnames of groups to create in the file (this is especially useful for MPI). If left blank (""), no prefix will be given
groupIndexthe groupIndex to write to
newFileshould we create (or overwrite) the file? If false, the file will be opened and fail if it does not exist or if the data does not match (ie. if the sizes mismatch, or if the datasets are named differently)
mpiCommunicatorthe given mpiCommunicator (used for pNETCDF)
mpiInfothe mpiInfo (passed to pNetCDF)
Note
Timestep information will be added to the filename, as well as proper extension (.h5).

◆ ~NetCDFMPIWriter()

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

We could inherit from this, hence virtual destructor.

Member Function Documentation

◆ createDimensions()

NetCDFMPIWriter::dimension_vector alsfvm::io::NetCDFMPIWriter::createDimensions ( netcdf_raw_ptr  basegroup,
const grid::Grid grid,
bool  newFile 
)
protectedvirtual

Creates dimensions

Note
should only be called once per file
Parameters
basegroupthe basegroup to use (or file)
gridthe grid from which to extract size information
newFileif true, we will create the dimensions, otherwise we will try to open the dimensions from the file
Returns
the dimensions created by netcdf

◆ makeDataset()

std::vector< netcdf_raw_ptr > alsfvm::io::NetCDFMPIWriter::makeDataset ( netcdf_raw_ptr  baseGroup,
const volume::Volume volume,
std::array< netcdf_raw_ptr, 3 >  dimensions 
)
protectedvirtual

Creates or opens a dataset for the given volume

This will create variables for all variables in the volume

Note
these should be called before writing data.
Parameters
baseGroupthe file/group to write to
volumevolume is used for size and name information
dimensionsthe already created dimensions
Returns
a list of pairs where the first member is the file/group id, and the second the dataset. It is ordered according to the volume

◆ write()

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

write writes the data to disk

This writes the data in the format

<groupName>_<variable_name>

we do not use any groups to store the file at the moment, this is to ensure maximal compatability with pNetCDF.

Parameters
conservedVariablesthe conservedVariables to write
gridthe grid that is used (describes the whole domain)
timestepInformation

Reimplemented from alsfvm::io::NetCDFWriter.

◆ writeMemory()

void alsfvm::io::NetCDFMPIWriter::writeMemory ( netcdf_raw_ptr  baseGroup,
netcdf_raw_ptr  dataset,
const volume::Volume volume,
size_t  memoryIndex,
const grid::Grid grid 
)
protectedvirtual

Writes the given memory to the dataset/variable

Parameters
baseGroupthe basegroup/file to write to
datasetthe dataset to write to
volumethe volume is used to get size information
memoryIndexthe scalar memory index of the volume
gridthe grid to use

◆ writeToFile()

void alsfvm::io::NetCDFMPIWriter::writeToFile ( netcdf_raw_ptr  file,
const volume::Volume conservedVariables,
const grid::Grid grid,
const simulator::TimestepInformation timestepInformation,
bool  newFile 
)
protectedvirtual

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
newFileis true if the file is created for this iteration, otherwise false

◆ writeVolume()

void alsfvm::io::NetCDFMPIWriter::writeVolume ( netcdf_raw_ptr  baseGroup,
const volume::Volume volume,
std::array< netcdf_raw_ptr, 3 >  dimensions,
const std::vector< netcdf_raw_ptr > &  datasets,
const grid::Grid grid 
)
protectedvirtual

Writes the volume (ie looops over all memory areas and writes each memory area)

Parameters
baseGroupthe baseGroup to use
volumethe volume to use
dimensionsthe given dimensions
datasetsa list of datasets (produced by makeDataset) that is ordered according to the volume (makeDataset does this automatically)
gridthe grid to use

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