GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmFileIO.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_FILE_IO_H_
25#define _GEMA_FILE_IO_H_
26
27#include "gmCoreConfig.h"
28
29#include "gmStateDumpItem.h"
31
32#include <QStringList>
33#include <QVariantMap>
34
35class GmFileReader;
36class GmFileWriter;
37class GmFileFormat;
38class GmFileFilter;
39
40class GmLogCategory;
42class GmMesh;
43class GmCellMesh;
44class GmElementMesh;
45class GmCellGroupSet;
48
53
54class GmValueInfo;
56class GmValueAccessor;
57class GmSpatialIndex;
58class GmNumSolver;
59
60class GmNodeSet;
61
62class UnitConverter;
63
68{
69public:
77
86
89 NODE_ID_COLUMN = 0x001,
90 NODE_INTID_COLUMN = 0x002,
91 CELL_ID_COLUMN = 0x004,
92 CELL_INTID_COLUMN = 0x008,
93 CELL_TYPE_COLUMN = 0x010,
94 CELL_ACTIVE_COLUMN = 0x020,
95 CELL_MATERIAL_COLUMN = 0x040,
96 GAUSS_ID_COLUMN = 0x080,
97 NODE_BC_COLUMN = 0x100,
98
99 // --- Combined options ---
100 NODE_COLUMNS = NODE_ID_COLUMN | NODE_INTID_COLUMN,
101 CELL_COLUMNS = CELL_ID_COLUMN | CELL_INTID_COLUMN | CELL_TYPE_COLUMN | CELL_ACTIVE_COLUMN | CELL_MATERIAL_COLUMN,
102 GAUSS_COLUMNS = GAUSS_ID_COLUMN,
103 };
104
105 ~GmFileIO();
106
107 static GmFileIO* createInstance(QString fileType, bool writeMode, const GmLogCategory& logger);
108 static bool acceptedFormat(QString fileType, bool writeMode);
109
110 bool setNodeData (LuaTable& tab, GmMesh* mesh, bool split);
111 bool setCellData (LuaTable& tab, GmCellMesh* mesh, bool split);
112 bool setGaussData(LuaTable& tab, GmElementMesh* mesh, bool split);
113
114 bool setNodeData (const QVector<const GmNodeAcResultsDataSrc*>& data, GmMesh* mesh, bool split);
115 bool setCellData (const QVector<const GmCellAcResultsDataSrc*>& data, GmCellMesh* mesh, bool split);
116 bool setGaussData(const QVector<const GmGaussAcResultsDataSrc*>& data, GmElementMesh* mesh, bool split);
117
118 bool saveData(QString fileName, GmSimulationData* simData, GmMesh* mesh, const GmCellGroupSet* group, const QVariantMap& options);
119
120 bool prepareForSaving(QString fileName, GmSimulationData* simData, GmMesh* mesh, const GmCellGroupSet* group,
121 const QVariantMap& options, bool multipleTimeSteps = true);
122
123 bool saveCurrentResult(double currentTime, bool meshChanged = false, bool discChanged = false);
124 bool endWrite();
125 bool closeFile();
126
127 QString tempFile();
128
129 virtual bool addStateItemsToGroup(GmStateDump* state, int groupId);
130 virtual bool stateAboutToBeSaved (GmStateDump* state);
131 virtual bool stateLoaded (GmStateDump* state);
132
133 static QString extraColumnName(ExtraColumns col, const GmCellMesh* mesh = NULL, int psIndex = -1);
134
135private:
136 GmFileIO(GmFileReader* reader, GmFileWriter* writer, const GmLogCategory& logger);
137
138 Q_DISABLE_COPY(GmFileIO);
139
140 template <class T, class Mesh, class DsF>
141 bool setData(LuaTable& tab, Mesh* mesh, const DsF& dsF, QVector<T*>& dataList, const char* entity, bool split);
142
143 template <class T, class Mesh>
144 bool setData(const QVector<const T*>& data, Mesh* mesh, QVector<T*>& dataList, const char* entity, bool split);
145
146 bool parseAndCheckDumpMode (bool multipleTimeSteps);
147 bool parseAndCheckStates (bool multipleTimeSteps, int* state, bool* allStates, QVector<double>& timeList);
148 bool parseAndCheckGaussRules(QVector<int>& rules);
149 bool parseAndCheckGaussInterpolationOptions(GmSimulationData* simData);
150 bool parseAndCheckCoordAccessor();
151 bool parseAndCheckDiscontinuityOptions(const GmSimulationData* simData);
152 bool parseAndCheckExtraColumnOptions(const GmSimulationData* simData);
153 bool parseAndCheckTimeUnit(const GmSimulationData* simData, QString& timeUnit);
154 bool checkDataForSaving(bool multipleTimeSteps);
155 bool adjustAcStates (int state);
156 bool adjustAndCheckIds ();
157
158 bool prepareNodeInterpolatedValues();
159 bool prepareNodeBcValues();
160
161 bool setCurrentTime(int iter, double time);
162
163 bool savePrepare(QString fileName, GmSimulationData* simData, GmMesh* mesh, const GmCellGroupSet* group,
164 const QVariantMap& options, bool multipleTimeSteps, QVector<double>& timeList);
165
166 bool doSaveGeometry();
167 bool doSaveDiscontinuities();
168 bool doSaveData();
169
170 void updateInterpData(); //In case mesh changes (added cells) we need to update interpolation data (cell groups and node sets)
171
172 bool cleanup(bool deleteFiles = false);
173
180
185
188 double _coordScaleFactor[3];
189 double _coordOffset[3];
191
194 QVariantMap _options;
197 GmSimulationData* _simData;
198
206
207 InternalVsData(GmValueInfo* info, GmValueSetStoredData* vs, GmNodeAcResultsDataSrc* ds) : _info(info), _vs(vs), _ds(ds) {}
209 private:
210 Q_DISABLE_COPY(InternalVsData);
211 };
212
215
224
256
258
262
263 QVariantMap _stateMap;
264};
265
266#endif
267
A class used to represent a set of boundary conditions of the same type, tied to the same mesh.
Definition gmBoundaryCondition.h:287
A GmAcResultsDataSrc class holding a cell value accessor.
Definition gmAcResultsDataSrc.h:295
Interface for helping managing mesh cell groups and returning the elements in their union.
Definition gmCellGroupSet.h:35
Base interface class for CellMesh type plugins.
Definition gmCellMesh.h:40
Base interface for providing discontinuity geometry information for spatial indices.
Definition gmDiscontinuitySet.h:59
Base interface for FEM (finite element) meshes.
Definition gmElementMesh.h:42
A generic auxiliary class for managing the various options that can be used to define the set of node...
Definition gmFileFilter.h:47
Basic interface for describing high level file format capabilities.
Definition gmFileFormat.h:35
An object for conducting high level aspects of writing results to export files and / or reading mesh ...
Definition gmFileIO.h:68
const GmLogCategory & _logger
The logger object used to report errors.
Definition gmFileIO.h:174
InterpDataMode
The value set used to saved Bc tag data when _extraColumns includes NODE_BC_COLUMN.
Definition gmFileIO.h:218
@ ELEMENT_INT_MODE
EB_G2N interpolation.
Definition gmFileIO.h:219
@ SPLINE_INT_MODE
SPLINE_G2N interpolation.
Definition gmFileIO.h:221
@ NODE_INT_MODE
NB_GN2N interpolation.
Definition gmFileIO.h:220
@ CLOUD_INT_MODE
MESH_G2N interpolation.
Definition gmFileIO.h:222
QVector< GmCellAcResultsDataSrc * > _cellData
Data accessors & save definitions for cell results that will be saved / loaded.
Definition gmFileIO.h:183
GmFileWriter * _writer
The object used for writing data when instanced in write mode. Null otherwise.
Definition gmFileIO.h:175
QVector< int > _propertySets
The list of property sets whose material indices should be saved when _extraColumns includes CELL_MAT...
Definition gmFileIO.h:196
UnitConverter * _timeConv
A time converter from the time unit to the user desired unit. Can be NULL.
Definition gmFileIO.h:190
int _extraColumns
The set of extra columns that should be saved. An or of GmFileWriter::ExtraColumns values.
Definition gmFileIO.h:195
QVector< GmGaussAcResultsDataSrc * > _gaussData
Data accessors & save definitions for Gauss results that will be saved / loaded.
Definition gmFileIO.h:184
QVariantMap _options
Keeps track of save options in a statefull operation.
Definition gmFileIO.h:194
GmFileReader * _reader
The object used for reading data when instanced in write mode. Null otherwise.
Definition gmFileIO.h:176
bool _openFiles
States if we have an open file or not.
Definition gmFileIO.h:192
DumpMode
The dump mode when creating the file.
Definition gmFileIO.h:72
@ DISABLED
No save & restore operations in use.
Definition gmFileIO.h:73
@ RESTORE
The file will be involved as part of an initial restore operation (maybe followed by other dump opera...
Definition gmFileIO.h:75
@ DUMP
The file will take part in state dumping.
Definition gmFileIO.h:74
ExtraColumns
The set of extra columns that should be saved on file.
Definition gmFileIO.h:88
GmMesh * _mesh
The mesh for load / save operations.
Definition gmFileIO.h:181
QVector< GmNodeAcResultsDataSrc * > _nodeData
Data accessors & save definitions for node results that will be saved / loaded. May include srcs from...
Definition gmFileIO.h:182
DiscontinuityDataMode _dsMode
The selected mode defining which kind of discontinuity data should be saved.
Definition gmFileIO.h:260
GmFileFilter * _filter
The configured filter for saving operations.
Definition gmFileIO.h:177
UnitConverter * _dsConv
The unit converter needed to convert from the mesh unit to the _nodeAc unit. NULL if not needed.
Definition gmFileIO.h:261
QString _fileName
The base file name.
Definition gmFileIO.h:178
bool _coordTransf
A boolean defining if the coordinate transformation vectors are filled or not.
Definition gmFileIO.h:187
InterpData * _interpData
The set of interpolation options and data when Gauss to node interpolation is configured.
Definition gmFileIO.h:257
GmValueAccessor * _nodeAc
The accessor used for retrieving node coordinates. Can be different from the mesh coordinate accessor...
Definition gmFileIO.h:186
DumpMode _dumpMode
Will this file take part on a dump / restore operation?
Definition gmFileIO.h:179
QVariantMap _stateMap
Variant map used for state dumping.
Definition gmFileIO.h:263
DiscontinuityDataMode
The selected mode when saving discontinuity data.
Definition gmFileIO.h:80
@ INTERSECTION_DISC_DATA
Only the intersection data will be saved.
Definition gmFileIO.h:83
@ BOTH_DISC_DATA
Both the original and the intersection data will be saved.
Definition gmFileIO.h:84
@ ORIGINAL_DISC_DATA
Only the original, user given, discontinuity data will be saved.
Definition gmFileIO.h:82
@ NO_DISC_DATA
No data will be saved.
Definition gmFileIO.h:81
QVector< GmDiscontinuitySet * > _dsList
The list with saved discontinuity sets.
Definition gmFileIO.h:259
InternalVsData * _nodeBcVsData
The set of mesh boundary conditions, WITH TAGS, that should be saved when _extraColumns includes NODE...
Definition gmFileIO.h:214
int _saveIter
Keeps track of the number of times that saveCurrentResult was called.
Definition gmFileIO.h:193
Basic interface for file deserializers.
Definition gmFileReader.h:41
Basic interface for file serializers.
Definition gmFileWriter.h:37
A GmAcResultsDataSrc class holding a Gauss value accessor.
Definition gmAcResultsDataSrc.h:318
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition gmStateDumpItem.h:53
virtual bool stateAboutToBeSaved(GmStateDump *state)
Virtual method called just before starting a save operation on the given state. Returning false abort...
Definition gmStateDumpItem.h:70
virtual bool addStateItemsToGroup(GmStateDump *state, int groupId)=0
Initialization method, called once, allowing the object to add its state items to the given group of ...
virtual bool stateLoaded(GmStateDump *state)
Virtual method called just after succesfully completing a load operation on the given state....
Definition gmStateDumpItem.h:85
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
A GmAcResultsDataSrc class holding a node value accessor.
Definition gmAcResultsDataSrc.h:272
This class stores a set of nodes belonging to a mesh. The nodes can belong to the mesh boundary but t...
Definition gmNodeSet.h:34
Base interface class for NumSolver type plugins.
Definition gmNumSolver.h:36
A basic interface with the metadata common to all results data src types. This is the information tha...
Definition gmResultsDataSrcInfo.h:50
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
Base interface class for Spatial Index type plugins.
Definition gmSpatialIndex.h:66
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition gmStateDump.h:54
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
The generic GmValueSetData interface for classes that do store their own data.
Definition gmValueSetStoredData.h:45
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of the GmGaussToElementNodeInterpolator class.
GmInterpolatorAveraging
Averaging options for calculating nodal values from multiple element contributions.
Definition gmGaussToElementNodeInterpolator.h:71
GmInterpolatorType
Available interpolation methods. Not every method is suitable for every kind of interpolator class....
Definition gmInterpolator.h:64
Declaration of the GmStateDumpBaseDataItem and basic derived classes.
A helper structure to store data for the value sets created to enable Gauss to node interpolations & ...
Definition gmFileIO.h:202
GmValueInfo * _info
An info object with most of its data copied from the "parent" Gauss value set or representing the Bc ...
Definition gmFileIO.h:203
GmNodeAcResultsDataSrc * _ds
The associated data src stored and owned by _nodeData.
Definition gmFileIO.h:205
GmValueSetStoredData * _vs
The value set storing the new (interpolated/Bc tag) data buffer.
Definition gmFileIO.h:204
A helper structure to collect all the needed interpolation configuration options.
Definition gmFileIO.h:226
const GmSpatialIndex * _gaussIndex
The spatial index object used for SPLINE or CLOUD based interpolations.
Definition gmFileIO.h:235
const GmNodeSet * _interfaceNodeSet
The interface node set used for interpolation.
Definition gmFileIO.h:248
InterpDataMode _mode
The interpolation mode.
Definition gmFileIO.h:227
QVariant _interpParam
Optional interpolation parameters.
Definition gmFileIO.h:230
GmInterpolatorType _interpType
The interpolator used when mode is different from SPLINE.
Definition gmFileIO.h:229
int _interfaceGroupId
GroupSet of interface elements.
Definition gmFileIO.h:241
GmCellGroupSet * _meshGroup
A group set for the entire mesh. Used by the interpolation routines.
Definition gmFileIO.h:240
double _searchDomain
The search radius or number of closets points for SPLINE or CLOUD based interpolations.
Definition gmFileIO.h:234
const GmSpatialIndex * _continuumGaussIndex
The spatial index object used for SPLINE or CLOUD based interpolations.
Definition gmFileIO.h:237
QVector< InternalVsData * > _nodeVsData
Stores for each entry in _gaussData the associated node interpolated values.
Definition gmFileIO.h:246
bool _hasContSubset
True if any gaussAc interpolation subset is set to continuum only.
Definition gmFileIO.h:244
bool _alsoSaveAtGauss
When interpolating Gauss to nodes, should we also save the original Gauss data?
Definition gmFileIO.h:228
bool _hasIntSubset
True if any gaussAc interpolation subset is set to interface only.
Definition gmFileIO.h:243
const GmNumSolver * _splineNumSolver
The numeric solver object used for SPLINE based interpolations.
Definition gmFileIO.h:238
const GmSpatialIndex * _interfaceGaussIndex
The spatial index object used for SPLINE or CLOUD based interpolations.
Definition gmFileIO.h:236
int _continuumGroupId
GroupSet of continuum elements.
Definition gmFileIO.h:242
GmInterpolatorAveraging _elemAvgMode
The averaging mode for ELEMENT based interpolations.
Definition gmFileIO.h:231
bool _nodeClosest
The "closest" mode for NODE based interpolations.
Definition gmFileIO.h:232
bool _searchModeRadius
Is the search mode radius (true) or closest (false) for SPLINE or CLOUD based interpolations.
Definition gmFileIO.h:233
double _alpha
Alpha parameter for SPLINE based interpolations.
Definition gmFileIO.h:239
const GmNodeSet * _meshNodeSet
The mesh node set used for interpolation.
Definition gmFileIO.h:247