gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
qualityMeasuresJacobian.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 QUALITY_MEASURES_JACOBIAN_H
7 #define QUALITY_MEASURES_JACOBIAN_H
8 
9 #include <stdio.h>
10 #include <vector>
11 
12 class bezierCoeff;
13 class MElement;
14 template <class scalar> class fullVector;
15 template <class scalar> class fullMatrix;
16 
17 namespace jacobianBasedQuality {
18 
19  void minMaxJacobianDeterminant(MElement *el, double &min, double &max,
20  const fullMatrix<double> *normals = nullptr,
21  bool debug = false);
22  double minIGEMeasure(MElement *el, bool knownValid = false,
23  bool reversedOk = false,
24  const fullMatrix<double> *normals = nullptr,
25  bool debug = false);
26  double minICNMeasure(MElement *el, bool knownValid = false,
27  bool reversedOk = false,
28  const fullMatrix<double> *normals = nullptr,
29  bool debug = false);
30  void sampleJacobianDeterminant(MElement *el, int order, double &min,
31  double &max,
32  const fullMatrix<double> *normals = nullptr);
33  void sampleIGEMeasure(MElement *el, int order, double &min, double &max);
34  void sampleICNMeasure(MElement *el, int order, double &min, double &max);
35  void sampleJacobianDeterminant(MElement *el, int order,
36  fullVector<double> &jac,
37  const fullMatrix<double> *normals = nullptr);
38  void sampleIGEMeasure(MElement *el, int order, fullVector<double> &ige);
39  void sampleICNMeasure(MElement *el, int order, fullVector<double> &icn);
40 
41  // For regression tests:
43  void testAllMeasures(MElement *el,
44  const fullMatrix<double> *normals = nullptr);
45 
46  class _coeffData {
47  protected:
48  double _minL, _maxL; // Extremum of measure at corners
49  double _minB, _maxB; // Extremum of measure
50 
51  public:
52  _coeffData() : _minL(0), _maxL(0), _minB(0), _maxB(0) {}
53  virtual ~_coeffData() {}
54 
55  inline double minL() const { return _minL; }
56  inline double maxL() const { return _maxL; }
57  inline double minB() const { return _minB; }
58  inline double maxB() const { return _maxB; }
59 
60  virtual bool boundsOk(double minL, double maxL) const = 0;
61  virtual void getSubCoeff(std::vector<_coeffData *> &) const = 0;
62  virtual void deleteBezierCoeff() = 0;
63  };
64 
65  struct _lessMinB {
66  bool operator()(_coeffData *, _coeffData *) const;
67  };
68  struct _lessMaxB {
69  bool operator()(_coeffData *, _coeffData *) const;
70  };
71 
72  class _coeffDataJac : public _coeffData {
73  private:
75 
76  public:
77  _coeffDataJac(const bezierCoeff *coeffs);
79 
80  bool boundsOk(double minL, double maxL) const;
81  void getSubCoeff(std::vector<_coeffData *> &) const;
82  void deleteBezierCoeff();
83  };
84 
85  class _coeffDataIGE : public _coeffData {
86  private:
89  const int _type;
90 
91  public:
92  _coeffDataIGE(int type, const bezierCoeff *det, const bezierCoeff *mat);
94 
95  bool boundsOk(double minL, double maxL) const;
96  void getSubCoeff(std::vector<_coeffData *> &) const;
97  void deleteBezierCoeff();
98 
99  private:
100  void _computeAtCorner(double &min, double &max) const;
101  double _computeLowerBound() const;
102  };
103 
104  class _coeffDataICN : public _coeffData {
105  private:
108  const int _dim;
109 
110  public:
111  _coeffDataICN(int dim, const bezierCoeff *det, const bezierCoeff *mat);
113 
114  bool boundsOk(double minL, double maxL) const;
115  void getSubCoeff(std::vector<_coeffData *> &) const;
116  void deleteBezierCoeff();
117 
118  private:
119  void _computeAtCorner(double &min, double &max) const;
120  double _computeLowerBound() const;
121  };
122 
123  double _computeBoundRational(const fullVector<double> &numerator,
124  const fullVector<double> &denominator,
125  bool lower, bool positiveDenom = true);
126 
127  void _subdivideDomains(std::vector<_coeffData *> &domains,
128  bool alsoMax = true, bool debug = false);
129  double _getMinAndDeleteDomains(std::vector<_coeffData *> &domains);
130 
131 } // namespace jacobianBasedQuality
132 
133 #endif
jacobianBasedQuality::testAllMeasures
void testAllMeasures(MElement *el, const fullMatrix< double > *normals)
Definition: qualityMeasuresJacobian.cpp:979
jacobianBasedQuality::_coeffData::deleteBezierCoeff
virtual void deleteBezierCoeff()=0
jacobianBasedQuality::_coeffDataIGE::_coeffMat
const bezierCoeff * _coeffMat
Definition: qualityMeasuresJacobian.h:88
jacobianBasedQuality::_coeffDataIGE::boundsOk
bool boundsOk(double minL, double maxL) const
Definition: qualityMeasuresJacobian.cpp:547
jacobianBasedQuality::_coeffData
Definition: qualityMeasuresJacobian.h:46
jacobianBasedQuality
Definition: qualityMeasuresJacobian.cpp:240
jacobianBasedQuality::_coeffDataICN::_coeffMat
const bezierCoeff * _coeffMat
Definition: qualityMeasuresJacobian.h:107
jacobianBasedQuality::_lessMinB::operator()
bool operator()(_coeffData *, _coeffData *) const
Definition: qualityMeasuresJacobian.cpp:482
jacobianBasedQuality::_coeffData::_minL
double _minL
Definition: qualityMeasuresJacobian.h:48
fullVector
Definition: MElement.h:26
jacobianBasedQuality::_coeffDataIGE::~_coeffDataIGE
~_coeffDataIGE()
Definition: qualityMeasuresJacobian.h:93
jacobianBasedQuality::_coeffDataICN::_coeffDet
const bezierCoeff * _coeffDet
Definition: qualityMeasuresJacobian.h:106
jacobianBasedQuality::_coeffDataIGE::deleteBezierCoeff
void deleteBezierCoeff()
Definition: qualityMeasuresJacobian.cpp:568
jacobianBasedQuality::_coeffData::maxL
double maxL() const
Definition: qualityMeasuresJacobian.h:56
jacobianBasedQuality::_coeffDataJac
Definition: qualityMeasuresJacobian.h:72
jacobianBasedQuality::minMaxJacobianDeterminant
void minMaxJacobianDeterminant(MElement *el, double &min, double &max, const fullMatrix< double > *normals, bool debug)
Definition: qualityMeasuresJacobian.cpp:242
jacobianBasedQuality::_coeffData::minB
double minB() const
Definition: qualityMeasuresJacobian.h:57
jacobianBasedQuality::sampleJacobianDeterminant
void sampleJacobianDeterminant(MElement *el, int deg, double &min, double &max, const fullMatrix< double > *normals)
Definition: qualityMeasuresJacobian.cpp:372
jacobianBasedQuality::_coeffDataICN::_computeAtCorner
void _computeAtCorner(double &min, double &max) const
Definition: qualityMeasuresJacobian.cpp:764
jacobianBasedQuality::_coeffDataICN::_dim
const int _dim
Definition: qualityMeasuresJacobian.h:108
jacobianBasedQuality::_coeffDataIGE
Definition: qualityMeasuresJacobian.h:85
jacobianBasedQuality::_coeffDataJac::deleteBezierCoeff
void deleteBezierCoeff()
Definition: qualityMeasuresJacobian.cpp:529
jacobianBasedQuality::_coeffDataIGE::_computeLowerBound
double _computeLowerBound() const
Definition: qualityMeasuresJacobian.cpp:593
jacobianBasedQuality::_coeffDataJac::_coeffs
const bezierCoeff * _coeffs
Definition: qualityMeasuresJacobian.h:74
jacobianBasedQuality::minICNMeasure
double minICNMeasure(MElement *el, bool knownValid, bool reversedOk, const fullMatrix< double > *normals, bool debug)
Definition: qualityMeasuresJacobian.cpp:326
jacobianBasedQuality::_coeffData::_maxL
double _maxL
Definition: qualityMeasuresJacobian.h:48
fullMatrix
Definition: MElement.h:27
jacobianBasedQuality::_coeffData::_maxB
double _maxB
Definition: qualityMeasuresJacobian.h:49
jacobianBasedQuality::_coeffData::_minB
double _minB
Definition: qualityMeasuresJacobian.h:49
jacobianBasedQuality::_coeffDataIGE::_coeffDet
const bezierCoeff * _coeffDet
Definition: qualityMeasuresJacobian.h:87
bezierCoeff
Definition: bezierBasis.h:127
jacobianBasedQuality::_coeffDataJac::boundsOk
bool boundsOk(double minL, double maxL) const
Definition: qualityMeasuresJacobian.cpp:510
jacobianBasedQuality::_lessMaxB::operator()
bool operator()(_coeffData *, _coeffData *) const
Definition: qualityMeasuresJacobian.cpp:487
jacobianBasedQuality::testAllMeasuresAllElements
void testAllMeasuresAllElements()
Definition: qualityMeasuresJacobian.cpp:959
jacobianBasedQuality::_computeBoundRational
double _computeBoundRational(const fullVector< double > &numerator, const fullVector< double > &denominator, bool lower, bool positiveDenom)
Definition: qualityMeasuresJacobian.cpp:903
jacobianBasedQuality::_coeffDataICN
Definition: qualityMeasuresJacobian.h:104
jacobianBasedQuality::sampleIGEMeasure
void sampleIGEMeasure(MElement *el, int deg, double &min, double &max)
Definition: qualityMeasuresJacobian.cpp:386
jacobianBasedQuality::_coeffData::~_coeffData
virtual ~_coeffData()
Definition: qualityMeasuresJacobian.h:53
jacobianBasedQuality::_coeffDataICN::boundsOk
bool boundsOk(double minL, double maxL) const
Definition: qualityMeasuresJacobian.cpp:737
MElement
Definition: MElement.h:30
jacobianBasedQuality::_coeffData::_coeffData
_coeffData()
Definition: qualityMeasuresJacobian.h:52
jacobianBasedQuality::minIGEMeasure
double minIGEMeasure(MElement *el, bool knownValid, bool reversedOk, const fullMatrix< double > *normals, bool debug)
Definition: qualityMeasuresJacobian.cpp:280
jacobianBasedQuality::_coeffDataIGE::_coeffDataIGE
_coeffDataIGE(int type, const bezierCoeff *det, const bezierCoeff *mat)
Definition: qualityMeasuresJacobian.cpp:532
jacobianBasedQuality::_coeffData::getSubCoeff
virtual void getSubCoeff(std::vector< _coeffData * > &) const =0
jacobianBasedQuality::_coeffDataJac::getSubCoeff
void getSubCoeff(std::vector< _coeffData * > &) const
Definition: qualityMeasuresJacobian.cpp:518
jacobianBasedQuality::_coeffDataJac::~_coeffDataJac
~_coeffDataJac()
Definition: qualityMeasuresJacobian.h:78
jacobianBasedQuality::_coeffDataICN::_coeffDataICN
_coeffDataICN(int dim, const bezierCoeff *det, const bezierCoeff *mat)
Definition: qualityMeasuresJacobian.cpp:722
jacobianBasedQuality::_subdivideDomains
void _subdivideDomains(std::vector< _coeffData * > &domains, bool alsoMax, bool debug)
Definition: qualityMeasuresJacobian.cpp:860
jacobianBasedQuality::_coeffData::boundsOk
virtual bool boundsOk(double minL, double maxL) const =0
jacobianBasedQuality::_coeffDataICN::~_coeffDataICN
~_coeffDataICN()
Definition: qualityMeasuresJacobian.h:112
jacobianBasedQuality::_coeffDataICN::deleteBezierCoeff
void deleteBezierCoeff()
Definition: qualityMeasuresJacobian.cpp:758
jacobianBasedQuality::_coeffDataJac::_coeffDataJac
_coeffDataJac(const bezierCoeff *coeffs)
Definition: qualityMeasuresJacobian.cpp:493
jacobianBasedQuality::_coeffDataIGE::getSubCoeff
void getSubCoeff(std::vector< _coeffData * > &) const
Definition: qualityMeasuresJacobian.cpp:555
jacobianBasedQuality::_coeffDataIGE::_type
const int _type
Definition: qualityMeasuresJacobian.h:89
jacobianBasedQuality::_lessMinB
Definition: qualityMeasuresJacobian.h:65
jacobianBasedQuality::_lessMaxB
Definition: qualityMeasuresJacobian.h:68
jacobianBasedQuality::_coeffData::minL
double minL() const
Definition: qualityMeasuresJacobian.h:55
jacobianBasedQuality::sampleICNMeasure
void sampleICNMeasure(MElement *el, int deg, double &min, double &max)
Definition: qualityMeasuresJacobian.cpp:399
jacobianBasedQuality::_coeffData::maxB
double maxB() const
Definition: qualityMeasuresJacobian.h:58
jacobianBasedQuality::_coeffDataICN::getSubCoeff
void getSubCoeff(std::vector< _coeffData * > &) const
Definition: qualityMeasuresJacobian.cpp:745
jacobianBasedQuality::_coeffDataICN::_computeLowerBound
double _computeLowerBound() const
Definition: qualityMeasuresJacobian.cpp:780
jacobianBasedQuality::_getMinAndDeleteDomains
double _getMinAndDeleteDomains(std::vector< _coeffData * > &domains)
Definition: qualityMeasuresJacobian.cpp:879
jacobianBasedQuality::_coeffDataIGE::_computeAtCorner
void _computeAtCorner(double &min, double &max) const
Definition: qualityMeasuresJacobian.cpp:574