![]() |
Peano
|
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...
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. | |
Static Private Attributes | |
__repr__ = __str__ | |
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.
exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__init__ | ( | self, | |
num_points ) |
Definition at line 29 of file LagrangeBasis.py.
|
private |
See Eq.
3.2 in https://people.maths.ox.ac.uk/trefethen/barycentric.pdf
Definition at line 97 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.
|
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().
|
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.
|
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.
|
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.
|
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.
|
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().
|
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().
|
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.
|
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.
|
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.
|
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.
exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__str__ | ( | self | ) |
Reimplemented in exahype2.solvers.aderdg.LagrangeBasis.GaussLegendreBasis, and exahype2.solvers.aderdg.LagrangeBasis.GaussLobattoBasis.
Definition at line 53 of file LagrangeBasis.py.
References peano4.output.ActionSet.ActionSet.__class__, peano4.output.Jinja2TemplatedHeaderImplementationFilePair.Jinja2TemplatedHeaderImplementationFilePair.__class__, peano4.output.Observer.Observer.__class__, peano4.output.TemplatedHeaderFile.TemplatedHeaderFile.__class__, peano4.output.TemplatedHeaderImplementationFilePair.TemplatedHeaderImplementationFilePair.__class__, exahype2.solvers.aderdg.ADERDG.ADERDG._init_dictionary_with_default_parameters(), exahype2.solvers.aderdg.SingleSweep.SingleSweep._init_dictionary_with_default_parameters(), exahype2.solvers.fv.FV.FV._init_dictionary_with_default_parameters(), exahype2.solvers.limiting.PosterioriLimiting.PosterioriLimiting._init_dictionary_with_default_parameters(), exahype2.solvers.limiting.StaticLimiting.StaticLimiting._init_dictionary_with_default_parameters(), exahype2.solvers.rkdg.RungeKuttaDG.RungeKuttaDG._init_dictionary_with_default_parameters(), and exahype2.solvers.rkfd.CellCenteredFiniteDifferences.CellCenteredFiniteDifferences._init_dictionary_with_default_parameters().
Referenced by peano4.toolbox.particles.postprocessing.ParticleVTUReader.VTUParticleSet.__repr__().
|
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.
|
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().
exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.init_dictionary_with_default_parameters | ( | self, | |
d, | |||
multiDimArrays = False ) |
Definition at line 421 of file LagrangeBasis.py.
References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__fine_grid_projector, and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__max_poly_order.
Referenced by exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__str__().
exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.quadrature_points | ( | self, | |
render = True ) |
Definition at line 458 of file LagrangeBasis.py.
References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_points, and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__quadrature_points.
Referenced by exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_derivative_operator(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_restriction_matrix(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.derivative1d(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.init_dictionary_with_default_parameters(), and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.value1d().
exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.quadrature_weights | ( | self, | |
render = True ) |
Definition at line 461 of file LagrangeBasis.py.
References exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__quadrature_weights.
Referenced by exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.init_dictionary_with_default_parameters().
|
private |
Definition at line 35 of file LagrangeBasis.py.
|
private |
Definition at line 41 of file LagrangeBasis.py.
|
private |
Definition at line 42 of file LagrangeBasis.py.
|
private |
Definition at line 43 of file LagrangeBasis.py.
|
private |
Definition at line 44 of file LagrangeBasis.py.
|
private |
Definition at line 45 of file LagrangeBasis.py.
Referenced by exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.init_dictionary_with_default_parameters().
|
private |
Definition at line 40 of file LagrangeBasis.py.
|
private |
Definition at line 39 of file LagrangeBasis.py.
|
private |
Definition at line 37 of file LagrangeBasis.py.
|
private |
Definition at line 31 of file LagrangeBasis.py.
Referenced by exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.init_dictionary_with_default_parameters().
|
private |
Definition at line 30 of file LagrangeBasis.py.
Referenced by exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_barycentric_weights(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_barycentric_weights(), 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(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_mass_matrix(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_stiffness_operator(), and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate().
|
private |
Definition at line 33 of file LagrangeBasis.py.
Referenced by exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_barycentric_weights(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_derivative_operator(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_fine_grid_projector(), exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_fine_grid_projector(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_stiffness_operator(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__evaluate(), and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.quadrature_points().
|
private |
Definition at line 33 of file LagrangeBasis.py.
Referenced by exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_mass_matrix(), exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_stiffness_operator(), and exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.quadrature_weights().
|
staticprivate |
Definition at line 57 of file LagrangeBasis.py.
|
private |
Definition at line 38 of file LagrangeBasis.py.
Referenced by exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.__compute_K1(), and exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.__compute_K1().
exahype2.solvers.aderdg.LagrangeBasis.LagrangeBasis.order |
Definition at line 50 of file LagrangeBasis.py.
Referenced by exahype2.solvers.LagrangeBasisWithDiagonalMassMatrix.LagrangeBasisWithDiagonalMassMatrix.init_dictionary_with_default_parameters().