escript
Revision_
|
Represents an escript dataset including a domain and data variables for one timestep. More...
#include <EscriptDataset.h>
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 VarVector & | getVariables () const |
Returns a vector with the dataset's variables. | |
const VarVector & | getMeshVariables () 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 |
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.
Default constructor.
Destructor.
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().
void weipa::EscriptDataset::convertMeshVariables | ( | ) | [private] |
References weipa::VarInfo::dataChunks, domainChunks, meshVariables, updateSampleDistribution(), weipa::VarInfo::valid, and weipa::VarInfo::varName.
Referenced by loadDomain(), and setDomain().
DomainChunks weipa::EscriptDataset::getConvertedDomain | ( | ) | [inline] |
Returns the dataset's converted domain so it can be reused.
int weipa::EscriptDataset::getCycle | ( | ) | const [inline] |
Returns the cycle number.
const VarVector& weipa::EscriptDataset::getMeshVariables | ( | ) | const [inline] |
Returns a vector with the mesh variables.
void* weipa::EscriptDataset::getMPIComm | ( | ) | [inline] |
double weipa::EscriptDataset::getTime | ( | ) | const [inline] |
Returns the time value.
const VarVector& weipa::EscriptDataset::getVariables | ( | ) | const [inline] |
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] |
References weipa::VarInfo::dataChunks, domainChunks, MPI_INT, mpiComm, mpiRank, mpiSize, weipa::VarInfo::units, updateSampleDistribution(), weipa::VarInfo::valid, variables, and weipa::VarInfo::varName.
Referenced by loadNetCDF().
bool weipa::EscriptDataset::loadDomain | ( | const std::string | filePattern, |
int | nChunks | ||
) | [private] |
References convertMeshVariables(), domainChunks, MPI_INT, mpiComm, mpiRank, and mpiSize.
Referenced by loadNetCDF().
bool weipa::EscriptDataset::loadNetCDF | ( | const std::string | domainFilePattern, |
const StringVec & | varFiles, | ||
const StringVec & | varNames, | ||
int | nChunks | ||
) |
Loads domain and variables from escript NetCDF files.
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 |
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] |
References cycle, weipa::VarInfo::dataChunks, weipa::VarInfo::sampleDistribution, time, and weipa::VarInfo::varName.
Referenced by saveSilo().
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().
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().
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] |
References cycle, domainChunks, mdSchema, mdString, weipa::MESH_VARS, meshVariables, MPI_INT, mpiComm, mpiRank, mpiSize, time, weipa::VarInfo::varName, wantsMeshVars, and writeVarToVTK().
Referenced by saveVTK().
void weipa::EscriptDataset::setCycleAndTime | ( | int | c, |
double | t | ||
) | [inline] |
Sets the cycle number and time value for this dataset.
Referenced by BOOST_PYTHON_MODULE().
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.
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.
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.
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.
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::updateSampleDistribution | ( | VarInfo & | vi | ) | [private] |
References weipa::VarInfo::dataChunks, MPI_INT, mpiComm, mpiSize, and weipa::VarInfo::sampleDistribution.
Referenced by addData(), convertMeshVariables(), and loadData().
void weipa::EscriptDataset::writeVarToVTK | ( | const VarInfo & | varInfo, |
std::ostream & | os | ||
) | [private] |
References weipa::VarInfo::dataChunks, mpiRank, mpiSize, and weipa::VarInfo::varName.
Referenced by saveVTKsingle().
int weipa::EscriptDataset::cycle [private] |
Referenced by putSiloMultiMesh(), putSiloMultiTensor(), putSiloMultiVar(), saveSilo(), and saveVTKsingle().
Referenced by addData(), convertMeshVariables(), loadData(), loadDomain(), putSiloMultiMesh(), putSiloMultiVar(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), and setExternalDomain().
bool weipa::EscriptDataset::externalDomain [private] |
Referenced by saveSilo(), and setExternalDomain().
std::string weipa::EscriptDataset::mdSchema [private] |
Referenced by saveVTKsingle().
std::string weipa::EscriptDataset::mdString [private] |
Referenced by saveVTKsingle().
StringVec weipa::EscriptDataset::meshLabels [private] |
Referenced by saveSilo(), and setMeshLabels().
StringVec weipa::EscriptDataset::meshUnits [private] |
Referenced by saveSilo(), and setMeshUnits().
Referenced by convertMeshVariables(), putSiloMultiMesh(), saveSilo(), and saveVTKsingle().
void* weipa::EscriptDataset::mpiComm [private] |
Referenced by loadData(), loadDomain(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), setExternalDomain(), and updateSampleDistribution().
int weipa::EscriptDataset::mpiRank [private] |
Referenced by loadData(), loadDomain(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), and writeVarToVTK().
int weipa::EscriptDataset::mpiSize [private] |
Referenced by loadData(), loadDomain(), saveSilo(), saveVTK(), saveVTKsingle(), setDomain(), setExternalDomain(), updateSampleDistribution(), and writeVarToVTK().
double weipa::EscriptDataset::time [private] |
Referenced by putSiloMultiMesh(), putSiloMultiTensor(), putSiloMultiVar(), saveSilo(), and saveVTKsingle().
VarVector weipa::EscriptDataset::variables [private] |
Referenced by addData(), loadData(), putSiloMultiMesh(), saveSilo(), and saveVTK().
bool weipa::EscriptDataset::wantsMeshVars [private] |
Referenced by saveSilo(), and saveVTKsingle().