v0.15.0
Loading...
Searching...
No Matches
Functions | Variables
base_functions.c File Reference
#include <cblas.h>
#include <petscsys.h>
#include <phg-quadrule/quad.h>
#include <definitions.h>
#include <base_functions.h>

Go to the source code of this file.

Functions

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.
 
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.
 
static double f_phi0 (double x)
 
static double f_phi1 (double x)
 
static double f_phi2 (double x)
 
static double f_phi3 (double x)
 
static double f_phi4 (double x)
 
static double f_phi5 (double x)
 
static double f_phi6 (double x)
 
static double f_phi7 (double x)
 
static double f_phi8 (double x)
 
static double f_phi9 (double x)
 
static double f_phi0x (double x)
 
static double f_phi1x (double x)
 
static double f_phi2x (double x)
 
static double f_phi3x (double x)
 
static double f_phi4x (double x)
 
static double f_phi5x (double x)
 
static double f_phi6x (double x)
 
static double f_phi7x (double x)
 
static double f_phi8x (double x)
 
static double f_phi9x (double x)
 
PetscErrorCode LobattoKernel_polynomials (int p, double s, double *diff_s, double *L, double *diffL, const int dim)
 Calculate Kernel Lobatto base functions.
 

Variables

static PetscErrorCode ierr
 
static double(* f_phi [])(double x)
 
static double(* f_phix [])(double x)
 

Function Documentation

◆ f_phi0()

static double f_phi0 ( double  x)
static

Definition at line 134 of file base_functions.c.

134{ return LOBATTO_PHI0(x); }
#define LOBATTO_PHI0(x)
Definitions taken from Hermes2d code.

◆ f_phi0x()

static double f_phi0x ( double  x)
static

Definition at line 148 of file base_functions.c.

148{ return LOBATTO_PHI0X(x); }
#define LOBATTO_PHI0X(x)
Derivatives of kernel functions for Lobbatto base.

◆ f_phi1()

static double f_phi1 ( double  x)
static

Definition at line 135 of file base_functions.c.

135{ return LOBATTO_PHI1(x); }
#define LOBATTO_PHI1(x)

◆ f_phi1x()

static double f_phi1x ( double  x)
static

Definition at line 149 of file base_functions.c.

149{ return LOBATTO_PHI1X(x); }
#define LOBATTO_PHI1X(x)

◆ f_phi2()

static double f_phi2 ( double  x)
static

Definition at line 136 of file base_functions.c.

136{ return LOBATTO_PHI2(x); }
#define LOBATTO_PHI2(x)

◆ f_phi2x()

static double f_phi2x ( double  x)
static

Definition at line 150 of file base_functions.c.

150{ return LOBATTO_PHI2X(x); }
#define LOBATTO_PHI2X(x)

◆ f_phi3()

static double f_phi3 ( double  x)
static

Definition at line 137 of file base_functions.c.

137{ return LOBATTO_PHI3(x); }
#define LOBATTO_PHI3(x)

◆ f_phi3x()

static double f_phi3x ( double  x)
static

Definition at line 151 of file base_functions.c.

151{ return LOBATTO_PHI3X(x); }
#define LOBATTO_PHI3X(x)

◆ f_phi4()

static double f_phi4 ( double  x)
static

Definition at line 138 of file base_functions.c.

138{ return LOBATTO_PHI4(x); }
#define LOBATTO_PHI4(x)

◆ f_phi4x()

static double f_phi4x ( double  x)
static

Definition at line 152 of file base_functions.c.

152{ return LOBATTO_PHI4X(x); }
#define LOBATTO_PHI4X(x)

◆ f_phi5()

static double f_phi5 ( double  x)
static

Definition at line 139 of file base_functions.c.

139{ return LOBATTO_PHI5(x); }
#define LOBATTO_PHI5(x)

◆ f_phi5x()

static double f_phi5x ( double  x)
static

Definition at line 153 of file base_functions.c.

153{ return LOBATTO_PHI5X(x); }
#define LOBATTO_PHI5X(x)

◆ f_phi6()

static double f_phi6 ( double  x)
static

Definition at line 140 of file base_functions.c.

140{ return LOBATTO_PHI6(x); }
#define LOBATTO_PHI6(x)

◆ f_phi6x()

static double f_phi6x ( double  x)
static

Definition at line 154 of file base_functions.c.

154{ return LOBATTO_PHI6X(x); }
#define LOBATTO_PHI6X(x)

◆ f_phi7()

static double f_phi7 ( double  x)
static

Definition at line 141 of file base_functions.c.

141{ return LOBATTO_PHI7(x); }
#define LOBATTO_PHI7(x)

◆ f_phi7x()

static double f_phi7x ( double  x)
static

Definition at line 155 of file base_functions.c.

155{ return LOBATTO_PHI7X(x); }
#define LOBATTO_PHI7X(x)

◆ f_phi8()

static double f_phi8 ( double  x)
static

Definition at line 142 of file base_functions.c.

142{ return LOBATTO_PHI8(x); }
#define LOBATTO_PHI8(x)

◆ f_phi8x()

static double f_phi8x ( double  x)
static

Definition at line 156 of file base_functions.c.

156{ return LOBATTO_PHI8X(x); }
#define LOBATTO_PHI8X(x)

◆ f_phi9()

static double f_phi9 ( double  x)
static

Definition at line 143 of file base_functions.c.

143{ return LOBATTO_PHI9(x); }
#define LOBATTO_PHI9(x)

◆ f_phi9x()

static double f_phi9x ( double  x)
static

Definition at line 157 of file base_functions.c.

157{ return LOBATTO_PHI9X(x); }
#define LOBATTO_PHI9X(x)

◆ 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 [25]

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

87 {
89#ifndef NDEBUG
90 if (dim < 1)
91 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
92 if (dim > 3)
93 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
94 if (p < 1)
95 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 1");
96#endif // NDEBUG
97 L[0] = x;
98 if (diffL != NULL) {
99 int d = 0;
100 for (; d != dim; ++d) {
101 diffL[d * p + 0] = diff_x[d];
102 }
103 }
104 if (p == 0)
106 double jacobi[(p + 1)];
107 double diff_jacobi[(p + 1) * dim];
108 ierr = Jacobi_polynomials(p, alpha, x, t, diff_x, diff_t, jacobi, diff_jacobi,
109 dim);
110 CHKERRQ(ierr);
111 int l = 1;
112 for (; l < p; l++) {
113 int i = l + 1;
114 const double a = (i + alpha) / ((2 * i + alpha - 1) * (2 * i + alpha));
115 const double b = alpha / ((2 * i + alpha - 2) * (2 * i + alpha));
116 const double c = (i - 1) / ((2 * i + alpha - 2) * (2 * i + alpha - 1));
117 L[l] = a * jacobi[i] + b * t * jacobi[i - 1] - c * t * t * jacobi[i - 2];
118 if (diffL != NULL) {
119 int d = 0;
120 for (; d != dim; ++d) {
121 diffL[d * p + l] = a * diff_jacobi[d * (p + 1) + i] +
122 b * (t * diff_jacobi[d * (p + 1) + i - 1] +
123 diff_t[d] * jacobi[i - 1]) -
124 c * (t * t * diff_jacobi[d * (p + 1) + i - 2] +
125 2 * t * diff_t[d] * jacobi[i - 2]);
126 }
127 }
128 }
130}
constexpr double a
static PetscErrorCode ierr
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.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ 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 ...
FTensor::Index< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
FTensor::Index< 'l', 3 > l
constexpr double t
plate stiffness
Definition plate.cpp:58

◆ 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 [25]

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

19 {
21#ifndef NDEBUG
22 if (dim < 1)
23 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
24 if (dim > 3)
25 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
26 if (p < 0)
27 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 0");
28
29 if (diffL != NULL) {
30 if (diff_x == NULL) {
31 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "diff_s == NULL");
32 }
33 }
34
35#endif // NDEBUG
36 L[0] = 1;
37 if (diffL != NULL) {
38 diffL[0 * (p + 1) + 0] = 0;
39 if (dim >= 2) {
40 diffL[1 * (p + 1) + 0] = 0;
41 if (dim == 3) {
42 diffL[2 * (p + 1) + 0] = 0;
43 }
44 }
45 }
46 if (p == 0)
48 L[1] = 2 * x - t + alpha * x;
49 if (diffL != NULL) {
50 int d = 0;
51 for (; d < dim; ++d) {
52 double d_t = (diff_t) ? diff_t[d] : 0;
53 diffL[d * (p + 1) + 1] = (2 + alpha) * diff_x[d] - d_t;
54 }
55 }
56 if (p == 1)
58 int l = 1;
59 for (; l < p; l++) {
60 int lp1 = l + 1;
61 double a = 2 * lp1 * (lp1 + alpha) * (2 * lp1 + alpha - 2);
62 double b = 2 * lp1 + alpha - 1;
63 double c = (2 * lp1 + alpha) * (2 * lp1 + alpha - 2);
64 double d = 2 * (lp1 + alpha - 1) * (lp1 - 1) * (2 * lp1 + alpha);
65 double A = b * (c * (2 * x - t) + alpha * alpha * t) / a;
66 double B = d * t * t / a;
67 L[lp1] = A * L[l] - B * L[l - 1];
68 if (diffL != NULL) {
69 int z = 0;
70 for (; z < dim; ++z) {
71 double d_t = (diff_t) ? diff_t[z] : 0;
72 double diffA =
73 b * (c * (2 * diff_x[z] - d_t) + alpha * alpha * d_t) / a;
74 double diffB = d * 2 * t * d_t / a;
75 diffL[z * (p + 1) + lp1] = A * diffL[z * (p + 1) + l] -
76 B * diffL[z * (p + 1) + l - 1] +
77 diffA * L[l] - diffB * L[l - 1];
78 }
79 }
80 }
82}
constexpr AssemblyType A
[Define dimension]

Variable Documentation

◆ f_phi

double(* f_phi[])(double x) ( double  x)
static
Initial value:
static double f_phi4(double x)
static double f_phi1(double x)
static double f_phi0(double x)
static double f_phi7(double x)
static double f_phi8(double x)
static double f_phi5(double x)
static double f_phi3(double x)
static double f_phi9(double x)
static double f_phi2(double x)
static double f_phi6(double x)

Definition at line 145 of file base_functions.c.

◆ f_phix

double(* f_phix[])(double x) ( double  x)
static
Initial value:
static double f_phi8x(double x)
static double f_phi0x(double x)
static double f_phi4x(double x)
static double f_phi2x(double x)
static double f_phi1x(double x)
static double f_phi9x(double x)
static double f_phi7x(double x)
static double f_phi3x(double x)
static double f_phi5x(double x)
static double f_phi6x(double x)

Definition at line 159 of file base_functions.c.

◆ ierr

PetscErrorCode ierr
static