gmsh-TingyuanDoc
0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
|
Go to the documentation of this file.
18 SVector3 a(p1->
x() - p2->
x(), p1->
y() - p2->
y(), p1->
z() - p2->
z());
19 SVector3 b(p3->
x() - p2->
x(), p3->
y() - p2->
y(), p3->
z() - p2->
z());
21 double sinA =
c.norm();
22 double cosA =
dot(a, b);
23 return std::atan2(sinA, cosA);
27 : _visible(1), _order(1), _x(x), _y(y), _z(
z), _ge(ge)
61 fprintf(fp,
"%ld %.16g %.16g %.16g ",
_index,
x() * scalingFactor,
62 y() * scalingFactor,
z() * scalingFactor);
66 fwrite(&i,
sizeof(
int), 1, fp);
67 double data[3] = {
x() * scalingFactor,
y() * scalingFactor,
69 fwrite(data,
sizeof(
double), 3, fp);
73 if(!
onWhat() || !saveParametric) {
77 fwrite(&zero,
sizeof(
int), 1, fp);
83 fprintf(fp,
"%d %d ", entity, dim);
85 fwrite(&entity,
sizeof(
int), 1, fp);
86 fwrite(&dim,
sizeof(
int), 1, fp);
90 if(!binary) fprintf(fp,
"\n");
96 fprintf(fp,
"%.16g\n", _u);
98 fwrite(&_u,
sizeof(
double), 1, fp);
105 fprintf(fp,
"%.16g %.16g\n", _u, _v);
107 fwrite(&_u,
sizeof(
double), 1, fp);
108 fwrite(&_v,
sizeof(
double), 1, fp);
113 fprintf(fp,
"0 0 0\n");
115 fwrite(&zero,
sizeof(
int), 1, fp);
116 fwrite(&zero,
sizeof(
int), 1, fp);
117 fwrite(&zero,
sizeof(
int), 1, fp);
125 double scalingFactor)
129 int myDim = 0, myTag = 0;
136 saveParametric =
false;
141 fprintf(fp,
"%ld %.16g %.16g %.16g\n",
_index,
x() * scalingFactor,
142 y() * scalingFactor,
z() * scalingFactor);
144 fprintf(fp,
"%ld %.16g %.16g %.16g %d %d",
_index,
x() * scalingFactor,
145 y() * scalingFactor,
z() * scalingFactor, myDim, myTag);
149 fwrite(&i,
sizeof(
int), 1, fp);
150 double data[3] = {
x() * scalingFactor,
y() * scalingFactor,
151 z() * scalingFactor};
152 fwrite(data,
sizeof(
double), 3, fp);
154 fwrite(&myDim,
sizeof(
int), 1, fp);
155 fwrite(&myTag,
sizeof(
int), 1, fp);
164 fprintf(fp,
" %.16g\n", _u);
166 fwrite(&_u,
sizeof(
double), 1, fp);
168 else if(myDim == 2) {
173 fprintf(fp,
" %.16g %.16g\n", _u, _v);
175 fwrite(&_u,
sizeof(
double), 1, fp);
176 fwrite(&_v,
sizeof(
double), 1, fp);
188 fprintf(fp,
"%.16g %.16g %.16g\n",
x(),
y(),
z());
195 fprintf(fp,
"%.16g %.16g %.16g,\n",
x() * scalingFactor,
y() * scalingFactor,
196 z() * scalingFactor);
200 double scalingFactor)
205 int displacement_coord_sys = 1;
207 fprintf(fp,
"%10ld%10d%10d%10d\n",
_index, coord_sys, displacement_coord_sys,
210 if(officialExponentFormat) {
213 sprintf(tmp,
"%25.16E%25.16E%25.16E\n",
x() * scalingFactor,
214 y() * scalingFactor,
z() * scalingFactor);
215 for(std::size_t i = 0; i < strlen(tmp); i++)
216 if(tmp[i] ==
'E') tmp[i] =
'D';
217 fprintf(fp,
"%s", tmp);
220 fprintf(fp,
"%25.16E%25.16E%25.16E\n",
x() * scalingFactor,
221 y() * scalingFactor,
z() * scalingFactor);
231 double data[3] = {
x() * scalingFactor,
y() * scalingFactor,
232 z() * scalingFactor};
234 if(!bigEndian)
SwapBytes((
char *)data,
sizeof(
double), 3);
235 fwrite(data,
sizeof(
double), 3, fp);
238 fprintf(fp,
"%.16g %.16g %.16g\n",
x() * scalingFactor,
y() * scalingFactor,
239 z() * scalingFactor);
244 double scalingFactor)
248 Msg::Warning(
"Binary format not available for Matlab, saving in ASCII");
251 fprintf(fp,
"%.16g %.16g %.16g;\n",
x() * scalingFactor,
y() * scalingFactor,
252 z() * scalingFactor);
259 fprintf(fp,
"node %ld %.16g %.16g\n",
_index,
x() * scalingFactor,
260 y() * scalingFactor);
263 fprintf(fp,
"node %ld %.16g %.16g %.16g\n",
_index,
x() * scalingFactor,
264 y() * scalingFactor,
z() * scalingFactor);
267 fprintf(fp,
"node %ld %.16g\n",
_index,
x() * scalingFactor);
270 fprintf(fp,
"ERROR -- unsupported dimension: %d\n", dim);
278 fprintf(fp,
" %20.14G %20.14G %20.14G %d\n",
279 x() * scalingFactor,
y() * scalingFactor,
z() * scalingFactor,
287 fprintf(fp,
"%g %g %g\n",
x() * scalingFactor,
y() * scalingFactor,
288 z() * scalingFactor);
297 fprintf(fp,
"%10ld%20.11e%20.11e%20.11e\n",
_index,
x() * scalingFactor,
298 y() * scalingFactor,
z() * scalingFactor);
301 fprintf(fp,
"%10ld%20.11e%20.11e\n",
_index,
x() * scalingFactor,
302 y() * scalingFactor);
304 case 1: fprintf(fp,
"%10ld%20.11e\n",
_index,
x() * scalingFactor);
break;
311 sprintf(str,
"%.2E", val);
312 else if(val >= 1.e-3)
313 sprintf(str,
"%f", val);
315 sprintf(str,
"%.2E", val);
316 else if(val >= -1.e-3)
317 sprintf(str,
"%.1E", val);
318 else if(val >= -1.e6)
319 sprintf(str,
"%f", val);
321 sprintf(str,
"%.1E", val);
326 if(strlen(str) == 9 && (str[4] ==
'E' || str[5] ==
'E')) {
339 char xs[17], ys[17], zs[17];
340 double x1 =
x() * scalingFactor;
341 double y1 =
y() * scalingFactor;
342 double z1 =
z() * scalingFactor;
348 fprintf(fp,
"GRID,%ld,%d,%s,%s,%s\n",
_index, 0, xs, ys, zs);
350 else if(format == 1) {
355 fprintf(fp,
"GRID %-8ld%-8d%-8s%-8s%-8s\n",
_index, 0, xs, ys, zs);
359 fprintf(fp,
"GRID* %-16ld%-16d%-16.9G%-16.9G\n",
_index, 0, x1, y1);
360 fprintf(fp,
"* %-16.9G\n", z1);
368 fprintf(fp,
"%ld, %.14g, %.14g, %.14g\n",
_index,
x() * scalingFactor,
369 y() * scalingFactor,
z() * scalingFactor);
376 fprintf(fp,
"%ld, %.12g, %.12g, %.12g\n",
_index,
x() * scalingFactor,
377 y() * scalingFactor,
z() * scalingFactor);
384 fprintf(fp,
"%10ld%20g%20g%20g\n",
_index,
x() * scalingFactor,
385 y() * scalingFactor,
z() * scalingFactor);
392 fprintf(fp,
" %ld ( %25.16E , %25.16E , %25.16E )",
_index,
393 x() * scalingFactor,
y() * scalingFactor,
z() * scalingFactor);
401 fprintf(fp,
"%.16g %.16g %ld\n",
x() * scalingFactor,
y() * scalingFactor,
404 fprintf(fp,
"%.16g %.16g %.16g %ld\n",
x() * scalingFactor,
405 y() * scalingFactor,
z() * scalingFactor,
_index - 1);
426 std::vector<SPoint2> ¶ms)
437 std::vector<GEdge *>
const &ed = gv->
edges();
439 for(
auto it = ed.begin(); it != ed.end(); it++) {
440 if((*it)->isSeam(gf)) {
442 if(gv == (*it)->getBeginVertex()) {
443 params.push_back((*it)->reparamOnFace(gf, range.
low(), -1));
444 params.push_back((*it)->reparamOnFace(gf, range.
low(), 1));
446 if(gv == (*it)->getEndVertex()) {
447 params.push_back((*it)->reparamOnFace(gf, range.
high(), -1));
448 params.push_back((*it)->reparamOnFace(gf, range.
high(), 1));
450 if(gv != (*it)->getBeginVertex() && gv != (*it)->getEndVertex()) {
470 params.push_back(
SPoint2(UU, VV));
477 std::vector<SPoint2> p1, p2;
480 if(p1.size() == 1 && p2.size() == 1) {
484 else if(p1.size() >= 1 && p2.size() >= 1) {
488 double d = (p2[0].x() - p1[0].x()) * (p2[0].x() - p1[0].x()) +
489 (p2[0].y() - p1[0].y()) * (p2[0].y() - p1[0].y());
490 for(std::size_t i = 0; i < p2.size(); i++) {
491 double d1 = (p2[i].x() - p1[0].x()) * (p2[i].x() - p1[0].x()) +
492 (p2[i].y() - p1[0].y()) * (p2[i].y() - p1[0].y());
500 double d = (p2[0].x() - p1[0].x()) * (p2[0].x() - p1[0].x()) +
501 (p2[0].y() - p1[0].y()) * (p2[0].y() - p1[0].y());
502 for(std::size_t i = 0; i < p1.size(); i++) {
503 double d1 = (p2[0].x() - p1[i].x()) * (p2[0].x() - p1[i].x()) +
504 (p2[0].y() - p1[i].y()) * (p2[0].y() - p1[i].y());
523 bool onSurface,
bool failOnSeam,
int dir)
526 Msg::Error(
"Mesh node %d is not classified: cannot reparametrize",
552 std::vector<GEdge *>
const &ed = gv->
edges();
553 for(
auto it = ed.begin(); it != ed.end(); it++)
554 if((*it)->isSeam(gf))
return false;
568 Msg::Warning(
"No parametric coordinate on node %d classified on curve %d",
576 if(ge->
isSeam(gf))
return false;
598 param = bounds.
low();
600 param = bounds.
high();
604 if(!ok || param == 1.e6)
607 if(param < 1.e6)
return true;
SVector3 crossprod(const SVector3 &a, const SVector3 &b)
std::size_t incrementAndGetMaxVertexNumber()
void writeRAD(FILE *fp, double scalingFactor=1.0)
void decrementMaxVertexNumber()
virtual SPoint2 reparamOnFace(const GFace *face, double epar, int dir) const
double dot(const SVector3 &a, const SMetric3 &m, const SVector3 &b)
void writeVRML(FILE *fp, double scalingFactor=1.0)
bool operator()(const MVertex *v1, const MVertex *v2) const
void writeUNV(FILE *fp, bool officialExponentFormat, double scalingFactor=1.0)
void writeINP(FILE *fp, double scalingFactor=1.0)
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
static void Warning(const char *fmt,...)
static void Error(const char *fmt,...)
bool reparamMeshVertexOnFace(MVertex const *v, const GFace *gf, SPoint2 ¶m, bool onSurface, bool failOnSeam, int dir)
std::size_t getNum() const
virtual std::vector< GEdge * > const & edges() const
virtual ModelType getNativeType() const
static void getAllParameters(MVertex *v, GFace *gf, std::vector< SPoint2 > ¶ms)
std::size_t getMaxVertexNumber() const
void setMaxVertexNumber(std::size_t num)
bool reparamMeshVertexOnEdge(MVertex *v, const GEdge *ge, double ¶m)
void writeMESH(FILE *fp, double scalingFactor=1.0)
void SwapBytes(char *array, int size, int n)
std::vector< MVertex * > mesh_vertices
void writeBDF(FILE *fp, int format=0, double scalingFactor=1.0)
void writeVTK(FILE *fp, bool binary=false, double scalingFactor=1.0, bool bigEndian=false)
bool reparamMeshEdgeOnFace(MVertex *v1, MVertex *v2, GFace *gf, SPoint2 ¶m1, SPoint2 ¶m2)
virtual GVertex * getBeginVertex() const
void writeNEU(FILE *fp, int dim, double scalingFactor=1.0)
virtual SPoint2 parFromPoint(const SPoint3 &, bool onSurface=true, bool convTestXYZ=false) const
virtual GeomType geomType() const
void writeSU2(FILE *fp, int dim, double scalingFactor=1.0)
void writeMATLAB(FILE *fp, int type, bool binary, double scalingFactor=1.0)
static double getTolerance()
virtual bool isSeam(const GFace *face) const
void writeMSH2(FILE *fp, bool binary=false, bool saveParametric=false, double scalingFactor=1.0)
double angle3Vertices(const MVertex *p1, const MVertex *p2, const MVertex *p3)
void writeMSH(FILE *fp, bool binary=false, bool saveParametric=false, double scalingFactor=1.0)
void forceNum(std::size_t num)
virtual bool getParameter(int i, double &par) const
virtual Range< double > parBounds(int i) const =0
void writeKEY(FILE *fp, double scalingFactor=1.0)
void writeTOCHNOG(FILE *fp, int dim, double scalingFactor=1.0)
static void double_to_char8(double val, char *str)
virtual SPoint2 reparamOnFace(const GFace *gf, int) const
void writeOFF(FILE *fp, double scalingFactor=1.0)
virtual GVertex * getEndVertex() const
void writeDIFF(FILE *fp, bool binary, double scalingFactor=1.0)
virtual double parFromPoint(const SPoint3 &P) const
MVertex(double x, double y, double z, GEntity *ge=nullptr, std::size_t num=0)
static GModel * current(int index=-1)
virtual bool haveParametrization()