ESYS13  Revision_
Public Member Functions | Private Member Functions | Private Attributes
weipa::EscriptDataset Class Reference

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

#include <EscriptDataset.h>

List of all members.

Public Member Functions

 EscriptDataset ()
 Default constructor.
 ~EscriptDataset ()
 Destructor.
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.
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.
bool loadNetCDF (const std::string domainFilePattern, const StringVec &varFiles, const StringVec &varNames, int nChunks)
 Loads domain and variables from escript NetCDF files.
bool loadNetCDF (const DomainChunks &domain, const StringVec &varFiles, const StringVec &varNames)
 Loads only variables from escript NetCDF files using the domain provided.
void setCycleAndTime (int c, double t)
 Sets the cycle number and time value for this dataset.
int getCycle () const
 Returns the cycle number.
double getTime () const
 Returns the time value.
void setMeshLabels (const std::string x, const std::string y, const std::string z="")
 Sets labels for the mesh axes.
void setMeshUnits (const std::string x, const std::string y, const std::string z="")
 Sets units for the mesh axes.
void setMetadataSchemaString (const std::string schema, const std::string metadata)
 Sets a metadata schema and content.
void setSaveMeshData (bool flag)
 Enables/Disables saving of mesh-related data.
bool saveSilo (const std::string fileName, bool useMultiMesh=true)
 Saves the dataset in the Silo file format.
bool saveVTK (const std::string fileName)
 Saves the dataset in the VTK XML file format.
DomainChunks getConvertedDomain ()
 Returns the dataset's converted domain so it can be reused.
const VarVectorgetVariables () const
 Returns a vector with the dataset's variables.
const VarVectorgetMeshVariables () const
 Returns a vector with the mesh variables.
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

Default constructor.

Destructor.


Member Function Documentation

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

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

int weipa::EscriptDataset::getCycle ( ) const [inline]

Returns the cycle number.

Returns a vector with the mesh variables.

double weipa::EscriptDataset::getTime ( ) const [inline]

Returns the time value.

Returns a vector with the dataset's variables.

bool weipa::EscriptDataset::loadData ( const std::string  filePattern,
const std::string  name,
const std::string  units 
) [private]
bool weipa::EscriptDataset::loadDomain ( const std::string  filePattern,
int  nChunks 
) [private]
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().

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

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

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

Referenced by saveSilo().

void weipa::EscriptDataset::putSiloMultiTensor ( DBfile *  dbfile,
const VarInfo vi 
) [private]
void weipa::EscriptDataset::putSiloMultiVar ( DBfile *  dbfile,
const VarInfo vi,
bool  useMeshFile = false 
) [private]
bool weipa::EscriptDataset::saveSilo ( const std::string  fileName,
bool  useMultiMesh = true 
)
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().

bool weipa::EscriptDataset::saveVTKsingle ( const std::string &  fileName,
const std::string &  meshName,
const VarVector vars 
) [private]
void weipa::EscriptDataset::setCycleAndTime ( int  c,
double  t 
) [inline]

Sets the cycle number and time value for this dataset.

Referenced by BOOST_PYTHON_MODULE().

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, mpiComm, mpiRank, and mpiSize.

Referenced by BOOST_PYTHON_MODULE().

bool weipa::EscriptDataset::setExternalDomain ( const DomainChunks domain) [private]

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

Referenced by loadNetCDF().

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

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

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

void weipa::EscriptDataset::setSaveMeshData ( bool  flag) [inline]

Enables/Disables saving of mesh-related data.

Referenced by BOOST_PYTHON_MODULE().

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

Member Data Documentation

Referenced by saveSilo(), and setExternalDomain().

std::string weipa::EscriptDataset::mdSchema [private]

Referenced by saveVTKsingle().

std::string weipa::EscriptDataset::mdString [private]

Referenced by saveVTKsingle().

Referenced by saveSilo(), and setMeshLabels().

Referenced by saveSilo(), and setMeshUnits().

double weipa::EscriptDataset::time [private]

Referenced by saveSilo(), and saveVTKsingle().


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