gmsh-TingyuanDoc
0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
CurvedBndDist.cpp
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
#include "
GmshGlobal.h
"
7
#include "GmshConfig.h"
8
#include "
GModel.h
"
9
#include "
MElement.h
"
10
#include "
PViewDataList.h
"
11
#include "
BasisFactory.h
"
12
#include "
nodalBasis.h
"
13
#include "
CurvedBndDist.h
"
14
15
#if defined(HAVE_OPTHOM)
16
#include "IntegralBoundaryDist.h"
17
#endif
18
19
extern
"C"
{
20
GMSH_Plugin
*
GMSH_RegisterCurvedBndDistPlugin
()
21
{
22
return
new
GMSH_CurvedBndDistPlugin
();
23
}
24
}
25
26
std::string
GMSH_CurvedBndDistPlugin::getHelp
()
const
27
{
28
return
"Plugin(CurvedBndDist) ..."
;
29
}
30
31
#if defined(HAVE_OPTHOM)
32
33
static
void
addLine(
PViewDataList
*data,
const
SVector3
&p0,
const
SVector3
&p1,
34
double
v0,
double
v1)
35
{
36
data->
NbSL
++;
37
data->
SL
.push_back(p0.
x
());
38
data->
SL
.push_back(p1.
x
());
39
data->
SL
.push_back(p0.
y
());
40
data->
SL
.push_back(p1.
y
());
41
data->
SL
.push_back(p0.
z
());
42
data->
SL
.push_back(p1.
z
());
43
data->
SL
.push_back(v0);
44
data->
SL
.push_back(v1);
45
}
46
47
/*
48
static void addQua(PViewDataList *data, const SVector3 &p0, const SVector3
49
&p1, const SVector3 &p2, const SVector3 &p3, double v)
50
{
51
data->NbSQ ++;
52
data->SQ.push_back(p0.x()); data->SQ.push_back(p1.x());
53
data->SQ.push_back(p2.x()); data->SQ.push_back(p3.x());
54
data->SQ.push_back(p0.y()); data->SQ.push_back(p1.y());
55
data->SQ.push_back(p2.y()); data->SQ.push_back(p3.y());
56
data->SQ.push_back(p0.z()); data->SQ.push_back(p1.z());
57
data->SQ.push_back(p2.z()); data->SQ.push_back(p3.z()); data->SQ.push_back(v);
58
data->SQ.push_back(v); data->SQ.push_back(v); data->SQ.push_back(v);
59
}
60
61
static void addPoint(PViewDataList *data, const SVector3 &p0, double v0)
62
{
63
data->NbSP ++;
64
data->SP.push_back(p0.x());
65
data->SP.push_back(p0.y());
66
data->SP.push_back(p0.z());
67
data->SP.push_back(v0);
68
}
69
70
static void addVP(PViewDataList *data, const SVector3 p0, SVector3 v)
71
{
72
data->NbVP ++;
73
data->VP.push_back(p0.x());
74
data->VP.push_back(p0.y());
75
data->VP.push_back(p0.z());
76
data->VP.push_back(v.x());
77
data->VP.push_back(v.y());
78
data->VP.push_back(v.z());
79
}
80
*/
81
82
#include <limits>
83
static
void
drawElementDist(
PViewDataList
*data,
GEdge
*edge,
84
const
std::vector<MVertex *> &vertices,
85
const
nodalBasis
&basis)
86
{
87
std::vector<double> gradient;
88
std::vector<double> param(vertices.size());
89
std::vector<bool> onEdge(vertices.size());
90
std::vector<SPoint3> xyz(vertices.size());
91
for
(
size_t
i = 0; i < vertices.size(); ++i) {
92
MVertex
*v = vertices[i];
93
reparamMeshVertexOnEdge
(v, edge, param[i]);
94
onEdge[i] = v->
onWhat
() == edge;
95
xyz[i] = v->
point
();
96
}
97
parametricLineGEdge line0(edge, param[0], param[1]);
98
parametricLineNodalBasis line1(basis, xyz);
99
{
100
SPoint3
p, p1;
101
line0.hausdorffDistance(line1, p, p1);
102
addLine(data, p, p1, 0., 1);
103
}
104
}
105
106
/*
107
static void drawElement(PViewDataList *data, GEdge *edge,
108
const std::vector<MVertex *>&vertices, const
109
nodalBasis &basis)
110
{
111
std::vector<double> gradient;
112
std::vector<double> param(vertices.size());
113
std::vector<bool> onEdge(vertices.size());
114
std::vector<SPoint3> xyz(vertices.size());
115
for (size_t i = 0; i < vertices.size(); ++i) {
116
MVertex *v = vertices[i];
117
reparamMeshVertexOnEdge(v, edge, param[i]);
118
onEdge[i] = v->onWhat() == edge;
119
xyz[i] = v->point();
120
}
121
computeBndDistAndGradient(edge, param, vertices, basis, xyz, onEdge,
122
gradient,1.e-6); for (size_t i = 0; i < vertices.size(); ++i) { double t0;
123
reparamMeshVertexOnEdge(vertices[i], edge, t0);
124
SPoint3 p = vertices[i]->point();
125
GPoint gpt = edge->point(t0 + 1e-8);
126
SPoint3 pt(gpt.x(), gpt.y(), gpt.z());
127
SVector3 t = (pt - p);
128
t.normalize();
129
//addPoint(data, p, 0);
130
addVP(data, p, t * (-gradient[i]));
131
}
132
}
133
*/
134
135
#endif
136
137
PView
*
GMSH_CurvedBndDistPlugin::execute
(
PView
*v)
138
{
139
#if defined(HAVE_OPTHOM)
140
PView
*pv =
new
PView
();
141
PViewDataList
*data =
getDataList
(pv);
142
data->
Time
.push_back(0.);
143
GModel
*m =
GModel::current
();
144
for
(
auto
iface = m->
firstFace
(); iface != m->
lastFace
(); ++iface) {
145
GFace
*face = *iface;
146
for
(
size_t
iElement = 0; iElement < face->
getNumMeshElements
();
147
++iElement) {
148
MElement
*
element
= face->
getMeshElement
(iElement);
149
const
nodalBasis
&elbasis = *
element
->getFunctionSpace();
150
for
(
int
iEdge = 0; iEdge <
element
->
getNumEdges
(); ++iEdge) {
151
int
clId = elbasis.
getClosureId
(iEdge, 1);
152
const
std::vector<int> &closure = elbasis.
closures
[clId];
153
std::vector<MVertex *> vertices;
154
GEdge
*edge =
nullptr
;
155
for
(
size_t
i = 0; i < closure.size(); ++i) {
156
MVertex
*v =
element
->getVertex(closure[i]);
157
vertices.push_back(v);
158
if
((
int
)i >= 2 && v->
onWhat
() && v->
onWhat
()->
dim
() == 1) {
159
edge = v->
onWhat
()->
cast2Edge
();
160
}
161
}
162
if
(edge) {
163
drawElementDist(
164
data, edge, vertices,
165
*
BasisFactory::getNodalBasis
(elbasis.
getClosureType
(clId)));
166
}
167
}
168
}
169
}
170
data->
finalize
();
171
return
pv;
172
#else
173
Msg::Error
(
"Plugin requires OPTHOM module"
);
174
return
v;
175
#endif
176
}
PView
Definition:
PView.h:27
GFace
Definition:
GFace.h:33
GMSH_Plugin
Definition:
Plugin.h:26
PViewDataList
Definition:
PViewDataList.h:17
MVertex
Definition:
MVertex.h:24
nodalBasis.h
Msg::Error
static void Error(const char *fmt,...)
Definition:
GmshMessage.cpp:482
SPoint3
Definition:
SPoint3.h:14
SVector3
Definition:
SVector3.h:16
MVertex::onWhat
GEntity * onWhat() const
Definition:
MVertex.h:82
MVertex::point
SPoint3 point() const
Definition:
MVertex.h:67
GMSH_CurvedBndDistPlugin::execute
PView * execute(PView *)
Definition:
CurvedBndDist.cpp:137
reparamMeshVertexOnEdge
bool reparamMeshVertexOnEdge(MVertex *v, const GEdge *ge, double ¶m)
Definition:
MVertex.cpp:592
GMSH_RegisterCurvedBndDistPlugin
GMSH_Plugin * GMSH_RegisterCurvedBndDistPlugin()
Definition:
CurvedBndDist.cpp:20
GModel::lastFace
fiter lastFace()
Definition:
GModel.h:359
nodalBasis::getClosureId
int getClosureId(int iFace, int iSign=1, int iRot=0) const
Definition:
nodalBasis.h:86
BasisFactory::getNodalBasis
static const nodalBasis * getNodalBasis(int tag)
Definition:
BasisFactory.cpp:23
CurvedBndDist.h
GModel
Definition:
GModel.h:44
PViewDataList::SL
std::vector< double > SL
Definition:
PViewDataList.h:29
PViewDataList.h
GModel::firstFace
fiter firstFace()
Definition:
GModel.h:355
nodalBasis::getClosureType
virtual int getClosureType(int id) const
Definition:
nodalBasis.h:73
PViewDataList::finalize
bool finalize(bool computeMinMax=true, const std::string &interpolationScheme="")
Definition:
PViewDataList.cpp:81
MElement
Definition:
MElement.h:30
GMSH_CurvedBndDistPlugin::getHelp
std::string getHelp() const
Definition:
CurvedBndDist.cpp:26
GMSH_CurvedBndDistPlugin
Definition:
CurvedBndDist.h:15
SVector3::x
double x(void) const
Definition:
SVector3.h:30
element
Definition:
shapeFunctions.h:12
GmshGlobal.h
GFace::getMeshElement
MElement * getMeshElement(std::size_t index) const
Definition:
GFace.cpp:234
PViewDataList::NbSL
int NbSL
Definition:
PViewDataList.h:28
nodalBasis
Definition:
nodalBasis.h:12
nodalBasis::closures
clCont closures
Definition:
nodalBasis.h:68
SVector3::y
double y(void) const
Definition:
SVector3.h:31
element::getNumEdges
virtual int getNumEdges()=0
MElement.h
GEdge
Definition:
GEdge.h:26
SVector3::z
double z(void) const
Definition:
SVector3.h:32
PViewDataList::Time
std::vector< double > Time
Definition:
PViewDataList.h:25
GModel.h
GEntity::cast2Edge
GEdge * cast2Edge()
Definition:
GEntity.cpp:123
GFace::getNumMeshElements
std::size_t getNumMeshElements() const
Definition:
GFace.cpp:181
GEntity::dim
virtual int dim() const
Definition:
GEntity.h:196
GModel::current
static GModel * current(int index=-1)
Definition:
GModel.cpp:136
GMSH_PostPlugin::getDataList
virtual PViewDataList * getDataList(PView *view, bool showError=true)
Definition:
Plugin.cpp:107
BasisFactory.h
src
plugin
CurvedBndDist.cpp
Generated by
1.8.18