v0.9.1
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::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 [24]. 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.

MoFEM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with MoFEM. If not, see http://www.gnu.org/licenses/

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 25 of file base_functions.c.

26  {
28  if (dim < 1)
29  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
30  if (dim > 3)
31  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
32  if (p < 0)
33  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 0");
34  L[0] = 1;
35  if (diffL != NULL) {
36  diffL[0 * (p + 1) + 0] = 0;
37  if (dim >= 2) {
38  diffL[1 * (p + 1) + 0] = 0;
39  if (dim == 3) {
40  diffL[2 * (p + 1) + 0] = 0;
41  }
42  }
43  }
44  if (p == 0)
46  L[1] = s;
47  if (diffL != NULL) {
48  if (diff_s == NULL) {
49  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
50  }
51  diffL[0 * (p + 1) + 1] = diff_s[0];
52  if (dim >= 2) {
53  diffL[1 * (p + 1) + 1] = diff_s[1];
54  if (dim == 3) {
55  diffL[2 * (p + 1) + 1] = diff_s[2];
56  }
57  }
58  }
59  if (p == 1)
61  int l = 1;
62  for (; l < p; l++) {
63  double A = ((2 * (double)l + 1) / ((double)l + 1));
64  double B = ((double)l / ((double)l + 1));
65  L[l + 1] = A * s * L[l] - B * L[l - 1];
66  if (diffL != NULL) {
67  diffL[0 * (p + 1) + l + 1] =
68  A * (s * diffL[0 * (p + 1) + l] + diff_s[0] * L[l]) -
69  B * diffL[0 * (p + 1) + l - 1];
70  if (dim >= 2) {
71  diffL[1 * (p + 1) + l + 1] =
72  A * (s * diffL[1 * (p + 1) + l] + diff_s[1] * L[l]) -
73  B * diffL[1 * (p + 1) + l - 1];
74  if (dim == 3) {
75  diffL[2 * (p + 1) + l + 1] =
76  A * (s * diffL[2 * (p + 1) + l] + diff_s[2] * L[l]) -
77  B * diffL[2 * (p + 1) + l - 1];
78  }
79  }
80  }
81  }
83 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
const int dim
FTensor::Index< 'l', 2 > l
Definition: ContactOps.hpp:29

◆ Lobatto_polynomials()

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

Calculate Lobatto base functions [24].

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  if (dim < 1)
216  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
217  if (dim > 3)
218  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
219  if (p < 2)
220  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 2");
221 
222  p -= 2; // polynomial order starts from 2
223  double l[p + 3];
224  ierr = Legendre_polynomials(p + 2, s, NULL, l, NULL, 1);
225  CHKERRQ(ierr);
226 
227  // Derivatives are Legender function
228  for (int k = 0; k <= p; k++) {
229  if (diffL != NULL) {
230  if (diff_s == NULL) {
231  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
232  }
233  double a = 0.5 * l[k + 1];
234  diffL[0 * (p + 1) + k] = a * diff_s[0];
235  if (dim >= 2) {
236  diffL[1 * (p + 1) + k] = a * diff_s[1];
237  if (dim == 3) {
238  diffL[2 * (p + 1) + k] = a * diff_s[2];
239  }
240  }
241  }
242  }
243 
244  // Integrated Legendre
245  for (int k = 0; k <= p; k++) {
246  double factor = 2.0 * (2.0 * (k + 1.0) + 1.0);
247  L[k] = 1.0 / factor * (l[k + 2] - l[k]);
248  }
250 }
PetscErrorCode Legendre_polynomials(int p, double s, double *diff_s, double *L, double *diffL, const int dim)
Calculate Legendre approximation basis.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
static PetscErrorCode ierr
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
const int dim
CHKERRQ(ierr)
FTensor::Index< 'k', 2 > k
Definition: ContactOps.hpp:28
FTensor::Index< 'l', 2 > l
Definition: ContactOps.hpp:29

◆ 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 347 of file base_functions.c.

349  {
351  if (dim < 1)
352  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
353  if (dim > 3)
354  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
355  if (p < 0)
356  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 0");
357  if (p > 9)
358  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
359  "Polynomial beyond order 9 is not implemented");
360  if (L) {
361  int l = 0;
362  for (; l != p + 1; l++) {
363  L[l] = f_phi[l](s);
364  }
365  }
366  if (diffL != NULL) {
367  if (diff_s == NULL) {
368  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
369  }
370  int l = 0;
371  for (; l != p + 1; l++) {
372  double a = f_phix[l](s);
373  diffL[0 * (p + 1) + l] = diff_s[0] * a;
374  if (dim >= 2) {
375  diffL[1 * (p + 1) + l] = diff_s[1] * a;
376  if (dim == 3) {
377  diffL[2 * (p + 1) + l] = diff_s[2] * a;
378  }
379  }
380  }
381  }
383 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
static double(* f_phix[])(double x)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
const int dim
static double(* f_phi[])(double x)
FTensor::Index< 'l', 2 > l
Definition: ContactOps.hpp:29