GemaMesh
The GeMA Mesh Plugin
Loading...
Searching...
No Matches
uibhmGeometry.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 _UIBHM_GEOMETRY_H_
25#define _UIBHM_GEOMETRY_H_
26
27#include "uibhmTemplate.h"
28
29#include "gmpNodeMeshData.h"
30#include "gmpCellMeshData.h"
31#include "gmpCell.h"
32
33class GmPCR;
34
45template <bool Hybrid, template <class> class Vector>
46class GMP_GEMAMESH_API_EXPORT UibhmGemaCellMeshDataGeometry
47{
48public:
49
51 template <typename U> using VectorType = Vector<U>;
52
55
58
60 enum { IsHybrid = Hybrid };
61
62 UibhmGemaCellMeshDataGeometry(NodeData* nodeData, CellData* cellData, const GmPCR* pcr);
63
64 bool updateCellTypes(int numAddedCells);
65
67 int numNodes() const { return _nodeData->_numNodes; }
68
70 int numCells() const { return _cellData->_numCells; }
71
73 GmCell* cell(int cellId) { assert(cellId >= 0 && cellId < _cellData->_numCells); return _cellData->cell(cellId); }
74
76 bool solid() const { return _solid; }
77
82 bool hybrid() const { return Hybrid; }
83
85 bool hasInterface() const { return _interface; }
86
92 bool strange() const { return _strange; }
93
98 const UibhmGemaTemplate* const* typeTemplates() const { return _typeTemplateList; }
99
100 void faceVertices(int cellId, int face, QVarLengthArray<int, 10>& nodeList) const;
101 void faceNodes (int cellId, int face, bool mid, QVarLengthArray<int, 10>& nodeList) const;
102
109 void faceEdgeVertices(int cellId, int face, int edge, int* first, int* last) const
110 {
111 const UibhmGemaTemplate* t = tt(cellId);
112 assert(t);
113 t->faceEdgeVertices(face, edge, first, last, cn(cellId));
114 }
115
122 void faceEdgeNodes(int cellId, int face, int edge, QVarLengthArray<int, 4>& nodeList) const
123 {
124 const UibhmGemaTemplate* t = tt(cellId);
125 assert(t);
126 t->faceEdgeNodes(face, edge, nodeList, cn(cellId));
127 }
128
129 int findNodeIndex(int cellId, int v) const;
130 int colapsedInterfaceNode(int cellId, int v, int localIndex) const;
131 int colapsedInterfaceEdge(int cellId, int face, int faceEdge, int refFace) const;
132 int findFaceEdge (int cellId, int face, int v1, int v2) const;
133 int findFaceEdge (int cellId, int face, int* v1, int* v2) const;
134 int findFaceEdgeFromLocalNodes(int cellId, int face, int lv1, int lv2) const;
135 int findFaceEdgeFromMidEdgeNode(int cellId, int face, int v) const;
136
142 void edgeVertices(int cellId, int edge, int* first, int* last) const
143 {
144 const UibhmGemaTemplate* t = tt(cellId);
145 assert(t);
146 t->edgeVertices(edge, first, last, cn(cellId));
147 }
148
154 void edgeNodes(int cellId, int edge, QVarLengthArray<int, 4>& nodeList) const
155 {
156 const UibhmGemaTemplate* t = tt(cellId);
157 assert(t);
158 t->edgeNodes(edge, nodeList, cn(cellId));
159 }
160
162 int numSides(int cellId) const { const UibhmGemaTemplate* t = tt(cellId); return t ? t->numSides() : 0; }
163
164 void sideVertices(int cellId, int side, QVarLengthArray<int, 10>& nodeList) const;
165 void sideNodes (int cellId, int side, QVarLengthArray<int, 10>& nodeList) const;
166
170 int midCellNode(int cellId) const
171 {
172 const UibhmGemaTemplate* t = tt(cellId);
173 if(t && t->midNode() != -1)
174 return cn(cellId)[t->midNode()];
175 return -1;
176 }
177
183 bool quadraticMidEdgeNodeAdjacentVertices(int cellId, int localNode, int* v1, int* v2) const
184 {
185 const UibhmGemaTemplate* t = tt(cellId);
186 assert(t);
187 return t->quadraticMidEdgeNodeAdjacentVertices(localNode, v1, v2, cn(cellId));
188 }
189
193 void vertexAdjacentVertices(int cellId, int localNode, QVarLengthArray<int, 4>& nodeList) const
194 {
195 const UibhmGemaTemplate* t = tt(cellId);
196 assert(t);
197 t->vertexAdjacentVertices(localNode, nodeList, cn(cellId));
198 }
199
205 void vertexAdjacentNodes(int cellId, int localNode, QVarLengthArray<int, 4>& nodeList) const
206 {
207 const UibhmGemaTemplate* t = tt(cellId);
208 assert(t);
209 t->vertexAdjacentNodes(localNode, nodeList, cn(cellId));
210 }
211
213 static size_t encodeEdge(int v1, int v2)
214 {
215 if(v1 > v2) qSwap(v1, v2);
216 return (((size_t)v1) << 32) | ((size_t)v2);
217 }
218
223 static void decodeEdge(size_t edge, int* v1, int* v2)
224 {
225 *v1 = (int)(edge >> 32);
226 *v2 = (int)(edge & 0xFFFFFFFF);
227 }
228
230 const UibhmGemaTemplate* tt(int cellId) const
231 {
232 assert(cellId >= 0 && cellId < numCells());
233 if constexpr(Hybrid)
234 return _typeTemplateList[_cellData->cell(cellId)->type()];
235 else
236 {
237 Q_UNUSED(cellId);
238 return _typeTemplate;
239 }
240 }
241
246 int co(int cellId) const { return ((CellData::CellPrototype*)_cellData->cell(cellId))->offset(); }
247
249 const int* cn(int cellId) const { return _cellData->cellNodesPtr(co(cellId)); }
250
252 const GmPCR* pcr() const { return _pcr; }
253
256 const GmPCR* _pcr;
257 bool _solid;
258 bool _strange;
260
263
268 const UibhmGemaTemplate* _typeTemplateList[GM_NUM_CELL_TYPES];
269};
270
271
272#endif
Class for storing cell data, without ghost nodes support.
Definition gmpCell.h:132
Auxiliar structure used to share data between GmpCellMesh and GmpMeshLoader. All fields are public si...
Definition gmpCellMeshData.h:121
Auxiliar interface used to share node data between the mesh implementation and GmpMeshLoader....
Definition gmpNodeMeshData.h:53
A class used to provide all the geometric information needed by the topology and query Uibhm classes....
Definition uibhmGeometry.h:47
GmCell * cell(int cellId)
Returns the cell object from its id.
Definition uibhmGeometry.h:73
static size_t encodeEdge(int v1, int v2)
Encodes the edge definde by v1, v2 into a 64 bits integer number.
Definition uibhmGeometry.h:213
bool _interface
Flag set to true if the mesh includes interface elements.
Definition uibhmGeometry.h:259
const GmPCR * _pcr
The mesh PCR object to allow for needed model <--> internal cell and node id conversions.
Definition uibhmGeometry.h:256
bool _solid
Flag set to true if the mesh includes solid cells.
Definition uibhmGeometry.h:257
bool hasInterface() const
Returns true if the mesh includes any interface element.
Definition uibhmGeometry.h:85
int midCellNode(int cellId) const
If the element has a mid surface or a mid volume quadratic node, returns the node index....
Definition uibhmGeometry.h:170
int numCells() const
Return the number of mesh cells (including any 'strange' elements)
Definition uibhmGeometry.h:70
const int * cn(int cellId) const
Returns the cell node list.
Definition uibhmGeometry.h:249
void vertexAdjacentVertices(int cellId, int localNode, QVarLengthArray< int, 4 > &nodeList) const
Given a local vertex number (a geometry node, NOT a quadratic node), returns the set of global vertic...
Definition uibhmGeometry.h:193
void faceEdgeNodes(int cellId, int face, int edge, QVarLengthArray< int, 4 > &nodeList) const
Returns the list of nodes for the given element's face edge, where the face is defined by its local i...
Definition uibhmGeometry.h:122
bool _strange
Flag set to true if the mesh includes "strange" cells.
Definition uibhmGeometry.h:258
const GmPCR * pcr() const
Returns the PCR object used for model <--> internal cell and node id conversions.
Definition uibhmGeometry.h:252
int numSides(int cellId) const
Returns the number of sides(edges or faces) for the given element. Returns 0 for strange elements.
Definition uibhmGeometry.h:162
void edgeVertices(int cellId, int edge, int *first, int *last) const
Returns the pair of vertices for the given element's edge, where the edge is defined by its local ind...
Definition uibhmGeometry.h:142
int numNodes() const
Return the number of mesh nodes.
Definition uibhmGeometry.h:67
int co(int cellId) const
Returns the offset of the first node stored by the given cell.
Definition uibhmGeometry.h:246
NodeData * _nodeData
The mesh node data object.
Definition uibhmGeometry.h:254
const UibhmGemaTemplate * tt(int cellId) const
Returns the template type for the given cell. Will return NULL for "strange" cells.
Definition uibhmGeometry.h:230
bool solid() const
Returns true if the mesh includes any solid cell (a cell with more than one face)
Definition uibhmGeometry.h:76
bool strange() const
Returns true if the mesh includes "strange" cells. A surface mesh has strange cells if it includes ba...
Definition uibhmGeometry.h:92
static void decodeEdge(size_t edge, int *v1, int *v2)
Decodes the result of an encodeEdge() operation returning both nodes. Since encoded values are always...
Definition uibhmGeometry.h:223
const UibhmGemaTemplate *const * typeTemplates() const
Returns a vector with GM_NUM_CELL_TYPES entries storing the templates for the used cell types....
Definition uibhmGeometry.h:98
bool quadraticMidEdgeNodeAdjacentVertices(int cellId, int localNode, int *v1, int *v2) const
Given a mid-edge quadratic node defined by its local cell index, returns the pair of (global) vertice...
Definition uibhmGeometry.h:183
void faceEdgeVertices(int cellId, int face, int edge, int *first, int *last) const
Returns the pair of vertices for the given element's face edge, where the face is defined by its loca...
Definition uibhmGeometry.h:109
bool hybrid() const
Returns true if this mesh contains (or supports) hybrid cell types. It will always return true if the...
Definition uibhmGeometry.h:82
Vector< U > VectorType
The vector type used by the mesh.
Definition uibhmGeometry.h:51
CellData * _cellData
The mesh cell data object.
Definition uibhmGeometry.h:255
void edgeNodes(int cellId, int edge, QVarLengthArray< int, 4 > &nodeList) const
Returns the list of nodes for the given element's edge, where the edge is defined by its local index ...
Definition uibhmGeometry.h:154
void vertexAdjacentNodes(int cellId, int localNode, QVarLengthArray< int, 4 > &nodeList) const
Given a local vertex number (a geometry node, NOT a quadratic node), returns the set of global nodes ...
Definition uibhmGeometry.h:205
const UibhmGemaTemplate * _typeTemplate
The type template if the mesh has a single cell type that is not a strange type (not hybrid,...
Definition uibhmGeometry.h:262
A class used to store the type information needed by the Uibhm structure. The data is created based o...
Definition uibhmTemplate.h:46
void edgeVertices(int e, int *first, int *last) const
Returns the pair of edge vertices for the given edge definied by its local element number.
Definition uibhmTemplate.h:195
void faceEdgeNodes(int f, int e, QVarLengthArray< int, 4 > &list) const
Returns the set of edge nodes for the given face, local (face) edge pair. The list endpoints are the ...
Definition uibhmTemplate.h:220
void vertexAdjacentNodes(int v, QVarLengthArray< int, 4 > &list) const
Given a local vertex number, returns the set of local nodes adjacent to the given one....
Definition uibhmTemplate.h:189
void edgeNodes(int e, QVarLengthArray< int, 4 > &list) const
Returns the list of edge nodes for the given edge definied by its local element number.
Definition uibhmTemplate.h:201
bool quadraticMidEdgeNodeAdjacentVertices(int node, int *v1, int *v2) const
Given a mid-edge quadratic node defined by its local cell index v, returns the pair of vertices of th...
Definition uibhmTemplate.h:143
void vertexAdjacentVertices(int v, QVarLengthArray< int, 4 > &list) const
Given a local vertex number, returns the set of local vertices adjacent to the given one....
Definition uibhmTemplate.h:177
int midNode() const
For quadratic elements with a mid face (surface element) or mid volume (solid element) node,...
Definition uibhmTemplate.h:112
int numSides() const
Returns numEdges() for surface elements and numFaces() for solid elements.
Definition uibhmTemplate.h:69
void faceEdgeVertices(int f, int e, int *first, int *last) const
Returns the pair of edge vertices for the given face, local (face) edge pair.
Definition uibhmTemplate.h:207
GM_NUM_CELL_TYPES
Declaration of the GmpCellMeshData structure.
Declaration of the GmpNodeMeshData class.
Declaration of the UibhmGemaTemplate class.