gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
MPyramid.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef MPYRAMID_H
7 #define MPYRAMID_H
8 
9 #include "MElement.h"
10 
11 /*
12  * MPyramid
13  *
14  * 4
15  * ,/|\
16  * ,/ .'|\
17  * ,/ | | \
18  * ,/ .' | `.
19  * ,/ | '. \
20  * ,/ .' w | \
21  * ,/ | ^ | \
22  * 0----------.'--|-3 `.
23  * `\ | | `\ \
24  * `\ .' +----`\ - \ -> v
25  * `\ | `\ `\ \
26  * `\.' `\ `\`
27  * 1----------------2
28  * `\
29  * u
30  *
31  */
32 class MPyramid : public MElement {
33 protected:
34  MVertex *_v[5];
35  void _getEdgeVertices(const int num, std::vector<MVertex *> &v) const
36  {
37  v[0] = _v[edges_pyramid(num, 0)];
38  v[1] = _v[edges_pyramid(num, 1)];
39  }
40  void _getFaceVertices(const int num, std::vector<MVertex *> &v) const
41  {
42  if(num < 4) {
43  v[0] = _v[faces_pyramid(num, 0)];
44  v[1] = _v[faces_pyramid(num, 1)];
45  v[2] = _v[faces_pyramid(num, 2)];
46  }
47  else {
48  v[0] = _v[0];
49  v[1] = _v[3];
50  v[2] = _v[2];
51  v[3] = _v[1];
52  }
53  }
54 
55 public:
56  MPyramid(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
57  int num = 0, int part = 0)
58  : MElement(num, part)
59  {
60  _v[0] = v0;
61  _v[1] = v1;
62  _v[2] = v2;
63  _v[3] = v3;
64  _v[4] = v4;
65  }
66  MPyramid(const std::vector<MVertex *> &v, int num = 0, int part = 0)
67  : MElement(num, part)
68  {
69  for(int i = 0; i < 5; i++) _v[i] = v[i];
70  }
71  ~MPyramid() {}
72  virtual int getDim() const { return 3; }
73  virtual std::size_t getNumVertices() const { return 5; }
74  virtual MVertex *getVertex(int num) { return _v[num]; }
75  virtual const MVertex *getVertex(int num) const { return _v[num]; }
76  virtual void setVertex(int num, MVertex *v) { _v[num] = v; }
77  virtual int getNumEdges() const { return 8; }
78  virtual MEdge getEdge(int num) const
79  {
80  return MEdge(_v[edges_pyramid(num, 0)], _v[edges_pyramid(num, 1)]);
81  }
82  virtual int numEdge2numVertex(int numEdge, int numVert) const
83  {
84  return edges_pyramid(numEdge, numVert);
85  }
86  virtual int getNumEdgesRep(bool curved) { return 8; }
87  virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z,
88  SVector3 *n)
89  {
90  static const int f[8] = {0, 1, 1, 2, 0, 3, 2, 3};
91  MEdge e(getEdge(num));
92  _getEdgeRep(e.getVertex(0), e.getVertex(1), x, y, z, n, f[num]);
93  }
94  virtual void getEdgeVertices(const int num, std::vector<MVertex *> &v) const
95  {
96  v.resize(2);
97  _getEdgeVertices(num, v);
98  }
99  virtual int getNumFaces() { return 5; }
100  virtual MFace getFace(int num) const
101  {
102  if(num < 4)
103  return MFace(_v[faces_pyramid(num, 0)], _v[faces_pyramid(num, 1)],
104  _v[faces_pyramid(num, 2)]);
105  else
106  return MFace(_v[0], _v[3], _v[2], _v[1]);
107  }
108  virtual int getNumFacesRep(bool curved);
109  virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z,
110  SVector3 *n);
111  virtual void getFaceVertices(const int num, std::vector<MVertex *> &v) const
112  {
113  v.resize((num < 4) ? 3 : 4);
114  _getFaceVertices(num, v);
115  }
116  virtual bool getFaceInfo(const MFace &face, int &ithFace, int &sign,
117  int &rot) const;
118  virtual int getType() const { return TYPE_PYR; }
119  virtual int getTypeForMSH() const { return MSH_PYR_5; }
120  virtual int getTypeForVTK() const { return 14; }
121  virtual const char *getStringForPOS() const { return "SY"; }
122  virtual const char *getStringForBDF() const { return "CPYRAM"; }
123  virtual void reverse()
124  {
125  MVertex *tmp = _v[0];
126  _v[0] = _v[2];
127  _v[2] = tmp;
128  }
129  virtual int getVolumeSign();
130  virtual void getNode(int num, double &u, double &v, double &w) const
131  {
132  switch(num) {
133  case 0:
134  u = -1.;
135  v = -1.;
136  w = 0.;
137  break;
138  case 1:
139  u = 1.;
140  v = -1.;
141  w = 0.;
142  break;
143  case 2:
144  u = 1.;
145  v = 1.;
146  w = 0.;
147  break;
148  case 3:
149  u = -1.;
150  v = 1.;
151  w = 0.;
152  break;
153  case 4:
154  u = 0.;
155  v = 0.;
156  w = 1.;
157  break;
158  default:
159  u = 0.;
160  v = 0.;
161  w = 0.;
162  break;
163  }
164  }
165  virtual SPoint3 barycenterUVW() const { return SPoint3(0., 0., .2); }
166  virtual bool isInside(double u, double v, double w) const
167  {
168  double tol = getTolerance();
169  if(u < (w - (1. + tol)) || u > ((1. + tol) - w) || v < (w - (1. + tol)) ||
170  v > ((1. + tol) - w) || w < (-tol) || w > (1. + tol))
171  return false;
172  return true;
173  }
174  void getIntegrationPoints(int pOrder, int *npts, IntPt **pts);
175  static int edges_pyramid(const int edge, const int vert)
176  {
177  static const int e[8][2] = {{0, 1}, {0, 3}, {0, 4}, {1, 2},
178  {1, 4}, {2, 3}, {2, 4}, {3, 4}};
179  return e[edge][vert];
180  }
181  static int faces_pyramid(const int face, const int vert)
182  {
183  static const int f[5][4] = {
184  {0, 1, 4, -1}, {3, 0, 4, -1}, {1, 2, 4, -1}, {2, 3, 4, -1}, {0, 3, 2, 1}};
185  return f[face][vert];
186  }
187  static int faces2edge_pyramid(const int face, const int edge)
188  {
189  // return -iedge - 1 if edge is inverted
190  // iedge + 1 otherwise
191  static const int e[5][4] = {{1, 5, -3, 0},
192  {-2, 3, -8, 0},
193  {4, 7, -5, 0},
194  {6, 8, -7, 0},
195  {2, -6, -4, -1}};
196  return e[face][edge];
197  }
198  virtual int numCommonNodesInDualGraph(const MElement *const other) const;
199  virtual MVertex *getVertexNEU(int num)
200  {
201  static const int map[5] = {0, 1, 3, 2, 4};
202  return getVertex(map[num]);
203  }
204 };
205 
206 /*
207  * MPyramid13
208  *
209  * 4
210  * ,/|\
211  * ,/ .'|\
212  * ,/ | | \
213  * ,/ .' | `.
214  * ,7 | 12 \
215  * ,/ .' | \
216  * ,/ 9 | 11
217  * 0--------6-.'----3 `.
218  * `\ | `\ \
219  * `5 .' 10 \
220  * `\ | `\ \
221  * `\.' `\`
222  * 1--------8-------2
223  *
224  */
225 
226 /*
227  * MPyramid14
228  *
229  * 4
230  * ,/|\
231  * ,/ .'|\
232  * ,/ | | \
233  * ,/ .' | `.
234  * ,7 | 12 \
235  * ,/ .' | \
236  * ,/ 9 | 11
237  * 0--------6-.'----3 `.
238  * `\ | `\ \
239  * `5 .' 13 10 \
240  * `\ | `\ \
241  * `\.' `\`
242  * 1--------8-------2
243  *
244  */
245 
246 //------------------------------------------------------------------------------
247 
248 typedef std::vector<int> IndicesReversed;
249 
250 class MPyramidN : public MPyramid {
251  static std::map<int, IndicesReversed> _order2indicesReversedPyr;
252 
253 protected:
254  std::vector<MVertex *> _vs;
255  const char _order;
256 
257  void _addHOEdgePoints(int num, std::vector<MVertex *> &v,
258  bool fw = true) const;
259 
260 public:
261  MPyramidN(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4,
262  const std::vector<MVertex *> &v, char order, int num = 0,
263  int part = 0)
264  : MPyramid(v0, v1, v2, v3, v4, num, part), _vs(v), _order(order)
265  {
266  for(std::size_t i = 0; i < _vs.size(); i++)
267  _vs[i]->setPolynomialOrder(_order);
268  getFunctionSpace(order);
269  }
270  MPyramidN(const std::vector<MVertex *> &v, char order, int num = 0,
271  int part = 0)
272  : MPyramid(v[0], v[1], v[2], v[3], v[4], num, part), _order(order)
273  {
274  for(std::size_t i = 5; i < v.size(); i++) _vs.push_back(v[i]);
275  for(std::size_t i = 0; i < _vs.size(); i++)
276  _vs[i]->setPolynomialOrder(_order);
277  getFunctionSpace(order);
278  }
279  ~MPyramidN();
280  virtual int getPolynomialOrder() const { return _order; }
281  virtual std::size_t getNumVertices() const { return 5 + _vs.size(); }
282  virtual MVertex *getVertex(int num)
283  {
284  return num < 5 ? _v[num] : _vs[num - 5];
285  }
286  virtual const MVertex *getVertex(int num) const
287  {
288  return num < 5 ? _v[num] : _vs[num - 5];
289  }
290  virtual void setVertex(int num, MVertex *v)
291  {
292  if(num < 5)
293  _v[num] = v;
294  else
295  _vs[num - 5] = v;
296  }
297  virtual int getNumEdgeVertices() const { return 8 * (_order - 1); }
298  virtual int getNumFaceVertices() const
299  {
301  return 0;
302  else
303  return (_order - 1) * (_order - 1) +
304  4 * ((_order - 1) * (_order - 2)) / 2;
305  }
306  virtual void getEdgeVertices(const int num, std::vector<MVertex *> &v) const
307  {
308  v.resize(_order + 1);
310  int j = 2;
311  const int ie = (num + 1) * (_order - 1);
312  for(int i = num * (_order - 1); i != ie; ++i) v[j++] = _vs[i];
313  }
314  virtual void getFaceVertices(const int num, std::vector<MVertex *> &v) const;
315 
316  virtual int getNumVolumeVertices() const
317  {
319  return 0;
320  else
321  return (_order - 2) * ((_order - 2) + 1) * (2 * (_order - 2) + 1) / 6;
322  }
323  virtual int getTypeForMSH() const
324  {
325  if(_order == 1 && _vs.size() + 5 == 5) return MSH_PYR_5;
326  if(_order == 2 && _vs.size() + 5 == 14) return MSH_PYR_14;
327  if(_order == 3 && _vs.size() + 5 == 30) return MSH_PYR_30;
328  if(_order == 4 && _vs.size() + 5 == 55) return MSH_PYR_55;
329  if(_order == 5 && _vs.size() + 5 == 91) return MSH_PYR_91;
330  if(_order == 6 && _vs.size() + 5 == 140) return MSH_PYR_140;
331  if(_order == 7 && _vs.size() + 5 == 204) return MSH_PYR_204;
332  if(_order == 8 && _vs.size() + 5 == 285) return MSH_PYR_285;
333  if(_order == 9 && _vs.size() + 5 == 385) return MSH_PYR_385;
334 
335  if(_order == 2 && _vs.size() + 5 == 13) return MSH_PYR_13;
336  if(_order == 3 && _vs.size() + 5 == 21) return MSH_PYR_21;
337  if(_order == 4 && _vs.size() + 5 == 29) return MSH_PYR_29;
338  if(_order == 5 && _vs.size() + 5 == 37) return MSH_PYR_37;
339  if(_order == 6 && _vs.size() + 5 == 45) return MSH_PYR_45;
340  if(_order == 7 && _vs.size() + 5 == 53) return MSH_PYR_53;
341  if(_order == 8 && _vs.size() + 5 == 61) return MSH_PYR_61;
342  if(_order == 9 && _vs.size() + 5 == 69) return MSH_PYR_69;
343  Msg::Error("No MSH type found for P%d pyramid with %d nodes", _order,
344  5 + _vs.size());
345  return 0;
346  }
347  virtual void reverse();
348  virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z,
349  SVector3 *n);
350  virtual int getNumEdgesRep(bool curved);
351  virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z,
352  SVector3 *n);
353  virtual int getNumFacesRep(bool curved);
354  virtual void getNode(int num, double &u, double &v, double &w) const
355  {
356  num < 5 ? MPyramid::getNode(num, u, v, w) : MElement::getNode(num, u, v, w);
357  }
358 };
359 
360 #endif
MPyramidN::getNumFaceVertices
virtual int getNumFaceVertices() const
Definition: MPyramid.h:298
MPyramidN::getEdgeRep
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
Definition: MPyramid.cpp:62
MPyramidN
Definition: MPyramid.h:250
IndicesReversed
std::vector< int > IndicesReversed
Definition: MPyramid.h:248
MPyramid::getFaceVertices
virtual void getFaceVertices(const int num, std::vector< MVertex * > &v) const
Definition: MPyramid.h:111
MPyramid::getDim
virtual int getDim() const
Definition: MPyramid.h:72
MPyramid::edges_pyramid
static int edges_pyramid(const int edge, const int vert)
Definition: MPyramid.h:175
MEdge
Definition: MEdge.h:14
MPyramid::getStringForBDF
virtual const char * getStringForBDF() const
Definition: MPyramid.h:122
MPyramidN::~MPyramidN
~MPyramidN()
Definition: MPyramid.cpp:52
MPyramid::getNode
virtual void getNode(int num, double &u, double &v, double &w) const
Definition: MPyramid.h:130
MSH_PYR_45
#define MSH_PYR_45
Definition: GmshDefines.h:213
MSH_PYR_91
#define MSH_PYR_91
Definition: GmshDefines.h:204
MPyramidN::getEdgeVertices
virtual void getEdgeVertices(const int num, std::vector< MVertex * > &v) const
Definition: MPyramid.h:306
MPyramid::getStringForPOS
virtual const char * getStringForPOS() const
Definition: MPyramid.h:121
MPyramidN::reverse
virtual void reverse()
Definition: MPyramid.cpp:414
MPyramidN::MPyramidN
MPyramidN(const std::vector< MVertex * > &v, char order, int num=0, int part=0)
Definition: MPyramid.h:270
MSH_PYR_14
#define MSH_PYR_14
Definition: GmshDefines.h:93
MVertex
Definition: MVertex.h:24
MPyramid::getVertexNEU
virtual MVertex * getVertexNEU(int num)
Definition: MPyramid.h:199
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
MPyramid::getNumFaces
virtual int getNumFaces()
Definition: MPyramid.h:99
MPyramid::getEdgeRep
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
Definition: MPyramid.h:87
MPyramid::barycenterUVW
virtual SPoint3 barycenterUVW() const
Definition: MPyramid.h:165
SPoint3
Definition: SPoint3.h:14
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
MPyramid::numCommonNodesInDualGraph
virtual int numCommonNodesInDualGraph(const MElement *const other) const
Definition: MPyramid.cpp:375
SVector3
Definition: SVector3.h:16
MPyramidN::getNumEdgesRep
virtual int getNumEdgesRep(bool curved)
Definition: MPyramid.cpp:54
MPyramid
Definition: MPyramid.h:32
MPyramid::getFaceRep
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
Definition: MPyramid.cpp:349
MPyramid::_getEdgeVertices
void _getEdgeVertices(const int num, std::vector< MVertex * > &v) const
Definition: MPyramid.h:35
MPyramid::getNumFacesRep
virtual int getNumFacesRep(bool curved)
Definition: MPyramid.cpp:105
MSH_PYR_29
#define MSH_PYR_29
Definition: GmshDefines.h:211
MSH_PYR_5
#define MSH_PYR_5
Definition: GmshDefines.h:86
MPyramid::setVertex
virtual void setVertex(int num, MVertex *v)
Definition: MPyramid.h:76
MPyramid::MPyramid
MPyramid(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, int num=0, int part=0)
Definition: MPyramid.h:56
MPyramid::getFace
virtual MFace getFace(int num) const
Definition: MPyramid.h:100
MPyramidN::_order
const char _order
Definition: MPyramid.h:255
MPyramid::isInside
virtual bool isInside(double u, double v, double w) const
Definition: MPyramid.h:166
MSH_PYR_385
#define MSH_PYR_385
Definition: GmshDefines.h:208
MFace
Definition: MFace.h:20
MElement::_getEdgeRep
void _getEdgeRep(MVertex *v0, MVertex *v1, double *x, double *y, double *z, SVector3 *n, int faceIndex=-1)
Definition: MElement.cpp:107
MEdge::getVertex
MVertex * getVertex(std::size_t i) const
Definition: MEdge.h:39
MPyramid::faces2edge_pyramid
static int faces2edge_pyramid(const int face, const int edge)
Definition: MPyramid.h:187
MPyramid::getEdge
virtual MEdge getEdge(int num) const
Definition: MPyramid.h:78
MPyramid::getNumEdges
virtual int getNumEdges() const
Definition: MPyramid.h:77
MSH_PYR_37
#define MSH_PYR_37
Definition: GmshDefines.h:212
MPyramid::MPyramid
MPyramid(const std::vector< MVertex * > &v, int num=0, int part=0)
Definition: MPyramid.h:66
MPyramid::faces_pyramid
static int faces_pyramid(const int face, const int vert)
Definition: MPyramid.h:181
MPyramid::getNumVertices
virtual std::size_t getNumVertices() const
Definition: MPyramid.h:73
MSH_PYR_285
#define MSH_PYR_285
Definition: GmshDefines.h:207
MPyramidN::getNode
virtual void getNode(int num, double &u, double &v, double &w) const
Definition: MPyramid.h:354
MPyramidN::getTypeForMSH
virtual int getTypeForMSH() const
Definition: MPyramid.h:323
MPyramidN::getVertex
virtual const MVertex * getVertex(int num) const
Definition: MPyramid.h:286
MPyramid::getFaceInfo
virtual bool getFaceInfo(const MFace &face, int &ithFace, int &sign, int &rot) const
Definition: MPyramid.cpp:42
MElement::getIsAssimilatedSerendipity
virtual bool getIsAssimilatedSerendipity() const
Definition: MElement.h:81
MSH_PYR_53
#define MSH_PYR_53
Definition: GmshDefines.h:214
MPyramidN::getPolynomialOrder
virtual int getPolynomialOrder() const
Definition: MPyramid.h:280
MPyramid::getTypeForVTK
virtual int getTypeForVTK() const
Definition: MPyramid.h:120
MSH_PYR_55
#define MSH_PYR_55
Definition: GmshDefines.h:203
MPyramid::getTypeForMSH
virtual int getTypeForMSH() const
Definition: MPyramid.h:119
MElement
Definition: MElement.h:30
MSH_PYR_204
#define MSH_PYR_204
Definition: GmshDefines.h:206
MPyramidN::getNumEdgeVertices
virtual int getNumEdgeVertices() const
Definition: MPyramid.h:297
MSH_PYR_30
#define MSH_PYR_30
Definition: GmshDefines.h:202
MPyramidN::getFaceVertices
virtual void getFaceVertices(const int num, std::vector< MVertex * > &v) const
Definition: MPyramid.cpp:448
MPyramidN::setVertex
virtual void setVertex(int num, MVertex *v)
Definition: MPyramid.h:290
MPyramid::getType
virtual int getType() const
Definition: MPyramid.h:118
MPyramidN::_vs
std::vector< MVertex * > _vs
Definition: MPyramid.h:254
MElement::getTolerance
double getTolerance() const
Definition: MElement.cpp:61
MPyramidN::getNumFacesRep
virtual int getNumFacesRep(bool curved)
Definition: MPyramid.cpp:116
MPyramidN::MPyramidN
MPyramidN(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4, const std::vector< MVertex * > &v, char order, int num=0, int part=0)
Definition: MPyramid.h:261
MPyramid::getIntegrationPoints
void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
Definition: MPyramid.cpp:36
TYPE_PYR
#define TYPE_PYR
Definition: GmshDefines.h:69
MSH_PYR_140
#define MSH_PYR_140
Definition: GmshDefines.h:205
MPyramid::getNumEdgesRep
virtual int getNumEdgesRep(bool curved)
Definition: MPyramid.h:86
MPyramidN::getFaceRep
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
Definition: MPyramid.cpp:386
MSH_PYR_69
#define MSH_PYR_69
Definition: GmshDefines.h:216
IntPt
Definition: GaussIntegration.h:12
z
const double z
Definition: GaussQuadratureQuad.cpp:56
MPyramid::getVertex
virtual MVertex * getVertex(int num)
Definition: MPyramid.h:74
MSH_PYR_61
#define MSH_PYR_61
Definition: GmshDefines.h:215
MPyramidN::getNumVertices
virtual std::size_t getNumVertices() const
Definition: MPyramid.h:281
MElement.h
MPyramid::~MPyramid
~MPyramid()
Definition: MPyramid.h:71
MPyramid::numEdge2numVertex
virtual int numEdge2numVertex(int numEdge, int numVert) const
Definition: MPyramid.h:82
MPyramidN::getNumVolumeVertices
virtual int getNumVolumeVertices() const
Definition: MPyramid.h:316
MPyramid::getVolumeSign
virtual int getVolumeSign()
Definition: MPyramid.cpp:15
MElement::getNode
virtual void getNode(int num, double &u, double &v, double &w) const
Definition: MElement.cpp:448
MPyramidN::_order2indicesReversedPyr
static std::map< int, IndicesReversed > _order2indicesReversedPyr
Definition: MPyramid.h:251
MPyramid::_v
MVertex * _v[5]
Definition: MPyramid.h:34
MPyramid::reverse
virtual void reverse()
Definition: MPyramid.h:123
MPyramid::getVertex
virtual const MVertex * getVertex(int num) const
Definition: MPyramid.h:75
MSH_PYR_13
#define MSH_PYR_13
Definition: GmshDefines.h:98
MPyramidN::getVertex
virtual MVertex * getVertex(int num)
Definition: MPyramid.h:282
MSH_PYR_21
#define MSH_PYR_21
Definition: GmshDefines.h:210
MElement::getFunctionSpace
virtual const nodalBasis * getFunctionSpace(int order=-1, bool serendip=false) const
Definition: MElement.cpp:666
MPyramid::getEdgeVertices
virtual void getEdgeVertices(const int num, std::vector< MVertex * > &v) const
Definition: MPyramid.h:94
MPyramid::_getFaceVertices
void _getFaceVertices(const int num, std::vector< MVertex * > &v) const
Definition: MPyramid.h:40
MPyramidN::_addHOEdgePoints
void _addHOEdgePoints(int num, std::vector< MVertex * > &v, bool fw=true) const
Definition: MPyramid.cpp:436