 v0.13.2
Searching...
No Matches
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 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...

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. More...

## Variables

static PetscErrorCode ierr

static double(* f_phi [])(double x)

static double(* f_phix [])(double x)

## ◆ f_phi0()

 static double f_phi0 ( double x )
static

Definition at line 275 of file base_functions.c.

275{ 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 289 of file base_functions.c.

289{ 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 276 of file base_functions.c.

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

## ◆ f_phi1x()

 static double f_phi1x ( double x )
static

Definition at line 290 of file base_functions.c.

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

## ◆ f_phi2()

 static double f_phi2 ( double x )
static

Definition at line 277 of file base_functions.c.

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

## ◆ f_phi2x()

 static double f_phi2x ( double x )
static

Definition at line 291 of file base_functions.c.

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

## ◆ f_phi3()

 static double f_phi3 ( double x )
static

Definition at line 278 of file base_functions.c.

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

## ◆ f_phi3x()

 static double f_phi3x ( double x )
static

Definition at line 292 of file base_functions.c.

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

## ◆ f_phi4()

 static double f_phi4 ( double x )
static

Definition at line 279 of file base_functions.c.

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

## ◆ f_phi4x()

 static double f_phi4x ( double x )
static

Definition at line 293 of file base_functions.c.

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

## ◆ f_phi5()

 static double f_phi5 ( double x )
static

Definition at line 280 of file base_functions.c.

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

## ◆ f_phi5x()

 static double f_phi5x ( double x )
static

Definition at line 294 of file base_functions.c.

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

## ◆ f_phi6()

 static double f_phi6 ( double x )
static

Definition at line 281 of file base_functions.c.

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

## ◆ f_phi6x()

 static double f_phi6x ( double x )
static

Definition at line 295 of file base_functions.c.

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

## ◆ f_phi7()

 static double f_phi7 ( double x )
static

Definition at line 282 of file base_functions.c.

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

## ◆ f_phi7x()

 static double f_phi7x ( double x )
static

Definition at line 296 of file base_functions.c.

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

## ◆ f_phi8()

 static double f_phi8 ( double x )
static

Definition at line 283 of file base_functions.c.

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

## ◆ f_phi8x()

 static double f_phi8x ( double x )
static

Definition at line 297 of file base_functions.c.

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

## ◆ f_phi9()

 static double f_phi9 ( double x )
static

Definition at line 284 of file base_functions.c.

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

## ◆ f_phi9x()

 static double f_phi9x ( double x )
static

Definition at line 298 of file base_functions.c.

298{ 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 

Parameters
 p is approximation order alpha polynomial parameter x is position $$s\in[0,t]$$ t range of polynomial diff_x derivatives of shape functions, i.e. $$\frac{\partial x}{\partial \xi_i}$$ diff_t derivatives of shape functions, i.e. $$\frac{\partial t}{\partial \xi_i}$$
Return values
 L approximation functions diffL derivatives, i.e. $$\frac{\partial L}{\partial \xi_i}$$
Parameters
 dim dimension
Returns
error code

Definition at line 163 of file base_functions.c.

166 {
168#ifndef NDEBUG
169 if (dim < 1)
170 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim < 1");
171 if (dim > 3)
172 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "dim > 3");
173 if (p < 1)
174 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "p < 1");
175#endif // NDEBUG
176 L = 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}
static Index< 'L', 3 > L
static Index< 'p', 3 > p
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()
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< 'i', SPACE_DIM > i
const double c
speed of light (cm/ns)
FTensor::Index< 'l', 3 > l
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
constexpr double t
plate stiffness
Definition: plate.cpp:59

## ◆ 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 

Parameters
 p is approximation order alpha polynomial parameter x is position $$s\in[0,t]$$ t range of polynomial diff_x derivatives of shape functions, i.e. $$\frac{\partial x}{\partial \xi_i}$$ diff_t derivatives of shape functions, i.e. $$\frac{\partial t}{\partial \xi_i}$$
Return values
 L approximation functions diffL derivatives, i.e. $$\frac{\partial L}{\partial \xi_i}$$
Parameters
 dim dimension
Returns
error code

Definition at line 79 of file base_functions.c.

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

## ◆ 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 286 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 300 of file base_functions.c.