escript  Revision_
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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...
 
bool 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 VarVectorgetVariables () const
 Returns a vector with the dataset's variables. More...
 
const VarVectorgetMeshVariables () 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)
 
bool 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.

References cycle, externalDomain, mpiComm, mpiRank, mpiSize, time, and wantsMeshVars.

◆ ~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

◆ 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

◆ loadDomain()

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

◆ loadNetCDF() [1/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
domainFilePatterna printf-style pattern for the domain file names (e.g. "dom.%02d.nc")
varFilesa vector of file name patterns for variables
varNamesa vector of variable names
nChunksnumber 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().

◆ loadNetCDF() [2/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().

◆ 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

◆ putSiloMultiVar()

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

◆ saveSilo()

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

◆ saveVTK()

bool 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()

bool weipa::EscriptDataset::saveVTKsingle ( const std::string &  fileName,
const std::string &  meshName,
const VarVector vars 
)
private

◆ 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

◆ writeVarToVTK()

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

Member Data Documentation

◆ cycle

int weipa::EscriptDataset::cycle
private

◆ domainChunks

DomainChunks weipa::EscriptDataset::domainChunks
private

◆ externalDomain

bool weipa::EscriptDataset::externalDomain
private

◆ 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

◆ mpiComm

void* weipa::EscriptDataset::mpiComm
private

◆ mpiRank

int weipa::EscriptDataset::mpiRank
private

◆ mpiSize

int weipa::EscriptDataset::mpiSize
private

◆ time

double weipa::EscriptDataset::time
private

◆ variables

VarVector weipa::EscriptDataset::variables
private

◆ wantsMeshVars

bool weipa::EscriptDataset::wantsMeshVars
private

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