1"""Define various DG finite elements. These finite elements essentially allow us to evaluate
2the local basis functions at an arbitrary point of the referent-domain for the respective element.
3This reference element can be either a reference cell [-1,+1] x [-1,+1] or a reference
6We use the following elements:
8 * DGScalarElement: scalar-valued functions such as pressure defined in cells
9 * DGVectorElement: vector-valued functions such as velocity or momentum defined in cells: to be implemented later. Now use scalar elements for individual components of a vector
10 * DGFacetElement: scalar-valued functions such as the function lambda that arises from hyrbidisation
14from abc
import ABC, abstractmethod
18from .nodal_basis
import NodalBasisGaussLegendre
19from .quadrature
import GaussianQuadrature, Quadrature2d
24 """Defines a finite element which describes the local function space on a reference element"""
27 """Initialise object"""
32 """return number of unknowns"""
37 """Evaluate the k-th basis function at the point x_local
39 :arg k: index of basis function
40 :arg x_local: local position in cell or on facet
46 """Evaluate the derivatibe k-th basis function at the point x_local in the
47 direction dir which can be 0 (x-direction) or 1 (y-direction)
49 :arg k: index of basis function
50 :arg direction: direction (0 or 1)
51 :arg x_local: local position in cell or on facet
57 """Compute nodal points on reference entity"""
61class DGScalarElement(FiniteElement):
62 """Scalar DG finite element on cells
64 Scalar valued Discontinuous Galerkin functions on reference cell [-1,+1] x [-1,+1]
70 :arg degree: polynomial degree
79 """return number of unknowns"""
83 """Evaluate the k-th basis function at the point x_local = (xi,eta)
84 2D basis functions are enumerated as follows
85 !!! So far, for 2D only
89 2 | 6 7 8 k = i + j * (self.basis.degree+1)
90 j 1 | 3 4 5 => i = k % (self.basis.degree+1)
91 0 | 0 1 2 j = k // (self.basis.degree+1)
96 :arg k: index of basis function
97 :arg x_local: position (xi,eta) in [-1,+1] x [-1,+1]
105 """Evaluate the derivative of k-th basis function at the point x_local = (xi,eta) in the
106 direction dir which can be 0 (x-direction) or 1 (y-direction)
108 :arg k: index of basis function
109 :arg direction: direction (0 or 1)
110 :arg x_local: position (xi,eta) in [-1,+1] x [-1,+1]
118 raise ValueError(
"Direction can only be 0 (x-direction) or 1 (y-direction)")
122 """Compute nodal points on reference entity"""
126 index_set = itertools.product(range(self.
degree + 1), repeat=self.
dim)
127 for index
in index_set:
132 reverse_index = tuple(reversed(index))
133 node_coordinates = [self.
basis.node1d(self.
degree, idx)
for idx
in reverse_index]
134 nodes.append(np.asarray(node_coordinates))
140 """Scalar DG finite element on facets
142 Scalar valued Discontinuous Galerkin functions on reference interval [-1,+1]
148 :arg degree: polynomial degree
157 """return number of unknowns"""
158 return (self.
degree + 1) ** (self.
dim - 1)
161 """Evaluate the k-th basis function at the point x_local = (xi,eta)
163 :arg k: index of basis function
164 :arg x_local: position xi in [-1,+1]
169 """Evaluate the derivative k-th basis function at the point x_local = xi
171 :arg k: index of basis function
172 :arg x_local: position xi in [-1,+1]
178 """Compute nodal points on reference facet"""
Scalar DG finite element on facets.
__init__(self, dim, degree)
Initialise object.
nodes(self)
Compute nodal points on reference facet.
evaluate_derivative(self, k, x_local)
Evaluate the derivative k-th basis function at the point x_local = xi.
ndof(self)
return number of unknowns
evaluate(self, k, x_local)
Evaluate the k-th basis function at the point x_local = (xi,eta)
evaluate_derivative(self, k, direction, x_local)
Evaluate the derivative of k-th basis function at the point x_local = (xi,eta) in the direction dir w...
ndof(self)
return number of unknowns
evaluate(self, k, x_local)
Evaluate the k-th basis function at the point x_local = (xi,eta) 2D basis functions are enumerated as...
__init__(self, dim, degree)
Initialise object.
nodes(self)
Compute nodal points on reference entity.
Defines a finite element which describes the local function space on a reference element.
nodes(self)
Compute nodal points on reference entity.
evaluate(self, k, x_local)
Evaluate the k-th basis function at the point x_local.
ndof(self)
return number of unknowns
evaluate_derivative(self, k, direction, x_local)
Evaluate the derivatibe k-th basis function at the point x_local in the direction dir which can be 0 ...
__init__(self)
Initialise object.
Concrete implementation for Gauss Legendre nodes.