gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
meshGFaceOptimize.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 MESH_GFACE_OPTIMIZE_H
7 #define MESH_GFACE_OPTIMIZE_H
8 
9 #include <map>
10 //#include <unordered_map>
11 #include <vector>
12 #include "MElement.h"
13 #include "MEdge.h"
15 #include "STensor3.h"
16 
17 class GFace;
18 class GVertex;
19 class MVertex;
20 class Field;
21 
22 struct edge_angle {
24  double angle;
25  edge_angle(MVertex *_v1, MVertex *_v2, MElement *t1, MElement *t2);
26  bool operator<(const edge_angle &other) const { return other.angle < angle; }
27 };
28 
29 // TODO: switch to unordered_map here & verify deterministic behavior
30 typedef std::map<MVertex *, std::vector<MElement *>, MVertexPtrLessThan>
32 // typedef std::unordered_map<MVertex *, std::vector<MElement *> > v2t_cont;
33 
34 typedef std::map<MEdge, std::pair<MElement *, MElement *>, MEdgeLessThan>
36 
37 template <class T>
38 void buildVertexToElement(std::vector<T *> const &elements, v2t_cont &adj)
39 {
40  for(std::size_t i = 0, elements_size = elements.size(); i < elements_size;
41  i++) {
42  T *const t = elements[i];
43 
44  for(std::size_t j = 0, vertices_size = t->getNumVertices();
45  j < vertices_size; j++) {
46  adj[t->getVertex(j)].push_back(t);
47  }
48  }
49 }
50 
51 template <class T>
52 void buildEdgeToElement(std::vector<T *> &eles, e2t_cont &adj);
53 
54 void buildEdgeToTriangle(std::vector<MTriangle *> &, e2t_cont &adj);
55 void buildListOfEdgeAngle(e2t_cont adj, std::vector<edge_angle> &edges_detected,
56  std::vector<edge_angle> &edges_lonly);
57 void buildEdgeToElements(std::vector<MElement *> &tris, e2t_cont &adj);
58 
59 void laplaceSmoothing(GFace *gf, int niter = 1, bool infinity_norm = false);
60 
62  GFace *gf, std::set<MTri3 *, compareTri3Ptr> &AllTris, bidimMeshData &data);
64  std::set<MTri3 *, compareTri3Ptr> &AllTris,
65  bidimMeshData &DATA);
66 void computeEquivalences(GFace *gf, bidimMeshData &DATA);
67 void recombineIntoQuads(GFace *gf, bool blossom, int topologicalOptiPasses,
68  bool nodeRepositioning, double minqual);
69 
70 // used for meshGFaceRecombine development
71 void quadsToTriangles(GFace *gf, double minqual);
72 
74 
75 struct swapquad {
76  int v[4];
77  bool operator<(const swapquad &o) const
78  {
79  if(v[0] < o.v[0]) return true;
80  if(v[0] > o.v[0]) return false;
81  if(v[1] < o.v[1]) return true;
82  if(v[1] > o.v[1]) return false;
83  if(v[2] < o.v[2]) return true;
84  if(v[2] > o.v[2]) return false;
85  if(v[3] < o.v[3]) return true;
86  return false;
87  }
88 
89  swapquad(MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4)
90  {
91  v[0] = v1->getNum();
92  v[1] = v2->getNum();
93  v[2] = v3->getNum();
94  v[3] = v4->getNum();
95  std::sort(v, v + 4);
96  }
97 
98  swapquad(int const v1, int const v2, int const v3, int const v4)
99  {
100  v[0] = v1;
101  v[1] = v2;
102  v[2] = v3;
103  v[3] = v4;
104  std::sort(v, v + 4);
105  }
106 };
107 
110  double angle;
111  double quality;
112  MVertex *n1, *n2, *n3, *n4;
113 
114  RecombineTriangle(const MEdge &me, MElement *_t1, MElement *_t2, Field *f);
115 
116  bool operator<(const RecombineTriangle &other) const
117  {
118  return quality < other.quality;
119  }
120 };
121 
122 #endif
buildVertexToElement
void buildVertexToElement(std::vector< T * > const &elements, v2t_cont &adj)
Definition: meshGFaceOptimize.h:38
RecombineTriangle::quality
double quality
Definition: meshGFaceOptimize.h:111
quadsToTriangles
void quadsToTriangles(GFace *gf, double minqual)
Definition: meshGFaceOptimize.cpp:1374
MVertexPtrLessThan
Definition: MVertex.h:218
swapquad::swapquad
swapquad(MVertex *v1, MVertex *v2, MVertex *v3, MVertex *v4)
Definition: meshGFaceOptimize.h:89
MEdge
Definition: MEdge.h:14
RecombineTriangle::n2
MVertex * n2
Definition: meshGFaceOptimize.h:112
GFace
Definition: GFace.h:33
MVertex
Definition: MVertex.h:24
RecombineTriangle
Definition: meshGFaceOptimize.h:108
bidimMeshData
Definition: meshGFaceDelaunayInsertion.h:23
edge_angle::angle
double angle
Definition: meshGFaceOptimize.h:24
recombineIntoQuads
void recombineIntoQuads(GFace *gf, bool blossom, int topologicalOptiPasses, bool nodeRepositioning, double minqual)
Definition: meshGFaceOptimize.cpp:1311
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
MVertex::getNum
std::size_t getNum() const
Definition: MVertex.h:86
swapquad
Definition: meshGFaceOptimize.h:75
buildEdgeToElement
void buildEdgeToElement(std::vector< T * > &eles, e2t_cont &adj)
Definition: meshGFaceOptimize.cpp:417
swapquad::v
int v[4]
Definition: meshGFaceOptimize.h:76
edge_angle::edge_angle
edge_angle(MVertex *_v1, MVertex *_v2, MElement *t1, MElement *t2)
Definition: meshGFaceOptimize.cpp:103
edge_angle::v2
MVertex * v2
Definition: meshGFaceOptimize.h:23
v2t_cont
std::map< MVertex *, std::vector< MElement * >, MVertexPtrLessThan > v2t_cont
Definition: meshGFaceOptimize.h:31
transferDataStructure
void transferDataStructure(GFace *gf, std::set< MTri3 *, compareTri3Ptr > &AllTris, bidimMeshData &DATA)
Definition: meshGFaceOptimize.cpp:348
MEdgeLessThan
Definition: MEdge.h:122
RecombineTriangle::RecombineTriangle
RecombineTriangle(const MEdge &me, MElement *_t1, MElement *_t2, Field *f)
Definition: meshGFaceOptimize.cpp:37
GVertex
Definition: GVertex.h:23
edge_angle::v1
MVertex * v1
Definition: meshGFaceOptimize.h:23
RecombineTriangle::angle
double angle
Definition: meshGFaceOptimize.h:110
meshGFaceDelaunayInsertion.h
e2t_cont
std::map< MEdge, std::pair< MElement *, MElement * >, MEdgeLessThan > e2t_cont
Definition: meshGFaceOptimize.h:35
RecombineTriangle::t2
MElement * t2
Definition: meshGFaceOptimize.h:109
MElement
Definition: MElement.h:30
Field
Definition: Field.h:103
swapquad::operator<
bool operator<(const swapquad &o) const
Definition: meshGFaceOptimize.h:77
buildMeshGenerationDataStructures
bool buildMeshGenerationDataStructures(GFace *gf, std::set< MTri3 *, compareTri3Ptr > &AllTris, bidimMeshData &data)
Definition: meshGFaceOptimize.cpp:174
MEdge.h
edge_angle::operator<
bool operator<(const edge_angle &other) const
Definition: meshGFaceOptimize.h:26
computeEquivalences
void computeEquivalences(GFace *gf, bidimMeshData &DATA)
Definition: meshGFaceOptimize.cpp:271
RecombineTriangle::n1
MVertex * n1
Definition: meshGFaceOptimize.h:112
splitElementsInBoundaryLayerIfNeeded
void splitElementsInBoundaryLayerIfNeeded(GFace *gf)
Definition: meshGFaceOptimize.cpp:1457
MElement.h
STensor3.h
buildEdgeToTriangle
void buildEdgeToTriangle(std::vector< MTriangle * > &, e2t_cont &adj)
Definition: meshGFaceOptimize.cpp:443
laplaceSmoothing
void laplaceSmoothing(GFace *gf, int niter=1, bool infinity_norm=false)
Definition: meshGFaceOptimize.cpp:978
RecombineTriangle::t1
MElement * t1
Definition: meshGFaceOptimize.h:109
RecombineTriangle::operator<
bool operator<(const RecombineTriangle &other) const
Definition: meshGFaceOptimize.h:116
RecombineTriangle::n3
MVertex * n3
Definition: meshGFaceOptimize.h:112
buildListOfEdgeAngle
void buildListOfEdgeAngle(e2t_cont adj, std::vector< edge_angle > &edges_detected, std::vector< edge_angle > &edges_lonly)
Definition: meshGFaceOptimize.cpp:455
swapquad::swapquad
swapquad(int const v1, int const v2, int const v3, int const v4)
Definition: meshGFaceOptimize.h:98
edge_angle
Definition: meshGFaceOptimize.h:22
buildEdgeToElements
void buildEdgeToElements(std::vector< MElement * > &tris, e2t_cont &adj)
Definition: meshGFaceOptimize.cpp:449
RecombineTriangle::n4
MVertex * n4
Definition: meshGFaceOptimize.h:112