GemaMesh
The GeMA Mesh Plugin
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 
45 class GMP_GEMAMESH_API_EXPORT UibhmGemaTemplate
46 {
47 public:
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 
98  const int* faceNodes(int f) const { assert(f >= 0 && f < numFaces()); return _g->_faceNodeInfo[f]._faceNodes.constData(); }
99 
104  const int* faceVertices(int f) const { assert(f >= 0 && f < numFaces()); return _vg->_faceNodeInfo[f]._faceNodes.constData(); }
105 
109  int midNode() const { return _midNode; }
110 
115  const int* adjacentFaces(int f) const { assert(f >= 0 && f < numFaces()); return _CF + f * _maxNfv; }
116 
121  const int* vertexHalfEdges(int v) const { assert(v >= 0 && v < numVertices()); return _CE + v * numVertices(); }
122 
123  // --------------------------------------------------------
124  // Additional helper functions
125  // --------------------------------------------------------
126 
127  void print(const GmLogCategory& logger, GmLogLevel level) const;
128 
129  void vertexFaces(int v, QVarLengthArray<int, 4>& list) const;
130  void nodeFaces (int node, QVarLengthArray<int, 4>& list) const;
131 
133  int edgeFace(int edge) const { assert(edge >= 0 && edge < numEdges()); return _edgeFace[edge]; }
134 
140  bool quadraticMidEdgeNodeAdjacentVertices(int node, int* v1, int* v2) const { return quadraticMidEdgeNodeAdjacentVerticesImpl<false>(node, v1, v2); }
141 
143  bool quadraticMidEdgeNodeAdjacentVertices(int node, int* v1, int* v2, const int* cellNodes) const { return quadraticMidEdgeNodeAdjacentVerticesImpl<true>(node, v1, v2, cellNodes); }
144 
153  void vertexAdjacentVertices(int v, QVarLengthArray<int, 4>& list) const { vertexAdjacentImpl<false>(v, _vg, list); }
154 
156  void vertexAdjacentVertices(int v, QVarLengthArray<int, 4>& list, const int* cellNodes) const { vertexAdjacentImpl<true>(v, _vg, list, cellNodes); }
157 
165  void vertexAdjacentNodes(int v, QVarLengthArray<int, 4>& list) const { vertexAdjacentImpl<false>(v, _g, list); }
166 
168  void vertexAdjacentNodes(int v, QVarLengthArray<int, 4>& list, const int* cellNodes) const { vertexAdjacentImpl<true>(v, _g, list, cellNodes); }
169 
171  void edgeVertices(int e, int* first, int* last) const { edgeVerticesImpl<false>(e, first, last); }
172 
174  void edgeVertices(int e, int* first, int* last, const int* cellNodes) const { edgeVerticesImpl<true>(e, first, last, cellNodes); }
175 
177  void edgeNodes(int e, QVarLengthArray<int, 4>& list) const { edgeNodesImpl<false>(e, list); }
178 
180  void edgeNodes(int e, QVarLengthArray<int, 4>& list, const int* cellNodes) const { edgeNodesImpl<true>(e, list, cellNodes); }
181 
183  void faceEdgeVertices(int f, int e, int* first, int* last) const { faceEdgeVerticesImpl<false>(f, e, first, last); }
184 
186  void faceEdgeVertices(int f, int e, int* first, int* last, const int* cellNodes) const { faceEdgeVerticesImpl<true>(f, e, first, last, cellNodes); }
187 
193  void faceEdgeNodes(int f, int e, QVarLengthArray<int, 4>& list) const { faceEdgeNodesImpl<false>(f, e, list); }
194 
196  void faceEdgeNodes(int f, int e, QVarLengthArray<int, 4>& list, const int* cellNodes) const { faceEdgeNodesImpl<true>(f, e, list, cellNodes); }
197 
198 
200  static const UibhmGemaTemplate* typeTemplate(GmCellType t) { assert(t < GM_NUM_CELL_TYPES); return _typeTemplates[t]; }
201 
202 private:
203  Q_DISABLE_COPY(UibhmGemaTemplate);
204 
206 
207  friend bool UibhmGemaTemplateInit();
208 
210  const int* nodeOffsets(int f) const { assert(f >= 0 && f < numFaces()); return _edgeNodeOffset + f * (_maxNfv+1); }
211 
212  template <bool Translate> bool quadraticMidEdgeNodeAdjacentVerticesImpl(int node, int* v1, int* v2, const int* cellNodes = NULL) const;
213  template <bool Translate> void vertexAdjacentImpl (int v, const GmCellGeometryInfo* g, QVarLengthArray<int, 4>& list, const int* cellNodes = NULL) const;
214  template <bool Translate> void edgeVerticesImpl (int e, int* first, int* last, const int* cellNodes = NULL) const;
215  template <bool Translate> void edgeNodesImpl (int e, QVarLengthArray<int, 4>& list, const int* cellNodes = NULL) const;
216  template <bool Translate> void faceEdgeVerticesImpl(int f, int e, int* first, int* last, const int* cellNodes = NULL) const;
217  template <bool Translate> void faceEdgeNodesImpl (int f, int e, QVarLengthArray<int, 4>& list, const int* cellNodes = NULL) const;
218 
221  int _maxNfv;
222  int _midNode;
223 
228  int* _edgeFace;
229 
237 
244  int* _CF;
245 
253  int* _CE;
254 
258  static const UibhmGemaTemplate* _typeTemplates[GM_NUM_CELL_TYPES];
259 };
260 
261 
262 #endif
GM_NUM_CELL_TYPES
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:236
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:220
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:177
int * _CE
The half edge matrix, linearized by row. Known in the IBHM paper as CE. Size equal to numVertices() x...
Definition: uibhmTemplate.h:253
void faceEdgeVertices(int f, int e, int *first, int *last, const int *cellNodes) const
Overload for edgeVertices() returning global vertices translated with cellNodes.
Definition: uibhmTemplate.h:186
const int * nodeOffsets(int f) const
Returns the edge node offset vector for the given face.
Definition: uibhmTemplate.h:210
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
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:156
int _midNode
The local number of the mid face/volume node for a quadratic surface/solid element....
Definition: uibhmTemplate.h:222
A class used to store the type information needed by the Uibhm structure. The data is created based o...
Definition: uibhmTemplate.h:45
const GmCellGeometryInfo * _g
The type info object.
Definition: uibhmTemplate.h:219
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:165
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 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:153
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:104
void print(const GmMatrix &m, const GmLogCategory &logger, GmLogLevel level, int fieldWidth, char format, int precision)
int _maxNfv
The maximum number of vertices in a face for this element.
Definition: uibhmTemplate.h:221
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:171
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:98
int * _edgeFace
An auxiliar vector with numEdges() entries storing, for each edge, one (any) face that includes that ...
Definition: uibhmTemplate.h:228
int numFaces() const
Returns the number of faces for the type. Will return 1 for surface elements.
Definition: uibhmTemplate.h:61
bool isInterface() const
Returns true if this element is an interface element.
Definition: uibhmTemplate.h:58
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:200
Declaration of usefull configuration definitions for the plugin library.
GmLogLevel
GmCellType
int numFaceVertices(int f) const
The number of vertices in face f (0 <= f < numFaces())
Definition: uibhmTemplate.h:91
void edgeVertices(int e, int *first, int *last, const int *cellNodes) const
Overload for edgeVertices() returning global vertices translated with cellNodes.
Definition: uibhmTemplate.h:174
GmCellType type() const
Returns the cell type.
Definition: uibhmTemplate.h:55
int midNode() const
For quadratic elements with a mid face (surface element) or mid volume (solid element) node,...
Definition: uibhmTemplate.h:109
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:115
static bool UibhmGemaTemplateInit()
Initializes the UibhmGemaTemplate::_typeTemplates list.
Definition: uibhmTemplate.cpp:217
bool quadraticMidEdgeNodeAdjacentVertices(int node, int *v1, int *v2, const int *cellNodes) const
Overload for quadraticMidEdgeNodeAdjacentVertices() returning global vertices translated with cellNod...
Definition: uibhmTemplate.h:143
int numNodes() const
Returns the total number of nodes in the element.
Definition: uibhmTemplate.h:72
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:140
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:183
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:193
void faceEdgeNodes(int f, int e, QVarLengthArray< int, 4 > &list, const int *cellNodes) const
Overload for edgeNodes() returning global vertices translated with cellNodes.
Definition: uibhmTemplate.h:196
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:121
void edgeNodes(int e, QVarLengthArray< int, 4 > &list, const int *cellNodes) const
Overload for edgeNodes() returning global vertices translated with cellNodes.
Definition: uibhmTemplate.h:180
int * _CF
The face adjacency matrix, linearized by row. Known in the IBHM paper as CF. Size equal to numFaces()...
Definition: uibhmTemplate.h:244
int edgeFace(int edge) const
Given a cell edge index, returns one of the cell faces that includes that edge.
Definition: uibhmTemplate.h:133
void vertexAdjacentNodes(int v, QVarLengthArray< int, 4 > &list, const int *cellNodes) const
Overload for vertexAdjacentNodes() returning global vertices translated with cellNodes.
Definition: uibhmTemplate.h:168
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