GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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
32class GmCellAccessor;
33class GmGaussAccessor;
34
37{
38public:
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<GmNodeAcResultsDataSrc*>& nodeData,
105 const QVector<GmCellAcResultsDataSrc*>& cellData,
106 const QVector<GmGaussAcResultsDataSrc*>& gaussData,
107 int extraColumns, const QVector<int>& propertySets) = 0;
108
109 /*
110 *! \brief If there is anything to be done after ending the write phase
111 * it should be done here
112 */
113 virtual bool endWrite() = 0;
114
120 virtual bool closeFiles(bool deleteFiles = false) = 0;
121
123 virtual QString tempFile() { return QString(); }
124
126 virtual void flushFiles() = 0;
127
129 virtual GmFileFormat* fileFormat() = 0;
130
132 virtual bool dumpSupport() const { return false; }
133
140 virtual bool addSavedItemsToMap(QVariantMap& map) { Q_UNUSED(map); return true; }
141
147 virtual bool loadSavedItemsFromMap(QVariantMap& map) { Q_UNUSED(map); return true; }
148
149protected:
151};
152
153#endif
154
The GmCellAccessor class is a proxy object to a value accesor implementing a more convenient interfac...
Definition gmCellAccessor.h:67
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
DumpMode
The dump mode when creating the file.
Definition gmFileIO.h:72
DiscontinuityDataMode
The selected mode when saving discontinuity data.
Definition gmFileIO.h:80
Basic interface for file serializers.
Definition gmFileWriter.h:37
virtual GmFileFormat * fileFormat()=0
Returns the file format of the serializer.
virtual bool saveData(const QVector< GmNodeAcResultsDataSrc * > &nodeData, const QVector< GmCellAcResultsDataSrc * > &cellData, const QVector< GmGaussAcResultsDataSrc * > &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...
const GmLogCategory & _logger
The logger used to report errors.
Definition gmFileWriter.h:150
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 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:147
GmFileWriter(const GmLogCategory &logger)
Constructor. Receives as parameter the logger used to report errors.
Definition gmFileWriter.h:41
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....
virtual ~GmFileWriter()
Destructor. Should call closeFiles() on derived classes.
Definition gmFileWriter.h:44
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 dumpSupport() const
This function should return true if this serializer supports saving dump files.
Definition gmFileWriter.h:132
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...
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:140
virtual QString tempFile()
Returns, if any, the name of the temp file used for the operation started with createFiles()
Definition gmFileWriter.h:123
virtual void flushFiles()=0
Flush opened files.
The GmGaussAccessor class is a proxy object to a value accessor implementing a more convenient interf...
Definition gmGaussAccessor.h:39
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Declaration of the GmFileIO class.