deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
source
base
polynomials_integrated_legendre_sz.cc
Go to the documentation of this file.
1
// -----------------------------------------------------------------------------
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4
// Copyright (C) 2017 - 2026 by the deal.II authors
5
//
6
// This file is part of the deal.II library.
7
//
8
// Detailed license information governing the source code and contributions
9
// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10
//
11
// -----------------------------------------------------------------------------
12
13
14
#include <
deal.II/base/config.h
>
15
16
#include <
deal.II/base/polynomial.h
>
17
#include <
deal.II/base/polynomials_integrated_legendre_sz.h
>
18
19
#include <vector>
20
21
DEAL_II_NAMESPACE_OPEN
22
23
IntegratedLegendreSZ::IntegratedLegendreSZ
(
const
unsigned
int
k)
24
:
Polynomials
::Polynomial<double>(get_coefficients(k))
25
{}
26
27
28
29
std::vector<double>
30
IntegratedLegendreSZ::get_coefficients
(
const
unsigned
int
k)
31
{
32
std::vector<double>
coefficients
(k + 1);
33
34
// first two polynomials are hard-coded:
35
if
(k == 0)
36
{
37
coefficients
[0] = -1.;
38
return
coefficients
;
39
}
40
else
if
(k == 1)
41
{
42
coefficients
[0] = 0.;
43
coefficients
[1] = 1.;
44
return
coefficients
;
45
}
46
47
// General formula is:
48
// k*L_{k}(x) = (2*k-3)*x*L_{k-1} - (k-3)*L_{k-2}.
49
std::vector<double> coefficients_km2 =
get_coefficients
(k - 2);
50
std::vector<double> coefficients_km1 =
get_coefficients
(k - 1);
51
52
const
double
a = 1.0 / k;
53
const
double
b = 2.0 * k - 3.0;
54
const
double
c = k - 3.0;
55
56
// To maintain stability, delay the division (multiplication by a) until the
57
// end.
58
for
(
unsigned
int
i = 1; i <= k - 2; ++i)
59
{
60
coefficients
[i] = b * coefficients_km1[i - 1] - c * coefficients_km2[i];
61
}
62
63
coefficients
[0] = -c * coefficients_km2[0];
64
coefficients
[k] = b * coefficients_km1[k - 1];
65
coefficients
[k - 1] = b * coefficients_km1[k - 2];
66
67
for
(
double
&coefficient :
coefficients
)
68
{
69
coefficient *= a;
70
}
71
72
return
coefficients
;
73
}
74
75
76
77
std::vector<Polynomials::Polynomial<double>>
78
IntegratedLegendreSZ::generate_complete_basis
(
const
unsigned
int
degree)
79
{
80
std::vector<Polynomials::Polynomial<double>> v;
81
v.reserve(
degree
+ 1);
82
for
(
unsigned
int
i = 0; i <=
degree
; ++i)
83
{
84
v.push_back(
IntegratedLegendreSZ
(i));
85
}
86
return
v;
87
}
88
89
90
91
DEAL_II_NAMESPACE_CLOSE
IntegratedLegendreSZ
Definition
polynomials_integrated_legendre_sz.h:45
IntegratedLegendreSZ::generate_complete_basis
static std::vector< Polynomials::Polynomial< double > > generate_complete_basis(const unsigned int degree)
Definition
polynomials_integrated_legendre_sz.cc:78
IntegratedLegendreSZ::IntegratedLegendreSZ
IntegratedLegendreSZ(const unsigned int p)
Definition
polynomials_integrated_legendre_sz.cc:23
IntegratedLegendreSZ::get_coefficients
static std::vector< double > get_coefficients(const unsigned int k)
Definition
polynomials_integrated_legendre_sz.cc:30
Polynomials::Polynomial< double >::coefficients
std::vector< double > coefficients
Definition
polynomial.h:323
Polynomials::Polynomial< double >::degree
unsigned int degree() const
Definition
polynomial.h:918
config.h
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition
config.h:38
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition
config.h:39
Polynomials
Definition
polynomial.h:44
polynomial.h
polynomials_integrated_legendre_sz.h
Generated by
1.9.8