v0.14.0
BernsteinBezier.hpp
Go to the documentation of this file.
1 /** \file BernsteinBezier.hpp
2 \brief Bernstein-Bezier polynomials for H1 space
3 
4 Implementation based on \cite ainsworth2011bernstein
5 
6 */
7 
8 #ifndef _H1_BERNSTEIN_BEZIER__HPP_
9 #define _H1_BERNSTEIN_BEZIER__HPP_
10 
11 namespace MoFEM {
12 
13 /**
14  * @brief Evaluating BB polynomial
15  *
16  * Low level class for evaluation of Bernstein-Bezier polynomials and associated
17  * tools useful for fast intergartion.
18  *
19  */
21 
22  /** \name Edge BB functions */
23 
24  /**@{*/
25 
26  static MoFEMErrorCode generateIndicesVertexEdge(const int N, int *alpha);
27  static MoFEMErrorCode generateIndicesEdgeEdge(const int N, int *alpha);
28  static MoFEMErrorCode baseFunctionsEdge(const int N, const int gdim,
29  const int n_alpha, const int *alpha,
30  const double *lambda,
31  const double *grad_lambda,
32  double *base, double *grad_base);
34  const int N, const int n_alpha, const int *alpha, const int *diff,
35  const int n_alpha_diff, const int *alpha_diff, double *c);
36 
37  /**@}*/
38 
39  /** \name Triangle BB functions */
40 
41  /**@{*/
42 
43  static MoFEMErrorCode generateIndicesVertexTri(const int N, int *alpha);
44  static MoFEMErrorCode generateIndicesEdgeTri(const int N[], int *alpha[]);
45  static MoFEMErrorCode generateIndicesEdgeTri(const int side, const int N,
46  int *alpha);
47  static MoFEMErrorCode generateIndicesTriTri(const int N, int *alpha);
48  static MoFEMErrorCode baseFunctionsTri(const int N, const int gdim,
49  const int n_alpha, const int *alpha,
50  const double *lambda,
51  const double *grad_lambda,
52  double *base, double *grad_base);
53  static MoFEMErrorCode
54  genrateDerivativeIndicesTri(const int N, const int n_alpha, const int *alpha,
55  const int *diff, const int n_alpha_diff,
56  const int *alpha_diff, double *c);
57 
58  /**@}*/
59 
60  /** \name Tetrahedron BB functions */
61 
62  static MoFEMErrorCode generateIndicesVertexTet(const int N, int *alpha);
63  static MoFEMErrorCode generateIndicesEdgeTet(const int N[], int *alpha[]);
64  static MoFEMErrorCode generateIndicesEdgeTet(const int side, const int N,
65  int *alpha);
66  static MoFEMErrorCode generateIndicesTriTet(const int N[], int *alpha[]);
67  static MoFEMErrorCode generateIndicesTriTet(const int side, const int N,
68  int *alpha);
69  static MoFEMErrorCode generateIndicesTetTet(const int N, int *alpha);
70  static MoFEMErrorCode baseFunctionsTet(const int N, const int gdim,
71  const int n_alpha, const int *alpha,
72  const double *lambda,
73  const double *grad_lambda,
74  double *base, double *grad_base);
75  static MoFEMErrorCode
76  genrateDerivativeIndicesTet(const int N, const int n_alpha, const int *alpha,
77  const int *diff, const int n_alpha_diff,
78  const int *alpha_diff, double *c);
79 
80  /**@}*/
81 
82  /**
83  * @brief Genrate BB points in 3d
84  *
85  * @param N
86  * @param n_x
87  * @param n_alpha
88  * @param alpha
89  * @param x_k
90  * @param x_alpha
91  * @return MoFEMErrorCode
92  */
93  static MoFEMErrorCode domainPoints3d(const int N, const int n_x,
94  const int n_alpha, const int *alpha,
95  const double *x_k, double *x_alpha);
96 
97 
98  private:
99  /**
100  * @brief Generate BB indices on vertices
101  *
102  * @tparam D
103  * @tparam Side
104  * @param N
105  * @param alpha
106  * @return MoFEMErrorCode
107  */
108  template <int D, int Side>
109  inline static MoFEMErrorCode generateIndicesVertex(const int N, int *alpha);
110 
111  /**
112  * @brief Genarte BB incices od simplex edges
113  *
114  * @tparam D
115  * @tparam Side
116  * @param N
117  * @param alpha
118  * @return MoFEMErrorCode
119  */
120  template <int D, int Side>
121  inline static MoFEMErrorCode generateIndicesEdgeOnSimplex(const int N,
122  int *alpha);
123  /**
124  * @brief Generate BB indices on simples triangles
125  *
126  * @tparam D
127  * @tparam Side
128  * @param N
129  * @param alpha
130  * @return MoFEMErrorCode
131  */
132  template <int D, int Side>
133  inline static MoFEMErrorCode generateIndicesTriOnSimplex(const int N,
134  int *alpha);
135  /**
136  * @brief Genarte BB indices on simplex
137 
138 
139  \f[
140  \frac{\partial^{|\mathbf{v}|} \phi^n_{\pmb\alpha}}{\partial
141  \pmb\lambda^\mathbf{v}}= \mathbf{c}_{\pmb\alpha\pmb\beta}
142  \phi^{n-|\mathbf{v}|}_{\pmb\beta}
143  \f]
144 
145  * @param N
146  * @param alpha
147  * @return MoFEMErrorCode
148  */
149  static MoFEMErrorCode generateIndicesTetOnSimplex(const int N, int *alpha);
150 
151  /**
152  * @brief Brief calculate coefficients for directive of base functions
153  *
154  * \f[
155  *
156  * \f]
157  *
158  * @tparam D
159  * @param N
160  * @param n_alpha
161  * @param alpha
162  * @param diff
163  * @param n_alpha_diff
164  * @param alpha_diff
165  * @param c
166  * @return MoFEMErrorCode
167  */
168  template <int D>
169  static MoFEMErrorCode
170  genrateDerivativeIndices(const int N, const int n_alpha, const int *alpha,
171  const int *diff, const int n_alpha_diff,
172  const int *alpha_diff, double *c);
173 
174  /**
175  * @brief Evaluate coordinates of BB points
176  *
177  * @tparam D dimension
178  * @param N polynomail order
179  * @param n_x
180  * @param n_alpha
181  * @param alpha
182  * @param x_k cartesian coordinates of simplex nodes
183  * @param x_alpha BB points
184  * @return MoFEMErrorCode
185  */
186  template <int D>
187  inline static MoFEMErrorCode domainPoints(const int N, const int n_x,
188  const int n_alpha, const int *alpha,
189  const double *x_k, double *x_alpha);
190 
191  /**
192  * @brief BB base function
193  *
194  * @tparam D dimension
195  * @tparam GRAD_BASE true to calculate base
196  * @param N polynomial order
197  * @param gdim number of evaluation points
198  * @param n_alpha number BB base functions
199  * @param alpha BB coefficients
200  * @param lambda barycentric coefficients at evaluating points
201  * @param grad_lambda gradients of barycentric over spatial coordinates
202  * @param base base function
203  * @param grad_base vector base functions
204  * @return MoFEMErrorCode
205  */
206  template <int D, bool GRAD_BASE>
207  inline static MoFEMErrorCode
208  baseFunctions(const int N, const int gdim, const int n_alpha,
209  const int *alpha, const double *lambda,
210  const double *grad_lambda, double *base, double *grad_base);
211 };
212 
213 } // namespace MoFEM
214 
215 #endif // _H1_BERNSTEIN_BEZIER__HPP_
MoFEM::BernsteinBezier::baseFunctions
static MoFEMErrorCode baseFunctions(const int N, const int gdim, const int n_alpha, const int *alpha, const double *lambda, const double *grad_lambda, double *base, double *grad_base)
BB base function.
MoFEM::BernsteinBezier::genrateDerivativeIndicesEdges
static MoFEMErrorCode genrateDerivativeIndicesEdges(const int N, const int n_alpha, const int *alpha, const int *diff, const int n_alpha_diff, const int *alpha_diff, double *c)
Definition: BernsteinBezier.cpp:237
MoFEM::BernsteinBezier
Evaluating BB polynomial.
Definition: BernsteinBezier.hpp:20
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::BernsteinBezier::genrateDerivativeIndicesTri
static MoFEMErrorCode genrateDerivativeIndicesTri(const int N, const int n_alpha, const int *alpha, const int *diff, const int n_alpha_diff, const int *alpha_diff, double *c)
Definition: BernsteinBezier.cpp:244
MoFEM::BernsteinBezier::generateIndicesTriTri
static MoFEMErrorCode generateIndicesTriTri(const int N, int *alpha)
Definition: BernsteinBezier.cpp:124
MoFEM::BernsteinBezier::generateIndicesVertex
static MoFEMErrorCode generateIndicesVertex(const int N, int *alpha)
Generate BB indices on vertices.
MoFEM::BernsteinBezier::domainPoints3d
static MoFEMErrorCode domainPoints3d(const int N, const int n_x, const int n_alpha, const int *alpha, const double *x_k, double *x_alpha)
Genrate BB points in 3d.
Definition: BernsteinBezier.cpp:284
MoFEM::BernsteinBezier::genrateDerivativeIndices
static MoFEMErrorCode genrateDerivativeIndices(const int N, const int n_alpha, const int *alpha, const int *diff, const int n_alpha_diff, const int *alpha_diff, double *c)
Brief calculate coefficients for directive of base functions.
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
MoFEM::BernsteinBezier::generateIndicesEdgeOnSimplex
static MoFEMErrorCode generateIndicesEdgeOnSimplex(const int N, int *alpha)
Genarte BB incices od simplex edges.
MoFEM::BernsteinBezier::baseFunctionsEdge
static MoFEMErrorCode baseFunctionsEdge(const int N, const int gdim, const int n_alpha, const int *alpha, const double *lambda, const double *grad_lambda, double *base, double *grad_base)
Definition: BernsteinBezier.cpp:419
MoFEM::BernsteinBezier::generateIndicesEdgeTet
static MoFEMErrorCode generateIndicesEdgeTet(const int N[], int *alpha[])
Definition: BernsteinBezier.cpp:138
MoFEM::BernsteinBezier::generateIndicesTriTet
static MoFEMErrorCode generateIndicesTriTet(const int N[], int *alpha[])
Definition: BernsteinBezier.cpp:174
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::BernsteinBezier::generateIndicesEdgeTri
static MoFEMErrorCode generateIndicesEdgeTri(const int N[], int *alpha[])
Definition: BernsteinBezier.cpp:99
MoFEM::BernsteinBezier::generateIndicesVertexTet
static MoFEMErrorCode generateIndicesVertexTet(const int N, int *alpha)
Definition: BernsteinBezier.cpp:128
MoFEM::BernsteinBezier::domainPoints
static MoFEMErrorCode domainPoints(const int N, const int n_x, const int n_alpha, const int *alpha, const double *x_k, double *x_alpha)
Evaluate coordinates of BB points.
MoFEM::BernsteinBezier::generateIndicesVertexEdge
static MoFEMErrorCode generateIndicesVertexEdge(const int N, int *alpha)
Definition: BernsteinBezier.cpp:77
N
const int N
Definition: speed_test.cpp:3
MoFEM::BernsteinBezier::generateIndicesTetTet
static MoFEMErrorCode generateIndicesTetTet(const int N, int *alpha)
Definition: BernsteinBezier.cpp:203
lambda
static double lambda
Definition: incompressible_elasticity.cpp:199
MoFEM::BernsteinBezier::baseFunctionsTri
static MoFEMErrorCode baseFunctionsTri(const int N, const int gdim, const int n_alpha, const int *alpha, const double *lambda, const double *grad_lambda, double *base, double *grad_base)
Definition: BernsteinBezier.cpp:431
MoFEM::BernsteinBezier::generateIndicesTriOnSimplex
static MoFEMErrorCode generateIndicesTriOnSimplex(const int N, int *alpha)
Generate BB indices on simples triangles.
MoFEM::BernsteinBezier::genrateDerivativeIndicesTet
static MoFEMErrorCode genrateDerivativeIndicesTet(const int N, const int n_alpha, const int *alpha, const int *diff, const int n_alpha_diff, const int *alpha_diff, double *c)
Definition: BernsteinBezier.cpp:251
MoFEM::BernsteinBezier::generateIndicesTetOnSimplex
static MoFEMErrorCode generateIndicesTetOnSimplex(const int N, int *alpha)
Genarte BB indices on simplex.
Definition: BernsteinBezier.cpp:59
MoFEM::BernsteinBezier::baseFunctionsTet
static MoFEMErrorCode baseFunctionsTet(const int N, const int gdim, const int n_alpha, const int *alpha, const double *lambda, const double *grad_lambda, double *base, double *grad_base)
Definition: BernsteinBezier.cpp:443
MoFEM::BernsteinBezier::generateIndicesVertexTri
static MoFEMErrorCode generateIndicesVertexTri(const int N, int *alpha)
Definition: BernsteinBezier.cpp:90
MoFEM::BernsteinBezier::generateIndicesEdgeEdge
static MoFEMErrorCode generateIndicesEdgeEdge(const int N, int *alpha)
Definition: BernsteinBezier.cpp:85