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

A file serializer for saving data in the "Neutral File" file format. More...

#include <gmNfFileWriter.h>

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

Public Member Functions

 GmNfFileWriter (const GmLogCategory &logger)
 Default constructor.
 
virtual ~GmNfFileWriter ()
 Destructor.
 
virtual bool createFiles (QString fileName, const GmSimulationData *simData, const GmFileFilter *filter, const QVariantMap &options, bool multipleResults, bool gaussValues, bool discValues, GmFileIO::DumpMode dumpMode, QString timeUnit)
 
virtual bool setCurrentTime (int iter, double time)
 Sets the current time step, valid for the next calls to saveGeometry() and/or saveData(). This function IS CALLED even for single time step files in order to allow them to register the information. The first call is done with iter equal to 1, unless this is a single time step file, when iter will have a value of 0. Can return false on errors.
 
virtual bool saveGeometry (GmValueAccessor *nodeAc, const double *scaleFactor, const double *offset)
 Save mesh node coordinates, cell geometry and gauss rule set coordinates (if needed) to the file, as defined by the filter object received on createFiles(). Returns false on errors. Node coordinates should be multiplied by the scale factor and sum the provided offset if the pointers are not NULL (they are either both NULL or both valid). When working with multiple time steps, this function is called at the first time step and then when the mesh changed (and the file format supports mesh changes)
 
virtual bool saveDiscontinuities (const QVector< GmDiscontinuitySet * > &sets, GmFileIO::DiscontinuityDataMode mode, const UnitConverter *conv, const double *scaleFactor, const double *offset)
 Save discontinuity geometry data to the file. THe mode parameter defines which data should be saved. Returns false on errors. Node coordinates should be converted with the supplied converter (if not NULL) and also multiplied by the scale factor and sum the provided offset if the pointers are not NULL (they are either both NULL or both valid). When working with multiple time steps, this function is called at the first time step and then when the discontinuities changed (and the file format supports mesh changes)
 
virtual bool saveData (const QVector< GmResultNodeDataSrc * > &nodeData, const QVector< GmResultCellDataSrc * > &cellData, const QVector< GmResultGaussDataSrc * > &gaussData, int extraColumns, const QVector< int > &propertySets)
 Saves the current result set to the file for the node, cells and Gauss points as defined by the filter object received on createFiles(). Will be called multiple times if multipleResults was true on the call to createFiles(). This function is always called, even if the data lists are empty, since special values defined by save options might need to be handled. The extra columns value is an or of the set of GmFilIO::ExtraColumns that should also be saved. If CELL_MATERIAL_COLUMN is in that set, the propertySets list informs for which property sets the material index should be saved.
 
virtual bool createFiles (QString fileName, const GmSimulationData *simData, const GmMesh *mesh, const QVariantMap &options, int numNodeValues, int numElemValues, int intRuleSet, bool multipleResults)
 
virtual bool saveNodeCoordinates (const GmMesh *mesh, GmValueAccessor *nodeAcc, QList< double > &scaleFactor, QList< double > &offset)
 Save mesh node coordinates to the file. Returns false on errors. Node coordinates should be multiplied by the scale factor and sum the provided offset.
 
virtual bool saveCellGeometry (const GmCellMesh *mesh)
 Saves cell geometry to the file. Returns false on errors.
 
virtual bool saveNodeData (const GmMesh *mesh, const QList< GmValueAccessor * > &accList, int iter, double currentTime, bool split)
 Saves node data to the file. The accList parameter contains accessors for the values to be saved. Returns false on errors. Will be called multiple times if the parameter multipleResults was true on the call to createFiles().
 
virtual bool saveElementData (const GmCellMesh *mesh, const QList< GmCellAccessor * > &elemAccList, const QList< GmGaussAccessor * > &gaussAccList, int iter, double currentTime, bool split)
 Saves element data to the file. The accessor lists parameters contains accessors for the values to be saved. Returns false on errors. Will be called multiple times if the parameter multipleResults was true on the call to createFiles().
 
virtual bool closeFiles (bool deleteFiles=false)
 Closes the set of files opened by a call to createFiles(). Will be called automatically by the destructor (so may be called with a closed file). On errors, closeFiles is called with deleteFiles == true and should remove the created files.
 
virtual QString tempFile ()
 Returns, if any, the name of the temp file used for the operation started with createFiles()
 
virtual void flushFiles ()
 Flush opened files.
 
virtual GmFileFormatfileFormat ()
 Returns the file format of the serializer.
 
virtual bool dumpSupport () const
 This function should return true if this serializer supports saving dump files.
 
virtual bool addSavedItemsToMap (QVariantMap &map)
 This function should add to map any internal serializer state that must be saved on a dump operation, returning false on errors. More...
 
virtual bool loadSavedItemsFromMap (QVariantMap &map)
 This function should retrieve from the given map any internal writer state that was saved on a dump operation and now restored, returning false on errors. It should also be used to make any adjustments needed on the save files when restoring a state.
 
- Public Member Functions inherited from GmFileWriter
 GmFileWriter (const GmLogCategory &logger)
 Constructor. Receives as parameter the logger used to report errors.
 
virtual ~GmFileWriter ()
 Destructor. Should call closeFiles() on derived classes.
 
- Public Member Functions inherited from GmNfFileFormat
virtual const char * formatName () const
 Returns the file format name.
 
virtual bool supportsMultipleIterations () const
 Returns true if this file type supports multiple iterations (result sets)
 
virtual bool supportsSplitVectors () const
 Returns true if this writer prefers to split vector values into scalar values by itself.
 
virtual bool acceptsNodeDimension (int ndim) const
 Returns true if this file format accepts meshes with nodes of the given dimension.
 
virtual bool acceptsDataType (const GmValueInfo *info, int nodeDim, int dimFilter=-1) const
 Returns true if this file format can save node/element data with the specified type (especially its dimension and value set kind). The nodeDim parameter provides the mesh node dimension since some file formats only accept vectors and matrices with the same size as the mesh dimension. The dimFilter parameter specifies if a dimension filter will be applied to the data or not (dimFilter == -1)
 
virtual bool acceptsMultipleGaussProfiles () const
 Does the file supports multiple Gauss points per element type?
 
virtual bool acceptsGaussRuleForElement (GmCellType type, const GmIntegrationRule *ir) const
 Does the file support exporting data at Gauss points for an element of type type with the supplied integration rule?
 
virtual bool acceptsDiscontinuitySet (GmDiscontinuitySet::DiscontinuityType type) const
 
virtual int acceptsCellType (GmCellType type) const
 Does the file format accepts this cell type? Returns 0 if the cell type is not accepted, 1 if it is natively accepted or 2 if it is accepted requiring standard Gema transformations for adjusting interface elements that need extra interpolated nodes to be exported.
 
virtual const QVector< int > & cellNumbering (GmCellType type) const
 Returns the node cell type numbering order in the file format view or an empty vector for unsupported types. More...
 
virtual int fileCellType (GmCellType type) const
 Returns the cell type code as seen by the file format. Currently used only by HDF5 based formats.
 
virtual const char * fileCellTypeName (GmCellType type) const
 Returns the cell type name as seen by the exported file format.
 
virtual bool supportsMeshChanges () const
 Returns true if this writer can cope with mesh changes during the simulation.
 

Private Member Functions

bool copyResultData (FILE *srcFile, FILE *dstFile, qint64 size=0)
 Appends size bytes from srcFile to dstFile. More...
 
void saveResultCaseHeader (int iter, double currentTime)
 Saves the result case header taking into account the possibility of multiple result cases and that this function may be called twice for each result case (one from saveNodeData() and another from saveElementData()). More...
 
void findMaterialGroup (const GmMesh *mesh, const QVariantMap &options)
 Set _materialGroup with the property set index that will be used to exposrt material inidces.
 
void saveMaterialGroup (const GmCellMesh *mesh)
 Save material information.
 
void saveIntegrationRules (const GmCellMesh *mesh)
 Save integration rule information and fills _elementRule with the mapping between types and integration ids in the file.
 
void saveNodeDataValueType (const GmMesh *mesh, const char *valueTypeStr, int nfValues, const QList< GmValueAccessor * > &valueAccList)
 
void saveElementDataValueType (const GmCellMesh *mesh, const char *valueTypeStr, int nfValues, const QList< GmCellAccessor * > &elemAccList, const QList< GmGaussAccessor * > &gaussAccList)
 

Private Attributes

QString _nfFileName
 The neutral file file name.
 
FILE * _nfFile
 The neutral file file handle.
 
FILE * _tempFile
 The temporary file file handler (used for multiple result sets)
 
QTemporaryFile_tempFileObj
 The Qt object used to safelly create the temp object in a "sane" place.
 
int _materialGroup
 The material group used to identify cell materials.
 
int _intRuleSet
 The mesh integration rule set that will be used to export values.
 
int _elementRule [GM_NUM_CELL_TYPES]
 The integration rule bound to each element type.
 
int _nresults
 The number of added result cases.
 
bool _saveDisplacements
 Save displacement data?
 
QList< QPair< int, int > > _extraNodes
 

Additional Inherited Members

- Protected Member Functions inherited from GmNfFileFormat
int nf2gmCellNodeIndex (GmCellType type, int nfId)
 
int nf2gmCellGaussIndex (GmCellType type, int ngp, int nfId)
 
unsigned int offset (unsigned int n)
 
- Protected Attributes inherited from GmFileWriter
const GmLogCategory_logger
 The logger used to report errors.
 
- Static Protected Attributes inherited from GmNfFileFormat
static const SupportedTypesT supportedTypes []
 
static const int supportedTypesSize
 
static const nfrType nfrTypeTable []
 
static const nfrElement nfrElementTable []
 

Detailed Description

A file serializer for saving data in the "Neutral File" file format.

Member Function Documentation

◆ addSavedItemsToMap()

bool GmNfFileWriter::addSavedItemsToMap ( QVariantMap &  map)
virtual

This function should add to map any internal serializer state that must be saved on a dump operation, returning false on errors.

To avoid naming conflicts, each added key should have a prefix unique to this writer.

Reimplemented from GmFileWriter.

◆ copyResultData()

bool GmNfFileWriter::copyResultData ( FILE *  srcFile,
FILE *  dstFile,
qint64  size = 0 
)
private

Appends size bytes from srcFile to dstFile.

If size is 0, the whole contents will be appended. Assumes that the file pointer for dstFile is in the correct place. The src file is rewinded and ends in the end of the file or in position size.

On error, prints message and returns false

◆ saveResultCaseHeader()

void GmNfFileWriter::saveResultCaseHeader ( int  iter,
double  currentTime 
)
private

Saves the result case header taking into account the possibility of multiple result cases and that this function may be called twice for each result case (one from saveNodeData() and another from saveElementData()).

When called with -1 as iter, assumes that this is the last call to fill in the main file with the full set of result cases that where already saved to the temporary file


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