escript
Revision_
|
A class that provides functionality to read an escript data object from a dump file or an escript::Data instance and write that data in Silo or VTK XML formats. More...
#include <DataVar.h>
Public Member Functions | |
DataVar (const std::string &name) | |
Constructor with variable name. | |
DataVar (const DataVar &d) | |
Copy constructor. Performs a deep copy of the data values. | |
~DataVar () | |
Destructor. | |
bool | initFromEscript (escript::Data &escriptData, const_DomainChunk_ptr dom) |
Initialises values and IDs from an escript::Data instance. | |
bool | initFromMeshData (const_DomainChunk_ptr dom, const IntVec &data, int fsCode, Centering c, NodeData_ptr nodes, const IntVec &id) |
Initialises with integral mesh data like IDs or tags. | |
bool | initFromFile (const std::string &filename, const_DomainChunk_ptr dom) |
Reads values and IDs for this variable from an escript dump file. | |
bool | writeToSilo (DBfile *dbfile, const std::string &siloPath, const std::string &units) |
Writes the data into given directory within a Silo file. | |
void | writeToVTK (std::ostream &os, int ownIndex) |
Writes the data values to ostream in VTK text format. | |
int | getRank () const |
Returns the rank of the data. | |
bool | isNodeCentered () const |
Returns true if the variable data is node centered, false if zone centered. | |
std::string | getMeshName () const |
Returns the name of the associated mesh. | |
const IntVec & | getShape () const |
Returns the shape vector of the data. | |
std::string | getName () const |
Returns the variable name. | |
std::string | getTensorDef () const |
Returns the Silo tensor definition for this tensor. | |
int | getNumberOfSamples () const |
Returns the number of data values. | |
const CoordArray & | getData () const |
Returns the array of data values where array[i] is the i-th component of the data. | |
float * | getDataFlat () const |
Returns a flattened array of data values, i.e. the ordering is s0c0 s0c1 s0c2 s1c0 s1c1 s1c2 s2c0 ... where s denotes the sample number and c the component. | |
int | getNumberOfComponents () const |
Returns the total number of components (sum of shape elements). | |
Private Member Functions | |
void | cleanup () |
float * | averageData (const float *src, size_t stride) |
Averages and filters data. | |
IndexMap | buildIndexMap () |
Prepares a sample ID -> index mapping which is used to reorder data. | |
bool | reorderSamples () |
Reorders the samples according to the corresponding node or element IDs. | |
void | sampleToStream (std::ostream &os, int index) |
Outputs sample at index to output stream in VTK XML format. | |
Private Attributes | |
bool | initialized |
const_DomainChunk_ptr | domain |
std::string | varName |
int | numSamples |
int | rank |
int | ptsPerSample |
int | funcSpace |
Centering | centering |
IntVec | shape |
IntVec | sampleID |
CoordArray | dataArray |
std::string | meshName |
std::string | siloMeshName |
A class that provides functionality to read an escript data object from a dump file or an escript::Data instance and write that data in Silo or VTK XML formats.
weipa::DataVar::DataVar | ( | const std::string & | name | ) |
Constructor with variable name.
weipa::DataVar::DataVar | ( | const DataVar & | d | ) |
Copy constructor. Performs a deep copy of the data values.
References paso::util::copy(), dataArray, and numSamples.
Destructor.
References cleanup().
float * weipa::DataVar::averageData | ( | const float * | src, |
size_t | stride | ||
) | [private] |
Averages and filters data.
If a sample consists of more than one data point then this method averages over the data points and returns the resulting array. In any case, the data is filtered according to the stride value.
References domain, weipa::QuadMaskInfo::factor, funcSpace, weipa::QuadMaskInfo::mask, numSamples, and ptsPerSample.
Referenced by initFromEscript(), and initFromFile().
IndexMap weipa::DataVar::buildIndexMap | ( | ) | [inline, private] |
Prepares a sample ID -> index mapping which is used to reorder data.
References sampleID.
Referenced by reorderSamples(), and writeToVTK().
void weipa::DataVar::cleanup | ( | ) | [private] |
References dataArray, initialized, numSamples, sampleID, and shape.
Referenced by initFromEscript(), initFromFile(), initFromMeshData(), and ~DataVar().
const CoordArray& weipa::DataVar::getData | ( | ) | const [inline] |
Returns the array of data values where array[i] is the i-th component of the data.
References dataArray.
float * weipa::DataVar::getDataFlat | ( | ) | const |
Returns a flattened array of data values, i.e. the ordering is s0c0 s0c1 s0c2 s1c0 s1c1 s1c2 s2c0 ... where s denotes the sample number and c the component.
References paso::util::copy(), dataArray, getNumberOfComponents(), numSamples, rank, and shape.
std::string weipa::DataVar::getMeshName | ( | ) | const [inline] |
Returns the name of the associated mesh.
The returned name is one of the sub-meshes of the mesh set with setMesh() determined on the basis of the function space type and whether reduced elements are used or not.
References meshName.
std::string weipa::DataVar::getName | ( | ) | const [inline] |
Returns the variable name.
References varName.
int weipa::DataVar::getNumberOfComponents | ( | ) | const |
Returns the total number of components (sum of shape elements).
Referenced by getDataFlat().
int weipa::DataVar::getNumberOfSamples | ( | ) | const [inline] |
Returns the number of data values.
References numSamples.
int weipa::DataVar::getRank | ( | ) | const [inline] |
Returns the rank of the data.
References rank.
const IntVec& weipa::DataVar::getShape | ( | ) | const [inline] |
Returns the shape vector of the data.
The shape vector has as many elements as the rank of this variable.
References shape.
string weipa::DataVar::getTensorDef | ( | ) | const |
Returns the Silo tensor definition for this tensor.
If the data is tensor data then the components of the tensor are stored separately in the Silo file. This method then returns a string that contains the proper Silo expression to put the tensor together again. For non-tensor data this method returns an empty string.
Format string for Silo 2x2 tensor
Format string for Silo 3x3 tensor
References initialized, rank, shape, and varName.
bool weipa::DataVar::initFromEscript | ( | escript::Data & | escriptData, |
const_DomainChunk_ptr | dom | ||
) |
Initialises values and IDs from an escript::Data instance.
References escript::Data::actsExpanded(), averageData(), escript::FunctionSpace::borrowSampleReferenceIDs(), centering, cleanup(), paso::util::copy(), dataArray, domain, funcSpace, escript::Data::getDataPointRank(), escript::Data::getDataPointShape(), escript::Data::getFunctionSpace(), escript::Data::getNumDataPointsPerSample(), escript::Data::getNumSamples(), escript::Data::getSampleDataRO(), escript::FunctionSpace::getTypeCode(), initialized, escript::Data::isConstant(), meshName, numSamples, ptsPerSample, rank, reorderSamples(), sampleID, shape, siloMeshName, and varName.
bool weipa::DataVar::initFromFile | ( | const std::string & | filename, |
const_DomainChunk_ptr | dom | ||
) |
Reads values and IDs for this variable from an escript dump file.
References averageData(), centering, cleanup(), dataArray, domain, funcSpace, initialized, meshName, numSamples, ptsPerSample, rank, reorderSamples(), sampleID, shape, siloMeshName, and varName.
bool weipa::DataVar::initFromMeshData | ( | const_DomainChunk_ptr | dom, |
const IntVec & | data, | ||
int | fsCode, | ||
Centering | c, | ||
NodeData_ptr | nodes, | ||
const IntVec & | id | ||
) |
Initialises with integral mesh data like IDs or tags.
References centering, cleanup(), dataArray, domain, initialized, meshName, numSamples, ptsPerSample, rank, sampleID, and siloMeshName.
bool weipa::DataVar::isNodeCentered | ( | ) | const |
Returns true if the variable data is node centered, false if zone centered.
References centering, and weipa::NODE_CENTERED.
Referenced by writeToVTK().
bool weipa::DataVar::reorderSamples | ( | ) | [private] |
Reorders the samples according to the corresponding node or element IDs.
References buildIndexMap(), centering, paso::util::copy(), dataArray, domain, funcSpace, weipa::NODE_CENTERED, numSamples, sampleID, and varName.
Referenced by initFromEscript(), and initFromFile().
void weipa::DataVar::sampleToStream | ( | std::ostream & | os, |
int | index | ||
) | [private] |
Outputs sample at index to output stream in VTK XML format.
References dataArray, rank, and shape.
Referenced by writeToVTK().
bool weipa::DataVar::writeToSilo | ( | DBfile * | dbfile, |
const std::string & | siloPath, | ||
const std::string & | units | ||
) |
Writes the data into given directory within a Silo file.
If Silo was not available at compile time this method returns false.
References centering, dataArray, initialized, weipa::NODE_CENTERED, numSamples, rank, shape, siloMeshName, and varName.
void weipa::DataVar::writeToVTK | ( | std::ostream & | os, |
int | ownIndex | ||
) |
Writes the data values to ostream in VTK text format.
References buildIndexMap(), domain, isNodeCentered(), meshName, numSamples, and sampleToStream().
Centering weipa::DataVar::centering [private] |
Referenced by initFromEscript(), initFromFile(), initFromMeshData(), isNodeCentered(), reorderSamples(), and writeToSilo().
CoordArray weipa::DataVar::dataArray [private] |
Referenced by cleanup(), DataVar(), getData(), getDataFlat(), initFromEscript(), initFromFile(), initFromMeshData(), reorderSamples(), sampleToStream(), and writeToSilo().
const_DomainChunk_ptr weipa::DataVar::domain [private] |
Referenced by averageData(), initFromEscript(), initFromFile(), initFromMeshData(), reorderSamples(), and writeToVTK().
int weipa::DataVar::funcSpace [private] |
Referenced by averageData(), initFromEscript(), initFromFile(), and reorderSamples().
bool weipa::DataVar::initialized [private] |
Referenced by cleanup(), getTensorDef(), initFromEscript(), initFromFile(), initFromMeshData(), and writeToSilo().
std::string weipa::DataVar::meshName [private] |
Referenced by getMeshName(), initFromEscript(), initFromFile(), initFromMeshData(), and writeToVTK().
int weipa::DataVar::numSamples [private] |
Referenced by averageData(), cleanup(), DataVar(), getDataFlat(), getNumberOfSamples(), initFromEscript(), initFromFile(), initFromMeshData(), reorderSamples(), writeToSilo(), and writeToVTK().
int weipa::DataVar::ptsPerSample [private] |
Referenced by averageData(), initFromEscript(), initFromFile(), and initFromMeshData().
int weipa::DataVar::rank [private] |
Referenced by getDataFlat(), getNumberOfComponents(), getRank(), getTensorDef(), initFromEscript(), initFromFile(), initFromMeshData(), sampleToStream(), and writeToSilo().
IntVec weipa::DataVar::sampleID [private] |
Referenced by buildIndexMap(), cleanup(), initFromEscript(), initFromFile(), initFromMeshData(), and reorderSamples().
IntVec weipa::DataVar::shape [private] |
Referenced by cleanup(), getDataFlat(), getNumberOfComponents(), getShape(), getTensorDef(), initFromEscript(), initFromFile(), sampleToStream(), and writeToSilo().
std::string weipa::DataVar::siloMeshName [private] |
Referenced by initFromEscript(), initFromFile(), initFromMeshData(), and writeToSilo().
std::string weipa::DataVar::varName [private] |
Referenced by getName(), getTensorDef(), initFromEscript(), initFromFile(), reorderSamples(), and writeToSilo().