GemaCoreLib
The GeMA Core library
gmFileWriter.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_WRITER_H_
25 #define _GEMA_FILE_WRITER_H_
26 
27 #include "gmFileIO.h"
28 
29 #include <QList>
30 #include <QVariantMap>
31 
32 class GmCellAccessor;
33 class GmGaussAccessor;
34 
37 {
38 public:
39 
41  GmFileWriter(const GmLogCategory& logger) : _logger(logger) {}
42 
44  virtual ~GmFileWriter() { }
45 
46  /* \brief Creates files and initializes them in preperation for later calls to saveXxxx() functions.
47  After those calls, the opened state will be closed by a call to closeFiles().
48  On errors this function should delete any files that where eventually created and
49  return false.
50 
51  \param fileName The base name of the file that will be created
52  \param simData The simulation data object
53  \param filter The filter object specifying the mesh, the set of nodes, cells and Gauss
54  rules that should be saved.
55  \param options A set of options specific to the file type
56  \param multipleResults Set to true if multiple result sets will be saved to the file
57  \param gaussValues Set to true if Gauss values will be saved to the file at Gauss points.
58  Keep in mind that the filter may store Gauss rules, but if interpolation is
59  in place, that data is saved as node data, unless the user asked to save
60  both (node and Gauss values).
61  \param discValues Set to true if Discontinuity set information will be saved.
62  \param timeUnit The unit in which time step information is saved to the file
63  \returns Returns true on success, false on errors
64  */
65  virtual bool createFiles(QString fileName, const GmSimulationData* simData, const GmFileFilter* filter,
66  const QVariantMap& options, bool multipleResults, bool gaussValues, bool discValues,
67  GmFileIO::DumpMode dumpMode, QString timeUnit) = 0;
68 
74  virtual bool setCurrentTime(int iter, double time) = 0;
75 
83  virtual bool saveGeometry(GmValueAccessor* nodeAc, const double* scaleFactor, const double* offset) = 0;
84 
94  const UnitConverter* conv, const double* scaleFactor, const double* offset) = 0;
95 
104  virtual bool saveData(const QVector<GmResultNodeDataSrc*>& nodeData,
105  const QVector<GmResultCellDataSrc*>& cellData,
106  const QVector<GmResultGaussDataSrc*>& gaussData,
107  int extraColumns, const QVector<int>& propertySets) = 0;
108 
109 
110 #if 1
111 //--------------------------------------------------------------------------------------------------------------------
112 // DEPRECATED FUNCTIONS - Will be removed when the old nf and medit writers are migrated to the new structure
113 //--------------------------------------------------------------------------------------------------------------------
114 
115  /* \brief Creates files and initializes them in preperation for later calls to saveXxxx() functions.
116  After those calls, the opened state will be closed by a call to closeFiles().
117  On errors this function should delete any files that where eventually created and
118  return false.
119 
120  \param fileName The name of the file that will be created
121  \param simData The simulation data object
122  \param mesh The mesh that will be saved.
123  \param options A set of options specific to the file type
124  \param numNodeValues The number of node variables (state vars/attributes) that will be saved
125  \param numElemValues The number of element variables (attributes/properties) that will be saved
126  \param intRuleSet The integration rule set that should be used to determine Gauss points
127  when saving element data in Gauss points or -1 if no Gauss attributes
128  are present.
129  \param multipleResults Set to true if multiple result sets will be saved to the file
130  \returns Returns true on success, false on errors
131  */
132  virtual bool createFiles(QString fileName, const GmSimulationData* simData, const GmMesh* mesh,
133  const QVariantMap& options, int numNodeValues, int numElemValues,
134  int intRuleSet, bool multipleResults)
135  {
136  Q_UNUSED(fileName); Q_UNUSED(simData); Q_UNUSED(mesh); Q_UNUSED(options); Q_UNUSED(numNodeValues);
137  Q_UNUSED(numElemValues); Q_UNUSED(intRuleSet); Q_UNUSED(multipleResults);
138  return false;
139  }
140 
144  virtual bool saveNodeCoordinates(const GmMesh* mesh, GmValueAccessor* nodeAcc, QList<double>& scaleFactor, QList<double>& offset)
145  {
146  Q_UNUSED(mesh); Q_UNUSED(nodeAcc); Q_UNUSED(scaleFactor); Q_UNUSED(offset);
147  return false;
148  }
149 
151  virtual bool saveCellGeometry(const GmCellMesh* mesh) { Q_UNUSED(mesh); return false; }
152 
157  virtual bool saveNodeData(const GmMesh* mesh, const QList<GmValueAccessor*>& accList, int iter, double currentTime, bool split)
158  {
159  Q_UNUSED(mesh); Q_UNUSED(accList); Q_UNUSED(iter); Q_UNUSED(currentTime); Q_UNUSED(split);
160  return false;
161  }
162 
167  virtual bool saveElementData(const GmCellMesh* mesh, const QList<GmCellAccessor*>& elemAccList,
168  const QList<GmGaussAccessor*>& gaussAccList, int iter, double currentTime, bool split)
169  {
170  Q_UNUSED(mesh); Q_UNUSED(elemAccList); Q_UNUSED(gaussAccList); Q_UNUSED(iter); Q_UNUSED(currentTime); Q_UNUSED(split);
171  return false;
172  }
173 
174  //--------------------------------------------------------------------------------------------------------------------
175  // END DEPRECATED FUNCTIONS
176  //--------------------------------------------------------------------------------------------------------------------
177 #endif
178 
179 
185  virtual bool closeFiles(bool deleteFiles = false) = 0;
186 
188  virtual QString tempFile() { return QString(); }
189 
191  virtual void flushFiles() = 0;
192 
194  virtual GmFileFormat* fileFormat() = 0;
195 
197  virtual bool dumpSupport() const { return false; }
198 
205  virtual bool addSavedItemsToMap(QVariantMap& map) { Q_UNUSED(map); return true; }
206 
212  virtual bool loadSavedItemsFromMap(QVariantMap& map) { Q_UNUSED(map); return true; }
213 
214 protected:
216 };
217 
218 #endif
219 
virtual bool saveGeometry(GmValueAccessor *nodeAc, const double *scaleFactor, const double *offset)=0
Save mesh node coordinates, cell geometry and gauss rule set coordinates (if needed) to the file,...
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 multiplie...
Definition: gmFileWriter.h:144
virtual ~GmFileWriter()
Destructor. Should call closeFiles() on derived classes.
Definition: gmFileWriter.h:44
The GmGaussAccessor class is a proxy object to a value accesor implementing a more convenient interfa...
Definition: gmGaussAccessor.h:38
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...
Definition: gmFileWriter.h:167
virtual bool loadSavedItemsFromMap(QVariantMap &map)
This function should retrieve from the given map any internal writer state that was saved on a dump o...
Definition: gmFileWriter.h:212
Declaration of the GmFileIO class.
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
const GmLogCategory & _logger
The logger used to report errors.
Definition: gmFileWriter.h:215
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
virtual GmFileFormat * fileFormat()=0
Returns the file format of the serializer.
virtual bool saveCellGeometry(const GmCellMesh *mesh)
Saves cell geometry to the file. Returns false on errors.
Definition: gmFileWriter.h:151
GmFileWriter(const GmLogCategory &logger)
Constructor. Receives as parameter the logger used to report errors.
Definition: gmFileWriter.h:41
The GmCellAccessor class is a proxy object to a value accesor implementing a more convenient interfac...
Definition: gmCellAccessor.h:66
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
virtual bool saveData(const QVector< GmResultNodeDataSrc * > &nodeData, const QVector< GmResultCellDataSrc * > &cellData, const QVector< GmResultGaussDataSrc * > &gaussData, int extraColumns, const QVector< int > &propertySets)=0
Saves the current result set to the file for the node, cells and Gauss points as defined by the filte...
Basic interface for file serializers.
Definition: gmFileWriter.h:36
virtual QString tempFile()
Returns, if any, the name of the temp file used for the operation started with createFiles()
Definition: gmFileWriter.h:188
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
DiscontinuityDataMode
The selected mode when saving discontinuity data.
Definition: gmFileIO.h:76
virtual void flushFiles()=0
Flush opened files.
DumpMode
The dump mode when creating the file.
Definition: gmFileIO.h:68
virtual bool addSavedItemsToMap(QVariantMap &map)
This function should add to map any internal serializer state that must be saved on a dump operation,...
Definition: gmFileWriter.h:205
virtual bool saveDiscontinuities(const QVector< GmDiscontinuitySet * > &sets, GmFileIO::DiscontinuityDataMode mode, const UnitConverter *conv, const double *scaleFactor, const double *offset)=0
Save discontinuity geometry data to the file. THe mode parameter defines which data should be saved....
Basic interface for describing high level file format capabilities.
Definition: gmFileFormat.h:34
virtual bool closeFiles(bool deleteFiles=false)=0
Closes the set of files opened by a call to createFiles(). Will be called automatically by the destru...
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
virtual bool setCurrentTime(int iter, double time)=0
Sets the current time step, valid for the next calls to saveGeometry() and/or saveData()....
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....
Definition: gmFileWriter.h:157
virtual bool dumpSupport() const
This function should return true if this serializer supports saving dump files.
Definition: gmFileWriter.h:197
A generic auxilliary class for managing the various options that can be used to define the set of nod...
Definition: gmFileFilter.h:45