GemaCoreLib
The GeMA Core library
gmXdmfFileFormat.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_XDMF_FILE_FORMAT_H_
25 #define _GM_XDMF_FILE_FORMAT_H_
26 
27 #include "gmFileFormat.h"
28 
30 #define XDMF_POLYLINE_TYPE 2
31 
33 #define XDMF_POLYLINE_TYPENAME "Polyline"
34 
35 
38 {
39 public:
40 
59  {
60  int _xdmfType;
61  const char* _xdmfName;
63  int _accept;
64 
65  SupportedTypesT() : _xdmfType(-1), _xdmfName(""), _accept(0) {}
66  SupportedTypesT(int type, const char* name, QVector<int> nodes)
67  : _xdmfType(type), _xdmfName(name), _nodeNumbering(nodes), _accept(nodes.contains(-1) ? 2 : 1)
68  {
69  assert(type >= 0);
70  }
71  };
72 
73  // See comments on the base class
74  virtual const char* formatName() const { return "XDMF3"; }
75 
76  // See comments on the base class
77  virtual bool supportsMultipleIterations() const { return true; }
78 
79  // See comments on the base class
80  virtual bool acceptsNodeDimension(int ndim) const { return ndim == 2 || ndim == 3; }
81 
82  // See comments on the base class
83  virtual int acceptsCellType(GmCellType type) const { return supportedTypesList()[type]._accept; }
84 
85  // See comments on the base class
86  virtual const QVector<int>& cellNumbering(GmCellType type) const { return supportedTypesList()[type]._nodeNumbering; }
87 
88  // See comments on the base class
89  virtual int fileCellType(GmCellType type) const { return supportedTypesList()[type]._xdmfType; }
90 
91  // See comments on the base class
92  virtual const char* fileCellTypeName(GmCellType type) const { return supportedTypesList()[type]._xdmfName; }
93 
94  // See comments on the base class
95  virtual bool acceptsDataType(const GmValueInfo* info, int nodeDim, int dimFilter = -1) const
96  {
97  Q_UNUSED(info); Q_UNUSED(nodeDim); Q_UNUSED(dimFilter);
98  return true; // All data types are accepted!
99  }
100 
101  // See comments on the base class
102  virtual bool acceptsMultipleGaussProfiles() const { return true; }
103 
104  // See comments on the base class
105  virtual bool acceptsGaussRuleForElement(GmCellType type, const GmIntegrationRule* ir) const
106  {
107  Q_UNUSED(type); Q_UNUSED(ir);
108  return true; // All rules are accepted since Gauss data is exported as a point cloud in HDF5
109  }
110 
111  // See comments on the base class
112  virtual bool acceptsDiscontinuitySet(GmDiscontinuitySet::DiscontinuityType type) const
113  {
114  return type == GmDiscontinuitySet::GM_DISC_POLYLINE; // Poly lines are the only currently accepted type
115  }
116 
117  // See comments on the base class
118  virtual bool supportsSplitVectors() const { return false; /* Let the file IO module do the work for us. */ }
119 
120  // See comments on the base class
121  virtual bool supportsMeshChanges() const { return true; }
122 
135  {
136  assert(supportedTypesList()[type]._accept == 0); // types should be registered only once
137 
138  if(cellData._nodeNumbering.isEmpty())
139  {
140  GmCellGeometry g(type);
141  for(int i=0, n=g.numNodes(); i<n; i++)
142  cellData._nodeNumbering.append(i);
143  }
144 
145  supportedTypesList()[type] = std::move(cellData);
146  }
147 
148 private:
149 
158  {
159  static SupportedTypesT supportedTypes[GM_NUM_CELL_TYPES];
160  return supportedTypes;
161  }
162 
163 };
164 
165 
166 #endif // _GM_XDMF_FILE_FORMAT_H_
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
virtual bool acceptsMultipleGaussProfiles() const
Does the file supports multiple Gauss points per element type?
Definition: gmXdmfFileFormat.h:102
int _xdmfType
The cell type number for Xdmf, -1 for unsupported types.
Definition: gmXdmfFileFormat.h:60
QVector< int > _nodeNumbering
The cell node numbering. Empty if the type is not supported.
Definition: gmXdmfFileFormat.h:62
NOT a cell type. Stores the number of available types.
Definition: gmCellType.h:77
File format specifications for the Xdmf file format.
Definition: gmXdmfFileFormat.h:37
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: gmXdmfFileFormat.h:86
virtual const char * fileCellTypeName(GmCellType type) const
Returns the cell type name as seen by the exported file format.
Definition: gmXdmfFileFormat.h:92
virtual bool acceptsNodeDimension(int ndim) const
Returns true if this file format accepts meshes with nodes of the given dimension.
Definition: gmXdmfFileFormat.h:80
DiscontinuityType
Discontinuity type (defining how the disc. geometry is defined)
Definition: gmDiscontinuitySet.h:52
static void registerSupportedCellType(GmCellType type, SupportedTypesT &&cellData)
Registers the information needed about each element type to save it on the Xdmf file....
Definition: gmXdmfFileFormat.h:134
A class used to return static metadata information about a cell geometry, along with some methods for...
Definition: gmCellGeometry.h:54
Integration rule base classe.
Definition: gmIntegrationRule.h:88
virtual const char * formatName() const
Returns the file format name.
Definition: gmXdmfFileFormat.h:74
Declaration of the GmFileFormat class (old GmFileDataclass)
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: gmXdmfFileFormat.h:95
virtual bool supportsMultipleIterations() const
Returns true if this file type supports multiple iterations (result sets)
Definition: gmXdmfFileFormat.h:77
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: gmXdmfFileFormat.h:105
The disc. geometry is given by a polyline. Inserted elements are bars.
Definition: gmDiscontinuitySet.h:54
virtual bool supportsMeshChanges() const
Returns true if this writer can cope with mesh changes during the simulation.
Definition: gmXdmfFileFormat.h:121
virtual bool supportsSplitVectors() const
Returns true if this writer prefers to split vector values into scalar values by itself.
Definition: gmXdmfFileFormat.h:118
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: gmXdmfFileFormat.h:89
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition: gmCellType.h:30
virtual int acceptsCellType(GmCellType type) const
Does the file format accepts this cell type? Returns 0 if the cell type is not accepted,...
Definition: gmXdmfFileFormat.h:83
Basic interface for describing high level file format capabilities.
Definition: gmFileFormat.h:34
const char * _xdmfName
The cell type name for Xdmf.
Definition: gmXdmfFileFormat.h:61
Registered information about each element type. Needed to export said type in Xdmf format....
Definition: gmXdmfFileFormat.h:58
static SupportedTypesT * supportedTypesList()
Returns the vector with the definition of the GeMA supported types and their mapping to xdmf types....
Definition: gmXdmfFileFormat.h:157
int _accept
The precomputed result for the acceptsCellType() query: 0 for unsuported, 1 for native supported and ...
Definition: gmXdmfFileFormat.h:63
int numNodes() const
Returns the total number of nodes of this cell type.
Definition: gmCellGeometry.h:92