Skip to content

Commit 13a7722

Browse files
authored
Add Sobolev spaces to custom element (#530)
* sobolev_space * basix_sobolev_space * map type * _ * main branches
1 parent 763c6be commit 13a7722

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

ffcx/codegeneration/basix_custom_element_template.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
.x = {x},
2727
.M = {M},
2828
.map_type = {map_type},
29+
.sobolev_space = {sobolev_space},
2930
.discontinuous = {discontinuous},
3031
.highest_complete_degree = {highest_complete_degree},
3132
.interpolation_nderivs = {interpolation_nderivs},

ffcx/codegeneration/finite_element.py

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def generate_custom_element(name, ir):
120120
d["factory_name"] = name
121121
d["cell_type"] = int(ir.cell_type)
122122
d["map_type"] = int(ir.map_type)
123+
d["sobolev_space"] = int(ir.sobolev_space)
123124
d["highest_complete_degree"] = ir.highest_complete_degree
124125
d["highest_degree"] = ir.highest_degree
125126
d["discontinuous"] = "true" if ir.discontinuous else "false"

ffcx/codegeneration/ufcx.h

+3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ extern "C"
186186
/// The map type for the element
187187
int map_type;
188188

189+
/// The Sobolev space for the element
190+
int sobolev_space;
191+
189192
/// Indicates whether or not this is the discontinuous version of the element
190193
bool discontinuous;
191194

ffcx/element_interface.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ def __init__(self, element: ufl.finiteelement.FiniteElementBase):
126126
f"QuadratureElement({element})", "quadrature element", element.cell().cellname(), element.value_shape(),
127127
element.degree())
128128

129-
def sobolev_space(self):
129+
def basix_sobolev_space(self):
130130
"""Return the underlying Sobolev space."""
131-
return ufl.sobolevspace.L2
131+
return basix.sobolev_spaces.L2
132132

133133
def __eq__(self, other) -> bool:
134134
"""Check if two elements are equal."""
@@ -257,6 +257,11 @@ def discontinuous(self) -> bool:
257257
"""True if the discontinuous version of the element is used."""
258258
return False
259259

260+
@property
261+
def map_type(self) -> basix.MapType:
262+
"""The Basix map type."""
263+
return basix.MapType.identity
264+
260265

261266
class RealElement(basix.ufl_wrapper._BasixElementBase):
262267
"""A real element."""
@@ -408,6 +413,11 @@ def discontinuous(self) -> bool:
408413
"""True if the discontinuous version of the element is used."""
409414
return False
410415

411-
def sobolev_space(self):
416+
def basix_sobolev_space(self):
412417
"""Return the underlying Sobolev space."""
413-
return ufl.sobolevspace.Hinf
418+
return basix.sobolev_spaces.Hinf
419+
420+
@property
421+
def map_type(self) -> basix.MapType:
422+
"""The Basix map type."""
423+
return basix.MapType.identity

ffcx/ir/representation.py

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class CustomElementIR(typing.NamedTuple):
6363
x: typing.List[typing.List[numpy.typing.NDArray[numpy.float64]]]
6464
M: typing.List[typing.List[numpy.typing.NDArray[numpy.float64]]]
6565
map_type: basix.MapType
66+
sobolev_space: basix.SobolevSpace
6667
interpolation_nderivs: int
6768
discontinuous: bool
6869
highest_complete_degree: int
@@ -274,6 +275,7 @@ def _compute_custom_element_ir(basix_element: basix.finite_element.FiniteElement
274275
ir["x"] = basix_element.x
275276
ir["M"] = basix_element.M
276277
ir["map_type"] = basix_element.map_type
278+
ir["sobolev_space"] = basix_element.sobolev_space
277279
ir["discontinuous"] = basix_element.discontinuous
278280
ir["interpolation_nderivs"] = basix_element.interpolation_nderivs
279281
ir["highest_complete_degree"] = basix_element.highest_complete_degree

0 commit comments

Comments
 (0)