1 // Gmsh - Copyright (C) 1997-2021 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 // Reference :  "Higher-Order Finite Element  Methods"; Pavel Solin, Karel
8 // Segeth ,
9 //                 Ivo Dolezel , Chapman and Hall/CRC; Edition : Har/Cdr (2003).
10 
11 #ifndef HIERARCHICAL_BASIS_H
12 #define HIERARCHICAL_BASIS_H
13 
14 #include <vector>
15 #include "OrthogonalPoly.h"
16 #include <algorithm>
17 
18 class HierarchicalBasis {
19 protected:
20   int _nvertex;
21   int _nedge;
22   int _nfaceQuad; // number of quadrilateral faces
23   int _nfaceTri; // number of triangular faces
24   int _nVertexFunction;
25   int _nEdgeFunction;
26   int _nQuadFaceFunction;
27   int _nTriFaceFunction;
28   int _nBubbleFunction;
29   virtual void orientOneFace(double const &u, double const &v, double const &w,
30                              int const &flag1, int const &flag2,
31                              int const &flag3, int const &faceNumber,
32                              std::vector<double> &faceFunctions) = 0;
33   virtual void orientOneFace(double const &u, double const &v, double const &w,
34                              int const &flag1, int const &flag2,
35                              int const &flag3, int const &faceNumber,
36                              std::vector<std::vector<double> > &faceFunctions,
37                              std::string typeFunction) = 0;
38 
39 public:
40   virtual ~HierarchicalBasis() = 0;
41   int getnVertexFunction() const;
42   int getnEdgeFunction() const;
43   int getnTriFaceFunction() const;
44   int getnQuadFaceFunction() const;
45   int getnBubbleFunction() const;
46   int getNumTriFace() const;
47   int getNumQuadFace() const;
48   int getNumEdge() const;
49   virtual unsigned int getNumberOfOrientations() const = 0;
50   virtual void generateBasis(double const &u, double const &v, double const &w,
51                              std::vector<double> &vertexBasis,
52                              std::vector<double> &edgeBasis,
53                              std::vector<double> &faceBasis,
54                              std::vector<double> &bubbleBasis) = 0;
55 
56   virtual void generateBasis(
57     double const &u, double const &v, double const &w,
58     std::vector<std::vector<double> > &vertexBasis,
59     std::vector<std::vector<double> > &edgeBasis,
60     std::vector<std::vector<double> > &faceBasis,
61     std::vector<std::vector<double> > &bubbleBasis,
62     std::string typeFunction) = 0; // typeFunction =GradH1Legendre ,
63                                    // HcurlLegendre,curlHcurlLegendre
64 
65   virtual void
66   orientEdge(int const &flagOrientation, int const &edgeNumber,
67              std::vector<std::vector<double> > &edgeBasis,
68              const std::vector<std::vector<double> > &eTablePositiveFlag,
69              const std::vector<std::vector<double> > &eTableNegativeFlag) = 0;
70 
71   virtual void
72   orientEdgeFunctionsForNegativeFlag(std::vector<double> &edgeFunctions) = 0;
73   virtual void orientEdgeFunctionsForNegativeFlag(
74     std::vector<std::vector<double> > &edgeFunctions) = 0;
75 
76   virtual void addAllOrientedFaceFunctions(
77     double const &u, double const &v, double const &w,
78     const std::vector<double> &faceFunctions,
79     std::vector<double> &quadFaceFunctionsAllOrientation,
80     std::vector<double> &triFaceFunctionsAllOrientation) = 0;
81 
82   virtual void addAllOrientedFaceFunctions(
83     double const &u, double const &v, double const &w,
84     const std::vector<std::vector<double> > &faceFunctions,
85     std::vector<std::vector<double> > &quadFaceFunctionsAllOrientation,
86     std::vector<std::vector<double> > &triFaceFunctionsAllOrientation,
87     std::string typeFunction) = 0; // typeFunction =GradH1Legendre ,
88                                    // HcurlLegendre,curlHcurlLegendre
89   virtual void
90   orientFace(int const &flag1, int const &flag2, int const &flag3,
91              int const &faceNumber,
92              const std::vector<double> &quadFaceFunctionsAllOrientation,
93              const std::vector<double> &triFaceFunctionsAllOrientation,
94              std::vector<double> &fTableCopy) = 0;
95   virtual void orientFace(
96     int const &flag1, int const &flag2, int const &flag3, int const &faceNumber,
97     const std::vector<std::vector<double> > &quadFaceFunctionsAllOrientation,
98     const std::vector<std::vector<double> > &triFaceFunctionsAllOrientation,
99     std::vector<std::vector<double> > &fTableCopy) = 0;
100 
101   virtual void orientEdge(int const &flagOrientation, int const &edgeNumber,
102                           std::vector<double> &edgeFunctions,
103                           const std::vector<double> &eTablePositiveFlag,
104                           const std::vector<double> &eTableNegativeFlag) = 0;
numberOrientationQuadFace(int const & flag1,int const & flag2,int const & flag3)105   inline int numberOrientationQuadFace(int const &flag1, int const &flag2,
106                                        int const &flag3)
107   {
108     if(flag1 == 1 && flag2 == 1 && flag3 == 1) { return 0; }
109     else if(flag1 == -1 && flag2 == 1 && flag3 == 1) {
110       return 1;
111     }
112     else if(flag1 == 1 && flag2 == -1 && flag3 == 1) {
113       return 2;
114     }
115     else if(flag1 == -1 && flag2 == -1 && flag3 == 1) {
116       return 3;
117     }
118     else if(flag1 == 1 && flag2 == 1 && flag3 == -1) {
119       return 4;
120     }
121     else if(flag1 == -1 && flag2 == 1 && flag3 == -1) {
122       return 5;
123     }
124     else if(flag1 == 1 && flag2 == -1 && flag3 == -1) {
125       return 6;
126     }
127     else {
128       return 7;
129     }
130   }
numberOrientationTriFace(int const & flag1,int const & flag2)131   inline int numberOrientationTriFace(int const &flag1, int const &flag2)
132   {
133     if(flag1 == 0 && flag2 == 1) { return 0; }
134     else if(flag1 == 1 && flag2 == 1) {
135       return 1;
136     }
137     else if(flag1 == 2 && flag2 == 1) {
138       return 2;
139     }
140     else if(flag1 == 0 && flag2 == -1) {
141       return 3;
142     }
143     else if(flag1 == 1 && flag2 == -1) {
144       return 4;
145     }
146     else {
147       return 5;
148     }
149   }
150 
151   // Get information about the `keys' defined in GMSH API for one  element
152   virtual void getKeysInfo(std::vector<int> &functionTypeInfo,
153                            std::vector<int> &orderInfo) = 0;
154 };
155 
156 #endif
157