hummingbird
Solving the self-adjoint angular flux transport equation using spectral elements on Cartesian geometry
Loading...
Searching...
No Matches
hummingbird::GaussLobattoLegendre Class Reference

Class defining a 1D Gauss-Legendre-Lobatto quadrature set on [-1,1]. The quadrature set approximates the integral using a set of weights ( \(w_k\)) and abscissas ( \(\xi_k\)): More...

#include <gauss_lobatto_legendre.h>

Inheritance diagram for hummingbird::GaussLobattoLegendre:
[legend]
Collaboration diagram for hummingbird::GaussLobattoLegendre:
[legend]

Public Member Functions

 GaussLobattoLegendre (const size_t n_points)
 Construct a new GaussLobattoLegendre object.
double GetLagrangeDerivative (const size_t node_idx, const size_t polynomial_idx) const
 Get the derivative of the specific Lagrange polynomial at the specified node. Note that both the node index and the polynomial index are zero-indexed.
double IntegrateGridFunction (const std::valarray< double > &grid_function_vals)
 Integrate a function defined on the abscissae given in the order the abscissae are stored.
Public Member Functions inherited from hummingbird::QuadratureBase< double >
 QuadratureBase ()=default
double GetWeight (const unsigned int abscissa_index) const
 Get the weight value corresponding to a given abscissa value.
double GetAbscissa (const unsigned int index) const
 Get the abscissa corresponding to the index.
double Integrate (const std::vector< QuadraturePair > &quad_pairs) const
 Integrate the function using the function value and its location on the quadrature grid.
const std::vector< double > & abscissas () const
 Getter for the abscissas in the quadrature set.
size_t n_points () const
 Get total number of abscissas.

Private Member Functions

void ComputeLagrangeDerivatives ()
 Computes and sets the Lagrange polynomial derivatives at the GLL nodes. The vector lagrange_derivatives_ is constructed with the polynomial index being the "fast" counting index, and the node number being the "slow" counting index. That is, the derivative of the N=1 polynomial at the 3rd GLL node of 5 has a flattened index of 16.
std::vector< double > ComputeAbscissas (const size_t n_points)
 Computes the abscissa values, given by:
double ComputeWeight (const size_t k, const size_t n) override
 Computes the weights for a Gauss-Legendre-Lobatto quadrature scheme using:

Private Attributes

std::vector< double > lagrange_derivatives_
 Derivatives of the Lagrange polynomials at the GLL nodes. These are stored as a flattened array and are indexed using the node number and the polynomial number in GetLagrangeDerivative. See the extended description in ComputeLagrangeDerivatives().

Additional Inherited Members

Protected Member Functions inherited from hummingbird::QuadratureBase< double >
void CreateWeightMap ()
 Create the weight map.
Protected Attributes inherited from hummingbird::QuadratureBase< double >
std::vector< double > abscissas_
 Abscissa values.
std::map< unsigned int, double > weight_map_
 Map to store the weights of the quadrature set where the keys are the indices corresponding to abscissa values.

Detailed Description

Class defining a 1D Gauss-Legendre-Lobatto quadrature set on [-1,1]. The quadrature set approximates the integral using a set of weights ( \(w_k\)) and abscissas ( \(\xi_k\)):

\[\int_{-1}^{1}u(x)dx \approx \sum_{i=0}^{N-1}w_k u(\xi_k). \]

Formulae for this class were taken from the textbook "High-Order Methods for Incompressible Fluid Flow" by Deville, Fischer, and Mund. https://doi.org/10.1017/CBO9780511546792

Definition at line 27 of file gauss_lobatto_legendre.h.

Constructor & Destructor Documentation

◆ GaussLobattoLegendre()

hummingbird::GaussLobattoLegendre::GaussLobattoLegendre ( const size_t n_points)

Construct a new GaussLobattoLegendre object.

Parameters
n_pointsNumber of quadrature points to be created

Definition at line 9 of file gauss_lobatto_legendre.cc.

Member Function Documentation

◆ ComputeAbscissas()

std::vector< double > hummingbird::GaussLobattoLegendre::ComputeAbscissas ( const size_t n_points)
private

Computes the abscissa values, given by:

\[\xi_k = \begin{cases} -1, & k=0\\ \text{zeros of } P'_{N-1}, & 1\leq k\leq N-2\\ 1,& k=N-1 \end{cases} \]

Parameters
n_pointsTotal number of abscissa points
Returns
std::vector<double>

Definition at line 15 of file gauss_lobatto_legendre.cc.

◆ ComputeLagrangeDerivatives()

void hummingbird::GaussLobattoLegendre::ComputeLagrangeDerivatives ( )
private

Computes and sets the Lagrange polynomial derivatives at the GLL nodes. The vector lagrange_derivatives_ is constructed with the polynomial index being the "fast" counting index, and the node number being the "slow" counting index. That is, the derivative of the N=1 polynomial at the 3rd GLL node of 5 has a flattened index of 16.

Definition at line 31 of file gauss_lobatto_legendre.cc.

◆ ComputeWeight()

double hummingbird::GaussLobattoLegendre::ComputeWeight ( const size_t k,
const size_t n )
overrideprivatevirtual

Computes the weights for a Gauss-Legendre-Lobatto quadrature scheme using:

\[w_k=\frac{2}{(N-1)N}\frac{1}{[P_{N-1}(\xi_k)]^2} \]

Parameters
kAbscissa index
nTotal number of points
Returns
Quadrature weight associated with abscissa k

Reimplemented from hummingbird::QuadratureBase< double >.

Definition at line 54 of file gauss_lobatto_legendre.cc.

◆ GetLagrangeDerivative()

double hummingbird::GaussLobattoLegendre::GetLagrangeDerivative ( const size_t node_idx,
const size_t polynomial_idx ) const
inline

Get the derivative of the specific Lagrange polynomial at the specified node. Note that both the node index and the polynomial index are zero-indexed.

Parameters
node_idxGLL node index
polynomial_idxLagrange polynomial index
Returns
double

Definition at line 45 of file gauss_lobatto_legendre.h.

◆ IntegrateGridFunction()

double hummingbird::GaussLobattoLegendre::IntegrateGridFunction ( const std::valarray< double > & grid_function_vals)

Integrate a function defined on the abscissae given in the order the abscissae are stored.

Parameters
grid_function_valsGrid function values on the abscissae
Returns
double

Definition at line 62 of file gauss_lobatto_legendre.cc.

Member Data Documentation

◆ lagrange_derivatives_

std::vector<double> hummingbird::GaussLobattoLegendre::lagrange_derivatives_
private

Derivatives of the Lagrange polynomials at the GLL nodes. These are stored as a flattened array and are indexed using the node number and the polynomial number in GetLagrangeDerivative. See the extended description in ComputeLagrangeDerivatives().

Definition at line 65 of file gauss_lobatto_legendre.h.


The documentation for this class was generated from the following files: