GemaMesh
The GeMA Mesh Plugin
Loading...
Searching...
No Matches
uibhmTemplate.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_TEMPLATE_H_
25#define _UIBHM_TEMPLATE_H_
26
27#include "gmpGemaMeshConfig.h"
28
29#include <gmCellGeometry.h>
30
45class GMP_GEMAMESH_API_EXPORT UibhmGemaTemplate
46{
47public:
49
50 // --------------------------------------------------------
51 // Basic template properties
52 // --------------------------------------------------------
53
55 GmCellType type() const { return _g->_type; }
56
58 bool isInterface() const { return _g->_interface; }
59
61 int numFaces() const { return _g->_nfaces; }
62
66 int numEdges() const { return _g->_nedges; }
67
69 int numSides() const { return _g->_nfaces == 1 ? numEdges() : numFaces(); }
70
72 int numNodes() const { return _g->_nnodes; }
73
77 int numVertices() const { return _g->_nvertices; }
78
82 int numFaceNodes(int f, bool mid) const
83 {
84 assert(f >= 0 && f < numFaces());
85 // The following implementation assumes that, for a solid element, if it has a mid volume
86 // node it will also have mid face nodes and vice-versa.
87 return _g->_faceNodeInfo[f]._faceNodes.size() - (!mid && _midNode != -1);
88 }
89
91 int numFaceVertices(int f) const { assert(f >= 0 && f < numFaces()); return _vg->_faceNodeInfo[f]._faceNodes.size(); }
92
94 int maxNumFaceVertices() const { return _maxNfv; }
95
101 const int* faceNodes(int f) const { assert(f >= 0 && f < numFaces()); return _g->_faceNodeInfo[f]._faceNodes.constData(); }
102
107 const int* faceVertices(int f) const { assert(f >= 0 && f < numFaces()); return _vg->_faceNodeInfo[f]._faceNodes.constData(); }
108
112 int midNode() const { return _midNode; }
113
118 const int* adjacentFaces(int f) const { assert(f >= 0 && f < numFaces()); return _CF + f * _maxNfv; }
119
124 const int* vertexHalfEdges(int v) const { assert(v >= 0 && v < numVertices()); return _CE + v * numVertices(); }
125
126 // --------------------------------------------------------
127 // Additional helper functions
128 // --------------------------------------------------------
129
130 void print(const GmLogCategory& logger, GmLogLevel level) const;
131
132 void vertexFaces(int v, QVarLengthArray<int, 4>& list) const;
133 void nodeFaces (int node, QVarLengthArray<int, 4>& list) const;
134
136 int edgeFace(int edge) const { assert(edge >= 0 && edge < numEdges()); return _g->_edgeFaceInfo[edge][0]; }
137
143 bool quadraticMidEdgeNodeAdjacentVertices(int node, int* v1, int* v2) const { return quadraticMidEdgeNodeAdjacentVerticesImpl<false>(node, v1, v2); }
144
146 bool quadraticMidEdgeNodeAdjacentVertices(int node, int* v1, int* v2, const int* cellNodes) const { return quadraticMidEdgeNodeAdjacentVerticesImpl<true>(node, v1, v2, cellNodes); }
147
151 int midEdgeNode(int f, int e) const
152 {
153 assert(_g->_edgeNodeInfo[_g->_faceEdgeInfo[f][e]]._edgeNodes.size() == 3);
154 return _g->_edgeNodeInfo[_g->_faceEdgeInfo[f][e]]._edgeNodes[1];
155 }
156
161 bool isInterfaceExtraFlowNode(int v) const
162 {
163 assert(v >= 0 && v < _g->_nnodes);
164 return _g->_interface && v >= (_g->_nnodes - _g->_nextraDofNodes);
165 }
166
167 int colapsedInterfaceNodeSibling(int v) const;
168
177 void vertexAdjacentVertices(int v, QVarLengthArray<int, 4>& list) const { vertexAdjacentImpl<false>(v, _vg, list); }
178
180 void vertexAdjacentVertices(int v, QVarLengthArray<int, 4>& list, const int* cellNodes) const { vertexAdjacentImpl<true>(v, _vg, list, cellNodes); }
181
189 void vertexAdjacentNodes(int v, QVarLengthArray<int, 4>& list) const { vertexAdjacentImpl<false>(v, _g, list); }
190
192 void vertexAdjacentNodes(int v, QVarLengthArray<int, 4>& list, const int* cellNodes) const { vertexAdjacentImpl<true>(v, _g, list, cellNodes); }
193
195 void edgeVertices(int e, int* first, int* last) const { edgeVerticesImpl<false>(e, first, last); }
196
198 void edgeVertices(int e, int* first, int* last, const int* cellNodes) const { edgeVerticesImpl<true>(e, first, last, cellNodes); }
199
201 void edgeNodes(int e, QVarLengthArray<int, 4>& list) const { edgeNodesImpl<false>(e, list); }
202
204 void edgeNodes(int e, QVarLengthArray<int, 4>& list, const int* cellNodes) const { edgeNodesImpl<true>(e, list, cellNodes); }
205
207 void faceEdgeVertices(int f, int e, int* first, int* last) const { faceEdgeVerticesImpl<false>(f, e, first, last); }
208
210 void faceEdgeVertices(int f, int e, int* first, int* last, const int* cellNodes) const { faceEdgeVerticesImpl<true>(f, e, first, last, cellNodes); }
211
213 int numFaceEdgeNodes(int f, int e) const { const int* neo = nodeOffsets(f); return neo[e+1] - neo[e] + 1; }
214
220 void faceEdgeNodes(int f, int e, QVarLengthArray<int, 4>& list) const { faceEdgeNodesImpl<false>(f, e, list); }
221
223 void faceEdgeNodes(int f, int e, QVarLengthArray<int, 4>& list, const int* cellNodes) const { faceEdgeNodesImpl<true>(f, e, list, cellNodes); }
224
226 int numApertureSides() const { assert(_g->_interface); return _g->_interfaceInfo._apertureSides.size(); }
227
229 const int* apertureSides() const { assert(_g->_interface); return _g->_interfaceInfo._apertureSides.constData(); }
230
235 int firstContactEdge(int f) const { assert(_g->_interface); return _g->_interfaceInfo._contactEdges[f][0]; }
236
238 static const UibhmGemaTemplate* typeTemplate(GmCellType t) { assert(t < GM_NUM_CELL_TYPES); return _typeTemplates[t]; }
239
240private:
241 Q_DISABLE_COPY(UibhmGemaTemplate);
242
244
245 friend bool UibhmGemaTemplateInit();
246
248 const int* nodeOffsets(int f) const { assert(f >= 0 && f < numFaces()); return _edgeNodeOffset + f * (_maxNfv+1); }
249
250 template <bool Translate> bool quadraticMidEdgeNodeAdjacentVerticesImpl(int node, int* v1, int* v2, const int* cellNodes = NULL) const;
251 template <bool Translate> void vertexAdjacentImpl (int v, const GmCellGeometryInfo* g, QVarLengthArray<int, 4>& list, const int* cellNodes = NULL) const;
252 template <bool Translate> void edgeVerticesImpl (int e, int* first, int* last, const int* cellNodes = NULL) const;
253 template <bool Translate> void edgeNodesImpl (int e, QVarLengthArray<int, 4>& list, const int* cellNodes = NULL) const;
254 template <bool Translate> void faceEdgeVerticesImpl(int f, int e, int* first, int* last, const int* cellNodes = NULL) const;
255 template <bool Translate> void faceEdgeNodesImpl (int f, int e, QVarLengthArray<int, 4>& list, const int* cellNodes = NULL) const;
256
261
269
276 int* _CF;
277
285 int* _CE;
286
290 static const UibhmGemaTemplate* _typeTemplates[GM_NUM_CELL_TYPES];
291};
292
293
294#endif
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
bool isInterface() const
Returns true if this element is an interface element.
Definition uibhmTemplate.h:58
int numEdges() const
Returns the total number of edges for the type. For surfaces it is equal to the number of vertices....
Definition uibhmTemplate.h:66
int numApertureSides() const
Returns the number of aperture (or flow) sides. For interface elements only.
Definition uibhmTemplate.h:226
int numFaceEdgeNodes(int f, int e) const
Returns the number of nodes for the given face, local (face) edge pair.
Definition uibhmTemplate.h:213
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
int numNodes() const
Returns the total number of nodes in the element.
Definition uibhmTemplate.h:72
void edgeNodes(int e, QVarLengthArray< int, 4 > &list, const int *cellNodes) const
Overload for edgeNodes() returning global vertices translated with cellNodes.
Definition uibhmTemplate.h:204
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
int edgeFace(int edge) const
Given a cell edge index, returns one of the cell faces that includes that edge.
Definition uibhmTemplate.h:136
GmCellType type() const
Returns the cell type.
Definition uibhmTemplate.h:55
void faceEdgeVertices(int f, int e, int *first, int *last, const int *cellNodes) const
Overload for faceEdgeVertices() returning global vertices translated with cellNodes.
Definition uibhmTemplate.h:210
static const UibhmGemaTemplate * typeTemplate(GmCellType t)
Returns the template object for the given element type. Might return NULL for unsupported elements (b...
Definition uibhmTemplate.h:238
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
const int * faceVertices(int f) const
Returns a vector with the set of vertices in face f (0 <= f < numFaces()). Returned vector size is eq...
Definition uibhmTemplate.h:107
int numVertices() const
Returns the number of vertices in the element (the set of geometry nodes, excluding non-linear nodes ...
Definition uibhmTemplate.h:77
void faceEdgeNodes(int f, int e, QVarLengthArray< int, 4 > &list, const int *cellNodes) const
Overload for faceEdgeNodes() returning global vertices translated with cellNodes.
Definition uibhmTemplate.h:223
void vertexAdjacentNodes(int v, QVarLengthArray< int, 4 > &list, const int *cellNodes) const
Overload for vertexAdjacentNodes() returning global vertices translated with cellNodes.
Definition uibhmTemplate.h:192
int firstContactEdge(int f) const
Given a face index, returns the local index of the first contact edge from that face (a value from 0 ...
Definition uibhmTemplate.h:235
const GmCellGeometryInfo * _g
The type info object.
Definition uibhmTemplate.h:257
int numFaces() const
Returns the number of faces for the type. Will return 1 for surface elements.
Definition uibhmTemplate.h:61
int * _CE
The half edge matrix, linearized by row. Known in the IBHM paper as CE. Size equal to numVertices() x...
Definition uibhmTemplate.h:285
const GmCellGeometryInfo * _vg
The type info object used to query faces for vertices. Will be equal to _g for linear types without e...
Definition uibhmTemplate.h:258
int numFaceNodes(int f, bool mid) const
Returns the number of nodes in face f (0 <= f < numFaces()). If mid is true, that includes an eventua...
Definition uibhmTemplate.h:82
const int * faceNodes(int f) const
Returns a vector with the set of nodes in face f (0 <= f < numFaces()). Returned vector size is equal...
Definition uibhmTemplate.h:101
bool isInterfaceExtraFlowNode(int v) const
Given an element local node index, returns true if that node is a mid edge flow(extra dof) node of an...
Definition uibhmTemplate.h:161
int midEdgeNode(int f, int e) const
Return the local to the cell index of the mid edge node for the given face, local(face) edge pair....
Definition uibhmTemplate.h:151
int _midNode
The local number of the mid face/volume node for a quadratic surface/solid element....
Definition uibhmTemplate.h:260
const int * nodeOffsets(int f) const
Returns the edge node offset vector for the given face.
Definition uibhmTemplate.h:248
bool quadraticMidEdgeNodeAdjacentVertices(int node, int *v1, int *v2, const int *cellNodes) const
Overload for quadraticMidEdgeNodeAdjacentVertices() returning global vertices translated with cellNod...
Definition uibhmTemplate.h:146
int midNode() const
For quadratic elements with a mid face (surface element) or mid volume (solid element) node,...
Definition uibhmTemplate.h:112
int * _CF
The face adjacency matrix, linearized by row. Known in the IBHM paper as CF. Size equal to numFaces()...
Definition uibhmTemplate.h:276
void edgeVertices(int e, int *first, int *last, const int *cellNodes) const
Overload for edgeVertices() returning global vertices translated with cellNodes.
Definition uibhmTemplate.h:198
int numFaceVertices(int f) const
The number of vertices in face f (0 <= f < numFaces())
Definition uibhmTemplate.h:91
int numSides() const
Returns numEdges() for surface elements and numFaces() for solid elements.
Definition uibhmTemplate.h:69
void vertexAdjacentVertices(int v, QVarLengthArray< int, 4 > &list, const int *cellNodes) const
Overload for vertexAdjacentVertices() returning global vertices translated with cellNodes.
Definition uibhmTemplate.h:180
int _maxNfv
The maximum number of vertices in a face for this element.
Definition uibhmTemplate.h:259
const int * adjacentFaces(int f) const
Given a face number, returns a vector with size numFaceVertices(f) storing the index of the adjacent ...
Definition uibhmTemplate.h:118
int * _edgeNodeOffset
An auxiliary matrix used to to store the node index in the face node description of the first node of...
Definition uibhmTemplate.h:268
const int * apertureSides() const
Returns a list of aperture (or flow) side indices with numApertureSides() entries....
Definition uibhmTemplate.h:229
int maxNumFaceVertices() const
Returns the maximum number of vertices for a face from this element type.
Definition uibhmTemplate.h:94
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
const int * vertexHalfEdges(int v) const
Given a vertex number, returns a vector with size numVertices() storing in column i the index of the ...
Definition uibhmTemplate.h:124
GmCellType
GM_NUM_CELL_TYPES
GmLogLevel
Declaration of useful configuration definitions for the plugin library.
static bool UibhmGemaTemplateInit()
Initializes the UibhmGemaTemplate::_typeTemplates list.
Definition uibhmTemplate.cpp:195