v0.14.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 
)
inlinestaticprivate

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 294 of file BernsteinBezier.cpp.

297  {
299 
300  const int *const alpha0 = alpha;
301  const double fN = boost::math::factorial<double>(N);
302  constexpr int MAX_ALPHA = 12;
303  int max_alpha = *std::max_element(alpha, &alpha[(D + 1) * n_alpha]);
304  if(max_alpha > MAX_ALPHA)
305  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
306  "Is assumed maximal order not to be bigger than %d", MAX_ALPHA);
307  std::array<double, (D + 1) * (MAX_ALPHA + 1)> pow_alpha;
308  std::array<double, (MAX_ALPHA + 1)> factorial_alpha;
309  std::array<double, D + 1> terms, diff_terms;
310  const double *const grad_lambda0 = grad_lambda;
311 
312  factorial_alpha[0] = 1;
313  if (max_alpha >= 1)
314  factorial_alpha[1] = 1;
315  if (max_alpha >= 2)
316  for (int a = 2; a <= max_alpha; ++a)
317  factorial_alpha[a] = factorial_alpha[a - 1] * a;
318 
319  for (int g = 0; g != gdim; ++g) {
320 
321  for (int n = 0; n != D + 1; ++n, ++lambda) {
322  const size_t shift = (MAX_ALPHA + 1) * n;
323  double *pow_alpha_ptr = &pow_alpha[shift];
324  *pow_alpha_ptr = 1;
325 
326  if (max_alpha >= 1) {
327  ++pow_alpha_ptr;
328  *pow_alpha_ptr = *lambda;
329  }
330 
331  if (max_alpha >= 2)
332  for (int a = 2; a <= max_alpha; ++a) {
333  const double p = (*pow_alpha_ptr) * (*lambda);
334  ++pow_alpha_ptr;
335  *pow_alpha_ptr = p;
336  }
337  }
338 
339  for (int n0 = 0; n0 != n_alpha; ++n0) {
340 
341  grad_lambda = grad_lambda0;
342 
343  double f = factorial_alpha[(*alpha)];
344  double *terms_ptr = terms.data();
345  double *diff_terms_ptr = diff_terms.data();
346  *terms_ptr = pow_alpha[(*alpha)];
347  if (GRAD_BASE) {
348  if (*alpha > 0)
349  *diff_terms_ptr = (*alpha) * pow_alpha[(*alpha) - 1];
350  else
351  *diff_terms_ptr = 0;
352  }
353  *base = *terms_ptr;
354  ++alpha;
355  ++terms_ptr;
356  ++diff_terms_ptr;
357 
358  for (int n1 = 1; n1 < D + 1;
359  ++n1, ++alpha, ++terms_ptr, ++diff_terms_ptr) {
360  f *= factorial_alpha[(*alpha)];
361  const size_t shift = (MAX_ALPHA + 1) * n1;
362  *terms_ptr = pow_alpha[shift + (*alpha)];
363  if (GRAD_BASE) {
364  if (*alpha > 0)
365  *diff_terms_ptr = (*alpha) * pow_alpha[shift + (*alpha) - 1];
366  else
367  *diff_terms_ptr = 0;
368  }
369  *base *= *terms_ptr;
370  }
371 
372  const double b = fN / f;
373  *base *= b;
374  ++base;
375 
376  if (GRAD_BASE) {
377  double *terms_ptr = terms.data();
378  double *diff_terms_ptr = diff_terms.data();
379  double z = *diff_terms_ptr;
380  ++terms_ptr;
381  ++diff_terms_ptr;
382  for (int n2 = 1; n2 != D + 1; ++n2, ++terms_ptr)
383  z *= *terms_ptr;
384 
385  for (int d = 0; d != D; ++d, ++grad_lambda)
386  grad_base[d] = z * (*grad_lambda);
387 
388  for (int n1 = 1; n1 < D + 1; ++n1) {
389  z = *diff_terms_ptr;
390 
391  int n2 = 0;
392  for (terms_ptr = terms.data(); n2 != n1; ++n2, ++terms_ptr)
393  z *= *terms_ptr;
394 
395  ++n2;
396  ++terms_ptr;
397 
398  for (; n2 < D + 1; ++n2, ++terms_ptr)
399  z *= *terms_ptr;
400 
401  for (int d = 0; d != D; ++d, ++grad_lambda)
402  grad_base[d] += z * (*grad_lambda);
403 
404  ++diff_terms_ptr;
405  }
406  for (int d = 0; d != D; ++d)
407  grad_base[d] *= b;
408  grad_base += D;
409  }
410 
411  }
412 
413  alpha = alpha0;
414  }
415 
417 }

◆ 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 419 of file BernsteinBezier.cpp.

422  {
423  if (grad_base)
424  return baseFunctions<1, true>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
425  base, grad_base);
426  else
427  return baseFunctions<1, false>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
428  base, grad_base);
429 }

◆ 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 443 of file BernsteinBezier.cpp.

446  {
447  if (grad_base)
448  return baseFunctions<3, true>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
449  base, grad_base);
450  else
451  return baseFunctions<3, false>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
452  base, grad_base);
453 }

◆ 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 431 of file BernsteinBezier.cpp.

434  {
435  if (grad_base)
436  return baseFunctions<2, true>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
437  base, grad_base);
438  else
439  return baseFunctions<2, false>(N, gdim, n_alpha, alpha, lambda, grad_lambda,
440  base, grad_base);
441 }

◆ 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 
)
inlinestaticprivate

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 260 of file BernsteinBezier.cpp.

262  {
265 
267  x_alpha, &x_alpha[1], &x_alpha[2]);
268  for (int n0 = 0; n0 != n_alpha; ++n0) {
269  t_x_alpha(i) = 0;
271  x_k, &x_k[1], &x_k[2]);
272  for (int n1 = 0; n1 != n_x; ++n1) {
273  t_x_alpha(i) += static_cast<double>(*alpha) * t_x_k(i);
274  ++t_x_k;
275  ++alpha;
276  }
277  t_x_alpha(i) /= static_cast<double>(N);
278  ++t_x_alpha;
279  }
280 
282 }

◆ 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 284 of file BernsteinBezier.cpp.

288  {
289  return domainPoints<3>(N, n_x, n_alpha, alpha, x_k, x_alpha);
290 }

◆ generateIndicesEdgeEdge()

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

Definition at line 85 of file BernsteinBezier.cpp.

86  {
87  return generateIndicesEdgeOnSimplex<1, 0>(N, alpha);
88 }

◆ generateIndicesEdgeOnSimplex() [1/2]

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

Definition at line 16 of file BernsteinBezier.cpp.

17  {
18  constexpr int edge_nodes[6][2] = {{0, 1}, {1, 2}, {2, 0},
19  {0, 3}, {1, 3}, {2, 3}};
21  std::fill(alpha, &alpha[(D + 1) * NBEDGE_H1(N)], 0);
22  for (int n = N - 1; n != 0; --n) {
23 
24  // + o o o o +
25 
26  alpha[edge_nodes[Side][0]] = n;
27  alpha[edge_nodes[Side][1]] = N - n;
28  alpha += D + 1;
29  }
31 }

◆ generateIndicesEdgeOnSimplex() [2/2]

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

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 138 of file BernsteinBezier.cpp.

139  {
141  CHKERR generateIndicesEdgeOnSimplex<3, 0>(N[0], alpha[0]);
142  CHKERR generateIndicesEdgeOnSimplex<3, 1>(N[1], alpha[1]);
143  CHKERR generateIndicesEdgeOnSimplex<3, 2>(N[2], alpha[2]);
144  CHKERR generateIndicesEdgeOnSimplex<3, 3>(N[3], alpha[3]);
145  CHKERR generateIndicesEdgeOnSimplex<3, 4>(N[4], alpha[4]);
146  CHKERR generateIndicesEdgeOnSimplex<3, 5>(N[5], alpha[5]);
148 }

◆ generateIndicesEdgeTet() [2/2]

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

Definition at line 150 of file BernsteinBezier.cpp.

152  {
154  switch (side) {
155  case 0:
156  return generateIndicesEdgeOnSimplex<3, 0>(N, alpha);
157  case 1:
158  return generateIndicesEdgeOnSimplex<3, 1>(N, alpha);
159  case 2:
160  return generateIndicesEdgeOnSimplex<3, 2>(N, alpha);
161  case 3:
162  return generateIndicesEdgeOnSimplex<3, 3>(N, alpha);
163  case 4:
164  return generateIndicesEdgeOnSimplex<3, 4>(N, alpha);
165  case 5:
166  return generateIndicesEdgeOnSimplex<3, 5>(N, alpha);
167  default:
168  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
169  "Wrong side number, on tetrahedron are edges from 0 to 5");
170  }
172 }

◆ generateIndicesEdgeTri() [1/2]

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

Definition at line 99 of file BernsteinBezier.cpp.

100  {
102  CHKERR generateIndicesEdgeOnSimplex<2, 0>(N[0], alpha[0]);
103  CHKERR generateIndicesEdgeOnSimplex<2, 1>(N[1], alpha[1]);
104  CHKERR generateIndicesEdgeOnSimplex<2, 2>(N[2], alpha[2]);
106 }

◆ generateIndicesEdgeTri() [2/2]

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

Definition at line 108 of file BernsteinBezier.cpp.

110  {
111  switch (side) {
112  case 0:
113  return generateIndicesEdgeOnSimplex<2, 0>(N, alpha);
114  case 1:
115  return generateIndicesEdgeOnSimplex<2, 1>(N, alpha);
116  case 2:
117  return generateIndicesEdgeOnSimplex<2, 2>(N, alpha);
118  default:
119  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
120  "Wrong side number, on triangle are edges from 0 to 2");
121  }
122 }

◆ 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 59 of file BernsteinBezier.cpp.

60  {
62  std::fill(alpha, &alpha[4 * NBVOLUMETET_H1(N)], 0);
63  for (int n0 = 1; n0 != N - 1; ++n0) {
64  for (int n1 = 1; n1 != N - n0; ++n1) {
65  for (int n2 = 1; n2 != N - n0 - n1; ++n2) {
66  alpha[0] = n0;
67  alpha[1] = n1;
68  alpha[2] = n2;
69  alpha[3] = N - n0 - n1 - n2;
70  alpha += 4;
71  }
72  }
73  }
75 }

◆ generateIndicesTetTet()

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

Definition at line 203 of file BernsteinBezier.cpp.

203  {
204  return generateIndicesTetOnSimplex(N, alpha);
205 }

◆ generateIndicesTriOnSimplex() [1/2]

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

Definition at line 34 of file BernsteinBezier.cpp.

35  {
36  constexpr int tri_nodes[4][3] = {{0, 1, 3}, {1, 2, 3}, {0, 2, 3}, {0, 1, 2}};
38  std::fill(alpha, &alpha[(D + 1) * NBFACETRI_H1(N)], 0);
39  for (int n0 = 1; n0 != N - 1; ++n0) {
40  for (int n1 = 1; n1 != N - n0; ++n1) {
41 
42  // +
43  // + +
44  // + o +
45  // + o o +
46  // + o o o +
47  // + + + + + +
48 
49  alpha[tri_nodes[Side][0]] = n0;
50  alpha[tri_nodes[Side][1]] = n1;
51  alpha[tri_nodes[Side][2]] = N - n0 - n1;
52 
53  alpha += D + 1;
54  }
55  }
57 }

◆ generateIndicesTriOnSimplex() [2/2]

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

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 174 of file BernsteinBezier.cpp.

175  {
177  CHKERR generateIndicesTriOnSimplex<3, 0>(N[0], alpha[0]);
178  CHKERR generateIndicesTriOnSimplex<3, 1>(N[1], alpha[1]);
179  CHKERR generateIndicesTriOnSimplex<3, 2>(N[2], alpha[2]);
180  CHKERR generateIndicesTriOnSimplex<3, 3>(N[3], alpha[3]);
182 }

◆ generateIndicesTriTet() [2/2]

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

Definition at line 184 of file BernsteinBezier.cpp.

185  {
187  switch (side) {
188  case 0:
189  return generateIndicesTriOnSimplex<3, 0>(N, alpha);
190  case 1:
191  return generateIndicesTriOnSimplex<3, 1>(N, alpha);
192  case 2:
193  return generateIndicesTriOnSimplex<3, 2>(N, alpha);
194  case 3:
195  return generateIndicesTriOnSimplex<3, 3>(N, alpha);
196  default:
197  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
198  "Wrong side number, on tetrahedron are from from 0 to 3");
199  }
201 }

◆ generateIndicesTriTri()

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

Definition at line 124 of file BernsteinBezier.cpp.

124  {
125  return generateIndicesTriOnSimplex<2, 3>(N, alpha);
126 }

◆ generateIndicesVertex() [1/2]

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

Definition at line 9 of file BernsteinBezier.cpp.

9  {
11  alpha[(D + 1) * Side + Side] = N;
13 }

◆ generateIndicesVertex() [2/2]

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

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 77 of file BernsteinBezier.cpp.

78  {
80  CHKERR generateIndicesVertex<1, 0>(N, alpha);
81  CHKERR generateIndicesVertex<1, 1>(N, alpha);
83 }

◆ generateIndicesVertexTet()

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

Definition at line 128 of file BernsteinBezier.cpp.

129  {
131  CHKERR generateIndicesVertex<3, 0>(N, alpha);
132  CHKERR generateIndicesVertex<3, 1>(N, alpha);
133  CHKERR generateIndicesVertex<3, 2>(N, alpha);
134  CHKERR generateIndicesVertex<3, 3>(N, alpha);
136 }

◆ generateIndicesVertexTri()

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

Definition at line 90 of file BernsteinBezier.cpp.

91  {
93  CHKERR generateIndicesVertex<2, 0>(N, alpha);
94  CHKERR generateIndicesVertex<2, 1>(N, alpha);
95  CHKERR generateIndicesVertex<2, 2>(N, alpha);
97 }

◆ 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 208 of file BernsteinBezier.cpp.

210  {
212 
213  std::fill(c, &c[n_alpha * n_alpha_diff], 0);
214  int abs_diff = diff[0];
215  for (int d = 1; d != D + 1; ++d)
216  abs_diff += diff[d];
217 
218  const double b = boost::math::factorial<double>(N) /
219  boost::math::factorial<double>(N - abs_diff);
220 
221  for (int i = 0; i != n_alpha; ++i) {
222  for (int j = 0; j != n_alpha_diff; ++j) {
223  int d = 0;
224  for (; d != D + 1; ++d)
225  if (alpha_diff[(D + 1) * j + d] + diff[d] != alpha[(D + 1) * i + d])
226  break;
227  if (d == D + 1) {
228  c[i * n_alpha_diff + j] = b;
229  break;
230  }
231  }
232  }
233 
235 }

◆ 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 237 of file BernsteinBezier.cpp.

239  {
240  return genrateDerivativeIndices<1>(N, n_alpha, alpha, diff, n_alpha_diff,
241  alpha_diff, c);
242 }

◆ 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 251 of file BernsteinBezier.cpp.

253  {
254  return genrateDerivativeIndices<3>(N, n_alpha, alpha, diff, n_alpha_diff,
255  alpha_diff, c);
256 }

◆ 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 244 of file BernsteinBezier.cpp.

246  {
247  return genrateDerivativeIndices<2>(N, n_alpha, alpha, diff, n_alpha_diff,
248  alpha_diff, c);
249 }

The documentation for this struct was generated from the following files:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
g
constexpr double g
Definition: shallow_wave.cpp:63
NBEDGE_H1
#define NBEDGE_H1(P)
Number of base function on edge for H1 space.
Definition: h1_hdiv_hcurl_l2.h:55
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
NBVOLUMETET_H1
#define NBVOLUMETET_H1(P)
Number of base functions on tetrahedron for H1 space.
Definition: h1_hdiv_hcurl_l2.h:75
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
a
constexpr double a
Definition: approx_sphere.cpp:30
double
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index
Definition: Index.hpp:23
convert.n
n
Definition: convert.py:82
N
const int N
Definition: speed_test.cpp:3
NBFACETRI_H1
#define NBFACETRI_H1(P)
Number of base function on triangle for H1 space.
Definition: h1_hdiv_hcurl_l2.h:60
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
lambda
static double lambda
Definition: incompressible_elasticity.cpp:199
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
sdf_hertz_2d_axisymm_plane.d
float d
Definition: sdf_hertz_2d_axisymm_plane.py:4
ReactionDiffusionEquation::D
const double D
diffusivity
Definition: reaction_diffusion.cpp:20
MoFEM::BernsteinBezier::generateIndicesTetOnSimplex
static MoFEMErrorCode generateIndicesTetOnSimplex(const int N, int *alpha)
Genarte BB indices on simplex.
Definition: BernsteinBezier.cpp:59
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453