GemaCoreLib
The GeMA Core library
gmNfFileWriter.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_NF_FILE_WRITER_H_
25 #define _GEMA_NF_FILE_WRITER_H_
26 
27 #include "gmFileWriter.h"
28 #include "gmNfFileFormat.h"
29 #include "gmCell.h"
30 
31 #include <stdio.h>
32 
33 class QTemporaryFile;
34 
37 {
38 public:
39  GmNfFileWriter(const GmLogCategory& logger);
40 
41  virtual ~GmNfFileWriter();
42 
43  virtual bool createFiles(QString fileName, const GmSimulationData* simData, const GmFileFilter* filter,
44  const QVariantMap& options, bool multipleResults, bool gaussValues, bool discValues,
45  GmFileIO::DumpMode dumpMode, QString timeUnit)
46  {
47  Q_UNUSED(fileName); Q_UNUSED(simData); Q_UNUSED(options); Q_UNUSED(filter);
48  Q_UNUSED(multipleResults); Q_UNUSED(gaussValues); Q_UNUSED(discValues);
49  Q_UNUSED(dumpMode); Q_UNUSED(timeUnit);
50  return false;
51  }
52 
53  virtual bool setCurrentTime(int iter, double time)
54  {
55  Q_UNUSED(iter); Q_UNUSED(time); return true;
56  }
57 
58  virtual bool saveGeometry(GmValueAccessor* nodeAc, const double* scaleFactor, const double* offset)
59  {
60  Q_UNUSED(nodeAc); Q_UNUSED(scaleFactor); Q_UNUSED(offset);
61  return false;
62  }
63 
65  const UnitConverter* conv, const double* scaleFactor, const double* offset)
66  {
67  Q_UNUSED(sets); Q_UNUSED(mode); Q_UNUSED(conv); Q_UNUSED(scaleFactor); Q_UNUSED(offset);
68  return false;
69  }
70 
71  virtual bool saveData(const QVector<GmResultNodeDataSrc*>& nodeData,
72  const QVector<GmResultCellDataSrc*>& cellData,
73  const QVector<GmResultGaussDataSrc*>& gaussData,
74  int extraColumns, const QVector<int>& propertySets)
75  {
76  Q_UNUSED(nodeData); Q_UNUSED(cellData); Q_UNUSED(gaussData); Q_UNUSED(extraColumns); Q_UNUSED(propertySets);
77  return false;
78  }
79 
80 #if 1
81  //--------------------------------------------------------------------------------------------------------------------
82  // DEPRECTADE FUNCTIONS - Will be removed when the old nf and medit writers are migrated to the new structure
83  //--------------------------------------------------------------------------------------------------------------------
84  virtual bool createFiles(QString fileName, const GmSimulationData* simData, const GmMesh* mesh,
85  const QVariantMap& options, int numNodeValues, int numElemValues,
86  int intRuleSet, bool multipleResults);
87 
88  virtual bool saveNodeCoordinates(const GmMesh* mesh, GmValueAccessor* nodeAcc, QList<double>& scaleFactor, QList<double>& offset);
89  virtual bool saveCellGeometry(const GmCellMesh* mesh);
90 
91  virtual bool saveNodeData (const GmMesh* mesh, const QList<GmValueAccessor*>& accList, int iter, double currentTime, bool split);
92  virtual bool saveElementData(const GmCellMesh* mesh, const QList<GmCellAccessor*>& elemAccList,
93  const QList<GmGaussAccessor*>& gaussAccList, int iter, double currentTime, bool split);
94  //--------------------------------------------------------------------------------------------------------------------
95  // END DEPRECTADE FUNCTIONS
96  //--------------------------------------------------------------------------------------------------------------------
97 #endif
98 
99  virtual bool closeFiles(bool deleteFiles = false);
100 
101  virtual QString tempFile();
102 
103  virtual void flushFiles();
104 
105  virtual GmFileFormat* fileFormat() { return this; }
106 
107  virtual bool dumpSupport() const;
108  virtual bool addSavedItemsToMap (QVariantMap& map);
109  virtual bool loadSavedItemsFromMap(QVariantMap& map);
110 
111 private:
112  bool copyResultData(FILE* srcFile, FILE* dstFile, qint64 size = 0);
113  void saveResultCaseHeader(int iter, double currentTime);
114  void findMaterialGroup (const GmMesh* mesh, const QVariantMap& options);
115  void saveMaterialGroup (const GmCellMesh* mesh);
116  void saveIntegrationRules(const GmCellMesh* mesh);
117  void saveNodeDataValueType(const GmMesh* mesh, const char* valueTypeStr, int nfValues,
118  const QList<GmValueAccessor*>& valueAccList);
119  void saveElementDataValueType(const GmCellMesh* mesh, const char* valueTypeStr, int nfValues,
120  const QList<GmCellAccessor*>& elemAccList,
121  const QList<GmGaussAccessor*>& gaussAccList);
122 
124  FILE* _nfFile;
125  FILE* _tempFile;
130  int _nresults;
132 
133  QList<QPair<int, int> > _extraNodes; // Set of extra nodes created to transform a INT2DL6 into a QUAD8 and INT3DL12 into a HEX20
134 };
135 
136 #endif
137 
FILE * _nfFile
The neutral file file handle.
Definition: gmNfFileWriter.h:124
Declaration of the GmFileWriter class (old GmFileResultsSerializer)
NOT a cell type. Stores the number of available types.
Definition: gmCellType.h:77
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: gmNfFileWriter.cpp:1123
virtual bool setCurrentTime(int iter, double time)
Sets the current time step, valid for the next calls to saveGeometry() and/or saveData()....
Definition: gmNfFileWriter.h:53
virtual bool saveDiscontinuities(const QVector< GmDiscontinuitySet * > &sets, GmFileIO::DiscontinuityDataMode mode, const UnitConverter *conv, const double *scaleFactor, const double *offset)
Save discontinuity geometry data to the file. THe mode parameter defines which data should be saved....
Definition: gmNfFileWriter.h:64
QString _nfFileName
The neutral file file name.
Definition: gmNfFileWriter.h:123
void saveResultCaseHeader(int iter, double currentTime)
Saves the result case header taking into account the possibility of multiple result cases and that th...
Definition: gmNfFileWriter.cpp:802
virtual bool closeFiles(bool deleteFiles=false)
Closes the set of files opened by a call to createFiles(). Will be called automatically by the destru...
Definition: gmNfFileWriter.cpp:737
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
virtual bool addSavedItemsToMap(QVariantMap &map)
This function should add to map any internal serializer state that must be saved on a dump operation,...
Definition: gmNfFileWriter.cpp:1105
virtual ~GmNfFileWriter()
Destructor.
Definition: gmNfFileWriter.cpp:57
QTemporaryFile * _tempFileObj
The Qt object used to safelly create the temp object in a "sane" place.
Definition: gmNfFileWriter.h:126
virtual void flushFiles()
Flush opened files.
Definition: gmNfFileWriter.cpp:787
A file serializer for saving data in the "Neutral File" file format.
Definition: gmNfFileWriter.h:36
virtual QString tempFile()
Returns, if any, the name of the temp file used for the operation started with createFiles()
Definition: gmNfFileWriter.cpp:778
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
int _elementRule[GM_NUM_CELL_TYPES]
The integration rule bound to each element type.
Definition: gmNfFileWriter.h:129
bool copyResultData(FILE *srcFile, FILE *dstFile, qint64 size=0)
Appends size bytes from srcFile to dstFile.
Definition: gmNfFileWriter.cpp:853
void saveMaterialGroup(const GmCellMesh *mesh)
Save material information.
Definition: gmNfFileWriter.cpp:888
GmNfFileWriter(const GmLogCategory &logger)
Default constructor.
Definition: gmNfFileWriter.cpp:42
int _nresults
The number of added result cases.
Definition: gmNfFileWriter.h:130
virtual bool saveCellGeometry(const GmCellMesh *mesh)
Saves cell geometry to the file. Returns false on errors.
Definition: gmNfFileWriter.cpp:217
FILE * _tempFile
The temporary file file handler (used for multiple result sets)
Definition: gmNfFileWriter.h:125
int _materialGroup
The material group used to identify cell materials.
Definition: gmNfFileWriter.h:127
Declaration of the GmNfFileFormat class (old GmNeutralFileData class)
Basic interface for file serializers.
Definition: gmFileWriter.h:36
virtual bool saveData(const QVector< GmResultNodeDataSrc * > &nodeData, const QVector< GmResultCellDataSrc * > &cellData, const QVector< GmResultGaussDataSrc * > &gaussData, int extraColumns, const QVector< int > &propertySets)
Saves the current result set to the file for the node, cells and Gauss points as defined by the filte...
Definition: gmNfFileWriter.h:71
virtual GmFileFormat * fileFormat()
Returns the file format of the serializer.
Definition: gmNfFileWriter.h:105
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: gmNfFileWriter.cpp:140
bool _saveDisplacements
Save displacement data?
Definition: gmNfFileWriter.h:131
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
virtual bool dumpSupport() const
This function should return true if this serializer supports saving dump files.
Definition: gmNfFileWriter.cpp:1091
DiscontinuityDataMode
The selected mode when saving discontinuity data.
Definition: gmFileIO.h:76
File format specifications for the "Neutral File" file format.
Definition: gmNfFileFormat.h:33
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: gmNfFileWriter.cpp:495
DumpMode
The dump mode when creating the file.
Definition: gmFileIO.h:68
virtual bool saveGeometry(GmValueAccessor *nodeAc, const double *scaleFactor, const double *offset)
Save mesh node coordinates, cell geometry and gauss rule set coordinates (if needed) to the file,...
Definition: gmNfFileWriter.h:58
Declaration of the GmCell class.
Basic interface for describing high level file format capabilities.
Definition: gmFileFormat.h:34
int _intRuleSet
The mesh integration rule set that will be used to export values.
Definition: gmNfFileWriter.h:128
void findMaterialGroup(const GmMesh *mesh, const QVariantMap &options)
Set _materialGroup with the property set index that will be used to exposrt material inidces.
Definition: gmNfFileWriter.cpp:865
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
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: gmNfFileWriter.cpp:309
void saveIntegrationRules(const GmCellMesh *mesh)
Save integration rule information and fills _elementRule with the mapping between types and integrati...
Definition: gmNfFileWriter.cpp:909
A generic auxilliary class for managing the various options that can be used to define the set of nod...
Definition: gmFileFilter.h:45