Peano
Loading...
Searching...
No Matches
exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis Class Reference

Method representing a Lagrange basis which is used as a factory mechanism to produce all the vectors and matrices that we need within the DG solvers. More...

Inheritance diagram for exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis:

Public Member Functions

 __init__ (self, num_points)
 
 __str__ (self)
 
 init_dictionary_with_default_parameters (self, d, multiDimArrays=False)
 
 quadrature_points (self, render=True)
 
 quadrature_weights (self, render=True)
 

Data Fields

 order
 

Protected Member Functions

 _compute_quadrature_points_and_weights (self, num_points)
 To be implemented by subclass.
 
 _transform_and_sort_points_and_weights (self, quadrature_points, quadrature_weights)
 Transform quadrature quadrature_points and quadrature_weights for interval [-1,1] to quadrature_points and quadrature_weights for interval [0,1].
 

Private Member Functions

 __evaluate (self, xi)
 Evaluates a lagrange polynomial and its first derivative at a given point.
 
 __compute_barycentric_weights (self)
 See Eq.
 
 __compute_mass_matrix (self)
 Computes the (reference) element mass matrix for an approximation of order self.__max_poly_order.
 
 __compute_stiffness_operator (self)
 Computes the (reference) element stiffness matrix for an approximation of order self.__max_poly_order.
 
 __compute_K1 (self)
 Computes the difference between the reference element mass operator evaluated at point xi=1.0 and the element stiffness matrix.
 
 __compute_derivative_operator (self)
 Computes basis function derivatives at each support point.
 
 __compute_fine_grid_projector (self, j)
 Transforms the degrees of freedom located on a coarse grid edge quadrature_points to degrees of freedoms located on quadrature_points of a fine grid edge.
 
 __compute_equidistant_grid_projector (self)
 Transforms the degrees of freedom located at non-equidistant Lagrange support points quadrature_points to degrees of freedoms located at quadrature_points of an equidistant grid over (0,1).
 
 __make_initializer_list (cls, rendered_tensor)
 This implementation is a little bit nasty: We use the resulting strings within jinja2 templates which are then repeatedly resolved/rendered.
 
 __render_tensor_1 (cls, tensor)
 Converts nested list or numpy matrix to nested list of strings.
 
 __render_tensor_2 (cls, tensor, multiDimArray=True)
 Converts nested list or numpy matrix to nested list of strings.
 
 __render_tensor_3 (cls, tensor, multiDimArray=True)
 Converts nested list or numpy matrix to nested list of strings.
 

Private Attributes

 __num_points
 
 __max_poly_order
 
 __quadrature_points
 
 __quadrature_weights
 
 __barycentric_weights
 
 __mass_matrix
 
 __stiffness_operator
 
 __K1
 
 __inverted_predictor_lhs_operator
 
 __basis_function_values_left
 
 __basis_function_values_right
 
 __derivative_operator
 
 __equidistant_grid_projector
 
 __fine_grid_projector
 

Static Private Attributes

 __repr__ = __str__
 

Detailed Description

Method representing a Lagrange basis which is used as a factory mechanism to produce all the vectors and matrices that we need within the DG solvers.

Never use this class directly, but always rely on GaussLegendre or GaussLobatto. The only two things that are relevant for a user are the two routines quadrature_points() and quadrature_weights() as well as the routine to befill a map with replacement rules: init_dictionary_with_default_parameters()

Definition at line 17 of file LagrangeBasis.py.

Constructor & Destructor Documentation

◆ __init__()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__init__ ( self,
num_points )

Definition at line 29 of file LagrangeBasis.py.

Member Function Documentation

◆ __compute_barycentric_weights()

◆ __compute_derivative_operator()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_derivative_operator ( self)
private

Computes basis function derivatives at each support point.

Transposes the resulting operator.

u = sum_i u_i phi_i

=> d/dx u = sum_j (d/dx phi_j) u_j

To construct the gradient field, we make the ansatz:

grad u = sum_i g_i phi_i

=>

g_i = ( d/dx u, phi_i )_[0,1] / (phi_i,phi_i)_[0,1] = sum_j (d/dx phi_j, phi_i)_[0,1] / w_i

= w_i (d/dx phi_j) (x_i) / w_i = (d/dx phi_j) (x_i)

= DUDX^T

where DUDX is the operator computed by this function:

DUDX_ij = (d/dx phi_i) (x_j)

It can be further written as

DUDX_ij = 1/w_i * K^T_ij

where the stiffness matrix K is defined as

K_ij = <d/dx phi_i, phi_j>_[0,1] = w_j (d/dx phi_j) (x_i)

:return: transposed derivative operator

:note: If you want to use this operator to compute the gradient of the solution, you need to use the transpose.

Definition at line 205 of file LagrangeBasis.py.

References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__num_points, exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__num_points, exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_points, and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__quadrature_points.

Referenced by exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.init_dictionary_with_default_parameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ __compute_equidistant_grid_projector()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_equidistant_grid_projector ( self)
private

Transforms the degrees of freedom located at non-equidistant Lagrange support points quadrature_points to degrees of freedoms located at quadrature_points of an equidistant grid over (0,1).

Let us denote by P the projection operator (= equidistantGridProjector). The equidistant DoF are computed according to:

u^eq_i = sum_{m} P_im u^DG_m

Returns: equidistantGridProjector: The corresponding degrees of freedom located at quadrature_points of an equidistant grid over (0,1).

Definition at line 283 of file LagrangeBasis.py.

References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__num_points, and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__num_points.

Here is the call graph for this function:

◆ __compute_fine_grid_projector()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_fine_grid_projector ( self,
j )
private

Transforms the degrees of freedom located on a coarse grid edge quadrature_points to degrees of freedoms located on quadrature_points of a fine grid edge.

The difference in levels is 1.

Let us denote by P the fine grid projector (= equidistantGridProjector). The fine grid DoF are computed according to:

u^{fine;j}_i = sum_{m} P^{j}_im u^{coarse}_m

Args: j: subinterval index

Returns: fineGridProjector: Operator to express polynomial function associated with original interval with basis functions associated with subinterval j

Definition at line 255 of file LagrangeBasis.py.

References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__num_points, exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__num_points, exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_points, and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__quadrature_points.

Here is the call graph for this function:

◆ __compute_K1()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_K1 ( self)
private

Computes the difference between the reference element mass operator evaluated at point xi=1.0 and the element stiffness matrix.

:return: delta between the reference element mass operator at point xi=1.0 and the element stiffness matrix

Definition at line 179 of file LagrangeBasis.py.

References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__num_points, exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__num_points, and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__stiffness_operator.

Here is the call graph for this function:

◆ __compute_mass_matrix()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_mass_matrix ( self)
private

Computes the (reference) element mass matrix for an approximation of order self.__max_poly_order.

We evaluate the scalar product:

(phi_i, phi_j)_[0,1], i,j = 1 ... N > 0

where phi_i,phi_j are Lagrange basis functions associated with N support points x_i and x_j within the unit-interval. They are polynomials of maximum order N-1.

We evaluate the scalar product via a degree N Gauss quadrature rule that uses basis function support points as evaluation points. If we use Legendre nodes as support points, this is an exact evaluation if we use Lobatto nodes, this is an approximation.

:note:

:return: The (reference) element mass matrix. Exact for Gauss-Legrende nodes, inexact for Gauss-Lobatto (diagnoal lumping).

Definition at line 112 of file LagrangeBasis.py.

References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__num_points, exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__num_points, and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_weights.

◆ __compute_stiffness_operator()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_stiffness_operator ( self)
private

Computes the (reference) element stiffness matrix for an approximation of order self.__max_poly_order.

Computes:

K_ij = <d/dx phi_i, phi_j>_[0,1] = w_j (d/dx phi_j) (x_i)

where phi_i,phi_j are Lagrange basis functions associated with N support points x_i and x_j within the unit-interval. They are polynomials of maximum order N-1.

:note: Exact for both Lobatto and Legendre nodes due to the reduced degree in one scalar product operand.

:return: The (reference) element stiffness matrix.

Definition at line 148 of file LagrangeBasis.py.

References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__num_points, exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__num_points, exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_points, exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__quadrature_points, and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_weights.

Referenced by exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.init_dictionary_with_default_parameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ __evaluate()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate ( self,
xi )
private

Evaluates a lagrange polynomial and its first derivative at a given point.

Args: xi: The reference element point the basis functions are evaluated at. Here, xi refers to the greek letter that is often used as a reference element coordinate. Returns: phi: Basis function values. phi_xi: First derivatives of the basis functions.

Definition at line 61 of file LagrangeBasis.py.

References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__num_points, exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__num_points, exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_points, and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__quadrature_points.

Referenced by exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_derivative_operator(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_equidistant_grid_projector(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_equidistant_grid_projector(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_fine_grid_projector(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_fine_grid_projector(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_K1(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_K1(), and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_stiffness_operator().

Here is the caller graph for this function:

◆ __make_initializer_list()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__make_initializer_list ( cls,
rendered_tensor )
private

This implementation is a little bit nasty: We use the resulting strings within jinja2 templates which are then repeatedly resolved/rendered.

Therefore, we have to be carefully not to write {{ where we want to have two brackets. Instead, we have to write { { (not the space) so the render engine does not consider an initialisation list with nested arrays as a jinja2 token.

:param rendered_tensor: (nested) list of str elements :return: C++ initializer list for tensor

Definition at line 309 of file LagrangeBasis.py.

◆ __render_tensor_1()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__render_tensor_1 ( cls,
tensor )
private

Converts nested list or numpy matrix to nested list of strings.

:param tensor: list or numpy vector storing mpmath numbers

Definition at line 337 of file LagrangeBasis.py.

◆ __render_tensor_2()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__render_tensor_2 ( cls,
tensor,
multiDimArray = True )
private

Converts nested list or numpy matrix to nested list of strings.

:param tensor: nested list or numpy matrix storing mpmath numbers

Definition at line 349 of file LagrangeBasis.py.

◆ __render_tensor_3()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__render_tensor_3 ( cls,
tensor,
multiDimArray = True )
private

Converts nested list or numpy matrix to nested list of strings.

:param tensor: nested list or numpy matrix storing mpmath numbers

Definition at line 367 of file LagrangeBasis.py.

◆ __str__()

◆ _compute_quadrature_points_and_weights()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis._compute_quadrature_points_and_weights ( self,
num_points )
protected

To be implemented by subclass.

Reimplemented in exahype2.solvers.aderdg.LagrangeBasis.GaussLegendreBasis, and exahype2.solvers.aderdg.LagrangeBasis.GaussLobattoBasis.

Definition at line 390 of file LagrangeBasis.py.

◆ _transform_and_sort_points_and_weights()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis._transform_and_sort_points_and_weights ( self,
quadrature_points,
quadrature_weights )
protected

Transform quadrature quadrature_points and quadrature_weights for interval [-1,1] to quadrature_points and quadrature_weights for interval [0,1].

Definition at line 397 of file LagrangeBasis.py.

Referenced by exahype2.solvers.aderdg.LagrangeBasis.GaussLegendreBasis._compute_quadrature_points_and_weights(), exahype2.solvers.aderdg.LagrangeBasis.GaussLobattoBasis._compute_quadrature_points_and_weights(), and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.GaussLobattoBasisWithLumpedDiagonalBasis.quadrature_points().

Here is the caller graph for this function:

◆ init_dictionary_with_default_parameters()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.init_dictionary_with_default_parameters ( self,
d,
multiDimArrays = False )

◆ quadrature_points()

◆ quadrature_weights()

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.quadrature_weights ( self,
render = True )

Field Documentation

◆ __barycentric_weights

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__barycentric_weights
private

Definition at line 35 of file LagrangeBasis.py.

◆ __basis_function_values_left

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__basis_function_values_left
private

Definition at line 41 of file LagrangeBasis.py.

◆ __basis_function_values_right

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__basis_function_values_right
private

Definition at line 42 of file LagrangeBasis.py.

◆ __derivative_operator

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__derivative_operator
private

Definition at line 43 of file LagrangeBasis.py.

◆ __equidistant_grid_projector

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__equidistant_grid_projector
private

Definition at line 44 of file LagrangeBasis.py.

◆ __fine_grid_projector

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__fine_grid_projector
private

◆ __inverted_predictor_lhs_operator

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__inverted_predictor_lhs_operator
private

Definition at line 40 of file LagrangeBasis.py.

◆ __K1

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__K1
private

Definition at line 39 of file LagrangeBasis.py.

◆ __mass_matrix

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__mass_matrix
private

Definition at line 37 of file LagrangeBasis.py.

◆ __max_poly_order

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__max_poly_order
private

◆ __num_points

◆ __quadrature_points

◆ __quadrature_weights

◆ __repr__

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__repr__ = __str__
staticprivate

Definition at line 57 of file LagrangeBasis.py.

◆ __stiffness_operator

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__stiffness_operator
private

◆ order

exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.order

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