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

Emmarothwell1/restricted _function_space: Implement a RestrictedFunctionSpace class. #3215

Merged
merged 152 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 151 commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
eb5b131
Initial idea of RestrictedFunctionSpace.
emmarothwell1 Nov 8, 2023
f4d1898
Neatened up RestrictedFunctionSpace methods.
emmarothwell1 Nov 9, 2023
5ee8d36
create_section + related have boundary_set added.
emmarothwell1 Nov 23, 2023
891ddd0
Changes to create_section + docs.
emmarothwell1 Nov 23, 2023
22bc52f
Added boundary_set to sdata.
emmarothwell1 Nov 27, 2023
7ff616c
Trying to get dmcommon to build.
emmarothwell1 Nov 27, 2023
91b3fa6
Work on compiling issues from dmcommon.
emmarothwell1 Nov 29, 2023
083d25f
Added boundary_set, changed allocation of memory.
emmarothwell1 Dec 5, 2023
5839dfc
Minor changes to make tests work.
emmarothwell1 Dec 5, 2023
b110407
Rearrange args+use kw arg (get_global_numbering)
emmarothwell1 Dec 5, 2023
db590b0
Use function_space._mesh in RFS __init__.
emmarothwell1 Dec 6, 2023
a898117
Initial layout, testing restricted function space.
emmarothwell1 Dec 6, 2023
969a33a
Added boundary_set in app. functionspacedata docs
emmarothwell1 Dec 6, 2023
f945527
Changes made in meeting 7/12 (need to change test)
emmarothwell1 Dec 7, 2023
9641635
Trying to fix global numbering in the Restricted case.
emmarothwell1 Dec 10, 2023
7138eb7
Added local_to_global_map and dof_count to restrictedfunctionspace.
emmarothwell1 Dec 10, 2023
8c567f4
defined _init_with_shared_data for FunctionSpace.
emmarothwell1 Dec 12, 2023
832b1e4
Added boundary_set to self.map_cache and self._entity_node_lists.
emmarothwell1 Dec 12, 2023
1319347
fix RestrictedFunctionSpace dof_count.
emmarothwell1 Dec 12, 2023
0902e49
value comparison with FunctionSpace with bc applied.
emmarothwell1 Dec 12, 2023
a20f858
use my pyop2 branch in build
emmarothwell1 Dec 13, 2023
ce0deeb
initial work on plex_renumbering
emmarothwell1 Dec 28, 2023
1926d57
merging, need to combine _init_with_shared_data with set_shared_data …
emmarothwell1 Dec 29, 2023
8a3522e
plex_renumbering counting constrained nodes first.
emmarothwell1 Jan 5, 2024
9806a25
Hopefully passing number of constrained nodes back up.
emmarothwell1 Jan 5, 2024
9a7153d
Apply suggestions Koki made for constr. entities
emmarothwell1 Jan 10, 2024
3ca64da
linting my code with flake8
emmarothwell1 Jan 10, 2024
1d2a58a
removed _init_with_shared_data
emmarothwell1 Jan 11, 2024
6d4a87e
reordering in plex_renumbering in create_section
emmarothwell1 Jan 11, 2024
b2998cf
Initial test for the restrictedfunctionspace.
emmarothwell1 Jan 12, 2024
291dacf
Test RFS on other square, fail if CG1 pass if not
emmarothwell1 Jan 12, 2024
6991a5e
Added global_numbering att. to RFS, changed __eq__
emmarothwell1 Jan 14, 2024
7f91921
Added Poisson homogeneous bcs test, fails for CG1
emmarothwell1 Jan 14, 2024
5909baf
remove comments in RestrictedFunctionSpace
emmarothwell1 Jan 17, 2024
73e077e
added mesh coord change test + refactored
emmarothwell1 Jan 24, 2024
8b42dbc
start adding bc label to functionspace for ufl
emmarothwell1 Jan 27, 2024
13e4593
pass form signature to GlobalKernel
emmarothwell1 Jan 28, 2024
d4a31d2
actually pass label through to ufl function space
emmarothwell1 Jan 29, 2024
300631c
apply koki's changes: bset in global kernel args
emmarothwell1 Feb 9, 2024
2895c42
assemble works with no bcs but doesn't with bcs
emmarothwell1 Feb 10, 2024
fd2d91e
Add RFS boundary set to boundary node caching.
emmarothwell1 Feb 15, 2024
fe5eb4f
lgmap now returns lgmap / dof_dset lgmap, +naming
emmarothwell1 Feb 15, 2024
26dd89c
Added more inhomogenous tests, updated to use bset
emmarothwell1 Feb 15, 2024
0393542
first attempts at getting mixed restricted spaces to work
emmarothwell1 Feb 20, 2024
5e73dc4
warning if constaining all dofs, apply pr changes
emmarothwell1 Mar 6, 2024
8defda0
update due to pyop2 naming changes
emmarothwell1 Mar 6, 2024
3b48016
more tidying up
emmarothwell1 Mar 19, 2024
1f632fd
first ideas on eigensolver
emmarothwell1 Mar 26, 2024
5fadddf
more work on eigensolver
emmarothwell1 Mar 26, 2024
425b456
added in some tests for the eigensolver
emmarothwell1 Apr 3, 2024
910b768
error if bc made with sd not in boundary_set
emmarothwell1 Apr 3, 2024
f95b01b
updated eigensolver, tests, demo
emmarothwell1 Apr 10, 2024
946d4cc
work on putting restrict flag into solve (failing)
emmarothwell1 Apr 10, 2024
97778ba
replaced coefficients as well (not working)
emmarothwell1 Apr 10, 2024
04aa507
add changes from meeting to solve (works!)
emmarothwell1 Apr 11, 2024
378dedb
move functions up from restrictedfunctionspace
emmarothwell1 Apr 13, 2024
39b67c8
clean up the tests, add in mixed test
emmarothwell1 Apr 17, 2024
cbed740
add some documentation into dmcommon.
emmarothwell1 Apr 17, 2024
dee52a5
updating various docstrings
emmarothwell1 Apr 17, 2024
b26d12b
Add in a docstring to RestrictedFunctionSpace
emmarothwell1 Apr 17, 2024
f615be3
linting.
emmarothwell1 Apr 17, 2024
3de1531
added koki's pr review suggestions
emmarothwell1 Apr 21, 2024
598089a
docs stuff
emmarothwell1 Apr 21, 2024
228763c
more doc things
emmarothwell1 Apr 22, 2024
49d6494
hopefully fix doc/test failures.
emmarothwell1 Apr 22, 2024
73abab3
more test fixing
emmarothwell1 Apr 22, 2024
cec4122
apply pr suggestions
emmarothwell1 Apr 23, 2024
fd87345
hopefuly fix complex eigensolver
emmarothwell1 Apr 23, 2024
d2976a2
tried to sort to compare eigenvals
emmarothwell1 Apr 23, 2024
9160487
Add editables package (#3524)
JDBetteridge Apr 24, 2024
486fa41
Updates to Firedrake '24 webpage (#3523)
pefarrell Apr 24, 2024
c5f21ad
moved tests to eigensolver
emmarothwell1 Apr 25, 2024
3366c48
Update .github/workflows/build.yml
emmarothwell1 Apr 25, 2024
bba9d34
Initial idea of RestrictedFunctionSpace.
emmarothwell1 Nov 8, 2023
d9c5b7f
Neatened up RestrictedFunctionSpace methods.
emmarothwell1 Nov 9, 2023
8a1e382
create_section + related have boundary_set added.
emmarothwell1 Nov 23, 2023
8418bc2
Changes to create_section + docs.
emmarothwell1 Nov 23, 2023
0e4f297
Added boundary_set to sdata.
emmarothwell1 Nov 27, 2023
85474c6
Trying to get dmcommon to build.
emmarothwell1 Nov 27, 2023
604e8f8
Work on compiling issues from dmcommon.
emmarothwell1 Nov 29, 2023
79c356e
Added boundary_set, changed allocation of memory.
emmarothwell1 Dec 5, 2023
8350c72
Minor changes to make tests work.
emmarothwell1 Dec 5, 2023
242fe5f
Rearrange args+use kw arg (get_global_numbering)
emmarothwell1 Dec 5, 2023
1df6265
Use function_space._mesh in RFS __init__.
emmarothwell1 Dec 6, 2023
3318973
Initial layout, testing restricted function space.
emmarothwell1 Dec 6, 2023
f6a3318
Added boundary_set in app. functionspacedata docs
emmarothwell1 Dec 6, 2023
8ee3008
Changes made in meeting 7/12 (need to change test)
emmarothwell1 Dec 7, 2023
8918ba2
Trying to fix global numbering in the Restricted case.
emmarothwell1 Dec 10, 2023
34ee9d2
Added local_to_global_map and dof_count to restrictedfunctionspace.
emmarothwell1 Dec 10, 2023
2b355e4
defined _init_with_shared_data for FunctionSpace.
emmarothwell1 Dec 12, 2023
ddc4979
Added boundary_set to self.map_cache and self._entity_node_lists.
emmarothwell1 Dec 12, 2023
8fbd09b
fix RestrictedFunctionSpace dof_count.
emmarothwell1 Dec 12, 2023
77ea61f
value comparison with FunctionSpace with bc applied.
emmarothwell1 Dec 12, 2023
80003c3
use my pyop2 branch in build
emmarothwell1 Dec 13, 2023
a9d0f2a
initial work on plex_renumbering
emmarothwell1 Dec 28, 2023
d813009
merging, need to combine _init_with_shared_data with set_shared_data …
emmarothwell1 Dec 29, 2023
78d0422
plex_renumbering counting constrained nodes first.
emmarothwell1 Jan 5, 2024
5b66c61
Hopefully passing number of constrained nodes back up.
emmarothwell1 Jan 5, 2024
7875058
Apply suggestions Koki made for constr. entities
emmarothwell1 Jan 10, 2024
b6ceb3b
linting my code with flake8
emmarothwell1 Jan 10, 2024
a370123
removed _init_with_shared_data
emmarothwell1 Jan 11, 2024
c03805f
reordering in plex_renumbering in create_section
emmarothwell1 Jan 11, 2024
11a1251
Initial test for the restrictedfunctionspace.
emmarothwell1 Jan 12, 2024
1f5a52e
Test RFS on other square, fail if CG1 pass if not
emmarothwell1 Jan 12, 2024
0661e7f
Added global_numbering att. to RFS, changed __eq__
emmarothwell1 Jan 14, 2024
7b5ff2a
Added Poisson homogeneous bcs test, fails for CG1
emmarothwell1 Jan 14, 2024
0f4bfc1
remove comments in RestrictedFunctionSpace
emmarothwell1 Jan 17, 2024
d672b71
added mesh coord change test + refactored
emmarothwell1 Jan 24, 2024
96e1cf0
start adding bc label to functionspace for ufl
emmarothwell1 Jan 27, 2024
c211d33
pass form signature to GlobalKernel
emmarothwell1 Jan 28, 2024
7a4cf59
actually pass label through to ufl function space
emmarothwell1 Jan 29, 2024
50cc0e8
apply koki's changes: bset in global kernel args
emmarothwell1 Feb 9, 2024
08f769d
assemble works with no bcs but doesn't with bcs
emmarothwell1 Feb 10, 2024
fbdb2ea
Add RFS boundary set to boundary node caching.
emmarothwell1 Feb 15, 2024
152d6f5
lgmap now returns lgmap / dof_dset lgmap, +naming
emmarothwell1 Feb 15, 2024
109b0f9
Added more inhomogenous tests, updated to use bset
emmarothwell1 Feb 15, 2024
5ed5848
first attempts at getting mixed restricted spaces to work
emmarothwell1 Feb 20, 2024
60d9184
warning if constaining all dofs, apply pr changes
emmarothwell1 Mar 6, 2024
b950c2c
update due to pyop2 naming changes
emmarothwell1 Mar 6, 2024
bc1a2a6
more tidying up
emmarothwell1 Mar 19, 2024
d13f91c
first ideas on eigensolver
emmarothwell1 Mar 26, 2024
2bebf17
more work on eigensolver
emmarothwell1 Mar 26, 2024
f46fda3
added in some tests for the eigensolver
emmarothwell1 Apr 3, 2024
6530135
error if bc made with sd not in boundary_set
emmarothwell1 Apr 3, 2024
87bf646
updated eigensolver, tests, demo
emmarothwell1 Apr 10, 2024
798e214
work on putting restrict flag into solve (failing)
emmarothwell1 Apr 10, 2024
218943f
replaced coefficients as well (not working)
emmarothwell1 Apr 10, 2024
687f589
add changes from meeting to solve (works!)
emmarothwell1 Apr 11, 2024
66ef0fc
move functions up from restrictedfunctionspace
emmarothwell1 Apr 13, 2024
e468b21
clean up the tests, add in mixed test
emmarothwell1 Apr 17, 2024
00a3eb9
add some documentation into dmcommon.
emmarothwell1 Apr 17, 2024
4cd6887
updating various docstrings
emmarothwell1 Apr 17, 2024
09ca284
Add in a docstring to RestrictedFunctionSpace
emmarothwell1 Apr 17, 2024
f021d86
linting.
emmarothwell1 Apr 17, 2024
339ae76
added koki's pr review suggestions
emmarothwell1 Apr 21, 2024
3644530
docs stuff
emmarothwell1 Apr 21, 2024
29dc63a
more doc things
emmarothwell1 Apr 22, 2024
00a48b7
hopefully fix doc/test failures.
emmarothwell1 Apr 22, 2024
62f2ebf
more test fixing
emmarothwell1 Apr 22, 2024
e2fd92d
apply pr suggestions
emmarothwell1 Apr 23, 2024
1e76f4d
hopefuly fix complex eigensolver
emmarothwell1 Apr 23, 2024
476d741
tried to sort to compare eigenvals
emmarothwell1 Apr 23, 2024
8cc69e1
moved tests to eigensolver
emmarothwell1 Apr 25, 2024
c5be626
docstring things.
emmarothwell1 Apr 25, 2024
ffa9442
eigensolver things.
emmarothwell1 Apr 25, 2024
790d8e9
choose correct pyop2 branch
emmarothwell1 Apr 25, 2024
214dbff
change restrict to True, apply other suggestions.
emmarothwell1 Apr 25, 2024
31bc3c6
var solver lint
emmarothwell1 Apr 25, 2024
a7a7a3c
restrict=true on linear var problem too.
emmarothwell1 Apr 25, 2024
a74740f
change restrict back to false in solve
emmarothwell1 Apr 25, 2024
4d50879
only loop over bcs if there are any
emmarothwell1 Apr 25, 2024
0bf8011
Update .github/workflows/build.yml
ksagiyam Apr 26, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
--install defcon \
--install gadopt \
--install asQ \
--package-branch pyop2 emmarothwell1/restricted_function_space_review \
ksagiyam marked this conversation as resolved.
Show resolved Hide resolved
|| (cat firedrake-install.log && /bin/false)
- name: Install test dependencies
run: |
Expand Down
9 changes: 6 additions & 3 deletions demos/eigenvalues_QG_basinmodes/qgbasinmodes.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Oceanic Basin Modes: Quasi-Geostrophic approach
.. rst-class:: emphasis

This tutorial was contributed by Christine Kaufhold and `Francis
Poulin <mailto:[email protected]>`__.
Poulin <mailto:[email protected]>`__. The tutorial was later updated by
Emma Rothwell to add in the restrict flag in the LinearEigenproblem.

As a continuation of the Quasi-Geostrophic (QG) model described in the other
tutorial, we will now see how we can use Firedrake to compute the spatial
Expand Down Expand Up @@ -138,12 +139,14 @@ We define the Test Function :math:`\phi` and the Trial Function

To build the weak formulation of our equation we need to build two PETSc
matrices in the form of a generalized eigenvalue problem,
:math:`A\psi = \lambda M\psi` ::
:math:`A\psi = \lambda M\psi`. This eigenproblem takes `restrict=True` to help
users to avoid convergence failures by removing eigenvalues on the
boundary, while preserving the original function space for the eigenmodes. ::

eigenproblem = LinearEigenproblem(
A=beta*phi*psi.dx(0)*dx,
M=-inner(grad(psi), grad(phi))*dx - F*psi*phi*dx,
bcs=bc)
bcs=bc, restrict=True)

Next we program our eigenvalue solver through the PETSc options system. The
first is specifying that we have an generalized eigenvalue problem that is
Expand Down
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
\sphinxDUC{22C5}{$\cdot$}
\sphinxDUC{25A3}{$\boxdot$}
\sphinxDUC{03BB}{$\lambda$}
\sphinxDUC{0393}{$\Gamma$}
% Sphinx equivalent of
% \DeclareUnicodeCharacter{}{}
Expand Down
71 changes: 69 additions & 2 deletions docs/source/firedrake_24.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,76 @@ in the numerical solution of partial differential equations. The event
will provide Firedrake users with the opportunity to interact directly
with developers and with other users.

The conference will begin around lunchtime on 16 September and end on the
evening of 18 September.

More details about registration, submissions, accommodation and the
conference dinner will be posted in due course.
Conference venue
----------------

The conference will take place in the Andrew Wiles Building. Its main entrance
is located on Woodstock Road (`see here for the precise location
<https://what3words.com/policy.rises.bets>`__). Take some care in navigation, as
Google Maps sometimes directs people to the old mathematics building on St.
Giles.

Accommodation
-------------

We have arranged a number of single en-suite rooms at `Oriel college, Oxford
<https://www.oriel.ox.ac.uk>`__, for the nights of Monday 16 September and Tuesday
17 September. The fee includes breakfast on the following days. Oriel College,
founded in 1326, is one of the constituent colleges of the university of Oxford.
The accommodation is approximately fifteen minutes walk from the Andrew Wiles
Building.


Conference dinner
-----------------

Registration includes a drinks reception and three-course dinner at `Corpus
Christi college, Oxford <https://www.ccc.ox.ac.uk>`__, founded in 1517. The dinner will take place on the
evening of 17 September. Corpus Christi college is right next to Oriel, about
fifteen minutes walk from the Andrew Wiles building.

It is possible during registration to purchase additional tickets for the
dinner, to bring non-registered companions.

.. image:: images/corpusdininghall.jpg
:width: 100%
:alt: Corpus Christi dining hall
:align: center


Registration
------------

Registration is **now open**! `To register, please follow this link
<https://www.oxforduniversitystores.co.uk/conferences-and-events/mathematical-institute/events/firedrake-2024>`__.

The registration fees are as follows:

.. list-table::
:widths: 25 25 50
:header-rows: 0

* -
- Without accommodation
- With accommodation
* - Student
- £25
- £200
* - Non-student
- £115
- £350


Support
-------

The conference has been kindly supported by `EPSRC grant EP/W026163/1
<https://gow.epsrc.ukri.org/NGBOViewGrant.aspx?GrantRef=EP/W026163/1>`__ and
`EPSRC grant EP/W026066/1
<https://gow.epsrc.ukri.org/NGBOViewGrant.aspx?GrantRef=EP/W026066/1>`__.

..
Programme
Expand Down
Binary file added docs/source/images/corpusdininghall.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions firedrake/adjoint_utils/variational_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ def wrapper(self, *args, **kwargs):
from firedrake import derivative, adjoint, TrialFunction
init(self, *args, **kwargs)
self._ad_F = self.F
self._ad_u = self.u
self._ad_u = self.u_restrict
self._ad_bcs = self.bcs
self._ad_J = self.J
try:
# Some forms (e.g. SLATE tensors) are not currently
# differentiable.
dFdu = derivative(self.F,
self.u,
TrialFunction(self.u.function_space()))
self.u_restrict,
TrialFunction(self.u_restrict.function_space()))
self._ad_adj_F = adjoint(dFdu)
except (TypeError, NotImplementedError):
self._ad_adj_F = None
Expand Down Expand Up @@ -130,7 +130,7 @@ def _ad_problem_clone(self, problem, dependencies):
_ad_count_map[J_replace_map[coeff]] = coeff.count()

nlvp = NonlinearVariationalProblem(replace(problem.F, F_replace_map),
F_replace_map[problem.u],
F_replace_map[problem.u_restrict],
bcs=problem.bcs,
J=replace(problem.J, J_replace_map))
nlvp._ad_count_map_update(_ad_count_map)
Expand Down
38 changes: 21 additions & 17 deletions firedrake/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -1631,15 +1631,15 @@ def _as_global_kernel_arg(self, tsfc_arg):
# TODO Make singledispatchmethod with Python 3.8
return _as_global_kernel_arg(tsfc_arg, self)

def _get_map_arg(self, finat_element):
def _get_map_arg(self, finat_element, boundary_set):
"""Get the appropriate map argument for the given FInAT element.
:arg finat_element: A FInAT element.
:returns: A :class:`op2.MapKernelArg` instance corresponding to
the given FInAT element. This function uses a cache to ensure
that PyOP2 knows when it can reuse maps.
"""
key = self._get_map_id(finat_element)
key = self._get_map_id(finat_element), boundary_set

try:
return self._map_arg_cache[key]
Expand Down Expand Up @@ -1679,28 +1679,28 @@ def _get_dim(self, finat_element):
else:
return (1,)

def _make_dat_global_kernel_arg(self, finat_element, index=None):
def _make_dat_global_kernel_arg(self, finat_element, boundary_set, index=None):
if isinstance(finat_element, finat.EnrichedElement) and finat_element.is_mixed:
assert index is None
subargs = tuple(self._make_dat_global_kernel_arg(subelem.element)
subargs = tuple(self._make_dat_global_kernel_arg(subelem.element, boundary_set)
for subelem in finat_element.elements)
return op2.MixedDatKernelArg(subargs)
else:
dim = self._get_dim(finat_element)
map_arg = self._get_map_arg(finat_element)
map_arg = self._get_map_arg(finat_element, boundary_set)
return op2.DatKernelArg(dim, map_arg, index)

def _make_mat_global_kernel_arg(self, relem, celem):
def _make_mat_global_kernel_arg(self, relem, celem, rbset, cbset):
if any(isinstance(e, finat.EnrichedElement) and e.is_mixed for e in {relem, celem}):
subargs = tuple(self._make_mat_global_kernel_arg(rel.element, cel.element)
subargs = tuple(self._make_mat_global_kernel_arg(rel.element, cel.element, rbset, cbset)
for rel, cel in product(relem.elements, celem.elements))
shape = len(relem.elements), len(celem.elements)
return op2.MixedMatKernelArg(subargs, shape)
else:
# PyOP2 matrix objects have scalar dims so we flatten them here
rdim = numpy.prod(self._get_dim(relem), dtype=int)
cdim = numpy.prod(self._get_dim(celem), dtype=int)
map_args = self._get_map_arg(relem), self._get_map_arg(celem)
map_args = self._get_map_arg(relem, rbset), self._get_map_arg(celem, cbset)
return op2.MatKernelArg((((rdim, cdim),),), map_args, unroll=self._unroll)

@staticmethod
Expand Down Expand Up @@ -1737,25 +1737,29 @@ def _as_global_kernel_arg_output(_, self):
if V.ufl_element().family() == "Real":
return op2.GlobalKernelArg((1,))
else:
return self._make_dat_global_kernel_arg(create_element(V.ufl_element()))
return self._make_dat_global_kernel_arg(create_element(V.ufl_element()), V.boundary_set)
elif rank == 2:
if all(V.ufl_element().family() == "Real" for V in Vs):
return op2.GlobalKernelArg((1,))
elif any(V.ufl_element().family() == "Real" for V in Vs):
el, = (create_element(V.ufl_element()) for V in Vs
if V.ufl_element().family() != "Real")
return self._make_dat_global_kernel_arg(el)
for V in Vs:
if V.ufl_element().family() != "Real":
el = create_element(V.ufl_element())
boundary_set = V.boundary_set
break
return self._make_dat_global_kernel_arg(el, boundary_set)
else:
rel, cel = (create_element(V.ufl_element()) for V in Vs)
return self._make_mat_global_kernel_arg(rel, cel)
rbset, cbset = (V.boundary_set for V in Vs)
return self._make_mat_global_kernel_arg(rel, cel, rbset, cbset)
else:
raise AssertionError


@_as_global_kernel_arg.register(kernel_args.CoordinatesKernelArg)
def _as_global_kernel_arg_coordinates(_, self):
finat_element = create_element(self._mesh.ufl_coordinate_element())
return self._make_dat_global_kernel_arg(finat_element)
return self._make_dat_global_kernel_arg(finat_element, self._mesh.coordinates.function_space().boundary_set)


@_as_global_kernel_arg.register(kernel_args.CoefficientKernelArg)
Expand All @@ -1773,7 +1777,7 @@ def _as_global_kernel_arg_coefficient(_, self):
return op2.GlobalKernelArg((ufl_element.value_size,))
else:
finat_element = create_element(ufl_element)
return self._make_dat_global_kernel_arg(finat_element, index)
return self._make_dat_global_kernel_arg(finat_element, V.boundary_set, index)


@_as_global_kernel_arg.register(kernel_args.ConstantKernelArg)
Expand All @@ -1788,7 +1792,7 @@ def _as_global_kernel_arg_cell_sizes(_, self):
# this mirrors tsfc.kernel_interface.firedrake_loopy.KernelBuilder.set_cell_sizes
ufl_element = finat.ufl.FiniteElement("P", self._mesh.ufl_cell(), 1)
finat_element = create_element(ufl_element)
return self._make_dat_global_kernel_arg(finat_element)
return self._make_dat_global_kernel_arg(finat_element, self._mesh.coordinates.function_space().boundary_set)


@_as_global_kernel_arg.register(kernel_args.ExteriorFacetKernelArg)
Expand All @@ -1815,7 +1819,7 @@ def _as_global_kernel_arg_cell_orientations(_, self):
# this mirrors firedrake.mesh.MeshGeometry.init_cell_orientations
ufl_element = finat.ufl.FiniteElement("DG", cell=self._mesh.ufl_cell(), degree=0)
finat_element = create_element(ufl_element)
return self._make_dat_global_kernel_arg(finat_element)
return self._make_dat_global_kernel_arg(finat_element, self._mesh.coordinates.function_space().boundary_set)


@_as_global_kernel_arg.register(LayerCountKernelArg)
Expand Down
2 changes: 2 additions & 0 deletions firedrake/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ def __init__(self, V, g, sub_domain, method=None):
warnings.simplefilter('always', DeprecationWarning)
warnings.warn("Selecting a bcs method is deprecated. Only topological association is supported",
DeprecationWarning)
if len(V.boundary_set) and sub_domain not in V.boundary_set:
raise ValueError(f"Sub-domain {sub_domain} not in the boundary set of the restricted space.")
super().__init__(V, sub_domain)
if len(V) > 1:
raise ValueError("Cannot apply boundary conditions on mixed spaces directly.\n"
Expand Down
2 changes: 1 addition & 1 deletion firedrake/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1437,7 +1437,7 @@ def _get_dm_for_checkpointing(self, tV):
sd_key = self._get_shared_data_key_for_checkpointing(tV.mesh(), tV.ufl_element())
if isinstance(tV.ufl_element(), (finat.ufl.VectorElement, finat.ufl.TensorElement)):
nodes_per_entity, real_tensorproduct, block_size = sd_key
global_numbering = tV.mesh().create_section(nodes_per_entity, real_tensorproduct, block_size=block_size)
global_numbering, _ = tV.mesh().create_section(nodes_per_entity, real_tensorproduct, block_size=block_size)
topology_dm = tV.mesh().topology_dm
dm = PETSc.DMShell().create(tV.mesh()._comm)
dm.setPointSF(topology_dm.getPointSF())
Expand Down
Loading
Loading