66"""Finite elements."""
77
88from functools import singledispatch
9- from typing import Generic , TypeVar
9+ from typing import Generic
1010
1111import numpy as np
1212import numpy .typing as npt
1313
1414import basix
1515import basix .ufl
1616from dolfinx import cpp as _cpp
17+ from dolfinx .typing import Real
1718
18- _T = TypeVar ("_T" , np .float32 , np .float64 )
1919
20-
21- class CoordinateElement (Generic [_T ]):
20+ class CoordinateElement (Generic [Real ]):
2221 """Coordinate element describing the geometry map for mesh cells."""
2322
2423 _cpp_object : _cpp .fem .CoordinateElement_float32 | _cpp .fem .CoordinateElement_float64
@@ -63,7 +62,9 @@ def create_dof_layout(self) -> _cpp.fem.ElementDofLayout:
6362 """Compute and return the dof layout."""
6463 return self ._cpp_object .create_dof_layout ()
6564
66- def push_forward (self , X : npt .NDArray [_T ], cell_geometry : npt .NDArray [_T ]) -> npt .NDArray [_T ]:
65+ def push_forward (
66+ self , X : npt .NDArray [Real ], cell_geometry : npt .NDArray [Real ]
67+ ) -> npt .NDArray [Real ]:
6768 """Push points on the reference cell forward to the physical cell.
6869
6970 Args:
@@ -81,11 +82,11 @@ def push_forward(self, X: npt.NDArray[_T], cell_geometry: npt.NDArray[_T]) -> np
8182
8283 def pull_back (
8384 self ,
84- x : npt .NDArray [_T ],
85- cell_geometry : npt .NDArray [_T ],
85+ x : npt .NDArray [Real ],
86+ cell_geometry : npt .NDArray [Real ],
8687 tol : float = 1.0e-6 ,
8788 maxit : int = 15 ,
88- ) -> npt .NDArray [_T ]:
89+ ) -> npt .NDArray [Real ]:
8990 """Pull points on the physical cell back to the reference cell.
9091
9192 For non-affine cells, the pull-back is a nonlinear operation.
@@ -169,7 +170,7 @@ def _(e: basix.finite_element.FiniteElement) -> CoordinateElement:
169170 return CoordinateElement (_cpp .fem .CoordinateElement_float64 (e ._e ))
170171
171172
172- class FiniteElement (Generic [_T ]):
173+ class FiniteElement (Generic [Real ]):
173174 """A finite element."""
174175
175176 _cpp_object : _cpp .fem .FiniteElement_float32 | _cpp .fem .FiniteElement_float64
@@ -223,7 +224,7 @@ def value_shape(self) -> npt.NDArray[np.integer]:
223224 return self ._cpp_object .value_shape
224225
225226 @property
226- def interpolation_points (self ) -> npt .NDArray [_T ]:
227+ def interpolation_points (self ) -> npt .NDArray [Real ]:
227228 """Points at which to evaluate the function to be interpolated.
228229
229230 Interpolation point coordinates on the reference cell, returning
@@ -281,7 +282,7 @@ def signature(self) -> str:
281282 return self ._cpp_object .signature
282283
283284 def T_apply (
284- self , x : npt .NDArray [_T ], cell_permutations : npt .NDArray [np .uint32 ], dim : int
285+ self , x : npt .NDArray [Real ], cell_permutations : npt .NDArray [np .uint32 ], dim : int
285286 ) -> None :
286287 """Transform basis from reference to physical ordering/orientation.
287288
@@ -304,7 +305,7 @@ def T_apply(
304305 self ._cpp_object .T_apply (x , cell_permutations , dim )
305306
306307 def Tt_apply (
307- self , x : npt .NDArray [_T ], cell_permutations : npt .NDArray [np .uint32 ], dim : int
308+ self , x : npt .NDArray [Real ], cell_permutations : npt .NDArray [np .uint32 ], dim : int
308309 ) -> None :
309310 """Apply the transpose of the operator applied by T_apply().
310311
@@ -318,7 +319,7 @@ def Tt_apply(
318319 self ._cpp_object .Tt_apply (x , cell_permutations , dim )
319320
320321 def Tt_inv_apply (
321- self , x : npt .NDArray [_T ], cell_permutations : npt .NDArray [np .uint32 ], dim : int
322+ self , x : npt .NDArray [Real ], cell_permutations : npt .NDArray [np .uint32 ], dim : int
322323 ) -> None :
323324 """Apply the inverse transpose of T_apply().
324325
0 commit comments