v0.9.0
Public Member Functions | Static Public Member Functions | Static Private Member Functions | List of all members
MoFEM::BernsteinBezier Struct Reference

Evaluating BB polynomial. More...

#include <src/approximation/BernsteinBezier.hpp>

Public Member Functions

template<int D, int Side>
MoFEMErrorCode generateIndicesVertex (const int N, int *alpha)
 
template<int D, int Side>
MoFEMErrorCode generateIndicesEdgeOnSimplex (const int N, int *alpha)
 
template<int D, int Side>
MoFEMErrorCode generateIndicesTriOnSimplex (const int N, int *alpha)
 
template<int D>
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)
 
template<int D>
MoFEMErrorCode domainPoints (const int N, const int n_x, const int n_alpha, const int *alpha, const double *x_k, double *x_alpha)
 
template<int D, bool GRAD_BASE>
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)
 

Static Public Member Functions

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. More...
 
Edge BB functions
static MoFEMErrorCode generateIndicesVertexEdge (const int N, int *alpha)
 
static MoFEMErrorCode generateIndicesEdgeEdge (const int N, int *alpha)
 
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)
 
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)
 
Triangle BB functions
static MoFEMErrorCode generateIndicesVertexTri (const int N, int *alpha)
 
static MoFEMErrorCode generateIndicesEdgeTri (const int N[], int *alpha[])
 
static MoFEMErrorCode generateIndicesEdgeTri (const int side, const int N, int *alpha)
 
static MoFEMErrorCode generateIndicesTriTri (const int N, int *alpha)
 
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)
 
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)
 
Tetrahedron BB functions
static MoFEMErrorCode generateIndicesVertexTet (const int N, int *alpha)
 
static MoFEMErrorCode generateIndicesEdgeTet (const int N[], int *alpha[])
 
static MoFEMErrorCode generateIndicesEdgeTet (const int side, const int N, int *alpha)
 
static MoFEMErrorCode generateIndicesTriTet (const int N[], int *alpha[])
 
static MoFEMErrorCode generateIndicesTriTet (const int side, const int N, int *alpha)
 
static MoFEMErrorCode generateIndicesTetTet (const int N, int *alpha)
 
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)
 
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)
 

Static Private Member Functions

template<int D, int Side>
static MoFEMErrorCode generateIndicesVertex (const int N, int *alpha)
 Generate BB indices on vertices. More...
 
template<int D, int Side>
static MoFEMErrorCode generateIndicesEdgeOnSimplex (const int N, int *alpha)
 Genarte BB incices od simplex edges. More...
 
template<int D, int Side>
static MoFEMErrorCode generateIndicesTriOnSimplex (const int N, int *alpha)
 Generate BB indices on simples triangles. More...
 
static MoFEMErrorCode generateIndicesTetOnSimplex (const int N, int *alpha)
 Genarte BB indices on simplex. More...
 
template<int D>
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. More...
 
template<int D>
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. More...
 
template<int D, bool GRAD_BASE>
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. More...
 

Detailed Description

Evaluating BB polynomial.

Low level class for evaluation of Bernstein-Bezier polynomials and associated tools useful for fast intergartion.

Definition at line 20 of file BernsteinBezier.hpp.

Member Function Documentation

◆ baseFunctions() [1/2]

template<int D, bool GRAD_BASE>
static MoFEMErrorCode MoFEM::BernsteinBezier::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 
)
staticprivate

BB base function.

Template Parameters
Ddimension
GRAD_BASEtrue to calculate base
Parameters
Npolynomial order
gdimnumber of evaluation points
n_alphanumber BB base functions
alphaBB coefficients
lambdabarycentric coefficients at evaluating points
grad_lambdagradients of barycentric over spatial coordinates
basebase function
grad_basevector base functions
Returns
MoFEMErrorCode

◆ baseFunctions() [2/2]

template<int D, bool GRAD_BASE>
MoFEMErrorCode MoFEM::BernsteinBezier::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 
)

Definition at line 309 of file BernsteinBezier.cpp.

312  {
314 
315  const int *const alpha0 = alpha;
316  const double fN = boost::math::factorial<double>(N);
317  constexpr int MAX_ALPHA = 12;
318  int max_alpha = *std::max_element(alpha, &alpha[(D + 1) * n_alpha]);
319  if(max_alpha > MAX_ALPHA)
320  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
321  "Is assumed maximal order not to be bigger than %d", MAX_ALPHA);
322  std::array<double, (D + 1) * (MAX_ALPHA + 1)> pow_alpha;
323  std::array<double, (MAX_ALPHA + 1)> factorial_alpha;
324  std::array<double, D + 1> terms, diff_terms;
325  const double *const grad_lambda0 = grad_lambda;
326 
327  factorial_alpha[0] = 1;
328  if (max_alpha >= 1)
329  factorial_alpha[1] = 1;
330  if (max_alpha >= 2)
331  for (int a = 2; a <= max_alpha; ++a)
332  factorial_alpha[a] = factorial_alpha[a - 1] * a;
333 
334  for (int g = 0; g != gdim; ++g) {
335 
336  for (int n = 0; n != D + 1; ++n, ++lambda) {
337  const size_t shift = (MAX_ALPHA + 1) * n;
338  double *pow_alpha_ptr = &pow_alpha[shift];
339  *pow_alpha_ptr = 1;
340 
341  if (max_alpha >= 1) {
342  ++pow_alpha_ptr;
343  *pow_alpha_ptr = *lambda;
344  }
345 
346  if (max_alpha >= 2)
347  for (int a = 2; a <= max_alpha; ++a) {
348  const double p = (*pow_alpha_ptr) * (*lambda);
349  ++pow_alpha_ptr;
350  *pow_alpha_ptr = p;
351  }
352  }
353 
354  for (int n0 = 0; n0 != n_alpha; ++n0) {
355 
356  grad_lambda = grad_lambda0;
357 
358  double f = factorial_alpha[(*alpha)];
359  double *terms_ptr = terms.data();
360  double *diff_terms_ptr = diff_terms.data();
361  *terms_ptr = pow_alpha[(*alpha)];
362  if (GRAD_BASE) {
363  if (*alpha > 0)
364  *diff_terms_ptr = (*alpha) * pow_alpha[(*alpha) - 1];
365  else
366  *diff_terms_ptr = 0;
367  }
368  *base = *terms_ptr;
369  ++alpha;
370  ++terms_ptr;
371  ++diff_terms_ptr;
372 
373  for (int n1 = 1; n1 < D + 1;
374  ++n1, ++alpha, ++terms_ptr, ++diff_terms_ptr) {
375  f *= factorial_alpha[(*alpha)];
376  const size_t shift = (MAX_ALPHA + 1) * n1;
377  *terms_ptr = pow_alpha[shift + (*alpha)];
378  if (GRAD_BASE) {
379  if (*alpha > 0)
380  *diff_terms_ptr = (*alpha) * pow_alpha[shift + (*alpha) - 1];
381  else
382  *diff_terms_ptr = 0;
383  }
384  *base *= *terms_ptr;
385  }
386 
387  const double b = fN / f;
388  *base *= b;
389  ++base;
390 
391  if (GRAD_BASE) {
392  double *terms_ptr = terms.data();
393  double *diff_terms_ptr = diff_terms.data();
394  double z = *diff_terms_ptr;
395  ++terms_ptr;
396  ++diff_terms_ptr;
397  for (int n2 = 1; n2 != D + 1; ++n2, ++terms_ptr)
398  z *= *terms_ptr;
399 
400  for (int d = 0; d != D; ++d, ++grad_lambda)
401  grad_base[d] = z * (*grad_lambda);
402 
403  for (int n1 = 1; n1 < D + 1; ++n1) {
404  z = *diff_terms_ptr;
405 
406  int n2 = 0;
407  for (terms_ptr = terms.data(); n2 != n1; ++n2, ++terms_ptr)
408  z *= *terms_ptr;
409 
410  ++n2;
411  ++terms_ptr;
412 
413  for (; n2 < D + 1; ++n2, ++terms_ptr)
414  z *= *terms_ptr;
415 
416  for (int d = 0; d != D; ++d, ++grad_lambda)
417  grad_base[d] += z * (*grad_lambda);
418 
419  ++diff_terms_ptr;
420  }
421  for (int d = 0; d != D; ++d)
422  grad_base[d] *= b;
423  grad_base += D;
424  }
425 
426  }
427 
428  alpha = alpha0;
429  }
430 
432 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27
const int N
Definition: speed_test.cpp:3

◆ baseFunctionsEdge()

MoFEMErrorCode BernsteinBezier::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 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 434 of file BernsteinBezier.cpp.

437  {
438  if (grad_base)
439  return baseFunctions<1, true>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
440  base, grad_base);
441  else
442  return baseFunctions<1, false>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
443  base, grad_base);
444 }
const int N
Definition: speed_test.cpp:3

◆ baseFunctionsTet()

MoFEMErrorCode BernsteinBezier::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 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 458 of file BernsteinBezier.cpp.

461  {
462  if (grad_base)
463  return baseFunctions<3, true>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
464  base, grad_base);
465  else
466  return baseFunctions<3, false>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
467  base, grad_base);
468 }
const int N
Definition: speed_test.cpp:3

◆ baseFunctionsTri()

MoFEMErrorCode BernsteinBezier::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 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 446 of file BernsteinBezier.cpp.

449  {
450  if (grad_base)
451  return baseFunctions<2, true>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
452  base, grad_base);
453  else
454  return baseFunctions<2, false>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
455  base, grad_base);
456 }
const int N
Definition: speed_test.cpp:3

◆ domainPoints() [1/2]

template<int D>
static MoFEMErrorCode MoFEM::BernsteinBezier::domainPoints ( const int  N,
const int  n_x,
const int  n_alpha,
const int alpha,
const double x_k,
double x_alpha 
)
staticprivate

Evaluate coordinates of BB points.

Template Parameters
Ddimension
Parameters
Npolynomail order
n_x
n_alpha
alpha
x_kcartesian coordinates of simplex nodes
x_alphaBB points
Returns
MoFEMErrorCode

◆ domainPoints() [2/2]

template<int D>
MoFEMErrorCode MoFEM::BernsteinBezier::domainPoints ( const int  N,
const int  n_x,
const int  n_alpha,
const int alpha,
const double x_k,
double x_alpha 
)

Definition at line 275 of file BernsteinBezier.cpp.

277  {
280 
282  x_alpha, &x_alpha[1], &x_alpha[2]);
283  for (int n0 = 0; n0 != n_alpha; ++n0) {
284  t_x_alpha(i) = 0;
286  x_k, &x_k[1], &x_k[2]);
287  for (int n1 = 0; n1 != n_x; ++n1) {
288  t_x_alpha(i) += static_cast<double>(*alpha) * t_x_k(i);
289  ++t_x_k;
290  ++alpha;
291  }
292  t_x_alpha(i) /= static_cast<double>(N);
293  ++t_x_alpha;
294  }
295 
297 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const int N
Definition: speed_test.cpp:3

◆ domainPoints3d()

MoFEMErrorCode BernsteinBezier::domainPoints3d ( const int  N,
const int  n_x,
const int  n_alpha,
const int alpha,
const double x_k,
double x_alpha 
)
static

Genrate BB points in 3d.

Parameters
N
n_x
n_alpha
alpha
x_k
x_alpha
Returns
MoFEMErrorCode
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 299 of file BernsteinBezier.cpp.

303  {
304  return domainPoints<3>(N, n_x, n_alpha, alpha, x_k, x_alpha);
305 }
const int N
Definition: speed_test.cpp:3

◆ generateIndicesEdgeEdge()

MoFEMErrorCode BernsteinBezier::generateIndicesEdgeEdge ( const int  N,
int alpha 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 100 of file BernsteinBezier.cpp.

101  {
102  return generateIndicesEdgeOnSimplex<1, 0>(N, alpha);
103 }
const int N
Definition: speed_test.cpp:3

◆ generateIndicesEdgeOnSimplex() [1/2]

template<int D, int Side>
MoFEMErrorCode MoFEM::BernsteinBezier::generateIndicesEdgeOnSimplex ( const int  N,
int alpha 
)

Definition at line 31 of file BernsteinBezier.cpp.

32  {
33  constexpr int edge_nodes[6][2] = {{0, 1}, {1, 2}, {2, 0},
34  {0, 3}, {1, 3}, {2, 3}};
36  std::fill(alpha, &alpha[(D + 1) * NBEDGE_H1(N)], 0);
37  for (int n = N - 1; n != 0; --n) {
38 
39  // + o o o o +
40 
41  alpha[edge_nodes[Side][0]] = n;
42  alpha[edge_nodes[Side][1]] = N - n;
43  alpha += D + 1;
44  }
46 }
#define NBEDGE_H1(P)
Numer of base function on edge for H1 space.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const int N
Definition: speed_test.cpp:3

◆ generateIndicesEdgeOnSimplex() [2/2]

template<int D, int Side>
static MoFEMErrorCode MoFEM::BernsteinBezier::generateIndicesEdgeOnSimplex ( const int  N,
int alpha 
)
staticprivate

Genarte BB incices od simplex edges.

Template Parameters
D
Side
Parameters
N
alpha
Returns
MoFEMErrorCode

◆ generateIndicesEdgeTet() [1/2]

MoFEMErrorCode BernsteinBezier::generateIndicesEdgeTet ( const int  N[],
int alpha[] 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 153 of file BernsteinBezier.cpp.

154  {
156  CHKERR generateIndicesEdgeOnSimplex<3, 0>(N[0], alpha[0]);
157  CHKERR generateIndicesEdgeOnSimplex<3, 1>(N[1], alpha[1]);
158  CHKERR generateIndicesEdgeOnSimplex<3, 2>(N[2], alpha[2]);
159  CHKERR generateIndicesEdgeOnSimplex<3, 3>(N[3], alpha[3]);
160  CHKERR generateIndicesEdgeOnSimplex<3, 4>(N[4], alpha[4]);
161  CHKERR generateIndicesEdgeOnSimplex<3, 5>(N[5], alpha[5]);
163 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
#define CHKERR
Inline error check.
Definition: definitions.h:596
const int N
Definition: speed_test.cpp:3

◆ generateIndicesEdgeTet() [2/2]

MoFEMErrorCode BernsteinBezier::generateIndicesEdgeTet ( const int  side,
const int  N,
int alpha 
)
static

Definition at line 165 of file BernsteinBezier.cpp.

167  {
169  switch (side) {
170  case 0:
171  return generateIndicesEdgeOnSimplex<3, 0>(N, alpha);
172  case 1:
173  return generateIndicesEdgeOnSimplex<3, 1>(N, alpha);
174  case 2:
175  return generateIndicesEdgeOnSimplex<3, 2>(N, alpha);
176  case 3:
177  return generateIndicesEdgeOnSimplex<3, 3>(N, alpha);
178  case 4:
179  return generateIndicesEdgeOnSimplex<3, 4>(N, alpha);
180  case 5:
181  return generateIndicesEdgeOnSimplex<3, 5>(N, alpha);
182  default:
183  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
184  "Wrong side number, on tetrahedron are edges from 0 to 5");
185  }
187 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const int N
Definition: speed_test.cpp:3

◆ generateIndicesEdgeTri() [1/2]

MoFEMErrorCode BernsteinBezier::generateIndicesEdgeTri ( const int  N[],
int alpha[] 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 114 of file BernsteinBezier.cpp.

115  {
117  CHKERR generateIndicesEdgeOnSimplex<2, 0>(N[0], alpha[0]);
118  CHKERR generateIndicesEdgeOnSimplex<2, 1>(N[1], alpha[1]);
119  CHKERR generateIndicesEdgeOnSimplex<2, 2>(N[2], alpha[2]);
121 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
#define CHKERR
Inline error check.
Definition: definitions.h:596
const int N
Definition: speed_test.cpp:3

◆ generateIndicesEdgeTri() [2/2]

MoFEMErrorCode BernsteinBezier::generateIndicesEdgeTri ( const int  side,
const int  N,
int alpha 
)
static

Definition at line 123 of file BernsteinBezier.cpp.

125  {
126  switch (side) {
127  case 0:
128  return generateIndicesEdgeOnSimplex<2, 0>(N, alpha);
129  case 1:
130  return generateIndicesEdgeOnSimplex<2, 1>(N, alpha);
131  case 2:
132  return generateIndicesEdgeOnSimplex<2, 2>(N, alpha);
133  default:
134  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
135  "Wrong side number, on triangle are edges from 0 to 2");
136  }
137 }
const int N
Definition: speed_test.cpp:3

◆ generateIndicesTetOnSimplex()

MoFEMErrorCode BernsteinBezier::generateIndicesTetOnSimplex ( const int  N,
int alpha 
)
staticprivate

Genarte BB indices on simplex.

\[ \frac{\partial^{|\mathbf{v}|} \phi^n_{\pmb\alpha}}{\partial \pmb\lambda^\mathbf{v}}= \mathbf{c}_{\pmb\alpha\pmb\beta} \phi^{n-|\mathbf{v}|}_{\pmb\beta} \]

Parameters
N
alpha
Returns
MoFEMErrorCode

Definition at line 74 of file BernsteinBezier.cpp.

75  {
77  std::fill(alpha, &alpha[4 * NBVOLUMETET_H1(N)], 0);
78  for (int n0 = 1; n0 != N - 1; ++n0) {
79  for (int n1 = 1; n1 != N - n0; ++n1) {
80  for (int n2 = 1; n2 != N - n0 - n1; ++n2) {
81  alpha[0] = n0;
82  alpha[1] = n1;
83  alpha[2] = n2;
84  alpha[3] = N - n0 - n1 - n2;
85  alpha += 4;
86  }
87  }
88  }
90 }
#define NBVOLUMETET_H1(P)
Number of base functions on tetrahedron for H1 space.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const int N
Definition: speed_test.cpp:3

◆ generateIndicesTetTet()

MoFEMErrorCode BernsteinBezier::generateIndicesTetTet ( const int  N,
int alpha 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 218 of file BernsteinBezier.cpp.

218  {
219  return generateIndicesTetOnSimplex(N, alpha);
220 }
static MoFEMErrorCode generateIndicesTetOnSimplex(const int N, int *alpha)
Genarte BB indices on simplex.
const int N
Definition: speed_test.cpp:3

◆ generateIndicesTriOnSimplex() [1/2]

template<int D, int Side>
MoFEMErrorCode MoFEM::BernsteinBezier::generateIndicesTriOnSimplex ( const int  N,
int alpha 
)

Definition at line 49 of file BernsteinBezier.cpp.

50  {
51  constexpr int tri_nodes[4][3] = {{0, 1, 3}, {1, 2, 3}, {0, 2, 3}, {0, 1, 2}};
53  std::fill(alpha, &alpha[(D + 1) * NBFACETRI_H1(N)], 0);
54  for (int n0 = 1; n0 != N - 1; ++n0) {
55  for (int n1 = 1; n1 != N - n0; ++n1) {
56 
57  // +
58  // + +
59  // + o +
60  // + o o +
61  // + o o o +
62  // + + + + + +
63 
64  alpha[tri_nodes[Side][0]] = n0;
65  alpha[tri_nodes[Side][1]] = n1;
66  alpha[tri_nodes[Side][2]] = N - n0 - n1;
67 
68  alpha += D + 1;
69  }
70  }
72 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
#define NBFACETRI_H1(P)
Number of base function on triangle for H1 space.
const int N
Definition: speed_test.cpp:3

◆ generateIndicesTriOnSimplex() [2/2]

template<int D, int Side>
static MoFEMErrorCode MoFEM::BernsteinBezier::generateIndicesTriOnSimplex ( const int  N,
int alpha 
)
staticprivate

Generate BB indices on simples triangles.

Template Parameters
D
Side
Parameters
N
alpha
Returns
MoFEMErrorCode

◆ generateIndicesTriTet() [1/2]

MoFEMErrorCode BernsteinBezier::generateIndicesTriTet ( const int  N[],
int alpha[] 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 189 of file BernsteinBezier.cpp.

190  {
192  CHKERR generateIndicesTriOnSimplex<3, 0>(N[0], alpha[0]);
193  CHKERR generateIndicesTriOnSimplex<3, 1>(N[1], alpha[1]);
194  CHKERR generateIndicesTriOnSimplex<3, 2>(N[2], alpha[2]);
195  CHKERR generateIndicesTriOnSimplex<3, 3>(N[3], alpha[3]);
197 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
#define CHKERR
Inline error check.
Definition: definitions.h:596
const int N
Definition: speed_test.cpp:3

◆ generateIndicesTriTet() [2/2]

MoFEMErrorCode BernsteinBezier::generateIndicesTriTet ( const int  side,
const int  N,
int alpha 
)
static

Definition at line 199 of file BernsteinBezier.cpp.

200  {
202  switch (side) {
203  case 0:
204  return generateIndicesTriOnSimplex<3, 0>(N, alpha);
205  case 1:
206  return generateIndicesTriOnSimplex<3, 1>(N, alpha);
207  case 2:
208  return generateIndicesTriOnSimplex<3, 2>(N, alpha);
209  case 3:
210  return generateIndicesTriOnSimplex<3, 3>(N, alpha);
211  default:
212  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
213  "Wrong side number, on tetrahedron are from from 0 to 3");
214  }
216 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const int N
Definition: speed_test.cpp:3

◆ generateIndicesTriTri()

MoFEMErrorCode BernsteinBezier::generateIndicesTriTri ( const int  N,
int alpha 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 139 of file BernsteinBezier.cpp.

139  {
140  return generateIndicesTriOnSimplex<2, 3>(N, alpha);
141 }
const int N
Definition: speed_test.cpp:3

◆ generateIndicesVertex() [1/2]

template<int D, int Side>
MoFEMErrorCode MoFEM::BernsteinBezier::generateIndicesVertex ( const int  N,
int alpha 
)

Definition at line 24 of file BernsteinBezier.cpp.

24  {
26  alpha[(D + 1) * Side + Side] = N;
28 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const int N
Definition: speed_test.cpp:3

◆ generateIndicesVertex() [2/2]

template<int D, int Side>
static MoFEMErrorCode MoFEM::BernsteinBezier::generateIndicesVertex ( const int  N,
int alpha 
)
staticprivate

Generate BB indices on vertices.

Template Parameters
D
Side
Parameters
N
alpha
Returns
MoFEMErrorCode

◆ generateIndicesVertexEdge()

MoFEMErrorCode BernsteinBezier::generateIndicesVertexEdge ( const int  N,
int alpha 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 92 of file BernsteinBezier.cpp.

93  {
95  CHKERR generateIndicesVertex<1, 0>(N, alpha);
96  CHKERR generateIndicesVertex<1, 1>(N, alpha);
98 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
#define CHKERR
Inline error check.
Definition: definitions.h:596
const int N
Definition: speed_test.cpp:3

◆ generateIndicesVertexTet()

MoFEMErrorCode BernsteinBezier::generateIndicesVertexTet ( const int  N,
int alpha 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 143 of file BernsteinBezier.cpp.

144  {
146  CHKERR generateIndicesVertex<3, 0>(N, alpha);
147  CHKERR generateIndicesVertex<3, 1>(N, alpha);
148  CHKERR generateIndicesVertex<3, 2>(N, alpha);
149  CHKERR generateIndicesVertex<3, 3>(N, alpha);
151 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
#define CHKERR
Inline error check.
Definition: definitions.h:596
const int N
Definition: speed_test.cpp:3

◆ generateIndicesVertexTri()

MoFEMErrorCode BernsteinBezier::generateIndicesVertexTri ( const int  N,
int alpha 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 105 of file BernsteinBezier.cpp.

106  {
108  CHKERR generateIndicesVertex<2, 0>(N, alpha);
109  CHKERR generateIndicesVertex<2, 1>(N, alpha);
110  CHKERR generateIndicesVertex<2, 2>(N, alpha);
112 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
#define CHKERR
Inline error check.
Definition: definitions.h:596
const int N
Definition: speed_test.cpp:3

◆ genrateDerivativeIndices() [1/2]

template<int D>
static MoFEMErrorCode MoFEM::BernsteinBezier::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 
)
staticprivate

Brief calculate coefficients for directive of base functions.

\[ \]

Template Parameters
D
Parameters
N
n_alpha
alpha
diff
n_alpha_diff
alpha_diff
c
Returns
MoFEMErrorCode

◆ genrateDerivativeIndices() [2/2]

template<int D>
MoFEMErrorCode MoFEM::BernsteinBezier::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 
)

Definition at line 223 of file BernsteinBezier.cpp.

225  {
227 
228  std::fill(c, &c[n_alpha * n_alpha_diff], 0);
229  int abs_diff = diff[0];
230  for (int d = 1; d != D + 1; ++d)
231  abs_diff += diff[d];
232 
233  const double b = boost::math::factorial<double>(N) /
234  boost::math::factorial<double>(N - abs_diff);
235 
236  for (int i = 0; i != n_alpha; ++i) {
237  for (int j = 0; j != n_alpha_diff; ++j) {
238  int d = 0;
239  for (; d != D + 1; ++d)
240  if (alpha_diff[(D + 1) * j + d] + diff[d] != alpha[(D + 1) * i + d])
241  break;
242  if (d == D + 1) {
243  c[i * n_alpha_diff + j] = b;
244  break;
245  }
246  }
247  }
248 
250 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27
const int N
Definition: speed_test.cpp:3

◆ genrateDerivativeIndicesEdges()

MoFEMErrorCode BernsteinBezier::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 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 252 of file BernsteinBezier.cpp.

254  {
255  return genrateDerivativeIndices<1>(N, n_alpha, alpha, diff, n_alpha_diff,
256  alpha_diff, c);
257 }
const int N
Definition: speed_test.cpp:3

◆ genrateDerivativeIndicesTet()

MoFEMErrorCode BernsteinBezier::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 
)
static

Definition at line 266 of file BernsteinBezier.cpp.

268  {
269  return genrateDerivativeIndices<3>(N, n_alpha, alpha, diff, n_alpha_diff,
270  alpha_diff, c);
271 }
const int N
Definition: speed_test.cpp:3

◆ genrateDerivativeIndicesTri()

MoFEMErrorCode BernsteinBezier::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 
)
static
Examples
bernstein_bezier_generate_base.cpp.

Definition at line 259 of file BernsteinBezier.cpp.

261  {
262  return genrateDerivativeIndices<2>(N, n_alpha, alpha, diff, n_alpha_diff,
263  alpha_diff, c);
264 }
const int N
Definition: speed_test.cpp:3

The documentation for this struct was generated from the following files: