weipa::EscriptDataset Class Reference

Represents an escript dataset including a domain and data variables for one timestep. More...

`#include <EscriptDataset.h>`

## Public Member Functions

| EscriptDataset ()
| Default constructor. More...
| ~EscriptDataset ()
| Destructor. More...
bool | setDomain (const escript::AbstractDomain *domain)
| Sets the escript domain for this dataset. This method can only be called once and should be the first call unless loading from dump files. More...
bool | addData (escript::Data &data, const std::string name, const std::string units="")
| Adds an escript data instance to this dataset. You must ensure that the data is defined on the domain that was used in. More...
bool | loadNetCDF (const std::string domainFilePattern, const StringVec &varFiles, const StringVec &varNames, int nChunks)
| Loads domain and variables from escript NetCDF files. More...
bool | loadNetCDF (const DomainChunks &domain, const StringVec &varFiles, const StringVec &varNames)
| Loads only variables from escript NetCDF files using the domain provided. More...
void | setCycleAndTime (int c, double t)
| Sets the cycle number and time value for this dataset. More...
int | getCycle () const
| Returns the cycle number. More...
double | getTime () const
| Returns the time value. More...
void | setMeshLabels (const std::string x, const std::string y, const std::string z="")
| Sets labels for the mesh axes. More...
void | setMeshUnits (const std::string x, const std::string y, const std::string z="")
| Sets units for the mesh axes. More...
void | setMetadataSchemaString (const std::string schema, const std::string metadata)
| Sets a metadata schema and content. More...
void | setSaveMeshData (bool flag)
| Enables/Disables saving of mesh-related data. More...
bool | saveSilo (const std::string fileName, bool useMultiMesh=true)
| Saves the dataset in the Silo file format. More...
void | saveVTK (const std::string fileName)
| Saves the dataset in the VTK XML file format. More...
DomainChunks | getConvertedDomain ()
| Returns the dataset's converted domain so it can be reused. More...
const VarVector & | getVariables () const
| Returns a vector with the dataset's variables. More...
const VarVector & | getMeshVariables () const
| Returns a vector with the mesh variables. More...
void * | getMPIComm ()

## Private Member Functions

bool | loadDomain (const std::string filePattern, int nChunks)
bool | setExternalDomain (const DomainChunks &domain)
bool | loadData (const std::string filePattern, const std::string name, const std::string units)
void | convertMeshVariables ()
void | updateSampleDistribution (VarInfo &vi)
void | putSiloMultiMesh (DBfile *dbfile, const std::string &meshName)
void | putSiloMultiTensor (DBfile *dbfile, const VarInfo &vi)
void | putSiloMultiVar (DBfile *dbfile, const VarInfo &vi, bool useMeshFile=false)
void | saveVTKsingle (const std::string &fileName, const std::string &meshName, const VarVector &vars)
void | writeVarToVTK (const VarInfo &varInfo, std::ostream &os)

## Private Attributes

int | cycle
double | time
std::string | mdSchema
std::string | mdString
StringVec | meshLabels
StringVec | meshUnits
bool | externalDomain
bool | wantsMeshVars
DomainChunks | domainChunks
VarVector | variables
VarVector | meshVariables
int | mpiRank
int | mpiSize
void * | mpiComm

## Detailed Description

Represents an escript dataset including a domain and data variables for one timestep.

This class represents an escript dataset complete with domain and variable data. It can read the dataset from files generated by the dump() methods within escript or through an escript domain instance plus a number of escript::Data instances. Subsequently, the dataset can be saved in the Silo or VTK file format or accessed through a number of accessor methods.

If the data is distributed via MPI then all ranks should create an instance of this class and call the respective methods. Dump files that stem from a parallel run can be read on one processor or on the same number of MPI processes as they were created with.

## Constructor & Destructor Documentation

## EscriptDataset()

weipa::EscriptDataset::EscriptDataset | ( |  | ) |

Default constructor.

## ~EscriptDataset()

weipa::EscriptDataset::~EscriptDataset | ( |  | ) |

Destructor.

## Member Function Documentation

## addData()

bool weipa::EscriptDataset::addData | ( | escript::Data & | data,
|  | const std::string | name,
|  | const std::string | units = `""`
| ) |  |

Adds an escript data instance to this dataset. You must ensure that the data is defined on the domain that was used in.

References weipa::VarInfo::dataChunks, domainChunks, weipa::VarInfo::units, updateSampleDistribution(), weipa::VarInfo::valid, variables, and weipa::VarInfo::varName.

Referenced by BOOST_PYTHON_MODULE().

## convertMeshVariables()

void weipa::EscriptDataset::convertMeshVariables | ( |  | ) |

private

References weipa::VarInfo::dataChunks, domainChunks, meshVariables, updateSampleDistribution(), weipa::VarInfo::valid, and weipa::VarInfo::varName.

Referenced by loadDomain(), and setDomain().

## getConvertedDomain()

DomainChunks weipa::EscriptDataset::getConvertedDomain | ( |  | ) |

inline

Returns the dataset's converted domain so it can be reused.

## getCycle()

int weipa::EscriptDataset::getCycle | ( |  | ) | const

inline

Returns the cycle number.

## getMeshVariables()

const VarVector& weipa::EscriptDataset::getMeshVariables | ( |  | ) | const

inline

Returns a vector with the mesh variables.

## getMPIComm()

void* weipa::EscriptDataset::getMPIComm | ( |  | ) |

inline

## getTime()

double weipa::EscriptDataset::getTime | ( |  | ) | const

inline

Returns the time value.

## getVariables()

const VarVector& weipa::EscriptDataset::getVariables | ( |  | ) | const

inline

Returns a vector with the dataset's variables.

## loadData()

bool weipa::EscriptDataset::loadData | ( | const std::string | filePattern,
|  | const std::string | name,
|  | const std::string | units
| ) |  |

private

References weipa::VarInfo::dataChunks, domainChunks, MPI_INT, MPI_MAX, mpiComm, mpiRank, mpiSize, weipa::VarInfo::units, updateSampleDistribution(), weipa::VarInfo::valid, variables, and weipa::VarInfo::varName.

Referenced by loadNetCDF().

## loadDomain()

bool weipa::EscriptDataset::loadDomain | ( | const std::string | filePattern,
|  | int | nChunks
| ) |  |

private

References convertMeshVariables(), domainChunks, MPI_INT, MPI_MAX, mpiComm, mpiRank, and mpiSize.

Referenced by loadNetCDF().

## loadNetCDF() [1/2]

bool weipa::EscriptDataset::loadNetCDF | ( | const DomainChunks & | domain,
|  | const StringVec & | varFiles,
|  | const StringVec & | varNames
| ) |  |

Loads only variables from escript NetCDF files using the domain provided.

References loadData(), and setExternalDomain().

## loadNetCDF() [2/2]

bool weipa::EscriptDataset::loadNetCDF | ( | const std::string | domainFilePattern,
|  | const StringVec & | varFiles,
|  | const StringVec & | varNames,
|  | int | nChunks
| ) |  |

Loads domain and variables from escript NetCDF files.

Parameters

  domainFilePattern | a printf-style pattern for the domain file names (e.g. "dom.%02d.nc")
  varFiles | a vector of file name patterns for variables
  varNames | a vector of variable names
  nChunks | number of chunks to load

Note
  If MPI is enabled nChunks must be equal to the size of the communicator or this method fails.

References loadData(), and loadDomain().

## putSiloMultiMesh()

void weipa::EscriptDataset::putSiloMultiMesh | ( | DBfile * | dbfile,
|  | const std::string & | meshName
| ) |  |

private

References cycle, domainChunks, meshVariables, time, and variables.

Referenced by saveSilo().

## putSiloMultiTensor()

void weipa::EscriptDataset::putSiloMultiTensor | ( | DBfile * | dbfile,
|  | const VarInfo & | vi
| ) |  |

private

References cycle, weipa::VarInfo::dataChunks, weipa::VarInfo::sampleDistribution, time, and weipa::VarInfo::varName.

Referenced by saveSilo().

## putSiloMultiVar()

void weipa::EscriptDataset::putSiloMultiVar | ( | DBfile * | dbfile,
|  | const VarInfo & | vi,
|  | bool | useMeshFile = `false`
| ) |  |

private

References cycle, domainChunks, weipa::MESH_VARS, weipa::VarInfo::sampleDistribution, time, and weipa::VarInfo::varName.

Referenced by saveSilo().

## saveSilo()

bool weipa::EscriptDataset::saveSilo | ( | const std::string | fileName,
|  | bool | useMultiMesh = `true`
| ) |  |

Saves the dataset in the Silo file format.

References cycle, domainChunks, externalDomain, weipa::MESH_VARS, meshLabels, meshUnits, meshVariables, mpiComm, mpiRank, mpiSize, putSiloMultiMesh(), putSiloMultiTensor(), putSiloMultiVar(), time, variables, and wantsMeshVars.

Referenced by BOOST_PYTHON_MODULE().

## saveVTK()

void weipa::EscriptDataset::saveVTK | ( | const std::string | fileName | ) |

Saves the dataset in the VTK XML file format.

References domainChunks, mpiComm, mpiRank, mpiSize, saveVTKsingle(), and variables.

Referenced by BOOST_PYTHON_MODULE().

## saveVTKsingle()

void weipa::EscriptDataset::saveVTKsingle | ( | const std::string & | fileName,
|  | const std::string & | meshName,
|  | const VarVector & | vars
| ) |  |

private

References cycle, domainChunks, mdSchema, mdString, weipa::MESH_VARS, meshVariables, MPI_INT, MPI_MAX, MPI_SUM, mpiComm, mpiRank, mpiSize, time, weipa::VarInfo::varName, wantsMeshVars, and writeVarToVTK().

Referenced by saveVTK().

## setCycleAndTime()

void weipa::EscriptDataset::setCycleAndTime | ( | int | c,
|  | double | t
| ) |  |

inline

Sets the cycle number and time value for this dataset.

Referenced by BOOST_PYTHON_MODULE().

## setDomain()

bool weipa::EscriptDataset::setDomain | ( | const escript::AbstractDomain * | domain | ) |

Sets the escript domain for this dataset. This method can only be called once and should be the first call unless loading from dump files.

Note
  If MPI is enabled this method also initialises the communicator that will be used subsequently.

References convertMeshVariables(), domainChunks, escript::AbstractDomain::getMPIComm(), escript::AbstractDomain::getMPIRank(), escript::AbstractDomain::getMPISize(), MPI_INT, MPI_MAX, mpiComm, mpiRank, and mpiSize.

Referenced by BOOST_PYTHON_MODULE().

## setExternalDomain()

bool weipa::EscriptDataset::setExternalDomain | ( | const DomainChunks & | domain | ) |

private

References domainChunks, externalDomain, MPI_INT, MPI_MAX, mpiComm, and mpiSize.

Referenced by loadNetCDF().

## setMeshLabels()

void weipa::EscriptDataset::setMeshLabels | ( | const std::string | x,
|  | const std::string | y,
|  | const std::string | z = `""`
| ) |  |

Sets labels for the mesh axes.

Note
  This information is only used by the Silo writer.

References meshLabels.

Referenced by BOOST_PYTHON_MODULE().

## setMeshUnits()

void weipa::EscriptDataset::setMeshUnits | ( | const std::string | x,
|  | const std::string | y,
|  | const std::string | z = `""`
| ) |  |

Sets units for the mesh axes.

Note
  This information is only used by the Silo writer.

References meshUnits.

Referenced by BOOST_PYTHON_MODULE().

## setMetadataSchemaString()

void weipa::EscriptDataset::setMetadataSchemaString | ( | const std::string | schema,
|  | const std::string | metadata
| ) |  |

inline

Sets a metadata schema and content.

Note
  Only used by the VTK writer.

Referenced by BOOST_PYTHON_MODULE().

## setSaveMeshData()

void weipa::EscriptDataset::setSaveMeshData | ( | bool | flag | ) |

inline

Enables/Disables saving of mesh-related data.

Referenced by BOOST_PYTHON_MODULE().

## updateSampleDistribution()

void weipa::EscriptDataset::updateSampleDistribution | ( | VarInfo & | vi | ) |

private

References weipa::VarInfo::dataChunks, MPI_INT, mpiComm, mpiSize, and weipa::VarInfo::sampleDistribution.

Referenced by addData(), convertMeshVariables(), and loadData().

## writeVarToVTK()

void weipa::EscriptDataset::writeVarToVTK | ( | const VarInfo & | varInfo,
|  | std::ostream & | os
| ) |  |

private

References weipa::VarInfo::dataChunks, mpiRank, mpiSize, and weipa::VarInfo::varName.

Referenced by saveVTKsingle().

## Member Data Documentation

## cycle

int weipa::EscriptDataset::cycle

private

Referenced by putSiloMultiMesh(), putSiloMultiTensor(), putSiloMultiVar(), saveSilo(), and saveVTKsingle().

## domainChunks

DomainChunks weipa::EscriptDataset::domainChunks

private

Referenced by addData(), convertMeshVariables(), loadData(), loadDomain(), putSiloMultiMesh(), putSiloMultiVar(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), and setExternalDomain().

## externalDomain

bool weipa::EscriptDataset::externalDomain

private

Referenced by saveSilo(), and setExternalDomain().

## mdSchema

std::string weipa::EscriptDataset::mdSchema

private

Referenced by saveVTKsingle().

## mdString

std::string weipa::EscriptDataset::mdString

private

Referenced by saveVTKsingle().

## meshLabels

StringVec weipa::EscriptDataset::meshLabels

private

Referenced by saveSilo(), and setMeshLabels().

## meshUnits

StringVec weipa::EscriptDataset::meshUnits

private

Referenced by saveSilo(), and setMeshUnits().

## meshVariables

VarVector weipa::EscriptDataset::meshVariables

private

Referenced by convertMeshVariables(), putSiloMultiMesh(), saveSilo(), and saveVTKsingle().

## mpiComm

void* weipa::EscriptDataset::mpiComm

private

Referenced by loadData(), loadDomain(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), setExternalDomain(), and updateSampleDistribution().

## mpiRank

int weipa::EscriptDataset::mpiRank

private

Referenced by loadData(), loadDomain(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), and writeVarToVTK().

## mpiSize

int weipa::EscriptDataset::mpiSize

private

Referenced by loadData(), loadDomain(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), setExternalDomain(), updateSampleDistribution(), and writeVarToVTK().

## time

double weipa::EscriptDataset::time

private

Referenced by putSiloMultiMesh(), putSiloMultiTensor(), putSiloMultiVar(), saveSilo(), and saveVTKsingle().

## variables

VarVector weipa::EscriptDataset::variables

private

Referenced by addData(), loadData(), putSiloMultiMesh(), saveSilo(), and saveVTK().

## wantsMeshVars

bool weipa::EscriptDataset::wantsMeshVars

private

Referenced by saveSilo(), and saveVTKsingle().

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

- EscriptDataset.h
- EscriptDataset.cpp