GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
GmHdf5ModelWriter Class Reference

A class used to export parts of a GeMA model to an HDF5 file. Its API includes both GeMA centric functions, exporting the model based on the contents from a GmModelData object, and more "neutral" functions, exporting the model contents from primitives that receive their data from standard vectors. The second set of functions is appropriate to be called from external codes using the GeMA core library as a helper to create the HDF5 model file. More...

#include <gmHdf5ModelWriter.h>

Inheritance diagram for GmHdf5ModelWriter:
Collaboration diagram for GmHdf5ModelWriter:

Public Member Functions

 GmHdf5ModelWriter (QString fileName, const GmLogCategory &logger)
 Constructor. Gets as parameters the file name and the message logger. The file is not created until the call to saveFromModel() or until the first call to addNewMesh().
 
 ~GmHdf5ModelWriter ()
 Destructor. Closes the file finishing the save process.
 
void setInitialData (const QStringList &nodeAttributes, const QStringList &cellAttributes, const QStringList &gaussAttributes)
 Allows for user specification of the attributes that should be saved on the file.
 
bool saveFromModel (const GmModelData *data, QString modelName="", QString meshName="")
 Saves the complete model file in a single call by retrieving all the saved information from the model data. The modelName parameter is optional and added only as metadata to the file.
 
bool addNewMesh (QString meshName, QString modelName="")
 Begins the addition of a new mesh to the save file. If this is the first added mesh, the file will be created (and the modelName added to the metadata). Sets the current mesh that will be in effect for all remaining calls to addXxxx() methods (until a new call to addNewMesh() or the object destruction). On failure, returns false. Error messages are emitted with the logger.
 
bool addDictionary (DictionaryType type, const QStringList &names)
 Adds a dictionary table to the file. Calls to addDictionary() should be made just after the call to addNewMesh() and before other adXXX() calls. The provided set of names is the dictionary contents and defines the mapping from the dictionary entries to their position on the given list. On failure, returns false. Error messages are emmited with the logger.
 
bool addGeometryNodeCoordinates (int n, int d, const double *values, int nghost=0)
 Adds the geometry node coordinates table to the file. The data vector should have size equal to n * d for a table with n lines and d columns (coord dimension). On failure, returns false. Error messages are emmited with the logger.
 
bool addGeometryCells (int ncells, int size, const int *data)
 Adds to the file the cell topology data. The given vector should be filled with the cell type, property set indices and node indices for each cell in sequence, as specified below. Its size should be equal to 'size', storing information from 'ncells' cells.
 
bool addGeometryCellGhostNodes (int ncells, int size, const int *data)
 Adds to the file the cell ghost nodes data. The given vector should be filled with the cell id, number of cell ghost nodes and node indices for each cell in sequence, as specified below. Its size should be equal to 'size', storing information from 'ncells' cells.
 
bool addGeometryIndexTable (GroupType group, QString tableName, int n, const int *values)
 Adds a table with cell or node indices to the file. Suitale for storing inactive cells, node sets and cell groups. Group must be either Geometry (for the inactive cells), Cell Groups or NodeSets. The table name should be either "InactiveCells" or the cell group / node set name. The values vector must contain "n" entries. On failure, returns false. Error messages are emmited with the logger.
 
bool addGeometryBorderTable (GroupType group, QString tableName, int n, const int *values)
 Adds a table with edge or face borders to the file. Group must be either BoundaryEdges or BoundaryFaces. The table name should be the boundary name. The values vector must contain "2 * n" entries. On failure, returns false. Error messages are emmited with the logger.
 
bool addInitialData (GroupType group, QString attributeName, int n, int d, const double *values, bool hasFunctions, int history=-1)
 Adds an initial data table to the file. The group should be one of the NodeData, CellData or GaussData groups and the attribute name its name. The data vector should have size equal to n * d for a table with n lines and d columns (attribute dimension). If the original data had any function values, those should already have been nan encoded into values by calls to dindexToNan(). If history is different from -1, it will be added to the table name following the appropriate syntax. The hasFunctions value is used to fill the functions table atttribute.
 
bool addBoundaryCondition (QString bcName, GmBoundaryCondition::BcType type, int n, const int *data)
 Adds a boundary condition to the file, providing its type and application point data. Associated properties should be added by later calls to addBoundaryConditionProperty(). The data field should have a size equal to '2*n' (the number of bc lines) for 'type' equal to GM_BC_NODE or GM_BC_CELL and '3*n' for 'type' equal to GM_BC_EDGE or GM_BC_FACE.
 
bool addBoundaryConditionProperty (QString bcName, QString propertyName, int n, int d, const double *values, bool hasFunctions)
 Adds a boundary condition property data table to the file. The data vector should have size equal to n * d for a table with n lines and d columns (attribute dimension). If the original data had any function values, those should already have been nan encoded into values by calls to dindexToNan(). Lua “nil” values should be filled with the attribute’s default value. For multi-dimensional attributes, the corresponding default value component should be used. The hasFunctions value is used to fill the functions table atttribute.
 
bool addDiscontinuitySet (QString dsName, GmDiscontinuitySet::DiscontinuityType type, const QStringList &discontinuityNames)
 Adds a discontinuity set to the file, providing its type and the list of discontinuity ids. The data associated with each id should be added by later calls to addDiscontinuityXxxx().
 
bool addDiscontinuityPolyline (QString dsName, int index, int n, int d, const double *coordinates)
 Adds a polyline discontinuity set data table to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The data field should have a size equal to 'n*d' where n is the the number of coordinates and d the coordinate dimension.
 
bool addDiscontinuitySurface (QString dsName, int index, int n, const double *coordinates, int ntri, const int *triangles)
 Adds a surface discontinuity set pair of data tables to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The coordinates field should have a size equal to 'n*3' where n is the the number of coordinates, and the triangles field should have a size equal to 'ntri*3'.
 
bool addDiscontinuityEdgeList (QString dsName, int index, int n, const int *borderData)
 Adds an edge discontinuity set data table to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The data field should have a size equal to 'n*2' where n is the the number of edges.
 
bool addDiscontinuityFaceList (QString dsName, int index, int n, const int *borderData)
 Adds a face discontinuity set data table to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The data field should have a size equal to 'n*2' where n is the the number of faces.
 
bool cellVectorBuildBegin (int npsets, int expectedSize)
 Starts the process of building the cell topology vector. Will pre-allocate a buffer with expectedSize integers. This is a hint. The buffer will be grown if necessary. 'npsets' should be the number of property sets attached to this mesh. It MUST be equal to the number of entries given in the call to addDictionary(GM_HDF5MODEL_PROPERTYSETS, ...).
 
bool cellVectorAddCell (GmCellType type, const int *propertyIndices, const int *nodeIndices)
 Adds the given cell data to the cell topology vector. 'type' is the cell type. 'propertyIndices' is a vector with size equal to the number of property sets (given in th call to the begin function and equal to the property set dictionary) and filled with the cell's property idices in the same order as the property sets in the dictionary. 'nodeIdices' is a vector with size equal to the number of nodes for this cell type and filled with nodes in the expected GeMA order for this type. THe data is copied. Returns false if there was a need to resize the internall buffer and we where unable to do so. Will never fail if the expected size given in the call to begin was exact.
 
const int * cellVectorBuildEnd (int *size)
 Ends the process of building the cell topology vector. Returns a pointer to the vector start and fills size with the vector size. The returned pointer is valid only until the call to addGeometryCells(). No other addXxxx() call should be made between the call to cellVectorBuildEnd() and the call to addGeometryCells(). It will be "released" automatically.
 
bool cellGhostNodesVectorBuildBegin (int expectedSize)
 Similar to cellVectorBuildBegin() for building the input vector to addGeometryCellGhostNodes()
 
bool cellGhostNodesVectorAddCell (int cellId, int numGhostNodes, const int *nodeIndices)
 Similar to bool cellVectorAddCell() for building the input vector to addGeometryCellGhostNodes()
 
const int * cellGhostNodesVectorBuildEnd (int *size)
 Similar to cellVectorBuildEnd() for building the input vector to addGeometryCellGhostNodes()
 
double dindexToNan (unsigned index) const
 Encodes a dictionary index into a nan entry.
 
double nanToCanonicNan (double v) const
 If v is not a Quiet nan value, returns v. Otherwise, returns the canonical Quiet NA.
 
- Public Member Functions inherited from GmHdf5Model
QString dictionaryTableName (DictionaryType type) const
 Returns the name on the HDF5 file for the given dictionary type.
 
GroupType dictionaryGeometryGroup (DictionaryType type) const
 Returns the associated geometry group type associated with the dictionary or GM_HDF5MODEL_INVALID if there is none.
 
QString groupName (QString meshName, GroupType group, QString subGroupName) const
 Returns the group name for the given mesh / group type. If type is GM_HDF5MODEL_BC_GROUP or GM_HDF5MODEL_DS_GROUP, the subGroupName should contain the boundary condition / discontinuity set name (if empty, the path to the root bc/ds group will be returned).
 
QPair< QString, int > splitAttributeName (QString attrName) const
 Splits an attribute name formatted as 'attr_name[state]' or 'attr_name' into its components. State will be 0 if missing from the input string.
 

Private Member Functions

bool buildAndSaveFunctionsDictionary (const GmModelData *data)
 Creates the "global" function map on the first call and saves it to the file under the current mesh.
 
bool buildAndSavePropertySetsDictionary (const GmCellMesh *mesh)
 Creates the current mesh property set map and saves it to the file under the current mesh.
 
bool buildAndSaveCellGroupsDictionary (const GmCellMesh *mesh)
 Creates the current mesh cell groups map and saves it to the file under the current mesh.
 
bool buildAndSaveNodeSetsDictionary (const GmMesh *mesh)
 Creates the current mesh node sets map and saves it to the file under the current mesh.
 
bool buildAndSaveCellBordersDictionary (const GmCellMesh *mesh)
 Creates the current mesh edge and face boundary maps and saves them to the file under the current mesh.
 
bool saveMeshGeometryNodes (const GmMesh *mesh)
 Saves the mesh node coordinates.
 
bool saveMeshGeometryNodeSets (const GmMesh *mesh)
 Saves mesh node sets.
 
bool saveMeshGeometryCells (const GmCellMesh *mesh)
 Saves mesh cell topology, ghost nodes, inactive cells and cell groups.
 
bool saveMeshGeometryBoundaries (const GmCellMesh *mesh)
 Saves cell boudary edges and faces.
 
bool saveInitialData (const GmMesh *mesh)
 Saves initial data for stateVars + node, cell and Gauss attributes, as defined by the _savedXxxxAttributes vectors.
 
bool saveBoundaryConditions (const GmMesh *mesh)
 Save boundary conditions attached to the given mesh.
 
bool saveDiscontinuitySets (const GmModelData *data, const GmCellMesh *mesh)
 Save discontinuity sets attached to the given mesh.
 
int * cellVectorAddCell (GmCellType type)
 Simmilar to cellVectorAddCell(GmCellType, const int*, const int*). It adds the type to the buffer and returns a pointer to the area where the caller should copy the property set indices and the node indices, in that order. Returns NULL if there was a need to resize the internall buffer and we where unable to do so. Will never fail if the expected size given in the call to begin was exact. Used internally to avoid an extra data copy.
 
int * cellGhostNodesVectorAddCell (int cellId, int numGhostNodes)
 Similar to int* cellVectorAddCell() for building the input vector to addGeometryCellGhostNodes()
 
template<class T >
bool addDataTable (GroupType group, QString subGroup, QString tableName, int n, int d, const T *values)
 Workhorse for both several addXxxx() functions.
 
template<class T , class A >
bool addDataTableWithAttributes (GroupType group, QString subGroup, QString tableName, int n, int d, const T *values, const QStringList &attrNames, const QVector< A > &attrValues)
 Similar to addDataTable, also adding attributes with integer values to the table.
 
QString groupName (GroupType group, QString subGroupName) const
 Returns the group name for the given group type.If type is GM_HDF5MODEL_BC_GROUP or GM_HDF5MODEL_DS_GROUP, the subGroupName should contain the boundary condition / discontinuity set name. The returned name INCLUDES the root mesh group.
 
bool createGroupIfNecessary (QString groupName)
 Creates, if necessary, the HDF5 groups from the given name. Accepts hierarchy names. Returns false on error.
 
void initSavedAttributeLists (const GmMesh *mesh)
 Fills the saved attribute lists by traversing the mesh looking for attributes that contain values that are different from the default. This is usually very efficient if the model saving was called just after model creation, since attributes that where not changed at all will still have a value set data based on the GmDefValueValueSetData class. Also, if it is a normal value set, the first value different from the default will stop the search.
 
bool initBuffer (const GmModelData *data, const GmMesh *mesh)
 Initializes the save buffer. To avoid the need for buffer resizing, the mesh is queried in a best effort way so that a tight guess is made about the memory that will be necessary for the saving process. Can be called multiple times (when changing meshes, for example).
 
template<class T >
T * getBuffer (int n)
 Returns the single save buffer, resized if necessary, to store n entries of type T. Returns NULL on error. If we have done a good job on guessing the initial buffer size (on initBuffer() when saving from the model), the buffer should never really need to be resized.
 
double * getFilledDataBuffer (GmValueAccessor *ac, const GmMesh *mesh, bool *bufferHasFunctions=NULL)
 If the given accessor is a tracked accessor with an underlying single data buffer and the accessor does NOT accept functions, the data is not stored in a sparse format, is not packed, there is no unit or data type conversion, and we don't have an active node or cell renumbering influencing the save order, returns the value set buffer. Otherwise, returns the save buffer, resized and filled with the accessor contents. If necessary, function nan encoding has already been done. Returns NULL on error. If bufferHasFunctions is not NULL, it will be filled with true if the buffer includes any nan-encoded function value.
 

Private Attributes

QString _fileName
 The saved file name.
 
const GmLogCategory_logger
 The logger used to emmit error messages.
 
bool _userDefinedAttributes
 Set to true if setInitialData() was called. Defines if the _savedXxxAttribtes vectors where user given or filled by the class.
 
QVector< QPair< QString, int > > _savedNodeAttributes
 Either the user given or the auto defined set of node attributes & state vars whose values should be saved. The pair is the attribute id + history state (filled with 0 for attributes without history or if not given by the user)
 
QVector< QPair< QString, int > > _savedCellAttributes
 Like _savedNodeAttributes for cell attributes.
 
QVector< QPair< QString, int > > _savedGaussAttributes
 Like _savedNodeAttributes for Gauss attributes.
 
GmPODVector< char, size_t, GmPODVectorTightGrow_saveBuffer
 An auxiliar buffer that is used by save routines to build temporary data vectors.
 
H5::H5File * _fileh
 The hdf5 file handle.
 
QString _currentMesh
 The name of the current mesh being saved.
 
QVector< const GmBoundaryCondition * > _currentMeshBcs
 The set of boundary conditions associated with the current mesh.
 
QVector< QStringList_dictionaries
 The set of saved dictionaries. Indexed by DictionaryType.
 
QSet< QString_fileGroups
 A set used by ensureGroupExists to control the set of groups already created on the file.
 
int _npsets
 The number of property sets currently stored in the Property set dictionary.
 
QMap< QString, int > _userFunctionMap
 Map for converting user functions to their associated dictionary entry.
 
QMap< const GmNodeSet *, int > _nodeSetMap
 Map for converting node sets to their associated dictionary entry.
 
QMap< const GmCellBoundary *, int > _edgeMap
 Map for converting boundary edges to their associated dictionary entry.
 
QMap< const GmCellBoundary *, int > _faceMap
 Map for converting boundary faces to their associated dictionary entry.
 

Additional Inherited Members

- Public Types inherited from GmHdf5Model
enum  DictionaryType {
  GM_HDF5MODEL_FUNCTIONS , GM_HDF5MODEL_PROPERTYSETS , GM_HDF5MODEL_CELLGROUPS , GM_HDF5MODEL_NODESETS ,
  GM_HDF5MODEL_EDGES , GM_HDF5MODEL_FACES , GM_HDF5MODEL_NUMDICTIONARIES
}
 
enum  GroupType {
  GM_HDF5MODEL_D_GROUP , GM_HDF5MODEL_G_GROUP , GM_HDF5MODEL_GCG_GROUP , GM_HDF5MODEL_GNS_GROUP ,
  GM_HDF5MODEL_GBE_GROUP , GM_HDF5MODEL_GBF_GROUP , GM_HDF5MODEL_ND_GROUP , GM_HDF5MODEL_CD_GROUP ,
  GM_HDF5MODEL_GD_GROUP , GM_HDF5MODEL_BC_GROUP , GM_HDF5MODEL_DS_GROUP , GM_HDF5MODEL_NUMGROUPS ,
  GM_HDF5MODEL_INVALID
}
 

Detailed Description

A class used to export parts of a GeMA model to an HDF5 file. Its API includes both GeMA centric functions, exporting the model based on the contents from a GmModelData object, and more "neutral" functions, exporting the model contents from primitives that receive their data from standard vectors. The second set of functions is appropriate to be called from external codes using the GeMA core library as a helper to create the HDF5 model file.

Member Function Documentation

◆ addBoundaryCondition()

bool GmHdf5ModelWriter::addBoundaryCondition ( QString bcName,
GmBoundaryCondition::BcType type,
int n,
const int * data )

Adds a boundary condition to the file, providing its type and application point data. Associated properties should be added by later calls to addBoundaryConditionProperty(). The data field should have a size equal to '2*n' (the number of bc lines) for 'type' equal to GM_BC_NODE or GM_BC_CELL and '3*n' for 'type' equal to GM_BC_EDGE or GM_BC_FACE.

On failure, returns false. Error messages are emmited with the logger.

◆ addBoundaryConditionProperty()

bool GmHdf5ModelWriter::addBoundaryConditionProperty ( QString bcName,
QString propertyName,
int n,
int d,
const double * values,
bool hasFunctions )

Adds a boundary condition property data table to the file. The data vector should have size equal to n * d for a table with n lines and d columns (attribute dimension). If the original data had any function values, those should already have been nan encoded into values by calls to dindexToNan(). Lua “nil” values should be filled with the attribute’s default value. For multi-dimensional attributes, the corresponding default value component should be used. The hasFunctions value is used to fill the functions table atttribute.

On failure, returns false. Error messages are emmited with the logger.

◆ addDiscontinuityEdgeList()

bool GmHdf5ModelWriter::addDiscontinuityEdgeList ( QString dsName,
int index,
int n,
const int * borderData )

Adds an edge discontinuity set data table to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The data field should have a size equal to 'n*2' where n is the the number of edges.

On failure, returns false. Error messages are emmited with the logger.

◆ addDiscontinuityFaceList()

bool GmHdf5ModelWriter::addDiscontinuityFaceList ( QString dsName,
int index,
int n,
const int * borderData )

Adds a face discontinuity set data table to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The data field should have a size equal to 'n*2' where n is the the number of faces.

On failure, returns false. Error messages are emmited with the logger.

◆ addDiscontinuityPolyline()

bool GmHdf5ModelWriter::addDiscontinuityPolyline ( QString dsName,
int index,
int n,
int d,
const double * coordinates )

Adds a polyline discontinuity set data table to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The data field should have a size equal to 'n*d' where n is the the number of coordinates and d the coordinate dimension.

On failure, returns false. Error messages are emmited with the logger.

◆ addDiscontinuitySet()

bool GmHdf5ModelWriter::addDiscontinuitySet ( QString dsName,
GmDiscontinuitySet::DiscontinuityType type,
const QStringList & discontinuityNames )

Adds a discontinuity set to the file, providing its type and the list of discontinuity ids. The data associated with each id should be added by later calls to addDiscontinuityXxxx().

On failure, returns false. Error messages are emmited with the logger.

◆ addDiscontinuitySurface()

bool GmHdf5ModelWriter::addDiscontinuitySurface ( QString dsName,
int index,
int n,
const double * coordinates,
int ntri,
const int * triangles )

Adds a surface discontinuity set pair of data tables to the file, where 'index' is the position of the associated discontinuity id in the string table provided to addDiscontinuitySet(). The coordinates field should have a size equal to 'n*3' where n is the the number of coordinates, and the triangles field should have a size equal to 'ntri*3'.

On failure, returns false. Error messages are emmited with the logger.

◆ addGeometryCellGhostNodes()

bool GmHdf5ModelWriter::addGeometryCellGhostNodes ( int ncells,
int size,
const int * data )

Adds to the file the cell ghost nodes data. The given vector should be filled with the cell id, number of cell ghost nodes and node indices for each cell in sequence, as specified below. Its size should be equal to 'size', storing information from 'ncells' cells.

Cell data Format (all ints): cell id, num ghost nodes, ghost node 1, ..., ghost node n

The data vector can be easily assembled by using the provided cellGhostNodesVectorBuildBegin(), cellGhostNodesVectorAddCell() and cellGhostNodesVectorBuildEnd() functions.

◆ addGeometryCells()

bool GmHdf5ModelWriter::addGeometryCells ( int ncells,
int size,
const int * data )

Adds to the file the cell topology data. The given vector should be filled with the cell type, property set indices and node indices for each cell in sequence, as specified below. Its size should be equal to 'size', storing information from 'ncells' cells.

Cell data Format (all ints): type, property index1, ..., property index n, node 1, ..., node n

The data vector can be easily assembled by using the provided cellVectorBuildBegin(), cellVectorAddCell() and cellVectorBuildEnd() functions.

◆ addInitialData()

bool GmHdf5ModelWriter::addInitialData ( GroupType group,
QString attributeName,
int n,
int d,
const double * values,
bool hasFunctions,
int history = -1 )

Adds an initial data table to the file. The group should be one of the NodeData, CellData or GaussData groups and the attribute name its name. The data vector should have size equal to n * d for a table with n lines and d columns (attribute dimension). If the original data had any function values, those should already have been nan encoded into values by calls to dindexToNan(). If history is different from -1, it will be added to the table name following the appropriate syntax. The hasFunctions value is used to fill the functions table atttribute.

On failure, returns false. Error messages are emmited with the logger.

◆ cellVectorBuildBegin()

bool GmHdf5ModelWriter::cellVectorBuildBegin ( int npsets,
int expectedSize )

Starts the process of building the cell topology vector. Will pre-allocate a buffer with expectedSize integers. This is a hint. The buffer will be grown if necessary. 'npsets' should be the number of property sets attached to this mesh. It MUST be equal to the number of entries given in the call to addDictionary(GM_HDF5MODEL_PROPERTYSETS, ...).

Expected usage: cellVectorBuildBegin() foreach cell cellVectorAddCell(...) int size; int* b = cellVectorBuildEnd(&size); addGeometryCells(ncells, size, b);

Returns false if the buffer could not be created with the expected size

◆ getFilledDataBuffer()

double * GmHdf5ModelWriter::getFilledDataBuffer ( GmValueAccessor * ac,
const GmMesh * mesh,
bool * bufferHasFunctions = NULL )
private

If the given accessor is a tracked accessor with an underlying single data buffer and the accessor does NOT accept functions, the data is not stored in a sparse format, is not packed, there is no unit or data type conversion, and we don't have an active node or cell renumbering influencing the save order, returns the value set buffer. Otherwise, returns the save buffer, resized and filled with the accessor contents. If necessary, function nan encoding has already been done. Returns NULL on error. If bufferHasFunctions is not NULL, it will be filled with true if the buffer includes any nan-encoded function value.

Caveat: With the current implementation, if the buffer attends all the necessary requirements for direct buffer access but the underlying storage is based on a GmDualVector, we can't return the internal buffer. To change that, we would need to return a buffer list from this function and change all its call points + create HDF5 util functions to save a table from multiple sources. At the moment that doesn't seem worthy. Saving the model to a HDF5 file is usually a one time only operation, so it should not be at the critical path.

◆ initSavedAttributeLists()

void GmHdf5ModelWriter::initSavedAttributeLists ( const GmMesh * mesh)
private

Fills the saved attribute lists by traversing the mesh looking for attributes that contain values that are different from the default. This is usually very efficient if the model saving was called just after model creation, since attributes that where not changed at all will still have a value set data based on the GmDefValueValueSetData class. Also, if it is a normal value set, the first value different from the default will stop the search.

IMPORTANT: Currently we do NOT check values for attributes whose implementation is NOT based on a GmValueSet. Currently we do not have any of them. If we ever do, we might have to change this.

◆ nanToCanonicNan()

double GmHdf5ModelWriter::nanToCanonicNan ( double v) const
inline

If v is not a Quiet nan value, returns v. Otherwise, returns the canonical Quiet NA.

This is done to make sure that any nan in v won't be mixed with one of our nan encodings. This might be overkill since it seems that only the canonical QT_NANBOX_QUIET_MASK (0xFFF8000000000000) pattern is ever generated, but sometimes being paranoid pays off...

◆ saveFromModel()

bool GmHdf5ModelWriter::saveFromModel ( const GmModelData * data,
QString modelName = "",
QString meshName = "" )

Saves the complete model file in a single call by retrieving all the saved information from the model data. The modelName parameter is optional and added only as metadata to the file.

When saving initial data, the set of node, cell and gauss attributes, whose values need to be saved to the file, can be defined by a previous call to setInitialData(). If that method has not been called, an automatic definition will be made by traversing all mesh attributes and looking for those which have values that are different from the default value. This is usually very efficient if the model saving was called just after model creation, since attributes that where not changed at all will still have a value set data based on the GmDefValueValueSetData class.

If meshName is not empty, only that mesh contents will be saved.

On failure, returns false. Error messages are emmited with the logger.

◆ setInitialData()

void GmHdf5ModelWriter::setInitialData ( const QStringList & nodeAttributes,
const QStringList & cellAttributes,
const QStringList & gaussAttributes )

Allows for user specification of the attributes that should be saved on the file.

If this function is not called, an automatic definition will be made based on attributes that have values that are different from the attribute's default value. If an attribute has a history and old values should be saved, the attribute name should be suffixed by '[h]', where h is the state number (0 = current, 1 = first old, etc). A missing suffix is interpreted as [0]. If the model contains multiple meshes, the lists will apply to ALL of them.

No validity checks are done at this time to check for invalid attribute names or history values. Those checks will be done by saveFromModel(). Any invalid attributes will be ignored and a warning emitted.

IMPORTANT: This function should be called only when saving data through the saveFromModel() method.


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