gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
MTrihedron.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 MTRIHEDRON_H
7 #define MTRIHEDRON_H
8 
9 #include "MElement.h"
10 
11 /*
12  * MTrihedron
13  * A MTrihedron is a plane element composed of
14  * a quadrangle and two triangles.
15  * It serves as an interface between two non-conforming
16  * elements
17  *
18  * v
19  * ^
20  * |
21  * 3-----------2
22  * |'\ | |
23  * | '\ | |
24  * | +---- | --> u
25  * | '\ |
26  * | '\ |
27  * 0-----------1
28  *
29  */
30 
31 class MTrihedron : public MElement {
32 protected:
33  MVertex *_v[4];
34  void _getEdgeVertices(const int num, std::vector<MVertex *> &v) const
35  {
36  v[0] = _v[edges_trihedron(num, 0)];
37  v[1] = _v[edges_trihedron(num, 1)];
38  }
39  void _getFaceVertices(const int num, std::vector<MVertex *> &v) const
40  {
41  if(num > 0) {
42  v[0] = _v[faces_trihedron(num, 0)];
43  v[1] = _v[faces_trihedron(num, 1)];
44  v[2] = _v[faces_trihedron(num, 2)];
45  }
46  else {
47  v[0] = _v[0];
48  v[1] = _v[1];
49  v[2] = _v[2];
50  v[3] = _v[3];
51  }
52  }
53 
54 public:
55  MTrihedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, int num = 0,
56  int part = 0)
57  : MElement(num, part)
58  {
59  _v[0] = v0;
60  _v[1] = v1;
61  _v[2] = v2;
62  _v[3] = v3;
63  }
64  MTrihedron(const std::vector<MVertex *> &v, int num = 0, int part = 0)
65  : MElement(num, part)
66  {
67  for(int i = 0; i < 4; i++) _v[i] = v[i];
68  }
70  virtual int getDim() const { return 3; } // Can have a volume...
71  virtual std::size_t getNumVertices() const { return 4; }
72  virtual MVertex *getVertex(int num) { return _v[num]; }
73  virtual const MVertex *getVertex(int num) const { return _v[num]; }
74  virtual void setVertex(int num, MVertex *v) { _v[num] = v; }
75  virtual int getNumEdges() const { return 5; }
76  virtual MEdge getEdge(int num) const
77  {
78  return MEdge(_v[edges_trihedron(num, 0)], _v[edges_trihedron(num, 1)]);
79  }
80  virtual int getNumEdgesRep(bool curved) { return 5; }
81  virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z,
82  SVector3 *n)
83  {
84  MEdge e(getEdge(num));
85  _getEdgeRep(e.getVertex(0), e.getVertex(1), x, y, z, n, 0);
86  }
87  virtual void getEdgeVertices(const int num, std::vector<MVertex *> &v) const
88  {
89  v.resize(2);
90  _getEdgeVertices(num, v);
91  }
92  virtual int getNumFaces() { return 3; }
93  virtual MFace getFace(int num) const
94  {
95  if(num > 0)
96  return MFace(_v[faces_trihedron(num, 0)], _v[faces_trihedron(num, 1)],
97  _v[faces_trihedron(num, 2)]);
98  else
99  return MFace(_v[0], _v[1], _v[2], _v[3]);
100  }
101 
102  virtual int getNumFacesRep(bool curved) { return 2; }
103  virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z,
104  SVector3 *n)
105  {
106  static const int f[2][3] = {{0, 1, 3}, {1, 2, 3}};
107  _getFaceRep(getVertex(f[num][0]), getVertex(f[num][1]),
108  getVertex(f[num][2]), x, y, z, n);
109  }
110  virtual void getFaceVertices(const int num, std::vector<MVertex *> &v) const
111  {
112  v.resize((num == 0) ? 4 : 3);
113  _getFaceVertices(num, v);
114  }
115  virtual int getType() const { return TYPE_TRIH; }
116  virtual int getTypeForMSH() const { return MSH_TRIH_4; }
117 
118  virtual void reverse()
119  {
120  MVertex *tmp = _v[1];
121  _v[1] = _v[3];
122  _v[3] = tmp;
123  }
124  virtual int getVolumeSign() { return 0; };
125  virtual double getVolume() { return 0; };
126  virtual bool setVolumePositive() { return false; };
127  virtual void getNode(int num, double &u, double &v, double &w) const
128  {
129  w = 0;
130  switch(num) {
131  case 0:
132  u = -1.;
133  v = -1.;
134  break;
135  case 1:
136  u = 1.;
137  v = -1.;
138  break;
139  case 2:
140  u = 1.;
141  v = 1.;
142  break;
143  case 3:
144  u = -1.;
145  v = 1.;
146  break;
147  default:
148  u = 0.;
149  v = 0.;
150  break;
151  }
152  }
153  virtual SPoint3 barycenterUVW() const { return SPoint3(0., 0., 0.); }
154  virtual bool isInside(double u, double v, double w) const
155  {
156  double tol = getTolerance();
157  if(u < -(1. + tol) || v < -(1. + tol) || u > (1. + tol) || v > (1. + tol) ||
158  fabs(w) > tol)
159  return false;
160  return true;
161  }
162  static int edges_trihedron(const int edge, const int vert)
163  {
164  static const int e[5][2] = {
165  {0, 1}, {1, 2}, {2, 3}, {3, 0}, {1, 3},
166  };
167  return e[edge][vert];
168  }
169  static int faces_trihedron(const int face, const int vert)
170  {
171  static const int f[3][4] = {
172  {0, 1, 2, 3},
173  {0, 3, 1, -1},
174  {1, 3, 2, -1},
175  };
176  return f[face][vert];
177  }
178 
179  // Return the number of nodes that this element must have with the other in
180  // order to put an edge between them in the dual graph used during the
181  // partitioning.
182  virtual int numCommonNodesInDualGraph(const MElement *const other) const;
183 };
184 
185 #endif
MTrihedron::getFaceRep
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
Definition: MTrihedron.h:103
MTrihedron::isInside
virtual bool isInside(double u, double v, double w) const
Definition: MTrihedron.h:154
MEdge
Definition: MEdge.h:14
MTrihedron::getNumEdgesRep
virtual int getNumEdgesRep(bool curved)
Definition: MTrihedron.h:80
MTrihedron::getDim
virtual int getDim() const
Definition: MTrihedron.h:70
MVertex
Definition: MVertex.h:24
MTrihedron::MTrihedron
MTrihedron(MVertex *v0, MVertex *v1, MVertex *v2, MVertex *v3, int num=0, int part=0)
Definition: MTrihedron.h:55
MTrihedron::faces_trihedron
static int faces_trihedron(const int face, const int vert)
Definition: MTrihedron.h:169
MTrihedron::getVolume
virtual double getVolume()
Definition: MTrihedron.h:125
SPoint3
Definition: SPoint3.h:14
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
SVector3
Definition: SVector3.h:16
MTrihedron::getEdgeVertices
virtual void getEdgeVertices(const int num, std::vector< MVertex * > &v) const
Definition: MTrihedron.h:87
MTrihedron::numCommonNodesInDualGraph
virtual int numCommonNodesInDualGraph(const MElement *const other) const
Definition: MTrihedron.cpp:8
MTrihedron::getEdgeRep
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
Definition: MTrihedron.h:81
MTrihedron::getVolumeSign
virtual int getVolumeSign()
Definition: MTrihedron.h:124
MTrihedron::MTrihedron
MTrihedron(const std::vector< MVertex * > &v, int num=0, int part=0)
Definition: MTrihedron.h:64
MTrihedron::getType
virtual int getType() const
Definition: MTrihedron.h:115
MTrihedron::setVertex
virtual void setVertex(int num, MVertex *v)
Definition: MTrihedron.h:74
MTrihedron::getFace
virtual MFace getFace(int num) const
Definition: MTrihedron.h:93
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
MTrihedron
Definition: MTrihedron.h:31
MEdge::getVertex
MVertex * getVertex(std::size_t i) const
Definition: MEdge.h:39
MTrihedron::getNumFaces
virtual int getNumFaces()
Definition: MTrihedron.h:92
MTrihedron::getNumEdges
virtual int getNumEdges() const
Definition: MTrihedron.h:75
MTrihedron::getNode
virtual void getNode(int num, double &u, double &v, double &w) const
Definition: MTrihedron.h:127
MTrihedron::_v
MVertex * _v[4]
Definition: MTrihedron.h:33
MTrihedron::getNumFacesRep
virtual int getNumFacesRep(bool curved)
Definition: MTrihedron.h:102
MTrihedron::getFaceVertices
virtual void getFaceVertices(const int num, std::vector< MVertex * > &v) const
Definition: MTrihedron.h:110
MTrihedron::_getFaceVertices
void _getFaceVertices(const int num, std::vector< MVertex * > &v) const
Definition: MTrihedron.h:39
MTrihedron::getEdge
virtual MEdge getEdge(int num) const
Definition: MTrihedron.h:76
MTrihedron::barycenterUVW
virtual SPoint3 barycenterUVW() const
Definition: MTrihedron.h:153
MElement
Definition: MElement.h:30
MTrihedron::~MTrihedron
~MTrihedron()
Definition: MTrihedron.h:69
MTrihedron::getTypeForMSH
virtual int getTypeForMSH() const
Definition: MTrihedron.h:116
MTrihedron::reverse
virtual void reverse()
Definition: MTrihedron.h:118
MTrihedron::getVertex
virtual const MVertex * getVertex(int num) const
Definition: MTrihedron.h:73
MElement::getTolerance
double getTolerance() const
Definition: MElement.cpp:61
MElement::_getFaceRep
void _getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2, double *x, double *y, double *z, SVector3 *n)
Definition: MElement.cpp:146
MSH_TRIH_4
#define MSH_TRIH_4
Definition: GmshDefines.h:226
z
const double z
Definition: GaussQuadratureQuad.cpp:56
MTrihedron::edges_trihedron
static int edges_trihedron(const int edge, const int vert)
Definition: MTrihedron.h:162
MElement.h
MTrihedron::_getEdgeVertices
void _getEdgeVertices(const int num, std::vector< MVertex * > &v) const
Definition: MTrihedron.h:34
MTrihedron::setVolumePositive
virtual bool setVolumePositive()
Definition: MTrihedron.h:126
TYPE_TRIH
#define TYPE_TRIH
Definition: GmshDefines.h:76
MTrihedron::getVertex
virtual MVertex * getVertex(int num)
Definition: MTrihedron.h:72
MTrihedron::getNumVertices
virtual std::size_t getNumVertices() const
Definition: MTrihedron.h:71