![]() |
GemaCoreLib
The GeMA Core library
|
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>
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 = 0x01, CELL_ID_COLUMN = 0x02, CELL_TYPE_COLUMN = 0x04, CELL_ACTIVE_COLUMN = 0x08, CELL_MATERIAL_COLUMN = 0x10, GAUSS_ID_COLUMN = 0x20, NODE_BC_COLUMN = 0x40, NODE_COLUMNS = NODE_ID_COLUMN, CELL_COLUMNS = CELL_ID_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. More... | |
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 | saveData (QString fileName, const 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. More... | |
bool | prepareForSaving (QString fileName, const GmSimulationData *simData, GmMesh *mesh, const GmCellGroupSet *group, const QVariantMap &options) |
Creates the requested file and prepares the object for saving multiple node and element result sets. See saveData() for a description of the parameters. More... | |
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. | |
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. | |
![]() | |
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 GmFileIO * | createInstance (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 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. More... | |
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. More... | |
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() 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) | |
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 (const 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 | 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. More... | |
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 | savePrepare (QString fileName, const 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. More... | |
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. | |
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< GmResultNodeDataSrc * > | _nodeData |
Data accessors & save definitions for node results that will be saved / loaded. May include srcs from interpolated Gauss data. | |
QVector< GmResultCellDataSrc * > | _cellData |
Data accessors & save definitions for cell results that will be saved / loaded. | |
QVector< GmResultGaussDataSrc * > | _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. | |
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. | |
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. | |
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:
2) Cell set related options:
3) Gauss set related options:
4) Value related options implemented by the FileIO class:
5) Value related options that SHOULD be implemented by the WRITERS:
6) Discontinuity set related options
7) Dump & restore related options
8) Hdf5 related options
TODO:
The selected mode when saving discontinuity data.
enum GmFileIO::DumpMode |
The set of extra columns that should be saved on file.
|
private |
|
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.
|
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.
|
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.
bool GmFileIO::prepareForSaving | ( | QString | fileName, |
const GmSimulationData * | simData, | ||
GmMesh * | mesh, | ||
const GmCellGroupSet * | group, | ||
const QVariantMap & | options | ||
) |
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:
bool GmFileIO::saveData | ( | QString | fileName, |
const 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.
fileName | The name of the file that will be created. If multiple files are created, this is the "base" file name. |
simData | The simulation data object |
mesh | The mesh that will be saved. |
group | An optional filter specifying that only cells from the given group should be saved |
options | A set of options specific to the file type |
|
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
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 splitted into scalar values when saved.