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

An object for conducting high level aspects of writing results to export files and / or reading mesh data from input files. More...

#include <gmFileIO.h>

Inheritance diagram for GmFileIO:
Collaboration diagram for GmFileIO:

Classes

struct  InternalVsData
 A helper structure to store data for the value sets created to enable Gauss to node interpolations & BC tag saving. More...
 
struct  InterpData
 A helper structure to collect all the needed interpolation configuration options. More...
 

Public Types

enum  DumpMode { DISABLED , DUMP , RESTORE }
 The dump mode when creating the file. More...
 
enum  DiscontinuityDataMode { NO_DISC_DATA , ORIGINAL_DISC_DATA , INTERSECTION_DISC_DATA , BOTH_DISC_DATA }
 The selected mode when saving discontinuity data. More...
 
enum  ExtraColumns {
  NODE_ID_COLUMN = 0x001 , NODE_INTID_COLUMN = 0x002 , CELL_ID_COLUMN = 0x004 , CELL_INTID_COLUMN = 0x008 ,
  CELL_TYPE_COLUMN = 0x010 , CELL_ACTIVE_COLUMN = 0x020 , CELL_MATERIAL_COLUMN = 0x040 , GAUSS_ID_COLUMN = 0x080 ,
  NODE_BC_COLUMN = 0x100 , NODE_COLUMNS = NODE_ID_COLUMN | NODE_INTID_COLUMN , CELL_COLUMNS = CELL_ID_COLUMN | CELL_INTID_COLUMN | CELL_TYPE_COLUMN | CELL_ACTIVE_COLUMN | CELL_MATERIAL_COLUMN , GAUSS_COLUMNS = GAUSS_ID_COLUMN
}
 The set of extra columns that should be saved on file. More...
 

Public Member Functions

 ~GmFileIO ()
 Destructor.
 
bool setNodeData (LuaTable &tab, GmMesh *mesh, bool split)
 Parses a node data list given by tab, filling in the object the set of node data that should be saved / read. On errors, returns false and logs an error explanation. Keep in mind that unknown ids only generate warnings.
 
bool setCellData (LuaTable &tab, GmCellMesh *mesh, bool split)
 Parses a cell data list given by tab. See comments for GmFileIO::setNodeData()
 
bool setGaussData (LuaTable &tab, GmElementMesh *mesh, bool split)
 Parses a gauss data list given by tab. See comments for GmFileIO::setNodeData()
 
bool setNodeData (const QVector< const GmNodeAcResultsDataSrc * > &data, GmMesh *mesh, bool split)
 Similar to setNodeData(LuaTable&, ...), except that it already receives the data src vector instead of a Lua table with their definitions.
 
bool setCellData (const QVector< const GmCellAcResultsDataSrc * > &data, GmCellMesh *mesh, bool split)
 Similar to setCellData(LuaTable&, ...), except that it already receives the data src vector instead of a Lua table with their definitions.
 
bool setGaussData (const QVector< const GmGaussAcResultsDataSrc * > &data, GmElementMesh *mesh, bool split)
 Similar to setGaussData(LuaTable&, ...), except that it already receives the data src vector instead of a Lua table with their definitions.
 
bool saveData (QString fileName, GmSimulationData *simData, GmMesh *mesh, const GmCellGroupSet *group, const QVariantMap &options)
 Saves the current configured mesh data to the given file in a single operation. The data to be saved should have been configured by calls to setXxxData(). The options table controls the saving behaviour.
 
bool prepareForSaving (QString fileName, GmSimulationData *simData, GmMesh *mesh, const GmCellGroupSet *group, const QVariantMap &options, bool multipleTimeSteps=true)
 Creates the requested file and prepares the object for saving multiple node and element result sets. See saveData() for a description of the parameters.
 
bool saveCurrentResult (double currentTime, bool meshChanged=false, bool discChanged=false)
 Adds the current mesh data to the file. Should be called after a call to prepareFile(). If mesh changed is true and the file format supports mesh changes, or this is the first call to saveCurrentResult, the mesh geometry is also saved. If discontinuity changed is true and the file format supports mesh changes, or this is the first call to saveCurrentResult, the mesh discontinuity geometry is also saved. THe currentTime values SHOULD be expressed in the standard time unit (the one set by a call to setCurrentTimeUnit()). If time unit conversion is in place, the conversion will be done automatically.
 
bool endWrite ()
 
bool closeFile ()
 Closes the opened file(s)
 
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)
 State dump init routine. Adds to 'state' the data items that should be saved for this File Io object. Checks with the file writer if it supports state dumping.
 
virtual bool stateAboutToBeSaved (GmStateDump *state)
 Prepares the Variant map with dumped data to be saved.
 
virtual bool stateLoaded (GmStateDump *state)
 Loads data from the loaded Variant map.
 
- 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 GmFileIOcreateInstance (QString fileType, bool writeMode, 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.
 
static bool acceptedFormat (QString fileType, bool writeMode)
 Returns true if the given file type matches a supported file type for the given read or write operation.
 
static QString extraColumnName (ExtraColumns col, const GmCellMesh *mesh=NULL, int psIndex=-1)
 Returns the column name that should be used for exporting the given extra column type. If col is CELL_MATERIAL_COLUMN, the property set name with index psIndex for the given mesh is included in the column name if the mesh is associated with more than on prperty set.
 

Private Types

enum  InterpDataMode { ELEMENT_INT_MODE , NODE_INT_MODE , SPLINE_INT_MODE , CLOUD_INT_MODE }
 The value set used to saved Bc tag data when _extraColumns includes NODE_BC_COLUMN. More...
 

Private Member Functions

 GmFileIO (GmFileReader *reader, GmFileWriter *writer, const GmLogCategory &logger)
 Private constructor. Objects should be instanced by a call to createInstance(). Takes ownership of the supplied reader / writer object.
 
 Q_DISABLE_COPY (GmFileIO)
 
template<class T , class Mesh , class DsF >
bool setData (LuaTable &tab, Mesh *mesh, const DsF &dsF, QVector< T * > &dataList, const char *entity, bool split)
 Work horse for the setXxxData(LuaTable&,...) family of functions. dsF should be the compatible GmResultsRule::createXxxxDataSrc() function. dataList is the vector to be filled and entity is the "Xxx" entity that we are implementing (used for better error message)
 
template<class T , class Mesh >
bool setData (const QVector< const T * > &data, Mesh *mesh, QVector< T * > &dataList, const char *entity, bool split)
 Work horse for the setXxxData(const QVector<T*>&,...) family of functions. dataList is the vector to be filled and entity is the "Xxx" entity that we are implementing (used for better error message)
 
bool parseAndCheckDumpMode (bool multipleTimeSteps)
 Parse and check dump & restore options. If the user asked for a dump or restore but the writer does not support it, or the file does not have multiple steps, emmits a warning and disables the option.
 
bool parseAndCheckStates (bool multipleTimeSteps, int *state, bool *allStates, QVector< double > &timeList)
 Parse and check state options and, if all states is true, fill the list with saved time steps. Also checks the compatibility of the state options with loaded data sources. If the user didn't defined a state, -1 is returned.
 
bool parseAndCheckGaussRules (QVector< int > &rules)
 Find which rule sets are being used by the selected gauss data. If there is more than one, check whether the file format supports multiple Gauss rules. If not, part of the requested Gauss data will be removed. Also checks if the file format accepts the specific Gauss rules or not (keep in mind that if the file does not accept Gauss data at all, the set of gauss data will be empty as a result of the filtering done by acceptsDataType(), that should have previously rejected every Gauss data).
 
bool parseAndCheckGaussInterpolationOptions (GmSimulationData *simData)
 Parses and checks Gauss to node interpolation options. If interpolation was requested, initializes the required data structures adding new entries to the node list.
 
bool parseAndCheckCoordAccessor ()
 Parses and check node coordinate accessor options.
 
bool parseAndCheckDiscontinuityOptions (const GmSimulationData *simData)
 Parses and checks options defining if and which discontinuity sets will be saved.
 
bool parseAndCheckExtraColumnOptions (const GmSimulationData *simData)
 Parses and checks standard options defining the saving of extra node/cell columns.
 
bool parseAndCheckTimeUnit (const GmSimulationData *simData, QString &timeUnit)
 Parses and checks time unit conversion option.
 
bool checkDataForSaving (bool multipleTimeSteps)
 Check the configured data sources and options against writer capabilities. Returns false if the writting operation can not proceed. Logs error and warning messages with the internal logger. State and Gauss related checks are done, respectively, in parseAndCheckStates() and parseAndCheckGaussRules(). Data type checks where already done by the setXxxData() functions.
 
bool adjustAcStates (int state)
 
bool adjustAndCheckIds ()
 Adjust saved attribute ids if auto alias is true. Also checks that saved id names are unique inside their groups. Depending on the file format requirements, uniqueness might be needed among different groups (a neutral file, for example, packs cell and gauss attributes together...)
 
bool prepareNodeInterpolatedValues ()
 Prepares the node interpolated data to be saved by doSaveData()
 
bool prepareNodeBcValues ()
 Prepares the node boundary condition data to be saved by doSaveData()
 
bool setCurrentTime (int iter, double time)
 Sets the current iteration and time on the writer, converting values if time unit conversion is in-place.
 
bool savePrepare (QString fileName, GmSimulationData *simData, GmMesh *mesh, const GmCellGroupSet *group, const QVariantMap &options, bool multipleTimeSteps, QVector< double > &timeList)
 Prepares the file for saving. Does not adds node or geometry information since that might need to be repeated for each time step. If multipleTimeSteps is false and the user specified the allStates options, fills timeList with state times. On errors, returns NULL and logs a message. Will call cleanup() on errors.
 
bool doSaveGeometry ()
 Calls the writer to save geometry data.
 
bool doSaveDiscontinuities ()
 Calls the writer to save discontinuity data.
 
bool doSaveData ()
 Calls the writer to save the selected data. If Gauss to node interpolation is in order, does the interpolation calculating the new node values.
 
void updateInterpData ()
 
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_writer
 The object used for writing data when instanced in write mode. Null otherwise.
 
GmFileReader_reader
 The object used for reading data when instanced in write mode. Null otherwise.
 
GmFileFilter_filter
 The configured filter for saving operations.
 
QString _fileName
 The base file name.
 
DumpMode _dumpMode
 Will this file take part on a dump / restore operation?
 
GmMesh_mesh
 The mesh for load / save operations.
 
QVector< GmNodeAcResultsDataSrc * > _nodeData
 Data accessors & save definitions for node results that will be saved / loaded. May include srcs from interpolated Gauss data.
 
QVector< GmCellAcResultsDataSrc * > _cellData
 Data accessors & save definitions for cell results that will be saved / loaded.
 
QVector< GmGaussAcResultsDataSrc * > _gaussData
 Data accessors & save definitions for Gauss results that will be saved / loaded.
 
GmValueAccessor_nodeAc
 The accessor used for retrieving node coordinates. Can be different from the mesh coordinate accessor.
 
bool _coordTransf
 A boolean defining if the coordinate transformation vectors are filled or not.
 
double _coordScaleFactor [3]
 An optional set of scale factors applied over node coordiantes.
 
double _coordOffset [3]
 An optional set of offsets applied over node coordinates

 
UnitConverter_timeConv
 A time converter from the time unit to the user desired unit. Can be NULL.
 
bool _openFiles
 States if we have an open file or not.
 
int _saveIter
 Keeps track of the number of times that saveCurrentResult was called.
 
QVariantMap _options
 Keeps track of save options in a statefull operation.
 
int _extraColumns
 The set of extra columns that should be saved. An or of GmFileWriter::ExtraColumns values.
 
QVector< int > _propertySets
 The list of property sets whose material indices should be saved when _extraColumns includes CELL_MATERIAL_COLUMN.
 
GmSimulationData_simData
 
QVector< const GmBoundaryCondition * > _meshBcs
 
InternalVsData_nodeBcVsData
 The set of mesh boundary conditions, WITH TAGS, that should be saved when _extraColumns includes NODE_BC_COLUMN.
 
InterpData_interpData
 The set of interpolation options and data when Gauss to node interpolation is configured.
 
QVector< GmDiscontinuitySet * > _dsList
 The list with saved discontinuity sets.
 
DiscontinuityDataMode _dsMode
 The selected mode defining which kind of discontinuity data should be saved.
 
UnitConverter_dsConv
 The unit converter needed to convert from the mesh unit to the _nodeAc unit. NULL if not needed.
 
QVariantMap _stateMap
 Variant map used for state dumping.
 

Detailed Description

An object for conducting high level aspects of writing results to export files and / or reading mesh data from input files.

General supported save option flags are:

1) Node set related options:

  • scaleFactorX, scaleFactorY, scaleFactorZ - A scale factor applied over the appropriate node coordinate dimension. Default = 1.0;
  • offsetX, offsetY, offsetZ - An offset added to the appropriate node coordinate dimension. Default = 0.0.
  • coordAttribute - The name of a node attribute used as the mesh coordinate. If empty (default), the mesh coordinate will be used. Can include a unit suffix (like 'depth(cm)'). To change the unit of the standard mesh coordinate, use 'coordinate(unit)'.
  • ghostMode - A string whose values can be 'geometry', 'ghost' or 'both' defining which kind of nodes should be exported. Keep in mind that when exporting ghost nodes, they do not take part in cell topology, but they can have associated values (which means that a ghostMode of 'ghost' will only export a point cloud). Keep in mind that node accessor modes should be compatible with the selected mode. (see GmFileFilter::nodeAcIsCompatible()). Default = 'geometry'.
  • activeNodesOnly - When activeOnly is true, should we include in the file nodes that do not belong to any active cell? Setting it to true will trigger a node reordering in the saved file so that unused nodes will be removed from the save set. This also applies for nodes that are unused due to cell group filtering or due to invalid cell removal. Default = false.

2) Cell set related options:

  • activeOnly - Should we save only the set of active cells? Default = false.
  • onInvalidCells - This option defines what the writer should do if the mesh includes cell types that can not be exported to the target file. A value of 'ignore' means that invalid cells will be silently ignored. A value of 'abort' means that the export should be aborted and a value of 'warn' means that a (single) warning message is logged and invalid cells are ignored. Default = 'warn'.

3) Gauss set related options:

  • gaussMode - A string whose values can be 'gauss', 'node' or 'both' defining if Gauss data should be kept at Gauss points, extrapolated to nodes or both. This option is incompatible with ghostMode different from 'geometry'. Extrapolation parameters are controlled by the gaussInterp option table. When mode is "both", the node interpolated attribute names will be prefixed with "gauss_" to distinguish them from the Gauss ones. Default = 'gauss'. IMPORTANT: Keep in mind that the interpolation is done only over active cells, so enabling activeOnly is probably for the best if you have inactive cells.
  • gaussInterp - A table collecting the set of options that control gauss to node interpolation when gaussMode is different from 'gauss'. The following set of keys are interpreted:
    • mode: The interpolation mode. Can be 'element', 'node', 'spline' or 'cloud. In element mode, the EB_G2N interpolation method is used. In 'node' mode, the NB_GN2N interpolation method is used. In 'spline' mode, the SPLINE_G2N interpolation method is used. In 'cloud' mode, the MESH_G2N interpolation method is used. See the "Interpolation functions" documentation in the orchestration reference manual for more details about the given methods. IMPORTANT: Please remember that for 'node' based mode, the mesh MUST support topological queries. Default is 'element'.
    • interpType: The interpolation method that will be used. If mode is 'element', can be 'shape' or 'lshape'. For method equal to 'node' or 'cloud', can be 'nn', 'idw' or 'mls'. Unused for 'spline' method. Default is 'shape' for the element mode and 'idw' for the node mode.
    • interpParam: The interpolation parameter when required by the interpType. The default is the interpolation method default.
    • averageMode: When in element mode, defines how the data extrapolated from each element is combined on the nodes. Options are 'mean' or 'area'. Default is 'mean'.
    • closestMode: When in node mode, defines if all the Gauss points in neighbour elements are used or if only the closets points are used. A boolean value. Default = false.
    • searchMode: When the method is 'spline' or 'cloud', this parameter defines if the compact domain radius is given by a radius (value equal to 'radius') or by number of closest points (value equal to 'closest'). Required (for mode == 'spline' or 'cloud').
    • searchDomain: When in 'spline' or 'cloud' modes, provides the radius or the number of closest nodes. Required (for mode == 'spline' or 'cloud').
    • index: When in 'spline' or 'cloud' modes, the name of the spatial index object used to find the source Gauss points. It must implement the 'closestGauss' capability. It also must be tied to the same rule set as the saved Gauss accessors. Required (for mode == 'spline' or 'cloud').
    • solver: When in 'spline' or 'cloud' modes, the name of the numerical solver object used to solve the linear system. Required (for mode == 'spline' or 'cloud').

4) Time related options when saving a file with multiple result sets

  • timeUnit - The unit to which time information should be converted to before time values being saved. By default, values are saved without conversion in the default time unit set by a call to setCurrentTimeUnit(). If timeUnit exists, time values will be converted from the default unit to the given one. IMPORTANT: Notice that time values given in calls to saveCurrentResult SHOULD be expressed in the default time unit!!!!

5) Value related options implemented by the FileIO class:

  • state - The state number used to find values when the attribute/ state var has an associated history. Default = nil (interpreted as 0, present state). If the state is invalid for an accessor, the default will be used for it. Ignored when mixed with history state definition done on a per accessor base (by using the history flag when defining the desired data ids) or with allSates.
  • allStates - A boolean value, valid only if the file format supports multiple states, tells that all states should be saved. Makes sense only if all variables share the same number of states (or have exactly one state which will be used for all states) AND we are saving the whole mesh data in a single operation. Default = false. Ignored when mixed with history state definition done on a per accessor base (by using he history flag when defining the desired data ids).
  • split - A boolean value that tells that all vector (and matrix) values should be split into multiple scalar values. Used to keep old code running. Prefer the new syntax used to filter dimensions on a per accessor base ('id[dim]'). Default = false.
  • saveNodeBcTags - A boolean value that tells that BC tags from all boundary conditions tied to this mesh should be combined together and saved as a node value. If this value is a table, instead of a boolean, the table should store the names of the boundary conditions that will be processed (all of them should be tied to the saved mesh). Default = false.

6) Value related options that SHOULD be implemented by the WRITERS:

  • saveNodeId - A boolean value defining if the GeMA node id should be saved as a node property value. Can be useful when activeNodesOnly is set to true, defining a mapping between the exported node and the original one. Ghost nodes are referenced by their linear index. Extra nodes, (exported only if cell types require type transformation) have a -1 index. Saved indices are 1-based as seen in the Lua orchestration. Default = false.
  • saveCellId - A boolean value defining if the GeMA cell id should be saved as a cell property value. Useful when there are filtered cells to define a mapping between the exported cells and their original ones. Saved indices are 1-based as seen in the Lua orchestration. Default = false;
  • saveCellType - A boolean value defining if the GeMA cell type should be saved as a cell property value. Saved indices are 1-based. Default = false.
  • saveCellMaterial - A value defining if cell material indices should be exported or not. Can be a single string with the exported property set name or a table with several strings defining the exported property sets. If the file format accepts only a single material, the first set listed will be used. Saved indices are 1-based as seen in the Lua orchestration. Default = empty.
  • saveCellActive - A boolean value defining if the GeMA cell active attribute should be saved as a cell property value. Makes sense only if activeOnly is false. Default = false.
  • saveGaussId - A boolean value defining if the GeMA cell id + Gauss point number should be saved as a vector cell property value (cellId, ipId). This option has no effect if no Gauss attribute is selected for saving (since without them we don't know which integration rules to save). Saved indices are 1-based as seen in the Lua orchestration. Default = false.
  • materialPropertySet - An alias to saveCellMaterial accepting only a string value. Ignored if saveCellMaterial is defined.
  • saveDisplacements - If the file format has a special way of defining node displacements, defines the name of the vector node attribute storing this information. Can include a unit suffix (like 'u(cm')). To keep old code working, if this value is true, the first node attribute in the node data list is used.
  • singlePrecision - A boolean value defining that every real value stored in the file should be stored as a single precision float. Valid only for binary files. Default = false.

7) Discontinuity set related options

  • discontinuitySet - Either the name of the discontinuity set to be saved or a table with the names of the discontinuity sets to be saved. Coordinates will be saved in the selected unit for mesh coordinate saving
  • discontinuityMode - A string whose values can be 'original', 'intersection' or 'both' defining whether the user provided, original discontinuity information will be saved, the intersection generated data will be saved or both. Default = 'original'. Has no meaning if discontinuitySet is empty.

8) Dump & restore related options

  • forDumping - Boolean value. States that this file will be part of an orchestration with state dumping commands and that it should take steps to enable, if supported, state dump & restore possibilities.
  • forRestore - Boolean value. States that this file is being opened as part of a dump restore operation (with possible additional dumps after the restore). Can not be specified together with forDumping.

9) Hdf5 related options

  • splitDataFile - Either a boolean, specifying that a different Hdf5 file should be saved for each time step, or an int specifying how many steps should be saved in each file before splitting. Setting its value to true is the same as setting it to one. When forDumping or forRestore is true, this flag will be implicitly set to true if not set by the user. Besides that, a dump operation forces a file split even if the current step is not a split step.
  • savePartialXdmf - When set to true or to an integer value, specifies that a partial xdmf file should be periodically saved to enable viewing partial results. If splitDataFile was not defined by the user, it will be automatically set to the same value as savePartialXdmf. Otherwise, the savePartialXdmf value MUST be a multiple of the splitDataFile value.

TODO:

  • Filter by node sets
  • Add unit and dimension as alias automatically
  • Check that all ids inside a data src vector (node, cell or gauss) are unique
  • Use compression
  • Transform functions
  • Dump / Split time files
  • Auto monitor mesh changes
  • Regular meshes
  • Save cell groups as sets on HDF5
  • Force saving double values as float
  • Filter cells based on material
  • Filter cells based on a function (dynamic - might change every time step... user function?)

Member Enumeration Documentation

◆ DiscontinuityDataMode

The selected mode when saving discontinuity data.

Enumerator
NO_DISC_DATA 

No data will be saved.

ORIGINAL_DISC_DATA 

Only the original, user given, discontinuity data will be saved.

INTERSECTION_DISC_DATA 

Only the intersection data will be saved.

BOTH_DISC_DATA 

Both the original and the intersection data will be saved.

◆ DumpMode

The dump mode when creating the file.

Enumerator
DISABLED 

No save & restore operations in use.

DUMP 

The file will take part in state dumping.

RESTORE 

The file will be involved as part of an initial restore operation (maybe followed by other dump operations)

◆ ExtraColumns

The set of extra columns that should be saved on file.

Enumerator
NODE_ID_COLUMN 

The original node id should be saved.

NODE_INTID_COLUMN 

The internal node id should be saved.

CELL_ID_COLUMN 

The original cell id should be saved.

CELL_INTID_COLUMN 

The internal cell id should be saved.

CELL_TYPE_COLUMN 

The GeMA cell type should be saved.

CELL_ACTIVE_COLUMN 

The cell active flag should be saved.

CELL_MATERIAL_COLUMN 

The cell material should be saved (possibly several columns)

GAUSS_ID_COLUMN 

The cell id + ip number should be saved.

NODE_BC_COLUMN 

BC tags should be combined and saved to a node column.

NODE_COLUMNS 

Does NOT include NODE_BC_COLUMN, treated internally by FileIO and not by the writers.

◆ InterpDataMode

The value set used to saved Bc tag data when _extraColumns includes NODE_BC_COLUMN.

The selected interpolation mode

Enumerator
ELEMENT_INT_MODE 

EB_G2N interpolation.

NODE_INT_MODE 

NB_GN2N interpolation.

SPLINE_INT_MODE 

SPLINE_G2N interpolation.

CLOUD_INT_MODE 

MESH_G2N interpolation.

Constructor & Destructor Documentation

◆ GmFileIO()

GmFileIO::GmFileIO ( GmFileReader * reader,
GmFileWriter * writer,
const GmLogCategory & logger )
private

Private constructor. Objects should be instanced by a call to createInstance(). Takes ownership of the supplied reader / writer object.

The current implementation is prepared for receiving either a reader or a writer, NOT BOTH.

Member Function Documentation

◆ addStateItemsToGroup()

bool GmFileIO::addStateItemsToGroup ( GmStateDump * state,
int groupId )
virtual

State dump init routine. Adds to 'state' the data items that should be saved for this File Io object. Checks with the file writer if it supports state dumping.

Implements GmGroupDumpItem.

◆ checkDataForSaving()

bool GmFileIO::checkDataForSaving ( bool multipleTimeSteps)
private

Check the configured data sources and options against writer capabilities. Returns false if the writting operation can not proceed. Logs error and warning messages with the internal logger. State and Gauss related checks are done, respectively, in parseAndCheckStates() and parseAndCheckGaussRules(). Data type checks where already done by the setXxxData() functions.

Expects that _mesh, _filter, _xxxData and _options are already filled! The multipleTimeSteps flag defines if the file is being prepared for multiple results or not.

◆ extraColumnName()

QString GmFileIO::extraColumnName ( ExtraColumns col,
const GmCellMesh * mesh = NULL,
int psIndex = -1 )
static

Returns the column name that should be used for exporting the given extra column type. If col is CELL_MATERIAL_COLUMN, the property set name with index psIndex for the given mesh is included in the column name if the mesh is associated with more than on prperty set.

Column names are standardised by GmFileIO, instead of being a free choice of the writer, to enable checking for duplicate column ids by the GmFileIO class, without the need to add extra query functions to GmFileFormat.

◆ prepareForSaving()

bool GmFileIO::prepareForSaving ( QString fileName,
GmSimulationData * simData,
GmMesh * mesh,
const GmCellGroupSet * group,
const QVariantMap & options,
bool multipleTimeSteps = true )

Creates the requested file and prepares the object for saving multiple node and element result sets. See saveData() 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:

prepareFile()
while(...)
{
addCurrentResult(t);
}
bool closeFile()
Closes the opened file(s)
Definition gmFileIO.cpp:577

If multipleTimeSteps is set to false (the default is true), this function can be used as a setup for a single call to addCurrentResult() that will have the same effect as calling saveData(). Although calling saveData() is preferred (and also the only way to handle the allStates option), doing this can be usefull if the calling code can be made simpler without having special cases for single or multiple results.

◆ saveData()

bool GmFileIO::saveData ( QString fileName,
GmSimulationData * simData,
GmMesh * mesh,
const GmCellGroupSet * group,
const QVariantMap & options )

Saves the current configured mesh data to the given file in a single operation. The data to be saved should have been configured by calls to setXxxData(). The options table controls the saving behaviour.

Parameters
fileNameThe name of the file that will be created. If multiple files are created, this is the "base" file name.
simDataThe simulation data object
meshThe mesh that will be saved.
groupAn optional filter specifying that only cells from the given group should be saved
optionsA set of options specific to the file type
Returns
Returns false on errors.

◆ savePrepare()

bool GmFileIO::savePrepare ( QString fileName,
GmSimulationData * simData,
GmMesh * mesh,
const GmCellGroupSet * group,
const QVariantMap & options,
bool multipleTimeSteps,
QVector< double > & timeList )
private

Prepares the file for saving. Does not adds node or geometry information since that might need to be repeated for each time step. If multipleTimeSteps is false and the user specified the allStates options, fills timeList with state times. On errors, returns NULL and logs a message. Will call cleanup() on errors.

Check and handle dump & restore options

◆ setNodeData()

bool GmFileIO::setNodeData ( LuaTable & tab,
GmMesh * mesh,
bool split )

Parses a node data list given by tab, filling in the object the set of node data that should be saved / read. On errors, returns false and logs an error explanation. Keep in mind that unknown ids only generate warnings.

Each tab entry can be a string or a table following the same syntax rules used to describe a monitored result. Eventual interpolator definitions are ignored. The split flag defines if the user wants that vector and matrix values to be split into scalar values when saved.

◆ stateAboutToBeSaved()

bool GmFileIO::stateAboutToBeSaved ( GmStateDump * state)
virtual

Prepares the Variant map with dumped data to be saved.

Reimplemented from GmGroupDumpItem.

◆ stateLoaded()

bool GmFileIO::stateLoaded ( GmStateDump * state)
virtual

Loads data from the loaded Variant map.

Reimplemented from GmGroupDumpItem.


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