gmsh-TingyuanDoc
0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
Go to the documentation of this file.
6 #include "GmshConfig.h"
14 #if defined(HAVE_MESH)
33 static const int vv[4] = {2, 3, 0, 1};
35 SVector3 t1(x[1] - x[0], y[1] - y[0],
z[1] -
z[0]);
36 SVector3 t2(v2->
x() - x[0], v2->
y() - y[0], v2->
z() -
z[0]);
70 double mn = 2. * m * n;
71 double abcd = a * a - b * b +
c *
c - d * d;
72 return sqrt(mn * mn - abcd * abcd) / 4.;
90 int ie = num / numSubEdges;
91 int isub = num % numSubEdges;
92 double xi1 = -1. + (2. * isub) / numSubEdges;
93 double xi2 = -1. + (2. * (isub + 1)) / numSubEdges;
97 q->
pnt(xi1, -1., 0., pnt1);
98 q->
pnt(xi2, -1., 0., pnt2);
101 q->
pnt(1., xi1, 0., pnt1);
102 q->
pnt(1., xi2, 0., pnt2);
105 q->
pnt(xi1, 1., 0., pnt1);
106 q->
pnt(xi2, 1., 0., pnt2);
109 q->
pnt(-1., xi1, 0., pnt1);
110 q->
pnt(-1., xi2, 0., pnt2);
160 #if defined(HAVE_VISUDEV)
171 return curved ? 2 * std::pow(
CTX::instance()->mesh.numSubEdges, 2) :
177 return curved ? 2 * std::pow(
CTX::instance()->mesh.numSubEdges, 2) :
183 return curved ? 2 * std::pow(
CTX::instance()->mesh.numSubEdges, 2) :
191 int ix = (num / 2) / numSubEdges;
192 int iy = (num / 2) % numSubEdges;
194 const double d = 2. / numSubEdges;
195 const double ox = -1. + d * ix;
196 const double oy = -1. + d * iy;
199 double J1[3][3], J2[3][3], J3[3][3];
201 t->
pnt(ox, oy, 0, pnt1);
202 t->
pnt(ox + d, oy, 0, pnt2);
203 t->
pnt(ox + d, oy + d, 0, pnt3);
209 t->
pnt(ox, oy, 0, pnt1);
210 t->
pnt(ox + d, oy + d, 0, pnt2);
211 t->
pnt(ox, oy + d, 0, pnt3);
217 SVector3 d1(J1[0][0], J1[0][1], J1[0][2]);
218 SVector3 d2(J1[1][0], J1[1][1], J1[1][2]);
223 SVector3 d1(J2[0][0], J2[0][1], J2[0][2]);
224 SVector3 d2(J2[1][0], J2[1][1], J2[1][2]);
229 SVector3 d1(J3[0][0], J3[0][1], J3[0][2]);
230 SVector3 d2(J3[1][0], J3[1][1], J3[1][2]);
249 #if defined(HAVE_VISUDEV)
250 static const int fquad[4][4] = {
251 {0, 1, 2, 3}, {1, 2, 3, 0}, {2, 3, 0, 1}, {3, 0, 1, 2}};
263 static const int f[2][3] = {{0, 1, 2}, {0, 2, 3}};
302 #if defined(HAVE_MESH)
311 #if defined(HAVE_MESH)
320 #if defined(HAVE_MESH)
335 #if defined(HAVE_LAPACK) || defined(HAVE_EIGEN)
337 double x[4] = {
_v[0]->
x(),
_v[1]->
x(),
_v[2]->
x(),
_v[3]->
x()};
338 double y[4] = {
_v[0]->
y(),
_v[1]->
y(),
_v[2]->
y(),
_v[3]->
y()};
339 double z[4] = {
_v[0]->
z(),
_v[1]->
z(),
_v[2]->
z(),
_v[3]->
z()};
345 double xm = (x[0] + x[1] + x[2] + x[3]) / 4;
346 double ym = (y[0] + y[1] + y[2] + y[3]) / 4;
347 double zm = (
z[0] +
z[1] +
z[2] +
z[3]) / 4;
352 for(
int i = 0; i < 4; i++) {
364 if(fabs(svd[0]) < fabs(svd[1]) && fabs(svd[0]) < fabs(svd[2]))
366 else if(fabs(svd[1]) < fabs(svd[0]) && fabs(svd[1]) < fabs(svd[2]))
370 double a = V(0, min);
371 double b = V(1, min);
372 double c = V(2, min);
374 double d = -(xm * a + ym * b + zm *
c);
376 double norm = sqrt(a * a + b * b +
c *
c);
380 double xp[4], yp[4], zp[4];
382 for(
int i = 0; i < 4; i++) {
384 ((b * b +
c *
c) * x[i] - a * b * y[i] - a *
c *
z[i] - d * a) /
norm;
386 (-a * b * x[i] + (a * a +
c *
c) * y[i] - b *
c *
z[i] - d * b) /
norm;
388 (-a *
c * x[i] - b *
c * y[i] + (a * a + b * b) *
z[i] - d *
c) /
norm;
395 double xn[4], yn[4], r[4];
402 for(
int j = 0; j < 4; j++) {
404 if(r[j] < R) { R = r[j]; }
430 double d =
D.distance(A);
433 double s = a + b +
c + d;
434 double halfs = 0.5 * s;
436 return 0.25 * sqrt((a *
c + b * d) * (a * d + b *
c) * (a * b +
c * d) /
437 ((halfs - a) * (halfs - b) * (halfs -
c) * (halfs - d)));
448 int npts =
_order - 1, base = 0;
449 auto begin =
_vs.begin() + base;
452 std::reverse(begin, begin + 4 * npts);
456 _vs[base + 1] =
_vs[base + 3];
460 begin =
_vs.begin() + base + 4;
468 for(
int i = 0; i < 4; i++) tmp[i] =
_v[(4 - i + rot) % 4];
470 for(
int i = 0; i < 4; i++) tmp[i] =
_v[(4 + i - rot) % 4];
471 std::memcpy(
_v, tmp, 4 *
sizeof(
MVertex *));
476 if(rot == 0 && !
swap)
return;
481 for(
int i = 0; i < 4; i++) tmp[i] =
_vs[(7 - i + rot) % 4];
483 for(
int i = 0; i < 4; i++) tmp[i] =
_vs[(4 + i - rot) % 4];
489 if(rot == 0 && !
swap)
return;
494 for(
int i = 0; i < 4; i++) tmp[i] =
_vs[(7 - i + rot) % 4];
496 for(
int i = 0; i < 4; i++) tmp[i] =
_vs[(4 + i - rot) % 4];
500 std::map<TupleReorientation, IndicesReoriented>
504 void _getIndicesReorientedQuad(
int order,
int rot,
bool swap,
508 ref.
add(-order / 2.);
510 indices.resize(ref.
size1());
511 for(
int i = 0; i < ref.
size1(); ++i) {
512 double u = ref(i, 0);
513 double v = ref(i, 1);
534 for(
int j = 0; j < ref.
size1(); ++j) {
535 if(u == ref(j, 0) && v == ref(j, 1)) {
546 if(rot == 0 && !
swap)
return;
552 _getIndicesReorientedQuad(
_order, rot,
swap, indices);
560 std::vector<MVertex *> oldv(4 +
_vs.size());
565 for(
int i = 0; i < 4; ++i) {
_v[i] = oldv[indices[i]]; }
566 for(std::size_t i = 0; i <
_vs.size(); ++i) {
_vs[i] = oldv[indices[4 + i]]; }
571 const bool swap = sign == -1;
575 for(
int i = 0; i < 4; i++) vertices[i] =
_v[(4 - i + rot) % 4];
577 for(
int i = 0; i < 4; i++) vertices[i] =
_v[(4 + i - rot) % 4];
584 const bool swap = sign == -1;
588 for(
int i = 0; i < 4; i++) {
589 vertices[i] =
_v[(4 - i + rot) % 4];
590 vertices[4 + i] =
_vs[(7 - i + rot) % 4];
594 for(
int i = 0; i < 4; i++) {
595 vertices[i] =
_v[(4 + i - rot) % 4];
596 vertices[4 + i] =
_vs[(4 + i - rot) % 4];
604 const bool swap = sign == -1;
608 for(
int i = 0; i < 4; i++) {
609 vertices[i] =
_v[(4 - i + rot) % 4];
610 vertices[4 + i] =
_vs[(7 - i + rot) % 4];
614 for(
int i = 0; i < 4; i++) {
615 vertices[i] =
_v[(4 + i - rot) % 4];
616 vertices[4 + i] =
_vs[(4 + i - rot) % 4];
619 vertices[8] =
_vs[4];
625 const bool swap = sign == -1;
630 _getIndicesReorientedQuad(
_order, rot,
swap, indices);
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
virtual std::size_t getNum() const
virtual double getVolume()
SVector3 crossprod(const SVector3 &a, const SVector3 &b)
void add(const double &a)
void planarQuad_xyz2xy(double *x, double *y, double *z, double *xn, double *yn)
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
virtual MFaceN getHighOrderFace(int num, int sign, int rot)
static double eta(MQuadrangle *el)
static void _myGetFaceRep(MQuadrangle *t, int num, double *x, double *y, double *z, SVector3 *n, int numSubEdges)
static double gamma(MQuadrangle *el)
std::vector< MVertex * > _vs
virtual MVertex * getVertex(int num)
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
static void Error(const char *fmt,...)
void f(int n, double u, double *val)
static void _myGetEdgeRep(MQuadrangle *q, int num, double *x, double *y, double *z, SVector3 *n, int numSubEdges)
virtual MFaceN getHighOrderFace(int num, int sign, int rot)
virtual void getIntegrationPoints(int pOrder, int *npts, IntPt **pts)
virtual int getNumFacesRep(bool curved)
static int edges_quad(const int edge, const int vert)
virtual double getOuterRadius()
virtual int getNumFacesRep(bool curved)
virtual double angleShapeMeasure()
std::pair< int, std::pair< int, int > > TupleReorientation
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
virtual double gammaShapeMeasure()
virtual MFaceN getHighOrderFace(int num, int sign, int rot)
virtual int getNumEdgesRep(bool curved)
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
static std::map< TupleReorientation, IndicesReoriented > _tuple2indicesReoriented
std::vector< int > IndicesReoriented
virtual std::size_t getNumVertices() const
virtual void reorient(int rotation, bool swap)
virtual void reorient(int rotation, bool swap)
virtual int getType() const =0
virtual double getInnerRadius()
virtual int getNumFacesRep(bool curved)
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
void swap(double &a, double &b)
virtual double getVolume()
virtual MFaceN getHighOrderFace(int num, int sign, int rot)
void norm(const double *vec, double *norm)
int getNGQQPts(int order, bool forceTensorRule=false)
double computeInnerRadiusForQuad(double *x, double *y, int i)
virtual void getFaceRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
static bool _getFaceInfo(const MFace &face, const MFace &other, int &sign, int &rot)
virtual std::size_t getNumVertices() const
virtual bool getFaceInfo(const MFace &face, int &ithFace, int &sign, int &rot) const
virtual void reorient(int rotation, bool swap)
virtual MFace getFace(int num) const
IntPt * getGQQPts(int order, bool forceTensorRule=false)
virtual int numCommonNodesInDualGraph(const MElement *const other) const
virtual int getNumEdgesRep(bool curved)
virtual std::size_t getNumVertices() const
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
virtual int getNumEdgesRep(bool curved)
virtual void pnt(double u, double v, double w, SPoint3 &p) const
double distance(const SPoint3 &p) const
void _getFaceRep(MVertex *v0, MVertex *v1, MVertex *v2, double *x, double *y, double *z, SVector3 *n)
static double angles(MQuadrangle *e)
virtual int getNumFacesRep(bool curved)
void copy(const std::string &s, Iter oi)
virtual int getTypeForMSH() const
virtual double etaShapeMeasure()
virtual void reorient(int rotation, bool swap)
virtual double getJacobian(const fullMatrix< double > &gsf, double jac[3][3]) const
double distance(MVertex *const v)
virtual MVertex * getVertex(int num)
fullMatrix< double > gmshGenerateMonomialsQuadrangle(int order, bool forSerendipPoints)
virtual void getEdgeRep(bool curved, int num, double *x, double *y, double *z, SVector3 *n)
virtual std::size_t getNumVertices() const