Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sobolev spaces to custom element #530

Merged
merged 6 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/dolfin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
if: github.event_name != 'workflow_dispatch'
run: |
python3 -m pip install git+https://github.com/FEniCS/ufl.git
python3 -m pip install git+https://github.com/FEniCS/basix.git
python3 -m pip install git+https://github.com/FEniCS/basix.git@mscroggs/sobolev_spaces
- name: Install UFL and Basix (specified branches/tags)
if: github.event_name == 'workflow_dispatch'
run: |
Expand All @@ -67,6 +67,7 @@ jobs:
with:
path: ./dolfinx
repository: FEniCS/dolfinx
ref: mscroggs/sobolev_spaces
- name: Get DOLFINx source (specified branch/tag)
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Install FEniCS dependencies (Python)
run: |
python -m pip install git+https://github.com/FEniCS/ufl.git
python -m pip install git+https://github.com/FEniCS/basix.git
python -m pip install git+https://github.com/FEniCS/basix.git@mscroggs/sobolev_spaces

- name: Install FFCx
run: |
Expand Down
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