v0.9.0
Macros | Functions
base_functions.h File Reference

Go to the source code of this file.

Macros

#define LOBATTO_PHI0(x)   (-2.0 * 1.22474487139158904909864203735)
 Definitions taken from Hermes2d code. More...
 
#define LOBATTO_PHI1(x)   (-2.0 * 1.58113883008418966599944677222 * (x))
 
#define LOBATTO_PHI2(x)   (-1.0 / 2.0 * 1.87082869338697069279187436616 * (5 * (x) * (x)-1))
 
#define LOBATTO_PHI3(x)   (-1.0 / 2.0 * 2.12132034355964257320253308631 * (7 * (x) * (x)-3) * (x))
 
#define LOBATTO_PHI4(x)
 
#define LOBATTO_PHI5(x)
 
#define LOBATTO_PHI6(x)
 
#define LOBATTO_PHI7(x)
 
#define LOBATTO_PHI8(x)
 
#define LOBATTO_PHI9(x)
 
#define LOBATTO_PHI0X(x)   (0)
 Derivatives of kernel functions for Lobbatto base. More...
 
#define LOBATTO_PHI1X(x)   (-2.0 * 1.58113883008418966599944677222)
 
#define LOBATTO_PHI2X(x)   (-1.0 / 2.0 * 1.87082869338697069279187436616 * (10 * (x)))
 
#define LOBATTO_PHI3X(x)   (-1.0 / 2.0 * 2.12132034355964257320253308631 * (21.0 * (x) * (x)-3.0))
 
#define LOBATTO_PHI4X(x)
 
#define LOBATTO_PHI5X(x)
 
#define LOBATTO_PHI6X(x)
 
#define LOBATTO_PHI7X(x)
 
#define LOBATTO_PHI8X(x)
 
#define LOBATTO_PHI9X(x)
 

Functions

PetscErrorCode Legendre_polynomials (int p, double s, double *diff_s, double *L, double *diffL, const int dim)
 Calculate Legendre approximation basis. More...
 
PetscErrorCode Jacobi_polynomials (int p, double alpha, double x, double t, double *diff_x, double *diff_t, double *L, double *diffL, const int dim)
 Calculate Jacobi approximation basis. More...
 
PetscErrorCode IntegratedJacobi_polynomials (int p, double alpha, double x, double t, double *diff_x, double *diff_t, double *L, double *diffL, const int dim)
 Calculate integrated Jacobi approximation basis. More...
 
PetscErrorCode Lobatto_polynomials (int p, double s, double *diff_s, double *L, double *diffL, const int dim)
 Calculate Lobatto base functions. More...
 
PetscErrorCode LobattoKernel_polynomials (int p, double s, double *diff_s, double *L, double *diffL, const int dim)
 Calculate Kernel Lobatto base functions. More...
 

Macro Definition Documentation

◆ LOBATTO_PHI0

#define LOBATTO_PHI0 (   x)    (-2.0 * 1.22474487139158904909864203735)

Definitions taken from Hermes2d code.

kernel functions for Lobatto base

Definition at line 135 of file base_functions.h.

◆ LOBATTO_PHI0X

#define LOBATTO_PHI0X (   x)    (0)

Derivatives of kernel functions for Lobbatto base.

Definition at line 166 of file base_functions.h.

◆ LOBATTO_PHI1

#define LOBATTO_PHI1 (   x)    (-2.0 * 1.58113883008418966599944677222 * (x))

Definition at line 136 of file base_functions.h.

◆ LOBATTO_PHI1X

#define LOBATTO_PHI1X (   x)    (-2.0 * 1.58113883008418966599944677222)

Definition at line 167 of file base_functions.h.

◆ LOBATTO_PHI2

#define LOBATTO_PHI2 (   x)    (-1.0 / 2.0 * 1.87082869338697069279187436616 * (5 * (x) * (x)-1))

Definition at line 137 of file base_functions.h.

◆ LOBATTO_PHI2X

#define LOBATTO_PHI2X (   x)    (-1.0 / 2.0 * 1.87082869338697069279187436616 * (10 * (x)))

Definition at line 168 of file base_functions.h.

◆ LOBATTO_PHI3

#define LOBATTO_PHI3 (   x)    (-1.0 / 2.0 * 2.12132034355964257320253308631 * (7 * (x) * (x)-3) * (x))

Definition at line 139 of file base_functions.h.

◆ LOBATTO_PHI3X

#define LOBATTO_PHI3X (   x)    (-1.0 / 2.0 * 2.12132034355964257320253308631 * (21.0 * (x) * (x)-3.0))

Definition at line 170 of file base_functions.h.

◆ LOBATTO_PHI4

#define LOBATTO_PHI4 (   x)
Value:
(-1.0 / 4.0 * 2.34520787991171477728281505677 * \
(21 * (x) * (x) * (x) * (x)-14 * (x) * (x) + 1))

Definition at line 141 of file base_functions.h.

◆ LOBATTO_PHI4X

#define LOBATTO_PHI4X (   x)
Value:
(-1.0 / 4.0 * 2.34520787991171477728281505677 * \
((84.0 * (x) * (x)-28.0) * (x)))

Definition at line 172 of file base_functions.h.

◆ LOBATTO_PHI5

#define LOBATTO_PHI5 (   x)
Value:
(-1.0 / 4.0 * 2.54950975679639241501411205451 * \
((33 * (x) * (x)-30) * (x) * (x) + 5) * (x))

Definition at line 144 of file base_functions.h.

◆ LOBATTO_PHI5X

#define LOBATTO_PHI5X (   x)
Value:
(-1.0 / 4.0 * 2.54950975679639241501411205451 * \
((165.0 * (x) * (x)-90.0) * (x) * (x) + 5.0))

Definition at line 175 of file base_functions.h.

◆ LOBATTO_PHI6

#define LOBATTO_PHI6 (   x)
Value:
(-1.0 / 32.0 * 2.73861278752583056728484891400 * \
(((429 * (x) * (x)-495) * (x) * (x) + 135) * (x) * (x)-5))

Definition at line 147 of file base_functions.h.

◆ LOBATTO_PHI6X

#define LOBATTO_PHI6X (   x)
Value:
(-1.0 / 32.0 * 2.73861278752583056728484891400 * \
(((2574.0 * (x) * (x)-1980.0) * (x) * (x) + 270.0) * (x)))

Definition at line 178 of file base_functions.h.

◆ LOBATTO_PHI7

#define LOBATTO_PHI7 (   x)
Value:
(-1.0 / 32.0 * 2.91547594742265023543707643877 * \
(((715 * (x) * (x)-1001) * (x) * (x) + 385) * (x) * (x)-35) * (x))

Definition at line 150 of file base_functions.h.

◆ LOBATTO_PHI7X

#define LOBATTO_PHI7X (   x)
Value:
(-1.0 / 32.0 * 2.91547594742265023543707643877 * \
(((5005.0 * (x) * (x)-5005.0) * (x) * (x) + 1155.0) * (x) * (x)-35.0))

Definition at line 181 of file base_functions.h.

◆ LOBATTO_PHI8

#define LOBATTO_PHI8 (   x)
Value:
(-1.0 / 64.0 * 3.08220700148448822512509619073 * \
((((2431 * (x) * (x)-4004) * (x) * (x) + 2002) * (x) * (x)-308) * (x) * \
(x) + \
7))

Definition at line 153 of file base_functions.h.

◆ LOBATTO_PHI8X

#define LOBATTO_PHI8X (   x)
Value:
(-1.0 / 64.0 * 3.08220700148448822512509619073 * \
((((19448.0 * (x) * (x)-24024.0) * (x) * (x) + 8008.0) * (x) * (x)-616.0) * \
(x)))

Definition at line 184 of file base_functions.h.

◆ LOBATTO_PHI9

#define LOBATTO_PHI9 (   x)
Value:
(-1.0 / 128.0 * 6.4807406984078603784382721642 * \
((((4199 * (x) * (x)-7956) * (x) * (x) + 4914) * (x) * (x)-1092) * (x) * \
(x) + \
63) * \
(x))

Definition at line 158 of file base_functions.h.

◆ LOBATTO_PHI9X

#define LOBATTO_PHI9X (   x)
Value:
(-1.0 / 128.0 * 6.4807406984078603784382721642 * \
((((37791.0 * (x) * (x)-55692.0) * (x) * (x) + 24570.0) * (x) * \
(x)-3276.0) * \
(x) * (x)-63.0))

Definition at line 188 of file base_functions.h.

Function Documentation

◆ IntegratedJacobi_polynomials()

PetscErrorCode IntegratedJacobi_polynomials ( int  p,
double  alpha,
double  x,
double  t,
double diff_x,
double diff_t,
double L,
double diffL,
const int  dim 
)

Calculate integrated Jacobi approximation basis.

For more details see [24]

Parameters
pis approximation order
alphapolynomial parameter
xis position \(s\in[0,t]\)
trange of polynomial
diff_xderivatives of shape functions, i.e. \(\frac{\partial x}{\partial \xi_i}\)
diff_tderivatives of shape functions, i.e. \(\frac{\partial t}{\partial \xi_i}\)
Return values
Lapproximation functions
diffLderivatives, i.e. \(\frac{\partial L}{\partial \xi_i}\)
Parameters
dimdimension
Returns
error code

Definition at line 165 of file base_functions.c.

168  {
170  if (dim < 1)
171  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
172  if (dim > 3)
173  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
174  if (p < 1)
175  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 1");
176  L[0] = x;
177  if (diffL != NULL) {
178  int d = 0;
179  for (; d != dim; ++d) {
180  diffL[d * p + 0] = diff_x[d];
181  }
182  }
183  if (p == 0)
185  double jacobi[(p + 1)];
186  double diff_jacobi[(p + 1) * dim];
187  ierr = Jacobi_polynomials(p, alpha, x, t, diff_x, diff_t, jacobi, diff_jacobi,
188  dim);
189  CHKERRQ(ierr);
190  int l = 1;
191  for (; l < p; l++) {
192  int i = l + 1;
193  const double a = (i + alpha) / ((2 * i + alpha - 1) * (2 * i + alpha));
194  const double b = alpha / ((2 * i + alpha - 2) * (2 * i + alpha));
195  const double c = (i - 1) / ((2 * i + alpha - 2) * (2 * i + alpha - 1));
196  L[l] = a * jacobi[i] + b * t * jacobi[i - 1] - c * t * t * jacobi[i - 2];
197  if (diffL != NULL) {
198  int dd = 0;
199  for (; dd != dim; ++dd) {
200  diffL[dd * p + l] = a * diff_jacobi[dd * (p + 1) + i] +
201  b * (t * diff_jacobi[dd * (p + 1) + i - 1] +
202  diff_t[dd] * jacobi[i - 1]) -
203  c * (t * t * diff_jacobi[dd * (p + 1) + i - 2] +
204  2 * t * diff_t[dd] * jacobi[i - 2]);
205  }
206  }
207  }
209 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
PetscErrorCode Jacobi_polynomials(int p, double alpha, double x, double t, double *diff_x, double *diff_t, double *L, double *diffL, const int dim)
Calculate Jacobi approximation basis.
static PetscErrorCode ierr
#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 Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
CHKERRQ(ierr)

◆ Jacobi_polynomials()

PetscErrorCode Jacobi_polynomials ( int  p,
double  alpha,
double  x,
double  t,
double diff_x,
double diff_t,
double L,
double diffL,
const int  dim 
)

Calculate Jacobi approximation basis.

For more details see [24]

Parameters
pis approximation order
alphapolynomial parameter
xis position \(s\in[0,t]\)
trange of polynomial
diff_xderivatives of shape functions, i.e. \(\frac{\partial x}{\partial \xi_i}\)
diff_tderivatives of shape functions, i.e. \(\frac{\partial t}{\partial \xi_i}\)
Return values
Lapproximation functions
diffLderivatives, i.e. \(\frac{\partial L}{\partial \xi_i}\)
Parameters
dimdimension
Returns
error code

Definition at line 85 of file base_functions.c.

87  {
89  if (dim < 1)
90  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
91  if (dim > 3)
92  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
93  if (p < 0)
94  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 0");
95  L[0] = 1;
96  if (diffL != NULL) {
97  diffL[0 * (p + 1) + 0] = 0;
98  if (dim >= 2) {
99  diffL[1 * (p + 1) + 0] = 0;
100  if (dim == 3) {
101  diffL[2 * (p + 1) + 0] = 0;
102  }
103  }
104  }
105  if (p == 0)
107  L[1] = 2 * x - t + alpha * x;
108  if (diffL != NULL) {
109  if (diff_x == NULL) {
110  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
111  }
112  double d_t = (diff_t) ? diff_t[0] : 0;
113  diffL[0 * (p + 1) + 1] = (2 + alpha) * diff_x[0] - d_t;
114  if (dim >= 2) {
115  double d_t = (diff_t) ? diff_t[1] : 0;
116  diffL[1 * (p + 1) + 1] = (2 + alpha) * diff_x[1] - d_t;
117  if (dim == 3) {
118  double d_t = (diff_t) ? diff_t[2] : 0;
119  diffL[2 * (p + 1) + 1] = (2 + alpha) * diff_x[2] - d_t;
120  }
121  }
122  }
123  if (p == 1)
125  int l = 1;
126  for (; l < p; l++) {
127  int lp1 = l + 1;
128  double a = 2 * lp1 * (lp1 + alpha) * (2 * lp1 + alpha - 2);
129  double b = 2 * lp1 + alpha - 1;
130  double c = (2 * lp1 + alpha) * (2 * lp1 + alpha - 2);
131  double d = 2 * (lp1 + alpha - 1) * (lp1 - 1) * (2 * lp1 + alpha);
132  double A = b * (c * (2 * x - t) + alpha * alpha * t) / a;
133  double B = d * t * t / a;
134  L[lp1] = A * L[l] - B * L[l - 1];
135  if (diffL != NULL) {
136  double d_t = (diff_t) ? diff_t[0] : 0;
137  double diffA = b * (c * (2 * diff_x[0] - d_t) + alpha * alpha * d_t) / a;
138  double diffB = d * 2 * t * d_t / a;
139  diffL[0 * (p + 1) + lp1] = A * diffL[0 * (p + 1) + l] -
140  B * diffL[0 * (p + 1) + l - 1] + diffA * L[l] -
141  diffB * L[l - 1];
142  if (dim >= 2) {
143  double d_t = (diff_t) ? diff_t[1] : 0;
144  double diffA =
145  b * (c * (2 * diff_x[1] - d_t) + alpha * alpha * d_t) / a;
146  double diffB = d * 2 * t * d_t / a;
147  diffL[1 * (p + 1) + lp1] = A * diffL[1 * (p + 1) + l] -
148  B * diffL[1 * (p + 1) + l - 1] +
149  diffA * L[l] - diffB * L[l - 1];
150  if (dim == 3) {
151  double d_t = (diff_t) ? diff_t[2] : 0;
152  double diffA =
153  b * (c * (2 * diff_x[2] - d_t) + alpha * alpha * d_t) / a;
154  double diffB = d * 2 * t * d_t / a;
155  diffL[2 * (p + 1) + lp1] = A * diffL[2 * (p + 1) + l] -
156  B * diffL[2 * (p + 1) + l - 1] +
157  diffA * L[l] - diffB * L[l - 1];
158  }
159  }
160  }
161  }
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
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