gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
HierarchicalBasisHcurlLine.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 // Contributed by Ismail Badia.
7 
8 // Reference : "Higher-Order Finite Element Methods"; Pavel Solin, Karel
9 // Segeth , Ivo Dolezel , Chapman and Hall/CRC; Edition : Har/Cdr (2003).
10 
11 #include <stdexcept>
13 
15 {
16  _nvertex = 2;
17  _nedge = 1;
18  _nfaceTri = 0;
19  _nfaceQuad = 0;
20  _nVertexFunction = 0;
21  _nEdgeFunction = order + 1;
24  _nBubbleFunction = 0;
25  _pe = order;
26 }
27 
29 
31 {
32  return 2; // factorial 2
33 }
34 
36 {
37  switch(j) {
38  case(1): return 0.5 * (1 + u);
39  case(2): return 0.5 * (1 - u);
40  default: throw std::runtime_error("j must be : 1<=j<=2");
41  }
42 }
43 
44 double HierarchicalBasisHcurlLine::dotProduct(const std::vector<double> &u,
45  const std::vector<double> &v)
46 {
47  return u[0] * v[0] + u[1] * v[1] + u[2] * v[2];
48 }
50  double const &u, double const &v, double const &w,
51  std::vector<std::vector<double> > &edgeBasis,
52  std::vector<std::vector<double> > &faceBasis,
53  std::vector<std::vector<double> > &bubbleBasis)
54 {
55  double lambda1 = _affineCoordinate(1, u);
56  double lambda2 = _affineCoordinate(2, u);
57  std::vector<double> t1 = std::vector<double>(3, 0);
58  t1[0] = 1;
59  std::vector<double> n1 = std::vector<double>(3, 0);
60  n1[0] = 1;
61  std::vector<double> n2 = std::vector<double>(3, 0);
62  n2[0] = -1;
63  // Whitney functions
64  std::vector<double> psie_0(3, 0);
65  std::vector<double> psie_1(3, 0);
66  for(int i = 0; i < 3; i++) {
67  psie_0[i] = lambda1 * n2[i] / dotProduct(n2, t1) +
68  lambda2 * n1[i] / dotProduct(n1, t1);
69  psie_1[i] = lambda1 * n2[i] / dotProduct(n2, t1) -
70  lambda2 * n1[i] / dotProduct(n1, t1);
71  }
72  double sub = lambda1 - lambda2;
73 
74  std::vector<double> legendreVector(_pe, 0);
75  for(unsigned int k = 0; k < legendreVector.size(); k++) {
76  legendreVector[k] = OrthogonalPoly::EvalLegendre(k, sub);
77  }
78  int edgeIt = 0;
79  for(int j = 0; j < 3; j++) { edgeBasis[edgeIt][j] = psie_0[j]; }
80  edgeIt++;
81  if(_pe >= 1) {
82  for(int j = 0; j < 3; j++) { edgeBasis[edgeIt][j] = psie_1[j]; }
83  edgeIt++;
84  for(int iedge = 2; iedge <= _pe; iedge++) {
85  for(int j = 0; j < 3; j++) {
86  edgeBasis[edgeIt][j] = (2 * float(iedge) - 1) / float(iedge) *
87  legendreVector[iedge - 1] * psie_1[j] -
88  (float(iedge) - 1) / float(iedge) *
89  legendreVector[iedge - 2] * psie_0[j];
90  }
91  edgeIt++;
92  }
93  }
94 }
96  int const &flagOrientation, int const &edgeNumber,
97  std::vector<std::vector<double> > &edgeFunctions,
98  const std::vector<std::vector<double> > &eTablePositiveFlag,
99  const std::vector<std::vector<double> > &eTableNegativeFlag)
100 {
101  if(flagOrientation == -1) {
102  for(int k = 0; k <= _pe; k++) {
103  edgeFunctions[k][0] = eTableNegativeFlag[k][0];
104  edgeFunctions[k][1] = eTableNegativeFlag[k][1];
105  edgeFunctions[k][2] = eTableNegativeFlag[k][2];
106  }
107  }
108  else {
109  for(int k = 0; k <= _pe; k++) {
110  edgeFunctions[k][0] = eTablePositiveFlag[k][0];
111  edgeFunctions[k][1] = eTablePositiveFlag[k][1];
112  edgeFunctions[k][2] = eTablePositiveFlag[k][2];
113  }
114  }
115 }
116 
118  std::vector<std::vector<double> > &edgeFunctions)
119 {
120  for(int k = 0; k <= _pe; k++) {
121  if(k % 2 == 0) {
122  edgeFunctions[k][0] = edgeFunctions[k][0] * (-1);
123  edgeFunctions[k][1] = edgeFunctions[k][1] * (-1);
124  edgeFunctions[k][2] = edgeFunctions[k][2] * (-1);
125  }
126  }
127 }
129  double const &u, double const &v, double const &w,
130  std::vector<std::vector<double> > &edgeBasis,
131  std::vector<std::vector<double> > &faceBasis,
132  std::vector<std::vector<double> > &bubbleBasis)
133 {
134  // zero for all orders
135 }
136 
137 void HierarchicalBasisHcurlLine::getKeysInfo(std::vector<int> &functionTypeInfo,
138  std::vector<int> &orderInfo)
139 {
140  for(int k = 0; k <= _pe; k++) {
141  orderInfo[k] = k;
142  functionTypeInfo[k] = 1;
143  }
144 }
OrthogonalPoly::EvalLegendre
double EvalLegendre(int order, double x)
Definition: OrthogonalPoly.cpp:415
HierarchicalBasis::_nTriFaceFunction
int _nTriFaceFunction
Definition: HierarchicalBasis.h:27
HierarchicalBasisHcurlLine.h
HierarchicalBasisHcurlLine::HierarchicalBasisHcurlLine
HierarchicalBasisHcurlLine(int order)
Definition: HierarchicalBasisHcurlLine.cpp:14
HierarchicalBasisHcurlLine::orientEdge
virtual void orientEdge(int const &flagOrientation, int const &edgeNumber, std::vector< std::vector< double > > &edgeBasis, const std::vector< std::vector< double > > &eTablePositiveFlag, const std::vector< std::vector< double > > &eTableNegativeFlag)
Definition: HierarchicalBasisHcurlLine.cpp:95
HierarchicalBasis::_nvertex
int _nvertex
Definition: HierarchicalBasis.h:20
HierarchicalBasis::_nBubbleFunction
int _nBubbleFunction
Definition: HierarchicalBasis.h:28
HierarchicalBasisHcurlLine::_affineCoordinate
static double _affineCoordinate(int j, double u)
Definition: HierarchicalBasisHcurlLine.cpp:35
HierarchicalBasisHcurlLine::generateCurlBasis
virtual void generateCurlBasis(double const &u, double const &v, double const &w, std::vector< std::vector< double > > &edgeBasis, std::vector< std::vector< double > > &faceBasis, std::vector< std::vector< double > > &bubbleBasis)
Definition: HierarchicalBasisHcurlLine.cpp:128
HierarchicalBasisHcurlLine::orientEdgeFunctionsForNegativeFlag
virtual void orientEdgeFunctionsForNegativeFlag(std::vector< std::vector< double > > &edgeFunctions)
Definition: HierarchicalBasisHcurlLine.cpp:117
HierarchicalBasisHcurlLine::~HierarchicalBasisHcurlLine
virtual ~HierarchicalBasisHcurlLine()
Definition: HierarchicalBasisHcurlLine.cpp:28
HierarchicalBasisHcurlLine::getKeysInfo
virtual void getKeysInfo(std::vector< int > &functionTypeInfo, std::vector< int > &orderInfo)
Definition: HierarchicalBasisHcurlLine.cpp:137
HierarchicalBasis::_nQuadFaceFunction
int _nQuadFaceFunction
Definition: HierarchicalBasis.h:26
HierarchicalBasis::_nfaceTri
int _nfaceTri
Definition: HierarchicalBasis.h:23
HierarchicalBasis::_nfaceQuad
int _nfaceQuad
Definition: HierarchicalBasis.h:22
HierarchicalBasis::_nVertexFunction
int _nVertexFunction
Definition: HierarchicalBasis.h:24
HierarchicalBasisHcurlLine::getNumberOfOrientations
virtual unsigned int getNumberOfOrientations() const
Definition: HierarchicalBasisHcurlLine.cpp:30
HierarchicalBasisHcurlLine::dotProduct
static double dotProduct(const std::vector< double > &u, const std::vector< double > &v)
Definition: HierarchicalBasisHcurlLine.cpp:44
HierarchicalBasisHcurlLine::_pe
int _pe
Definition: HierarchicalBasisHcurlLine.h:70
HierarchicalBasis::_nEdgeFunction
int _nEdgeFunction
Definition: HierarchicalBasis.h:25
HierarchicalBasisHcurlLine::generateHcurlBasis
virtual void generateHcurlBasis(double const &u, double const &v, double const &w, std::vector< std::vector< double > > &edgeBasis, std::vector< std::vector< double > > &faceBasis, std::vector< std::vector< double > > &bubbleBasis)
Definition: HierarchicalBasisHcurlLine.cpp:49
HierarchicalBasis::_nedge
int _nedge
Definition: HierarchicalBasis.h:21