gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
HierarchicalBasisH1Line.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 = 2;
21  _nEdgeFunction = (pe - 1);
24  _nBubbleFunction = 0;
25  _pe = pe;
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 void HierarchicalBasisH1Line::generateBasis(double const &u, double const &v,
45  double const &w,
46  std::vector<double> &vertexBasis,
47  std::vector<double> &edgeBasis,
48  std::vector<double> &faceBasis,
49  std::vector<double> &bubbleBasis)
50 {
51  double lambda1 = _affineCoordinate(1, u);
52  double lambda2 = _affineCoordinate(2, u);
53  double product = lambda1 * lambda2;
54  double substraction = lambda1 - lambda2;
55  // vertex shape functions:
56  vertexBasis[0] = lambda2;
57  vertexBasis[1] = lambda1;
58  // edge functions :
59  for(int k = 2; k <= _pe; k++) {
60  edgeBasis[k - 2] =
61  product * OrthogonalPoly::EvalKernelFunction(k - 2, substraction);
62  }
63 }
64 
66  double const &u, double const &v, double const &w,
67  std::vector<std::vector<double> > &gradientVertex,
68  std::vector<std::vector<double> > &gradientEdge,
69  std::vector<std::vector<double> > &gradientFace,
70  std::vector<std::vector<double> > &gradientBubble)
71 {
72  double dlambda1 = 0.5;
73  double dlambda2 = -0.5;
74  // vertex gradient functions:
75  gradientVertex[0][0] = dlambda2;
76  gradientVertex[1][0] = dlambda1;
77  for(int k = 2; k <= _pe; k++) {
78  gradientEdge[k - 2][0] = OrthogonalPoly::EvalDLobatto(k, u);
79  }
80 }
81 
83  int const &flagOrientation, int const &edgeNumber,
84  std::vector<double> &edgeFunctions,
85  const std::vector<double> &eTablePositiveFlag,
86  const std::vector<double> &eTableNegativeFlag)
87 {
88  if(flagOrientation == -1) {
89  for(int k = 0; k <= _pe - 2; k++) {
90  edgeFunctions[k] = eTableNegativeFlag[k];
91  }
92  }
93  else {
94  for(int k = 0; k <= _pe - 2; k++) {
95  edgeFunctions[k] = eTablePositiveFlag[k];
96  }
97  }
98 }
99 
101  int const &flagOrientation, int const &edgeNumber,
102  std::vector<std::vector<double> > &edgeFunctions,
103  const std::vector<std::vector<double> > &eTablePositiveFlag,
104  const std::vector<std::vector<double> > &eTableNegativeFlag)
105 {
106  if(flagOrientation == -1) {
107  for(int k = 0; k <= _pe - 2; k++) {
108  edgeFunctions[k][0] = eTableNegativeFlag[k][0];
109  }
110  }
111  else {
112  for(int k = 0; k <= _pe - 2; k++) {
113  edgeFunctions[k][0] = eTablePositiveFlag[k][0];
114  }
115  }
116 }
118  std::vector<double> &edgeFunctions)
119 {
120  for(int k = 0; k <= _pe - 2; k++) {
121  if(k % 2 != 0) { edgeFunctions[k] = edgeFunctions[k] * (-1); }
122  }
123 }
124 
126  std::vector<std::vector<double> > &edgeFunctions)
127 {
128  for(int k = 0; k <= _pe - 2; k++) {
129  if(k % 2 != 0) { edgeFunctions[k][0] = edgeFunctions[k][0] * (-1); }
130  }
131 }
132 
133 void HierarchicalBasisH1Line::getKeysInfo(std::vector<int> &functionTypeInfo,
134  std::vector<int> &orderInfo)
135 {
136  functionTypeInfo[0] = 0;
137  orderInfo[0] = 1;
138  functionTypeInfo[1] = 0;
139  orderInfo[1] = 1;
140  for(int k = 2; k <= _pe; k++) {
141  orderInfo[k] = k;
142  functionTypeInfo[k] = 1;
143  }
144 }
HierarchicalBasisH1Line::_affineCoordinate
static double _affineCoordinate(int j, double u)
Definition: HierarchicalBasisH1Line.cpp:35
HierarchicalBasis::_nTriFaceFunction
int _nTriFaceFunction
Definition: HierarchicalBasis.h:27
HierarchicalBasisH1Line::~HierarchicalBasisH1Line
virtual ~HierarchicalBasisH1Line()
Definition: HierarchicalBasisH1Line.cpp:28
OrthogonalPoly::EvalKernelFunction
double EvalKernelFunction(int order, double x)
Definition: OrthogonalPoly.cpp:238
HierarchicalBasisH1Line::getNumberOfOrientations
virtual unsigned int getNumberOfOrientations() const
Definition: HierarchicalBasisH1Line.cpp:30
HierarchicalBasisH1Line::generateBasis
virtual void generateBasis(double const &u, double const &v, double const &w, std::vector< double > &vertexBasis, std::vector< double > &edgeBasis, std::vector< double > &faceBasis, std::vector< double > &bubbleBasis)
Definition: HierarchicalBasisH1Line.cpp:44
HierarchicalBasis::_nvertex
int _nvertex
Definition: HierarchicalBasis.h:20
HierarchicalBasis::_nBubbleFunction
int _nBubbleFunction
Definition: HierarchicalBasis.h:28
HierarchicalBasisH1Line::orientEdge
virtual void orientEdge(int const &flagOrientation, int const &edgeNumber, std::vector< double > &edgeFunctions, const std::vector< double > &eTablePositiveFlag, const std::vector< double > &eTableNegativeFlag)
Definition: HierarchicalBasisH1Line.cpp:82
OrthogonalPoly::EvalDLobatto
double EvalDLobatto(int order, double x)
Definition: OrthogonalPoly.cpp:127
HierarchicalBasisH1Line::generateGradientBasis
void generateGradientBasis(double const &u, double const &v, double const &w, std::vector< std::vector< double > > &gradientVertex, std::vector< std::vector< double > > &gradientEdge, std::vector< std::vector< double > > &gradientFace, std::vector< std::vector< double > > &gradientBubble)
Definition: HierarchicalBasisH1Line.cpp:65
HierarchicalBasisH1Line.h
HierarchicalBasisH1Line::HierarchicalBasisH1Line
HierarchicalBasisH1Line(int pe)
Definition: HierarchicalBasisH1Line.cpp:14
HierarchicalBasisH1Line::orientEdgeFunctionsForNegativeFlag
virtual void orientEdgeFunctionsForNegativeFlag(std::vector< double > &edgeFunctions)
Definition: HierarchicalBasisH1Line.cpp:117
HierarchicalBasis::_nQuadFaceFunction
int _nQuadFaceFunction
Definition: HierarchicalBasis.h:26
HierarchicalBasis::_nfaceTri
int _nfaceTri
Definition: HierarchicalBasis.h:23
HierarchicalBasis::_nfaceQuad
int _nfaceQuad
Definition: HierarchicalBasis.h:22
HierarchicalBasisH1Line::getKeysInfo
virtual void getKeysInfo(std::vector< int > &functionTypeInfo, std::vector< int > &orderInfo)
Definition: HierarchicalBasisH1Line.cpp:133
HierarchicalBasis::_nVertexFunction
int _nVertexFunction
Definition: HierarchicalBasis.h:24
HierarchicalBasis::_nEdgeFunction
int _nEdgeFunction
Definition: HierarchicalBasis.h:25
HierarchicalBasisH1Line::_pe
int _pe
Definition: HierarchicalBasisH1Line.h:83
HierarchicalBasis::_nedge
int _nedge
Definition: HierarchicalBasis.h:21