GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmNfFileFormat.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 _GM_NF_FILE_FORMAT_H_
25#define _GM_NF_FILE_FORMAT_H_
26
27#include "gmFileFormat.h"
28
29#include "gmValueInfo.h"
30#include <nfr.h>
31
34{
35public:
36 // Supported element types and file section names
38 {
40 const char* _rst;
41 QVector<int> _numbering;
42 };
43 const char* _nfSecName;
44 const char* _ruleName;
45 const char* _afterMaterial;
46 const char* _afterNode;
47 int _accept;
51
53
54 SupportedTypesT(const char* nfSecName, const char* ruleName, const char* afterMaterial, const char* afterNode,
55 bool needsIntId, const QVector<int>& nodeNumbering, const QHash<int, GaussNumbering>& gaussNodeNumbering)
56 : _nfSecName(nfSecName), _ruleName(ruleName), _afterMaterial(afterMaterial), _afterNode(afterNode), _accept(1),
57 _nodeNumbering(nodeNumbering), _gaussData(gaussNodeNumbering), _needsIntId(needsIntId) {
58 }
59 };
60
61 // See comments on the base class
62 virtual const char* formatName() const { return "Neutral file"; }
63
64 // See comments on the base class
65 virtual bool supportsMultipleIterations() const { return true; }
66
67 // See comments on the base class
68 virtual bool supportsSplitVectors() const { return true; }
69
70 // See comments on the base class
71 virtual bool acceptsNodeDimension(int ndim) const { return ndim == 2 || ndim == 3; }
72
73 // See comments on the base class
74 virtual bool acceptsDataType(const GmValueInfo* info, int nodeDim, int dimFilter = -1) const
75 {
76 // The neutral file format accepts scalar, vector and tensor values
77 Q_UNUSED(info); Q_UNUSED(nodeDim); Q_UNUSED(dimFilter);
78 return true;
79 }
80
81 // See comments on the base class
82 virtual bool acceptsMultipleGaussProfiles() const { return false; }
83
84 virtual bool acceptsGaussRuleForElement(GmCellType type, const GmIntegrationRule* ir) const;
85
86 // See comments on the base class
87 virtual bool acceptsDiscontinuitySet(GmDiscontinuitySet::DiscontinuityType type) const { Q_UNUSED(type); return false; }
88
89 virtual int acceptsCellType(GmCellType type) const { return supportedTypesList()[type]._accept; }
90
91 virtual const QVector<int>& cellNumbering(GmCellType type) const { return supportedTypesList()[type]._nodeNumbering; }
92
93 virtual const QVector<int>& gaussNumbering(GmCellType type, int numIp) const {
94 static QVector<int> empty;
95
96 const auto& it = supportedTypesList()[type]._gaussData.find(numIp);
97 if (it != supportedTypesList()[type]._gaussData.end())
98 return it.value()._numbering;
99 else
100 return empty;
101 }
102 //NF does not index cell types with integers
103 virtual int fileCellType(GmCellType type) const { Q_UNUSED(type); return -1; }
104
105 virtual const char* fileCellTypeName(GmCellType type) const {return supportedTypesList()[type]._nfSecName; }
106
107 // See comments on the base class
108 virtual bool supportsMeshChanges() const { return false; }
109
110
121 {
122 assert(supportedTypesList()[type]._accept == 0); // types should be registered only once
123
124 if (cellData._accept) {
125 //Build node numbering (gema order) if not provided
126 if(cellData._nodeNumbering.isEmpty()) {
127 GmCellGeometry g(type);
128 for (int i = 0, n = g.numNodes(); i < n; i++)
129 cellData._nodeNumbering.append(i);
130 }
131
132 auto endIt = cellData._gaussData.end();
133 for(auto it = cellData._gaussData.begin(); it != endIt; ++it) {
134 //Entry exists, but numbering is empty -> build gema order
135 int nip = it.key();
136 auto& vec = it.value()._numbering;
137 if(vec.isEmpty()) {
138 for (int i = 0; i < nip; i++)
139 vec.append(i);
140 }
141 }
142 }
143
144 supportedTypesList()[type] = cellData;
145 }
146protected:
147
156 {
157 static SupportedTypesT supportedTypes[GM_NUM_CELL_TYPES];
158 return supportedTypes;
159 }
160
162 // Old code, needed by file reader //
164
165 //static const SupportedTypesT supportedTypes[];
166 //static const int supportedTypesSize;
167
168 struct nfrType {
169 NfrResultType nfType;
170 GmValueSetKind gmKind;
171 GmDimType gmType;
172 int nfSize;
173 };
174
175 struct nfrElement {
176 NfrElementType nfEleType;
177 NfrQuadratureType nfQuadType;
178 double nfQuadNatCrd[200];
179 };
180
181 static const nfrType nfrTypeTable[];
182 static const nfrElement nfrElementTable[];
183
184 //int nf2gmCellNodeIndex(GmCellType type, int nfId);
185 //int nf2gmCellGaussIndex(GmCellType type, int ngp, int nfId);
186
187 unsigned int offset(unsigned int n) { return n == 1 ? 0 : n-1 + offset(n-1); }
188};
189
190
191#endif // _GM_NF_FILE_FORMAT_H_
A class used to return static metadata information about a cell geometry, along with some methods for...
Definition gmCellGeometry.h:55
int numNodes() const
Returns the total number of nodes of this cell type.
Definition gmCellGeometry.h:92
DiscontinuityType
Discontinuity type (defining how the disc. geometry is defined)
Definition gmDiscontinuitySet.h:63
Basic interface for describing high level file format capabilities.
Definition gmFileFormat.h:35
Integration rule base classe.
Definition gmIntegrationRule.h:89
File format specifications for the "Neutral File" file format.
Definition gmNfFileFormat.h:34
virtual bool acceptsMultipleGaussProfiles() const
Does the file supports multiple Gauss points per element type?
Definition gmNfFileFormat.h:82
static void registerSupportedCellType(GmCellType type, SupportedTypesT &cellData)
Registers the information needed about each element type to save it on the NF file....
Definition gmNfFileFormat.h:120
static SupportedTypesT * supportedTypesList()
Returns the vector with the definition of the GeMA supported types and their mapping to xdmf types....
Definition gmNfFileFormat.h:155
virtual const char * fileCellTypeName(GmCellType type) const
Returns the cell type name as seen by the exported file format.
Definition gmNfFileFormat.h:105
virtual const char * formatName() const
Returns the file format name.
Definition gmNfFileFormat.h:62
virtual bool supportsMultipleIterations() const
Returns true if this file type supports multiple iterations (result sets)
Definition gmNfFileFormat.h:65
virtual bool acceptsGaussRuleForElement(GmCellType type, const GmIntegrationRule *ir) const
Does the file support exporting data at Gauss points for an element of type type with the supplied in...
Definition gmNfFileFormat.cpp:309
virtual int acceptsCellType(GmCellType type) const
Does the file format accepts this cell type? Returns 0 if the cell type is not accepted,...
Definition gmNfFileFormat.h:89
virtual const QVector< int > & cellNumbering(GmCellType type) const
Returns the node cell type numbering order in the file format view or an empty vector for unsupported...
Definition gmNfFileFormat.h:91
virtual bool supportsSplitVectors() const
Returns true if this writer prefers to split vector values into scalar values by itself.
Definition gmNfFileFormat.h:68
virtual bool acceptsDataType(const GmValueInfo *info, int nodeDim, int dimFilter=-1) const
Returns true if this file format can save node/element data with the specified type (especially its d...
Definition gmNfFileFormat.h:74
virtual bool acceptsNodeDimension(int ndim) const
Returns true if this file format accepts meshes with nodes of the given dimension.
Definition gmNfFileFormat.h:71
virtual int fileCellType(GmCellType type) const
Returns the cell type code as seen by the file format. Currently used only by HDF5 based formats.
Definition gmNfFileFormat.h:103
virtual const QVector< int > & gaussNumbering(GmCellType type, int numIp) const
Returns the Gauss point numbering order for a given cell type and number of integration points....
Definition gmNfFileFormat.h:93
virtual bool supportsMeshChanges() const
Returns true if this writer can cope with mesh changes during the simulation.
Definition gmNfFileFormat.h:108
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition gmCellType.h:31
@ GM_NUM_CELL_TYPES
NOT a cell type. Stores the number of available types.
Definition gmCellType.h:77
Declaration of the GmFileFormat class (old GmFileDataclass)
Declaration of the GmValueInfo class.
GmDimType
Value dimension type.
Definition gmValueInfo.h:72
GmValueSetKind
Type describing what kind of information is stored by a values set.
Definition gmValueInfo.h:37
void append(const T &value)
bool isEmpty() const const
Definition gmNfFileFormat.h:38
const char * _afterNode
Anything we should write after cell node indexes (topology)
Definition gmNfFileFormat.h:46
bool _needsIntId
Should we add an integration aid after the dummy values?
Definition gmNfFileFormat.h:50
QHash< int, GaussNumbering > _gaussData
Map from number of gauss points to the gauss points ordering for this cell type.
Definition gmNfFileFormat.h:49
const char * _nfSecName
Section name for this element type in the NF file.
Definition gmNfFileFormat.h:43
const char * _ruleName
Integration rule name for this element type.
Definition gmNfFileFormat.h:44
QVector< int > _nodeNumbering
The cell node numbering. Empty if the type is not supported.
Definition gmNfFileFormat.h:48
const char * _afterMaterial
Anything we should write after the material section for this element.
Definition gmNfFileFormat.h:45
int _accept
The precomputed result for the acceptsCellType() query: 0 for unsupported, 1 for native supported and...
Definition gmNfFileFormat.h:47
Definition gmNfFileFormat.h:175
Definition gmNfFileFormat.h:168