GemaMesh
The GeMA Mesh Plugin
gmpCellMeshData.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_PLUGIN_CELL_MESH_DATA_H_
25 #define _GEMA_PLUGIN_CELL_MESH_DATA_H_
26 
27 #include "gmpGemaMeshConfig.h"
28 #include "gmpMeshLoaderAllocator.h"
29 
30 class GmPropertySet;
31 class GmCellBoundary;
32 class GmMesh;
33 class GmCellMesh;
34 class GmElementMesh;
35 class GmCell;
36 class GmValueInfo;
37 class GmValueSet;
38 class GmSimulationData;
39 class GmStateDump;
40 class GmLogCategory;
41 
42 class UibhmTopologyBase;
43 class GmCellMeshTopology;
44 
45 #include <gmSingleVector.h>
46 #include <gmDualVector.h>
47 
48 #include <QScopedPointer>
49 #include <QVariantMap>
50 
57 #define GmpCellMeshDataMaxHTypes 3
58 
59 
63 struct GMP_GEMAMESH_API_EXPORT GmpCellMeshDataBase
64 {
67  {
68  _meshId = newMeshId(mesh, this);
69  _hierarchicalIndex = -1;
70  }
71 
73  virtual ~GmpCellMeshDataBase() { _meshTable[_meshId] = NULL; }
74 
76  bool hierarchicalElements() const { return _hierarchicalIndex >= 0; }
77 
78  static const int maxHTypes = GmpCellMeshDataMaxHTypes;
79 
80  static int hierarchicalOrderIndex(int P, int Q);
81 
85  static inline int hierarchicalPOrder(int index) { assert(index >= -1 && index < _hTableNumUsedSlots); return index == -1 ? 0 : _hTable[index].first; }
86 
90  static inline int hierarchicalQOrder(int index) { assert(index >= -1 && index < _hTableNumUsedSlots); return index == -1 ? 0 : _hTable[index].second; }
91 
92  static int newMeshId(GmCellMesh* mesh, GmpCellMeshDataBase* data);
93 
95  static inline GmCellMesh* mesh(int meshId) { assert(meshId >= 0 && meshId < GMP_GEMAMESH_MAX_NUM_MESHES); return _meshTable[meshId]; }
96 
98  static inline GmpCellMeshDataBase* meshData(int meshId) { assert(meshId >= 0 && meshId < GMP_GEMAMESH_MAX_NUM_MESHES); return _meshDataTable[meshId]; }
99 
100 
101  int _meshId;
102 
107 
108 protected:
110  static int _hTableNumUsedSlots;
113 };
114 
115 
116 
122 template <template <class> class Vector>
123 struct GMP_GEMAMESH_API_EXPORT GmpCellMeshData : public GmpCellMeshDataBase
124 {
126 
128  virtual ~GmpCellMeshData() { releaseMemory(); } // Destructor: will always call our own version of releaseMemory even though virtual ...
129 
130 
134  int* cellPropertiesPtr(int cellId) { assert(_propertySets.size() > 0); return _cellPropertyIndices.iptr(cellId * _propertySets.size()); }
135 
136 
137  virtual int addCells(GmCellMesh* mesh, int* addedCellsByType, GmpMeshLoaderCellAllocator alloc,
139 
140  virtual int addCellGroup(QString groupName);
141  virtual bool addCellsToGroup(int groupId, const QVector<int>& cellIds);
142  virtual bool addCellsToGroup(int groupId, const QVector<QPair<int, int>>& cellIds);
143 
144  virtual Vector<int>* cellNodesVector() { return NULL; }
145  virtual void updateCellNodeOffset(GmCell* c, int offset) = 0;
146 
147  virtual void clear(GmCellMesh* mesh);
148 
149  virtual void releaseMemory(bool clearBoundaryData = true);
150 
151  void increaseNumCells(int nCells) { _numCells += nCells; _numActiveCells += nCells; }
152 
153  size_t cellGroupsMemory() const;
154  size_t cellBoundariesMemory() const;
155 
156  void setGhostEnabled(bool state) { _ghostEnabled = state; }
157 
158  bool resizeValueSets (const QList<GmValueSet*>& valueSets, int numAddedCells);
159  bool resizeGaussValueSets(GmElementMesh* emesh, int* addedCellsByType);
160 
161  bool buildTopologyStructure(GmCellMesh* mesh);
162 
163  //---------------------------------------
164  // State dump control functions
165  //---------------------------------------
166 
167  virtual bool addStateGeometryData(GmSimulationData* simData, GmMesh* mesh, GmpMeshLoaderCellAllocator alloc,
168  GmStateDump* state, int groupId);
169 
170  virtual bool fillDumpControlMapData (GmMesh* mesh, QVariantMap* map, const GmLogCategory& logger);
171  virtual bool dumpControlMapDataLoaded(GmMesh* mesh, QVariantMap* map, const GmLogCategory& logger);
172 
173  bool fillAuxCellBuffers(int* cellSavedData, int* baseCellType, GmMesh* mesh, const GmLogCategory& logger);
174  bool auxCellBuffersLoaded(GmSimulationData* simData, GmMesh* mesh, GmpMeshLoaderCellAllocator alloc, const GmLogCategory& logger);
175 
176  virtual void releaseDumpMemory();
177 
178  int _numCells;
180  Vector<GmCell*> _cells;
181 
183  int _cellsByType[GM_NUM_CELL_TYPES];
184 
186  int _activeCellsByType[GM_NUM_CELL_TYPES];
187 
190 
193 
196 
199 
202 
205 
210 
215 
220 
225 
226 
228  Vector<int> _cellPropertyIndices;
229 
232  UibhmTopologyBase* _topology;
233  GmCellMeshTopology* _topoQuery;
234 
235  //---------------------------------------------------------------------
236  // Attributes used during mesh dumping
237  //---------------------------------------------------------------------
238 
244  static_assert(GM_NUM_CELL_TYPES <= 127, "Number of cell types exceeds 7 bits");
245  unsigned char* _cellDumpTypeActiveData;
246 
249 
256 
259 
261  QVariantMap* _cellDumpLoadedMap;
262 
269 
270  //---------------------------------------------------------------------
271 };
272 
273 #endif
bool _buildEdgeMap
The topology structure, if already built.
Definition: gmpCellMeshData.h:231
int _numActiveCells
The total number of active cells in the mesh.
Definition: gmpCellMeshData.h:179
GmStateDump * _state
Definition: gmpCellMeshData.h:268
int _meshId
Stores the mesh index in _meshTable for the current mesh.
Definition: gmpCellMeshData.h:101
int _maxNumGhostNodes
The maximum number of ghost nodes among mesh cells.
Definition: gmpCellMeshData.h:198
virtual ~GmpCellMeshDataBase()
Virtual destructor.
Definition: gmpCellMeshData.h:73
int _maxTotalNumNodes
The maximum number of nodes (common + ghost) among mesh cells.
Definition: gmpCellMeshData.h:201
GmCell *(* GmpMeshLoaderCellAllocator)(GmCellMesh *mesh, int meshId, GmCellType type, int hindex, int id, int offset)
Typedef for a function that can allocate a single cell of the given type and initialize it with the g...
Definition: gmpMeshLoaderAllocator.h:36
Vector< int > _cellPropertyIndices
A vector with size equal to _numCells * _propertySets.size() continuously storing the cell's property...
Definition: gmpCellMeshData.h:228
static int _hTableNumUsedSlots
The number of used entries in _hTable.
Definition: gmpCellMeshData.h:110
GM_NUM_CELL_TYPES
static int hierarchicalQOrder(int index)
Returns the Q order for hierarchical elements associated with the given index (returned by hierarchic...
Definition: gmpCellMeshData.h:90
bool _singleCellType
If set to true, the mesh has only one cell type and other types can NOT be added to it.
Definition: gmpCellMeshData.h:189
A non template base class for GmpCellMeshData storing the needed static attributes and controlling th...
Definition: gmpCellMeshData.h:63
int _cellDumpGhostDataSize
The size of the vector _cellDumpGhostData.
Definition: gmpCellMeshData.h:258
int _cellDumpTypeActiveDataSize
The size of the vector _cellDumpTypeActiveData. Needed since _numCells is not zero when the vector is...
Definition: gmpCellMeshData.h:248
QList< int > _numCellsInGroup
A list with the number of cells in each cell group. Its size should be equal to _cellGroupIds....
Definition: gmpCellMeshData.h:209
static GmpCellMeshDataBase * meshData(int meshId)
Returns the mesh data pointer associated with the given mesh id.
Definition: gmpCellMeshData.h:98
QList< GmPropertySet * > _propertySets
The list of property sets "indexed" by every cell. The order of property sets in this list is the sam...
Definition: gmpCellMeshData.h:224
bool hierarchicalElements() const
Returns true if the mesh uses hierarchical elements, false otherwise.
Definition: gmpCellMeshData.h:76
static GmCellMesh * mesh(int meshId)
Returns the mesh pointer associated with the given mesh id.
Definition: gmpCellMeshData.h:95
int _maxNumNodes
The maximum number of nodes among mesh cell types in use by the mesh.
Definition: gmpCellMeshData.h:192
QStringList _cellGroupIds
A list with available cell group names.
Definition: gmpCellMeshData.h:204
unsigned char * _cellDumpTypeActiveData
A vector storing temporary cell types + active data when needed for dumping code. If different from N...
Definition: gmpCellMeshData.h:244
GmpCellMeshDataBase(GmCellMesh *mesh)
Constructor.
Definition: gmpCellMeshData.h:66
#define GmpCellMeshDataMaxHTypes
The maximum number of distinct hierarchical type orders that can be used simmultaneously....
Definition: gmpCellMeshData.h:57
static int hierarchicalPOrder(int index)
Returns the P order for hierarchical elements associated with the given index (returned by hierarchic...
Definition: gmpCellMeshData.h:85
Interface for accessing the "exported" functions of a UibhmTopology class instance,...
Definition: uibhmTopology.h:83
Declaration of usefull configuration definitions for the plugin library.
virtual ~GmpCellMeshData()
Virtual destructor.
Definition: gmpCellMeshData.h:128
QMap< QString, GmCellBoundary * > _boundaryGroups
A map with the definition of each boundary group associated with the mesh. Map entries are instances ...
Definition: gmpCellMeshData.h:219
QVariantMap * _cellDumpLoadedMap
The map with loaded control data. Filled (different from NULL) only during the load process.
Definition: gmpCellMeshData.h:261
int _hierarchicalIndex
The hierarchical order index in _hTable if this mesh has hierarchical elements or -1 if elements are ...
Definition: gmpCellMeshData.h:106
Auxiliar structure used to share data between GmpXxxCellMeshBase and GmpMeshLoader.
Definition: gmpCellMeshData.h:123
int * cellPropertiesPtr(int cellId)
Returns a pointer to vector region where the property indices for the given cell are stored....
Definition: gmpCellMeshData.h:134
Vector< GmCell * > _cells
The cell vector (size equal to _numCells)
Definition: gmpCellMeshData.h:180
#define GMP_GEMAMESH_MAX_NUM_MESHES
The maximum number of allowed meshes.
Definition: gmpGemaMeshConfig.h:49
int * _cellDumpGhostData
A vector storing temporary information about ghost nodes when needed for dumping code....
Definition: gmpCellMeshData.h:255
bool _ghostEnabled
Can the cells store ghost nodes? (_maxNumGhostNodes can be zero if the mesh supports ghost nodes but ...
Definition: gmpCellMeshData.h:195
Declaration of the GmpMeshLoaderCellAllocator type.
QList< int * > _cellGroupCells
A list with a vector of cell Ids for each cell group. Its size should be equal to _cellGroupIds....
Definition: gmpCellMeshData.h:214
int _numCells
The total number of cells.
Definition: gmpCellMeshData.h:178