GemaCoreLib
The GeMA Core library
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
GmResultsSerializer Class Reference

A serializer object used to save mesh data to several file formats. More...

#include <gmResultsSerializer.h>

Inheritance diagram for GmResultsSerializer:
Inheritance graph
[legend]
Collaboration diagram for GmResultsSerializer:
Collaboration graph
[legend]

Public Member Functions

 ~GmResultsSerializer ()
 Destructor.
 
bool saveMeshDataToFile (const GmSimulationData *simData, GmMesh *mesh, const QStringList &nodeValues, const QList< Unit > &nodeUnits, Unit coordUnit, const QStringList &elementValues, const QList< Unit > &elementUnits, QString fileName, const QVariantMap &options)
 Saves mesh data to the specified file. More...
 
bool prepareFile (const GmSimulationData *simData, GmMesh *mesh, const QStringList &nodeValues, const QList< Unit > &nodeUnits, Unit coordUnit, const QStringList &elementValues, const QList< Unit > &elementUnits, QString fileName, const QVariantMap &options)
 Creates the requested file and prepares the object for saving multiple node and element result sets. See saveMeshDataToFile() for a description of the parameters. More...
 
bool addCurrentResult (double currentTime)
 Adds the current mesh data to the file. Should be called after a call to prepareFile()
 
bool closeFile ()
 Closes the file opened by prepareFile()
 
QString tempFile ()
 Returns, if any, the name of the temp file used for the operation started with prepareFile()
 
virtual bool addStateItemsToGroup (GmStateDump *state, int groupId)
 Adds to 'state' the data items that should be saved for this serializer.
 
virtual bool stateAboutToBeSaved (GmStateDump *state)
 Perapares the Variant map with dumped data to be saved.
 
virtual bool stateLoaded (GmStateDump *state)
 Loads data from the loaded Variant map into the serializer.
 
- Public Member Functions inherited from GmGroupDumpItem
virtual ~GmGroupDumpItem ()
 Virtual destructor.
 
virtual bool stateSaved (GmStateDump *state)
 Virtual method called just after succesfully completing a save operation on the given state. Returning false aborts the operation.
 
virtual bool stateAboutToBeLoaded (GmStateDump *state)
 Virtual method called just before starting a load operation on the given state. Returning false aborts the operation.
 

Static Public Member Functions

static GmResultsSerializercreateInstance (QString fileType, const GmLogCategory &logger)
 Creates an instance of a GmResultsSerializer object to save files of the given type Returns NULL if fileType is an unsupported type.
 

Private Member Functions

 GmResultsSerializer (QString fileType, GmFileWriter *ser, const GmLogCategory &logger)
 Private constructor. Objects should be instanced by a call to createInstance(). Takes ownership of the supplied serializer.
 
bool supportsMultipleIterations ()
 Returns true if the configured file format accepts more than one result set.
 
bool supportsSplitVectors ()
 Returns true if the configured file format accepts to split vector values into scalar values.
 
bool doPrepareFile (const GmSimulationData *simData, GmMesh *mesh, const QStringList &nodeValues, const QList< Unit > &nodeUnits, Unit coordUnit, const QStringList &elementValues, const QList< Unit > &elementUnits, QString fileName, const QVariantMap &options, bool forMultipleIterations)
 Internal function to prepare file for data saving. Saves node coordinates & element geometry. Used by both saveMeshDataToFile() and prepareFile()
 
void fillNodeAccessorList (GmMesh *mesh, const QStringList &nodeValues, const QList< Unit > &nodeUnits, QList< GmValueAccessor * > &accList, int state)
 Fill accList with the set of (valid) accessors associated with the requested list of node values.
 
void fillElementAccessorList (GmCellMesh *mesh, const QStringList &elementValues, const QList< Unit > &elementUnits, QList< GmCellAccessor * > &elemAccList, QList< GmGaussAccessor * > &gaussAccList, int *intRuleSet, int state, bool activeOnly)
 Fill accList with the set of (valid) accessors associated with the requested list of element values.
 
void updateNodeAccessorList (GmMesh *mesh, QList< GmValueAccessor * > &accList, int state)
 Updates the contents of the accessor list replacing each accessor by an equivalent with the requested state.
 
void updateElementAccessorList (GmCellMesh *mesh, QList< GmCellAccessor * > &elemAccList, QList< GmGaussAccessor * > &gaussAccList, int state)
 Updates the contents of the accessor list replacing each accessor by an equivalent with the requested state.
 
bool cleanup (bool deleteFiles=false)
 Cleans the object state, removing accessor and cleaning lists. Returns false as a convenience for error treatment.
 

Private Attributes

const GmLogCategory_logger
 The logger object used to report errors.
 
GmFileWriter_serializer
 The file serializer used to save data.
 
QString _fileType
 Serializer file type for use in error messages.
 
GmMesh_mesh
 The mesh whose state will be saved for a statefull operation begun with prepareFile(), NULL otherwise.
 
QList< GmValueAccessor * > _nodeAccList
 Accessors for node results that will be saved in a statefull operation.
 
QList< GmCellAccessor * > _elemAccList
 Accessors for element results that will be saved in a statefull operation.
 
QList< GmGaussAccessor * > _gaussAccList
 Accessors for element results in Gauss points that will be saved in a statefull operation.
 
bool _openFiles
 States if we have an open file or not.
 
int _iter
 Keeps track of the number of time that addCurrentResult was called.
 
bool _split
 States if we split vector values into scalar values or not.
 
QVariantMap _stateMap
 Variant map used for state dumping.
 

Detailed Description

A serializer object used to save mesh data to several file formats.

Member Function Documentation

◆ prepareFile()

bool GmResultsSerializer::prepareFile ( const GmSimulationData simData,
GmMesh mesh,
const QStringList nodeValues,
const QList< Unit > &  nodeUnits,
Unit  coordUnit,
const QStringList elementValues,
const QList< Unit > &  elementUnits,
QString  fileName,
const QVariantMap &  options 
)

Creates the requested file and prepares the object for saving multiple node and element result sets. See saveMeshDataToFile() for a description of the parameters.

Prepare the file saving node coordinates & element geometry This function should be used as part of a sequence of calls in the form:

◆ saveMeshDataToFile()

bool GmResultsSerializer::saveMeshDataToFile ( const GmSimulationData simData,
GmMesh mesh,
const QStringList nodeValues,
const QList< Unit > &  nodeUnits,
Unit  coordUnit,
const QStringList elementValues,
const QList< Unit > &  elementUnits,
QString  fileName,
const QVariantMap &  options 
)

Saves mesh data to the specified file.

Parameters
simDataThe simulation data object
meshThe mesh that will be saved.
nodeValuesA list with the names of node state vars and attributes that should be saved.
nodeUnitsA list with the desired unit in which node data will be saved. Should be either empty (values will be saved in their default unit) or a list with the same size as nodeValues.
coordUnitThe unit in which coordinates will be exported. If empty, the mesh unit will be used.
elementValuesA list with the names of element attributes that should be saved.
elementUnitsA list with the desired unit in which element data will be saved. Should be either empty (values will be saved in their default unit) or a list with the same size as elementValues.
fileNameThe name of the file that will be created.
optionsA set of options specific to the file type
Returns
Returns false on errors.

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