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. More... | |
DataVar (const DataVar &d) | |
Copy constructor. Performs a deep copy of the data values. More... | |
~DataVar () | |
Destructor. More... | |
bool | initFromEscript (escript::Data &escriptData, const_DomainChunk_ptr dom) |
Initialises values and IDs from an escript::Data instance. More... | |
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. More... | |
bool | initFromFile (const std::string &filename, const_DomainChunk_ptr dom) |
Reads values and IDs for this variable from an escript dump file. More... | |
bool | writeToSilo (DBfile *dbfile, const std::string &siloPath, const std::string &units) |
Writes the data into given directory within a Silo file. More... | |
void | writeToVTK (std::ostream &os, int ownIndex) |
Writes the data values to ostream in VTK text format. More... | |
int | getRank () const |
Returns the rank of the data. More... | |
bool | isNodeCentered () const |
Returns true if the variable data is node centered, false if zone centered. More... | |
std::string | getMeshName () const |
Returns the name of the associated mesh. More... | |
const IntVec & | getShape () const |
Returns the shape vector of the data. More... | |
std::string | getName () const |
Returns the variable name. More... | |
std::string | getTensorDef () const |
Returns the Silo tensor definition for this tensor. More... | |
int | getNumberOfSamples () const |
Returns the number of data values. More... | |
const CoordArray & | getData () const |
Returns the array of data values where array[i] is the i-th component of the data. More... | |
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. More... | |
int | getNumberOfComponents () const |
Returns the total number of components (sum of shape elements). More... | |
Private Member Functions | |
void | cleanup () |
float * | averageData (const float *src, size_t stride) |
Averages and filters data. More... | |
IndexMap | buildIndexMap () |
Prepares a sample ID -> index mapping which is used to reorder data. More... | |
bool | reorderSamples () |
Reorders the samples according to the corresponding node or element IDs. More... | |
void | sampleToStream (std::ostream &os, int index) |
Outputs sample at index to output stream in VTK XML format. More... | |
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.
weipa::DataVar::~DataVar | ( | ) |
Destructor.
References cleanup().
|
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().
|
inlineprivate |
Prepares a sample ID -> index mapping which is used to reorder data.
Referenced by reorderSamples(), and writeToVTK().
|
private |
References dataArray, initialized, numSamples, sampleID, and shape.
Referenced by initFromEscript(), initFromFile(), initFromMeshData(), and ~DataVar().
|
inline |
Returns the array of data values where array[i] is the i-th component of the data.
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.
|
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.
|
inline |
Returns the variable name.
int weipa::DataVar::getNumberOfComponents | ( | ) | const |
Returns the total number of components (sum of shape elements).
Referenced by getDataFlat().
|
inline |
Returns the number of data values.
|
inline |
Returns the rank of the data.
|
inline |
Returns the shape vector of the data.
The shape vector has as many elements as the rank of this variable.
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::getDataRO(), 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().
|
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().
|
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().
|
private |
Referenced by initFromEscript(), initFromFile(), initFromMeshData(), isNodeCentered(), reorderSamples(), and writeToSilo().
|
private |
Referenced by cleanup(), DataVar(), getDataFlat(), initFromEscript(), initFromFile(), initFromMeshData(), reorderSamples(), sampleToStream(), and writeToSilo().
|
private |
Referenced by averageData(), initFromEscript(), initFromFile(), initFromMeshData(), reorderSamples(), and writeToVTK().
|
private |
Referenced by averageData(), initFromEscript(), initFromFile(), and reorderSamples().
|
private |
Referenced by cleanup(), getTensorDef(), initFromEscript(), initFromFile(), initFromMeshData(), and writeToSilo().
|
private |
Referenced by initFromEscript(), initFromFile(), initFromMeshData(), and writeToVTK().
|
private |
Referenced by averageData(), cleanup(), DataVar(), getDataFlat(), initFromEscript(), initFromFile(), initFromMeshData(), reorderSamples(), writeToSilo(), and writeToVTK().
|
private |
Referenced by averageData(), initFromEscript(), initFromFile(), and initFromMeshData().
|
private |
Referenced by getDataFlat(), getNumberOfComponents(), getTensorDef(), initFromEscript(), initFromFile(), initFromMeshData(), sampleToStream(), and writeToSilo().
|
private |
Referenced by cleanup(), initFromEscript(), initFromFile(), initFromMeshData(), and reorderSamples().
|
private |
Referenced by cleanup(), getDataFlat(), getNumberOfComponents(), getTensorDef(), initFromEscript(), initFromFile(), sampleToStream(), and writeToSilo().
|
private |
Referenced by initFromEscript(), initFromFile(), initFromMeshData(), and writeToSilo().
|
private |
Referenced by getTensorDef(), initFromEscript(), initFromFile(), reorderSamples(), and writeToSilo().