v0.14.0
Loading...
Searching...
No Matches
Classes | Functions
Base functions

Calculation of base functions at integration points. More...

Collaboration diagram for Base functions:

Classes

struct  MoFEM::BaseFunctionCtx
 Base class used to exchange data between element data structures and class calculating base functions. More...
 
struct  MoFEM::BaseFunction
 Base class if inherited used to calculate base functions. More...
 
struct  MoFEM::EdgePolynomialBase
 Calculate base functions on tetrahedral. More...
 
struct  MoFEM::EntPolynomialBaseCtx
 Class used to pass element data to calculate base functions on tet,triangle,edge. More...
 
struct  MoFEM::FatPrismPolynomialBaseCtx
 Class used to pass element data to calculate base functions on fat prism. More...
 
struct  MoFEM::FatPrismPolynomialBase
 Calculate base functions on tetrahedralFIXME: Need moab and mofem finite element structure to work (that not perfect) More...
 
struct  MoFEM::FlatPrismPolynomialBaseCtx
 Class used to pass element data to calculate base functions on flat prism. More...
 
struct  MoFEM::FlatPrismPolynomialBase
 Calculate base functions on tetrahedralFIXME: Need moab and mofem finite element structure to work (that not perfect) More...
 
struct  MoFEM::HexPolynomialBase
 Calculate base functions on tetrahedral. More...
 
struct  MoFEM::JacobiPolynomialCtx
 Class used to give arguments to Legendre base functions. More...
 
struct  MoFEM::JacobiPolynomial
 Calculating Legendre base functions. More...
 
struct  MoFEM::LegendrePolynomialCtx
 Class used to give arguments to Legendre base functions. More...
 
struct  MoFEM::LegendrePolynomial
 Calculating Legendre base functions. More...
 
struct  MoFEM::LobattoPolynomialCtx
 Class used to give arguments to Lobatto base functions. More...
 
struct  MoFEM::LobattoPolynomial
 Calculating Lobatto base functions. More...
 
struct  MoFEM::KernelLobattoPolynomialCtx
 Class used to give arguments to Kernel Lobatto base functions. More...
 
struct  MoFEM::KernelLobattoPolynomial
 Calculating Lobatto base functions. More...
 
struct  MoFEM::QuadPolynomialBase
 Calculate base functions on triangle. More...
 
struct  MoFEM::TetPolynomialBase
 Calculate base functions on tetrahedral. More...
 
struct  MoFEM::TriPolynomialBase
 Calculate base functions on triangle. More...
 

Functions

PetscErrorCode Legendre_polynomials (int p, double s, double *diff_s, double *L, double *diffL, const int dim)
 Calculate Legendre approximation basis. More...
 
PetscErrorCode Lobatto_polynomials (int p, double s, double *diff_s, double *L, double *diffL, const int dim)
 Calculate Lobatto base functions [25]. More...
 
PetscErrorCode LobattoKernel_polynomials (int p, double s, double *diff_s, double *L, double *diffL, const int dim)
 Calculate Kernel Lobatto base functions. More...
 

Detailed Description

Calculation of base functions at integration points.

Function Documentation

◆ Legendre_polynomials()

PetscErrorCode Legendre_polynomials ( int  p,
double  s,
double diff_s,
double L,
double diffL,
const int  dim 
)

Calculate Legendre approximation basis.

Lagrange polynomial is given by

\[ L_0(s)=1;\quad L_1(s) = s \]

and following terms are generated inductively

\[ L_{l+1}=\frac{2l+1}{l+1}sL_l(s)-\frac{l}{l+1}L_{l-1}(s) \]

Note that:

\[ s\in[-1,1] \quad \textrm{and}\; s=s(\xi_0,\xi_1,\xi_2) \]

where \(\xi_i\) are barycentric coordinates of element.

Parameters
pis approximation order
sis position \(s\in[-1,1]\)
diff_sderivatives of shape functions, i.e. \(\frac{\partial s}{\partial \xi_i}\)
Return values
Lapproximation functions
diffLderivatives, i.e. \(\frac{\partial L}{\partial \xi_i}\)
Parameters
dimdimension
Returns
error code
Examples
edge_and_bubble_shape_functions_on_quad.cpp.

Definition at line 15 of file base_functions.c.

16 {
18#ifndef NDEBUG
19 if (dim < 1)
20 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
21 if (dim > 3)
22 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
23 if (p < 0)
24 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 0");
25#endif // NDEBUG
26 L[0] = 1;
27 if (diffL != NULL) {
28 diffL[0 * (p + 1) + 0] = 0;
29 if (dim >= 2) {
30 diffL[1 * (p + 1) + 0] = 0;
31 if (dim == 3) {
32 diffL[2 * (p + 1) + 0] = 0;
33 }
34 }
35 }
36 if (p == 0)
38 L[1] = s;
39 if (diffL != NULL) {
40#ifndef NDEBUG
41 if (diff_s == NULL) {
42 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
43 }
44#endif // NDEBUG
45 diffL[0 * (p + 1) + 1] = diff_s[0];
46 if (dim >= 2) {
47 diffL[1 * (p + 1) + 1] = diff_s[1];
48 if (dim == 3) {
49 diffL[2 * (p + 1) + 1] = diff_s[2];
50 }
51 }
52 }
53 if (p == 1)
55 int l = 1;
56 for (; l < p; l++) {
57 double A = ((2 * (double)l + 1) / ((double)l + 1));
58 double B = ((double)l / ((double)l + 1));
59 L[l + 1] = A * s * L[l] - B * L[l - 1];
60 if (diffL != NULL) {
61 diffL[0 * (p + 1) + l + 1] =
62 A * (s * diffL[0 * (p + 1) + l] + diff_s[0] * L[l]) -
63 B * diffL[0 * (p + 1) + l - 1];
64 if (dim >= 2) {
65 diffL[1 * (p + 1) + l + 1] =
66 A * (s * diffL[1 * (p + 1) + l] + diff_s[1] * L[l]) -
67 B * diffL[1 * (p + 1) + l - 1];
68 if (dim == 3) {
69 diffL[2 * (p + 1) + l + 1] =
70 A * (s * diffL[2 * (p + 1) + l] + diff_s[2] * L[l]) -
71 B * diffL[2 * (p + 1) + l - 1];
72 }
73 }
74 }
75 }
77}
static Index< 'L', 3 > L
static Index< 'p', 3 > p
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
@ MOFEM_INVALID_DATA
Definition: definitions.h:36
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
const int dim
FTensor::Index< 'l', 3 > l
constexpr AssemblyType A

◆ Lobatto_polynomials()

PetscErrorCode Lobatto_polynomials ( int  p,
double  s,
double diff_s,
double L,
double diffL,
const int  dim 
)

Calculate Lobatto base functions [25].

Order of first function is 2 and goes to p.

Parameters
pis approximation order
sis a mapping of coordinates of edge to \([-1, 1]\), i.e., \(s(\xi_1,\cdot,\xi_{dim})\in[-1,1]\)
diff_sjacobian of the transformation, i.e. \(\frac{\partial s}{\partial \xi_i}\)
  • output
Return values
Lvalues basis functions at s
diffLderivatives of basis functions at s, i.e. \(\frac{\partial L}{\partial \xi_i}\)
Parameters
dimdimension
Returns
error code

Definition at line 211 of file base_functions.c.

212 {
213
215#ifndef NDEBUG
216 if (dim < 1)
217 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
218 if (dim > 3)
219 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
220 if (p < 2)
221 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 2");
222#endif // NDEBUG
223 double l[p + 5];
224 ierr = Legendre_polynomials(p + 4, s, NULL, l, NULL, 1);
225 CHKERRQ(ierr);
226
227 L[0] = 1;
228 if (diffL != NULL) {
229 diffL[0 * (p + 1) + 0] = 0;
230 if (dim >= 2) {
231 diffL[1 * (p + 1) + 0] = 0;
232 if (dim == 3) {
233 diffL[2 * (p + 1) + 0] = 0;
234 }
235 }
236 }
237 L[1] = s;
238 if (diffL != NULL) {
239#ifndef NDEBUG
240 if (diff_s == NULL) {
241 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
242 }
243#endif // NDEBUG
244 diffL[0 * (p + 1) + 1] = diff_s[0];
245 if (dim >= 2) {
246 diffL[1 * (p + 1) + 1] = diff_s[1];
247 if (dim == 3) {
248 diffL[2 * (p + 1) + 1] = diff_s[2];
249 }
250 }
251 }
252
253 // Integrated Legendre
254 for (int k = 2; k <= p; k++) {
255 const double factor = 2 * (2 * k - 1);
256 L[k] = 1.0 / factor * (l[k] - l[k - 2]);
257
258 if (diffL != NULL) {
259 if (diff_s == NULL) {
260 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
261 }
262 double a = l[k - 1] / 2.;
263 diffL[0 * (p + 1) + k] = a * diff_s[0];
264 if (dim >= 2) {
265 diffL[1 * (p + 1) + k] = a * diff_s[1];
266 if (dim == 3) {
267 diffL[2 * (p + 1) + k] = a * diff_s[2];
268 }
269 }
270 }
271 }
273}
constexpr double a
static PetscErrorCode ierr
PetscErrorCode Legendre_polynomials(int p, double s, double *diff_s, double *L, double *diffL, const int dim)
Calculate Legendre approximation basis.
FTensor::Index< 'k', 3 > k

◆ LobattoKernel_polynomials()

PetscErrorCode LobattoKernel_polynomials ( int  p,
double  s,
double diff_s,
double L,
double diffL,
const int  dim 
)

Calculate Kernel Lobatto base functions.

This is implemented using definitions from Hermes2d https://github.com/hpfem/hermes following book by Pavel Solin et al [solin2003higher].

Parameters
pis approximation order
sis position \(s\in[-1,1]\)
diff_sderivatives of shape functions, i.e. \(\frac{\partial s}{\partial \xi_i}\)
Return values
Lapproximation functions
diffLderivatives, i.e. \(\frac{\partial L}{\partial \xi_i}\)
Parameters
dimdimension
Returns
error code

Definition at line 370 of file base_functions.c.

372 {
374#ifndef NDEBUG
375 if (dim < 1)
376 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
377 if (dim > 3)
378 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
379 if (p < 0)
380 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 0");
381 if (p > 9)
382 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
383 "Polynomial beyond order 9 is not implemented");
384#endif // NDEBUG
385 if (L) {
386 int l = 0;
387 for (; l != p + 1; l++) {
388 L[l] = f_phi[l](s);
389 }
390 }
391 if (diffL != NULL) {
392#ifndef NDEBUG
393 if (diff_s == NULL) {
394 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
395 }
396#endif // NDEBUG
397 int l = 0;
398 for (; l != p + 1; l++) {
399 double a = f_phix[l](s);
400 diffL[0 * (p + 1) + l] = diff_s[0] * a;
401 if (dim >= 2) {
402 diffL[1 * (p + 1) + l] = diff_s[1] * a;
403 if (dim == 3) {
404 diffL[2 * (p + 1) + l] = diff_s[2] * a;
405 }
406 }
407 }
408 }
410}
static double(* f_phi[])(double x)
static double(* f_phix[])(double x)
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32