GemaCoreLib
The GeMA Core library
gmResultsSerializer.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_RESULTS_SERIALIZER_H_
25 #define _GEMA_RESULTS_SERIALIZER_H_
26 
27 #include "gmCoreConfig.h"
28 
29 #include <gmStateDumpItem.h>
30 
31 #include <QStringList>
32 #include <QVariantMap>
33 
34 class GmFileWriter;
35 
36 class GmLogCategory;
37 class GmSimulationData;
38 class GmMesh;
39 class GmCellMesh;
40 class GmValueAccessor;
41 class GmCellAccessor;
42 class GmGaussAccessor;
43 class Unit;
44 
45 
49 {
50 public:
52 
53  static GmResultsSerializer* createInstance(QString fileType, const GmLogCategory& logger);
54 
55  bool saveMeshDataToFile(const GmSimulationData* simData, GmMesh* mesh,
56  const QStringList& nodeValues, const QList<Unit>& nodeUnits,
57  Unit coordUnit, const QStringList& elementValues,
58  const QList<Unit>& elementUnits, QString fileName,
59  const QVariantMap& options);
60 
61  bool prepareFile(const GmSimulationData* simData, GmMesh* mesh,
62  const QStringList& nodeValues, const QList<Unit>& nodeUnits,
63  Unit coordUnit, const QStringList& elementValues,
64  const QList<Unit>& elementUnits, QString fileName,
65  const QVariantMap& options);
66 
67  bool addCurrentResult(double currentTime);
68  bool closeFile();
69  QString tempFile();
70 
71  virtual bool addStateItemsToGroup(GmStateDump* state, int groupId);
72  virtual bool stateAboutToBeSaved (GmStateDump* state);
73  virtual bool stateLoaded (GmStateDump* state);
74 
75 private:
76  GmResultsSerializer(QString fileType, GmFileWriter* ser, const GmLogCategory& logger);
77 
78  bool supportsMultipleIterations();
79  bool supportsSplitVectors();
80 
81  bool doPrepareFile(const GmSimulationData* simData, GmMesh* mesh,
82  const QStringList& nodeValues, const QList<Unit>& nodeUnits,
83  Unit coordUnit, const QStringList& elementValues,
84  const QList<Unit>& elementUnits, QString fileName,
85  const QVariantMap& options, bool forMultipleIterations);
86 
87  void fillNodeAccessorList(GmMesh* mesh, const QStringList& nodeValues, const QList<Unit>& nodeUnits,
88  QList<GmValueAccessor*>& accList, int state);
89 
90  void fillElementAccessorList(GmCellMesh* mesh, const QStringList& elementValues, const QList<Unit>& elementUnits,
91  QList<GmCellAccessor*>& elemAccList, QList<GmGaussAccessor*>& gaussAccList,
92  int* intRuleSet, int state, bool activeOnly);
93 
94  void updateNodeAccessorList (GmMesh* mesh, QList<GmValueAccessor*>& accList, int state);
95  void updateElementAccessorList(GmCellMesh* mesh, QList<GmCellAccessor*>& elemAccList, QList<GmGaussAccessor*>& gaussAccList, int state);
96 
97  bool cleanup(bool deleteFiles = false);
98 
102 
107  bool _openFiles;
108  int _iter;
109  bool _split;
110 
111  QVariantMap _stateMap;
112 };
113 
114 #endif
115 
bool _split
States if we split vector values into scalar values or not.
Definition: gmResultsSerializer.h:109
QList< GmValueAccessor * > _nodeAccList
Accessors for node results that will be saved in a statefull operation.
Definition: gmResultsSerializer.h:104
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition: gmStateDump.h:52
The GmGaussAccessor class is a proxy object to a value accesor implementing a more convenient interfa...
Definition: gmGaussAccessor.h:38
Declaration of usefull configuration definitions for the Core library.
Declaration of the GmStateDumpBaseDataItem and basic derived classes.
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 ...
QVariantMap _stateMap
Variant map used for state dumping.
Definition: gmResultsSerializer.h:111
A serializer object used to save mesh data to several file formats.
Definition: gmResultsSerializer.h:48
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
virtual bool stateLoaded(GmStateDump *state)
Virtual method called just after succesfully completing a load operation on the given state....
Definition: gmStateDumpItem.h:85
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
const GmLogCategory & _logger
The logger object used to report errors.
Definition: gmResultsSerializer.h:99
QList< GmCellAccessor * > _elemAccList
Accessors for element results that will be saved in a statefull operation.
Definition: gmResultsSerializer.h:105
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
GmFileWriter * _serializer
The file serializer used to save data.
Definition: gmResultsSerializer.h:100
bool _openFiles
States if we have an open file or not.
Definition: gmResultsSerializer.h:107
QString _fileType
Serializer file type for use in error messages.
Definition: gmResultsSerializer.h:101
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
Basic interface for file serializers.
Definition: gmFileWriter.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
int _iter
Keeps track of the number of time that addCurrentResult was called.
Definition: gmResultsSerializer.h:108
QList< GmGaussAccessor * > _gaussAccList
Accessors for element results in Gauss points that will be saved in a statefull operation.
Definition: gmResultsSerializer.h:106
GmMesh * _mesh
The mesh whose state will be saved for a statefull operation begun with prepareFile(),...
Definition: gmResultsSerializer.h:103
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition: gmStateDumpItem.h:52
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
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