Skip to content

Commit

Permalink
Add Sobolev spaces to custom element (#530)
Browse files Browse the repository at this point in the history
* sobolev_space

* basix_sobolev_space

* map type

* _

* main branches
  • Loading branch information
mscroggs authored Sep 23, 2022
1 parent 763c6be commit 13a7722
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions ffcx/codegeneration/basix_custom_element_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
.x = {x},
.M = {M},
.map_type = {map_type},
.sobolev_space = {sobolev_space},
.discontinuous = {discontinuous},
.highest_complete_degree = {highest_complete_degree},
.interpolation_nderivs = {interpolation_nderivs},
Expand Down
1 change: 1 addition & 0 deletions ffcx/codegeneration/finite_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def generate_custom_element(name, ir):
d["factory_name"] = name
d["cell_type"] = int(ir.cell_type)
d["map_type"] = int(ir.map_type)
d["sobolev_space"] = int(ir.sobolev_space)
d["highest_complete_degree"] = ir.highest_complete_degree
d["highest_degree"] = ir.highest_degree
d["discontinuous"] = "true" if ir.discontinuous else "false"
Expand Down
3 changes: 3 additions & 0 deletions ffcx/codegeneration/ufcx.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ extern "C"
/// The map type for the element
int map_type;

/// The Sobolev space for the element
int sobolev_space;

/// Indicates whether or not this is the discontinuous version of the element
bool discontinuous;

Expand Down
18 changes: 14 additions & 4 deletions ffcx/element_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def __init__(self, element: ufl.finiteelement.FiniteElementBase):
f"QuadratureElement({element})", "quadrature element", element.cell().cellname(), element.value_shape(),
element.degree())

def sobolev_space(self):
def basix_sobolev_space(self):
"""Return the underlying Sobolev space."""
return ufl.sobolevspace.L2
return basix.sobolev_spaces.L2

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

@property
def map_type(self) -> basix.MapType:
"""The Basix map type."""
return basix.MapType.identity


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

def sobolev_space(self):
def basix_sobolev_space(self):
"""Return the underlying Sobolev space."""
return ufl.sobolevspace.Hinf
return basix.sobolev_spaces.Hinf

@property
def map_type(self) -> basix.MapType:
"""The Basix map type."""
return basix.MapType.identity
2 changes: 2 additions & 0 deletions ffcx/ir/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class CustomElementIR(typing.NamedTuple):
x: typing.List[typing.List[numpy.typing.NDArray[numpy.float64]]]
M: typing.List[typing.List[numpy.typing.NDArray[numpy.float64]]]
map_type: basix.MapType
sobolev_space: basix.SobolevSpace
interpolation_nderivs: int
discontinuous: bool
highest_complete_degree: int
Expand Down Expand Up @@ -274,6 +275,7 @@ def _compute_custom_element_ir(basix_element: basix.finite_element.FiniteElement
ir["x"] = basix_element.x
ir["M"] = basix_element.M
ir["map_type"] = basix_element.map_type
ir["sobolev_space"] = basix_element.sobolev_space
ir["discontinuous"] = basix_element.discontinuous
ir["interpolation_nderivs"] = basix_element.interpolation_nderivs
ir["highest_complete_degree"] = basix_element.highest_complete_degree
Expand Down

0 comments on commit 13a7722

Please sign in to comment.