66import sympy
77
88from ..finite_element import CiarletElement
9- from ..functionals import DotPointEvaluation , ListOfFunctionals , PointEvaluation
9+ from ..functionals import DotPointEvaluation , IntegralAgainst , ListOfFunctionals , PointEvaluation
1010from ..functions import FunctionInput
11- from ..polynomials import polynomial_set_1d , polynomial_set_vector
11+ from ..polynomials import (lobatto_dual_basis , orthonormal_basis , polynomial_set_1d ,
12+ polynomial_set_vector )
1213from ..quadrature import get_quadrature
1314from ..references import Reference
1415
@@ -25,21 +26,34 @@ def __init__(self, reference: Reference, order: int, variant: str = "equispaced"
2526 variant: The variant of the element
2627 """
2728 dofs : ListOfFunctionals = []
28- if order == 0 :
29- dofs = [
29+ if variant == "legendre" :
30+ basis = orthonormal_basis (reference .name , order , 0 )[0 ]
31+ for f in basis :
32+ dofs .append (IntegralAgainst (reference , f , (reference .tdim , 0 )))
33+ elif order == 0 :
34+ dofs .append (
3035 PointEvaluation (
3136 reference , reference .get_point (tuple (
3237 sympy .Rational (1 , reference .tdim + 1 )
3338 for i in range (reference .tdim )
3439 )),
3540 entity = (reference .tdim , 0 )
3641 )
37- ]
42+ )
43+ elif variant == "lobatto" :
44+ for v_n , v in enumerate (reference .vertices ):
45+ dofs .append (PointEvaluation (reference , v , entity = (0 , v_n )))
46+ for edim in range (1 , 4 ):
47+ for e_n in range (reference .sub_entity_count (edim )):
48+ entity = reference .sub_entity (edim , e_n )
49+ basis = lobatto_dual_basis (entity .name , order , False )
50+ for f in basis :
51+ dofs .append (IntegralAgainst (reference , f , (edim , e_n )))
3852 else :
3953 points , _ = get_quadrature (variant , order + 1 )
4054
41- for v_n , v in enumerate (reference .reference_vertices ):
42- dofs .append (PointEvaluation (reference , reference . get_point ( v ) , entity = (0 , v_n )))
55+ for v_n , v in enumerate (reference .vertices ):
56+ dofs .append (PointEvaluation (reference , v , entity = (0 , v_n )))
4357 for edim in range (1 , 4 ):
4458 for e_n in range (reference .sub_entity_count (edim )):
4559 entity = reference .sub_entity (edim , e_n )
@@ -66,7 +80,7 @@ def init_kwargs(self) -> typing.Dict[str, typing.Any]:
6680 references = ["interval" , "triangle" , "tetrahedron" ]
6781 min_order = 0
6882 continuity = "C0"
69- last_updated = "2023.06 "
83+ last_updated = "2023.07 "
7084
7185
7286class VectorLagrange (CiarletElement ):
@@ -85,7 +99,11 @@ def __init__(self, reference: Reference, order: int, variant: str = "equispaced"
8599 poly : typing .List [FunctionInput ] = []
86100 if reference .tdim == 1 :
87101 for p in scalar_space .dofs :
88- dofs .append (PointEvaluation (reference , p .dof_point (), entity = p .entity ))
102+ if isinstance (p , PointEvaluation ):
103+ dofs .append (PointEvaluation (reference , p .dof_point (), entity = p .entity ))
104+ elif isinstance (p , IntegralAgainst ):
105+ dofs .append (IntegralAgainst (
106+ reference , p .f * reference .jacobian (), entity = p .entity ))
89107
90108 poly += polynomial_set_1d (reference .tdim , order )
91109 else :
@@ -95,9 +113,15 @@ def __init__(self, reference: Reference, order: int, variant: str = "equispaced"
95113 ]
96114 for p in scalar_space .dofs :
97115 for d in directions :
98- dofs .append (DotPointEvaluation (reference , p .dof_point (), d , entity = p .entity ))
116+ if isinstance (p , PointEvaluation ):
117+ dofs .append (DotPointEvaluation (
118+ reference , p .dof_point (), d , entity = p .entity ))
119+ elif isinstance (p , IntegralAgainst ):
120+ dofs .append (IntegralAgainst (
121+ reference , tuple (p .f * i for i in d ), entity = p .entity ))
99122
100123 poly += polynomial_set_vector (reference .tdim , reference .tdim , order )
124+
101125 super ().__init__ (reference , order , poly , dofs , reference .tdim , reference .tdim )
102126 self .variant = variant
103127
@@ -113,7 +137,7 @@ def init_kwargs(self) -> typing.Dict[str, typing.Any]:
113137 references = ["interval" , "triangle" , "tetrahedron" ]
114138 min_order = 0
115139 continuity = "C0"
116- last_updated = "2023.05 "
140+ last_updated = "2023.07.1 "
117141
118142
119143class MatrixLagrange (CiarletElement ):
@@ -159,7 +183,7 @@ def init_kwargs(self) -> typing.Dict[str, typing.Any]:
159183 references = ["triangle" , "tetrahedron" ]
160184 min_order = 0
161185 continuity = "L2"
162- last_updated = "2023.05 "
186+ last_updated = "2023.07 "
163187
164188
165189class SymmetricMatrixLagrange (CiarletElement ):
0 commit comments