gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
gmshSurface.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 GMSH_SURFACE_H
7 #define GMSH_SURFACE_H
8 
9 #include <cmath>
10 #include <cstdio>
11 #include <map>
12 #include "Pair.h"
13 #include "Range.h"
14 #include "SPoint2.h"
15 #include "SPoint3.h"
16 #include "SVector3.h"
17 #include "SBoundingBox3d.h"
18 #include "Numeric.h"
19 
20 class mathEvaluator;
21 
22 class gmshSurface {
23 protected:
24  static std::map<int, gmshSurface *> allGmshSurfaces;
25 
26 public:
27  // there are points define in this surface parameterization
29  virtual ~gmshSurface() {}
30  static void reset()
31  {
32  auto it = allGmshSurfaces.begin();
33  for(; it != allGmshSurfaces.end(); ++it) {
34  if(!it->second->vertex_defined_on_surface) delete it->second;
35  }
36  allGmshSurfaces.clear();
37  };
38  static int maxTag()
39  {
40  int t = 0;
41  for(auto p : allGmshSurfaces) t = std::max(t, p.first);
42  return t;
43  }
44  static gmshSurface *getSurface(int tag);
45  virtual Range<double> parBounds(int i) const = 0;
46  // Underlying geometric representation of this entity.
56  };
58  virtual SPoint3 point(double par1, double par2) const = 0;
59  virtual SPoint3 point(const SPoint2 &p) const { return point(p.x(), p.y()); }
60  virtual SPoint2 parFromPoint(double x, double y, double z);
61  // Return the normal to the face at the given parameter location.
62  virtual SVector3 normal(const SPoint2 &param) const;
63  // Return the first derivate of the face at the parameter location.
64  virtual Pair<SVector3, SVector3> firstDer(const SPoint2 &param);
65  virtual double getMetricEigenvalue(const SPoint2 &);
66 };
67 
68 class gmshSphere : public gmshSurface {
69 private:
70  double xc, yc, zc, r;
71  gmshSphere(double _x, double _y, double _z, double _r)
72  : xc(_x), yc(_y), zc(_z), r(_r)
73  {
74  }
75 
76 public:
77  static gmshSurface *NewSphere(int _iSphere, double _x, double _y, double _z,
78  double _r);
79  virtual Range<double> parBounds(int i) const
80  {
81  if(i == 0)
82  return Range<double>(0., 2 * M_PI);
83  else
84  return Range<double>(0., M_PI);
85  }
87  {
88  return gmshSurface::Sphere;
89  }
90  using gmshSurface::point;
91  virtual SPoint3 point(double par1, double par2) const;
92  virtual SVector3 normal(const SPoint2 &param) const
93  {
94  SPoint3 p1 = gmshSurface::point(param);
95  SPoint3 p2(xc, yc, zc);
96  SVector3 n(p1, p2);
97  n.normalize();
98  return n;
99  }
100 };
101 
102 class gmshPolarSphere : public gmshSurface {
103 private:
104  double r;
106  gmshPolarSphere(double x, double y, double z, double _r);
107 
108 public:
109  static gmshSurface *NewPolarSphere(int _iSphere, double _x, double _y,
110  double _z, double _r);
111  virtual Range<double> parBounds(int i) const
112  {
113  if(i == 0)
114  return Range<double>(-M_PI, M_PI);
115  else
116  return Range<double>(-M_PI, M_PI);
117  }
119  {
121  }
122  using gmshSurface::point;
123  virtual SPoint3 point(double par1, double par2) const;
124  virtual SVector3 normal(const SPoint2 &param) const
125  {
126  SPoint3 p1 = gmshSurface::point(param);
127  SVector3 n(p1, o);
128  n.normalize();
129  return n;
130  }
131  virtual double getMetricEigenvalue(const SPoint2 &p)
132  {
133  double l = (4 * r * r) / (4 * r * r + p.x() * p.x() + p.y() * p.y());
134  return l * l;
135  }
136 };
137 
139 private:
141  gmshParametricSurface(const char *, const char *, const char *);
143 
144 public:
145  static gmshSurface *NewParametricSurface(int iSurf, const char *, const char *,
146  const char *);
147  virtual Range<double> parBounds(int i) const;
149  {
151  }
152  using gmshSurface::point;
153  virtual SPoint3 point(double par1, double par2) const;
154 };
155 
156 #endif
mathEvaluator
Definition: mathEvaluator.h:37
gmshPolarSphere::o
SPoint3 o
Definition: gmshSurface.h:105
SPoint2
Definition: SPoint2.h:12
gmshSphere::xc
double xc
Definition: gmshSurface.h:70
gmshPolarSphere::gmshPolarSphere
gmshPolarSphere(double x, double y, double z, double _r)
Definition: gmshSurface.cpp:83
gmshSurface::getSurface
static gmshSurface * getSurface(int tag)
Definition: gmshSurface.cpp:51
SPoint3
Definition: SPoint3.h:14
gmshPolarSphere::getMetricEigenvalue
virtual double getMetricEigenvalue(const SPoint2 &p)
Definition: gmshSurface.h:131
gmshSurface::point
virtual SPoint3 point(double par1, double par2) const =0
gmshParametricSurface::NewParametricSurface
static gmshSurface * NewParametricSurface(int iSurf, const char *, const char *, const char *)
Definition: gmshSurface.cpp:100
gmshSurface::parBounds
virtual Range< double > parBounds(int i) const =0
SVector3
Definition: SVector3.h:16
gmshSurface::getMetricEigenvalue
virtual double getMetricEigenvalue(const SPoint2 &)
Definition: gmshSurface.cpp:32
SVector3.h
gmshSphere
Definition: gmshSurface.h:68
gmshSurface::ParametricSurface
@ ParametricSurface
Definition: gmshSurface.h:54
gmshSphere::gmshSphere
gmshSphere(double _x, double _y, double _z, double _r)
Definition: gmshSurface.h:71
gmshSurface::vertex_defined_on_surface
bool vertex_defined_on_surface
Definition: gmshSurface.h:28
Pair.h
gmshSurface::Nurbs
@ Nurbs
Definition: gmshSurface.h:49
Range.h
gmshPolarSphere::geomType
virtual gmshSurface::gmshSurfaceType geomType() const
Definition: gmshSurface.h:118
gmshSurface::point
virtual SPoint3 point(const SPoint2 &p) const
Definition: gmshSurface.h:59
gmshSurface::parFromPoint
virtual SPoint2 parFromPoint(double x, double y, double z)
Definition: gmshSurface.cpp:13
gmshSurface::reset
static void reset()
Definition: gmshSurface.h:30
gmshSphere::yc
double yc
Definition: gmshSurface.h:70
gmshSphere::parBounds
virtual Range< double > parBounds(int i) const
Definition: gmshSurface.h:79
gmshParametricSurface::gmshParametricSurface
gmshParametricSurface(const char *, const char *, const char *)
Definition: gmshSurface.cpp:114
gmshSurface::Cylinder
@ Cylinder
Definition: gmshSurface.h:50
gmshSurface::firstDer
virtual Pair< SVector3, SVector3 > firstDer(const SPoint2 &param)
Definition: gmshSurface.cpp:26
gmshParametricSurface::parBounds
virtual Range< double > parBounds(int i) const
Definition: gmshSurface.cpp:147
Range
Definition: Range.h:10
gmshSphere::r
double r
Definition: gmshSurface.h:70
gmshPolarSphere::normal
virtual SVector3 normal(const SPoint2 &param) const
Definition: gmshSurface.h:124
gmshSurface
Definition: gmshSurface.h:22
gmshParametricSurface::point
virtual SPoint3 point(double par1, double par2) const
Definition: gmshSurface.cpp:136
gmshSurface::maxTag
static int maxTag()
Definition: gmshSurface.h:38
SBoundingBox3d.h
gmshSurface::allGmshSurfaces
static std::map< int, gmshSurface * > allGmshSurfaces
Definition: gmshSurface.h:24
Numeric.h
gmshSurface::Plane
@ Plane
Definition: gmshSurface.h:48
gmshSphere::NewSphere
static gmshSurface * NewSphere(int _iSphere, double _x, double _y, double _z, double _r)
Definition: gmshSurface.cpp:38
gmshSurface::~gmshSurface
virtual ~gmshSurface()
Definition: gmshSurface.h:29
gmshSurface::geomType
virtual gmshSurface::gmshSurfaceType geomType() const =0
gmshParametricSurface::geomType
virtual gmshSurface::gmshSurfaceType geomType() const
Definition: gmshSurface.h:148
gmshParametricSurface
Definition: gmshSurface.h:138
gmshSphere::normal
virtual SVector3 normal(const SPoint2 &param) const
Definition: gmshSurface.h:92
gmshSurface::Sphere
@ Sphere
Definition: gmshSurface.h:51
gmshPolarSphere::point
virtual SPoint3 point(double par1, double par2) const
Definition: gmshSurface.cpp:88
gmshPolarSphere
Definition: gmshSurface.h:102
SPoint2::x
double x(void) const
Definition: SPoint2.h:86
gmshSphere::point
virtual SPoint3 point(double par1, double par2) const
Definition: gmshSurface.cpp:61
z
const double z
Definition: GaussQuadratureQuad.cpp:56
gmshSurface::Torus
@ Torus
Definition: gmshSurface.h:53
gmshPolarSphere::r
double r
Definition: gmshSurface.h:104
Pair
Definition: Pair.h:10
gmshSurface::PolarSphere
@ PolarSphere
Definition: gmshSurface.h:55
gmshSurface::gmshSurfaceType
gmshSurfaceType
Definition: gmshSurface.h:47
gmshPolarSphere::parBounds
virtual Range< double > parBounds(int i) const
Definition: gmshSurface.h:111
gmshSurface::normal
virtual SVector3 normal(const SPoint2 &param) const
Definition: gmshSurface.cpp:20
gmshParametricSurface::~gmshParametricSurface
~gmshParametricSurface()
Definition: gmshSurface.cpp:131
SPoint3.h
gmshSurface::Cone
@ Cone
Definition: gmshSurface.h:52
gmshSphere::zc
double zc
Definition: gmshSurface.h:70
gmshSphere::geomType
virtual gmshSurface::gmshSurfaceType geomType() const
Definition: gmshSurface.h:86
gmshParametricSurface::_f
mathEvaluator * _f
Definition: gmshSurface.h:140
SVector3::normalize
double normalize()
Definition: SVector3.h:38
SPoint2.h
SPoint2::y
double y(void) const
Definition: SPoint2.h:88
gmshPolarSphere::NewPolarSphere
static gmshSurface * NewPolarSphere(int _iSphere, double _x, double _y, double _z, double _r)
Definition: gmshSurface.cpp:70