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

Integration with Fuse #3885

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ jobs:
--install defcon \
--install gadopt \
--install asQ \
--package-branch fiat indiamai/integrate_fuse \
--package-branch fuse main \
|| (cat firedrake-install.log && /bin/false)

- name: Install test dependencies
Expand Down
19 changes: 13 additions & 6 deletions firedrake/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from firedrake.adjoint_utils import MeshGeometryMixin
from pyadjoint import stop_annotating
import gem
from fuse import constructCellComplex

try:
import netgen
Expand Down Expand Up @@ -1216,15 +1217,15 @@ def _ufl_cell(self):

# TODO: this needs to be updated for mixed-cell meshes.
nfacets = self._comm.allreduce(nfacets, op=MPI.MAX)

# Note that the geometric dimension of the cell is not set here
# despite it being a property of a UFL cell. It will default to
# equal the topological dimension.
# Firedrake mesh topologies, by convention, which specifically
# represent a mesh topology (as here) have geometric dimension
# equal their topological dimension. This is reflected in the
# corresponding UFL mesh.
return ufl.Cell(_cells[tdim][nfacets])
# return ufl.Cell(_cells[tdim][nfacets])
return constructCellComplex(_cells[tdim][nfacets])

@utils.cached_property
def _ufl_mesh(self):
Expand Down Expand Up @@ -1262,6 +1263,7 @@ def cell_closure(self):

cell = self.ufl_cell()
assert tdim == cell.topological_dimension()

if self.submesh_parent is not None:
return dmcommon.submesh_create_cell_closure_cell_submesh(plex,
self.submesh_parent.topology_dm,
Expand All @@ -1273,10 +1275,16 @@ def cell_closure(self):
entity_per_cell = np.zeros(len(topology), dtype=IntType)
for d, ents in topology.items():
entity_per_cell[d] = len(ents)

return dmcommon.closure_ordering(plex, vertex_numbering,
cell_numbering, entity_per_cell)

# elif hasattr(cell, "to_fiat"):
# TODO
# topology = cell.to_fiat().topology
# entity_per_cell = np.zeros(len(topology), dtype=IntType)
# for d, ents in topology.items():
# entity_per_cell[d] = len(ents)
# return dmcommon.closure_ordering(plex, vertex_numbering,
# cell_numbering, entity_per_cell)
elif cell.cellname() == "quadrilateral":
from firedrake_citations import Citations
Citations().register("Homolya2016")
Expand Down Expand Up @@ -1332,7 +1340,6 @@ def merge_ids(x, y, datatype):
op.Free()
else:
unique_markers = None

local_facet_number, facet_cell = \
dmcommon.facet_numbering(dm, kind, facets,
self._cell_numbering,
Expand Down Expand Up @@ -1955,7 +1962,7 @@ def _mark_entity_classes(self):

@utils.cached_property
def _ufl_cell(self):
return ufl.Cell(_cells[0][0])
return constructCellComplex(_cells[0][0])

@utils.cached_property
def _ufl_mesh(self):
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies = [
"pyadjoint-ad @ git+https://github.com/dolfin-adjoint/pyadjoint.git",
"loopy @ git+https://github.com/firedrakeproject/loopy.git@main",
"libsupermesh @ git+https://github.com/firedrakeproject/libsupermesh.git",
"fuse-element @ git+https://github.com/indiamai/fuse.git",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
1 change: 1 addition & 0 deletions requirements-git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ git+https://github.com/firedrakeproject/loopy.git@main#egg=loopy
git+https://github.com/firedrakeproject/pytest-mpi.git@main#egg=pytest-mpi
git+https://github.com/firedrakeproject/petsc.git@firedrake#egg=petsc
git+https://github.com/firedrakeproject/libsupermesh.git#egg=libsupermesh
git+https://github.com/indiamai/fuse.git#egg=fuse
24 changes: 24 additions & 0 deletions tests/firedrake/regression/test_fuse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from test_helmholtz import helmholtz
from test_poisson_strong_bcs import run_test
import pytest
import numpy as np



@pytest.mark.parametrize(['params', 'degree', 'quadrilateral'],

Check failure on line 8 in tests/firedrake/regression/test_fuse.py

View workflow job for this annotation

GitHub Actions / Run linter

E303

tests/firedrake/regression/test_fuse.py:8:1: E303 too many blank lines (3)
[(p, d, q)
for p in [{}, {'snes_type': 'ksponly', 'ksp_type': 'preonly', 'pc_type': 'lu'}]
for d in (1, 2, 3)
for q in [False, True]])
def test_poisson_analytic(params, degree, quadrilateral):
assert (run_test(2, degree, parameters=params, quadrilateral=False) < 1.e-9)

@pytest.mark.parametrize(['conv_num', 'degree'],

Check failure on line 16 in tests/firedrake/regression/test_fuse.py

View workflow job for this annotation

GitHub Actions / Run linter

E302

tests/firedrake/regression/test_fuse.py:16:1: E302 expected 2 blank lines, found 1
[(p, d)
for p,d in zip([1.8, 2.8, 3.8],[1, 2, 3])])

Check failure on line 18 in tests/firedrake/regression/test_fuse.py

View workflow job for this annotation

GitHub Actions / Run linter

E231

tests/firedrake/regression/test_fuse.py:18:32: E231 missing whitespace after ','

Check failure on line 18 in tests/firedrake/regression/test_fuse.py

View workflow job for this annotation

GitHub Actions / Run linter

E231

tests/firedrake/regression/test_fuse.py:18:57: E231 missing whitespace after ','
def test_helmholtz(conv_num, degree):
diff = np.array([helmholtz(i, degree=degree)[0] for i in range(3, 6)])
print("l2 error norms:", diff)
conv = np.log2(diff[:-1] / diff[1:])
print("convergence order:", conv)
assert (np.array(conv) > conv_num).all()

Check failure on line 24 in tests/firedrake/regression/test_fuse.py

View workflow job for this annotation

GitHub Actions / Run linter

W292

tests/firedrake/regression/test_fuse.py:24:45: W292 no newline at end of file
Loading