Skip to content

Commit d78a670

Browse files
committed
merge conflict
2 parents 6134381 + 50a90e9 commit d78a670

File tree

15 files changed

+151
-168
lines changed

15 files changed

+151
-168
lines changed

MANIFEST.in

Lines changed: 0 additions & 5 deletions
This file was deleted.

firedrake/__init__.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
# the specific version, here we are more permissive. This is to catch the
44
# case where users don't update their PETSc for a really long time or
55
# accidentally install a too-new release that isn't yet supported.
6-
PETSC_SUPPORTED_VERSIONS = ">=3.24.2"
7-
8-
# TODO RELEASE
9-
# PETSC_SUPPORTED_VERSIONS = ">=3.25"
6+
# TODO RELEASE set to ">=3.25"
7+
PETSC_SUPPORTED_VERSIONS = ">=3.23.0"
108

119

1210
def init_petsc():
@@ -78,6 +76,7 @@ def init_petsc():
7876
from firedrake.mg.opencascade_mh import *
7977
from firedrake.norms import *
8078
from firedrake.nullspace import *
79+
from firedrake.output import *
8180
from firedrake.parameters import *
8281
from firedrake.parloops import *
8382
from firedrake.projection import *
@@ -99,11 +98,7 @@ def init_petsc():
9998
set_log_handlers(comm=COMM_WORLD)
10099

101100
# Moved functionality
102-
from firedrake._deprecation import plot, File # noqa: F401
103-
# Once `File` is deprecated update the above line removing `File` and add
104-
# from firedrake._deprecation import output
105-
# sys.modules["firedrake.output"] = output
106-
from firedrake.output import *
101+
from firedrake._deprecation import plot # noqa: F401
107102
import sys
108103
sys.modules["firedrake.plot"] = plot
109104
from firedrake.plot import *

firedrake/_deprecation.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"""
33
import importlib
44

5-
from warnings import warn
6-
75

86
class _fake_module:
97
""" Object which behaves like a module
@@ -47,28 +45,6 @@ def __call__(*args, **kwargs):
4745
return __call__
4846

4947

50-
# Deprecate output.File in the global namespace
51-
output = _fake_module(
52-
"firedrake.output",
53-
["File", ],
54-
["VTKFile", ]
55-
)
56-
57-
58-
# I hate it
59-
def File(*args, **kwargs):
60-
"""Deprecated File constructor.
61-
62-
Use `VTKFile` from `firedrake.output` instead
63-
"""
64-
from .output import VTKFile
65-
warn(
66-
"The use of `File` for output is deprecated, please update your "
67-
"code to use `VTKFile` from `firedrake.output`."
68-
)
69-
return VTKFile(*args, **kwargs)
70-
71-
7248
# Deprecate plotting in the global namespace
7349
plot = _fake_module(
7450
"firedrake.pyplot",

firedrake/adjoint/transformed_functional.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -176,28 +176,6 @@ def is_dg_space(space: WithGeometry) -> bool:
176176
return e.is_dg()
177177

178178

179-
def dg_space(space: WithGeometry) -> WithGeometry:
180-
"""Construct a DG space containing a given function space as a subspace.
181-
182-
Parameters
183-
----------
184-
185-
space
186-
A function space.
187-
188-
Returns
189-
-------
190-
191-
firedrake.functionspaceimpl.WithGeometry
192-
A DG space containing `space` as a subspace. May be `space`.
193-
"""
194-
195-
if is_dg_space(space):
196-
return space
197-
else:
198-
return fd.FunctionSpace(space.mesh(), finat.ufl.BrokenElement(space.ufl_element()))
199-
200-
201179
class L2TransformedFunctional(AbstractReducedFunctional):
202180
r"""Represents the functional
203181
@@ -265,7 +243,8 @@ def __init__(self, functional: pyadjoint.OverloadedType, controls: Union[Control
265243
self._space_D = Enlist(space_D)
266244
if len(self._space_D) != len(self._space):
267245
raise ValueError("Invalid length")
268-
self._space_D = tuple(dg_space(space) if space_D is None else space_D
246+
self._space_D = tuple((space if is_dg_space(space) else space.broken_space())
247+
if space_D is None else space_D
269248
for space, space_D in zip(self._space, self._space_D))
270249

271250
self._controls = tuple(Control(fd.Function(space_D), riesz_map="l2")

firedrake/cython/dmcommon.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3906,7 +3906,7 @@ def submesh_correct_entity_classes(PETSc.DM dm,
39063906
DMLabel lbl_core, lbl_owned, lbl_ghost
39073907
PetscBool has
39083908

3909-
if dm.comm.size == 1:
3909+
if subdm.comm.size == 1:
39103910
return
39113911
CHKERR(DMPlexGetChart(dm.dm, &pStart, &pEnd))
39123912
CHKERR(DMPlexGetChart(subdm.dm, &subpStart, &subpEnd))

firedrake/fml/form_manipulation_language.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class Term(object):
9393

9494
__slots__ = ["form", "labels"]
9595

96-
def __init__(self, form: ufl.BaseForm, label_dict: Mapping = None):
96+
def __init__(self, form: ufl.Form, label_dict: Mapping = None):
9797
"""
9898
9999
Parameters
@@ -216,9 +216,6 @@ def __mul__(
216216

217217
__rmul__ = __mul__
218218

219-
def __neg__(self):
220-
return -1 * self
221-
222219
def __truediv__(
223220
self,
224221
other: Union[float, Constant, ufl.algebra.Product]
@@ -277,7 +274,7 @@ def __init__(self, *terms: Sequence[Term]):
277274

278275
def __add__(
279276
self,
280-
other: Union[ufl.BaseForm, Term, "LabelledForm"]
277+
other: Union[ufl.Form, Term, "LabelledForm"]
281278
) -> "LabelledForm":
282279
"""Add a form, term or labelled form to this labelled form.
283280
@@ -292,12 +289,12 @@ def __add__(
292289
A labelled form containing the terms.
293290
294291
"""
295-
if type(other) is Term:
292+
if isinstance(other, ufl.Form):
293+
return LabelledForm(*self, Term(other))
294+
elif type(other) is Term:
296295
return LabelledForm(*self, other)
297296
elif type(other) is LabelledForm:
298297
return LabelledForm(*self, *other)
299-
elif isinstance(other, ufl.BaseForm):
300-
return LabelledForm(*self, Term(other))
301298
elif other is None:
302299
return self
303300
else:
@@ -307,7 +304,7 @@ def __add__(
307304

308305
def __sub__(
309306
self,
310-
other: Union[ufl.BaseForm, Term, "LabelledForm"]
307+
other: Union[ufl.Form, Term, "LabelledForm"]
311308
) -> "LabelledForm":
312309
"""Subtract a form, term or labelled form from this labelled form.
313310
@@ -323,18 +320,15 @@ def __sub__(
323320
324321
"""
325322
if type(other) is Term:
326-
return LabelledForm(*self, -other)
323+
return LabelledForm(*self, Constant(-1.)*other)
327324
elif type(other) is LabelledForm:
328-
return LabelledForm(*self, *[-t for t in other])
325+
return LabelledForm(*self, *[Constant(-1.)*t for t in other])
329326
elif other is None:
330327
return self
331328
else:
332329
# Make new Term for other and subtract it
333330
return LabelledForm(*self, Term(Constant(-1.)*other))
334331

335-
def __rsub__(self, other):
336-
return other + (-self)
337-
338332
def __mul__(
339333
self,
340334
other: Union[float, Constant, ufl.algebra.Product]
@@ -377,9 +371,6 @@ def __truediv__(
377371

378372
__rmul__ = __mul__
379373

380-
def __neg__(self):
381-
return -1 * self
382-
383374
def __iter__(self) -> Sequence:
384375
"""Iterable of the terms in the labelled form."""
385376
return iter(self.terms)
@@ -436,7 +427,7 @@ def label_map(
436427
return new_labelled_form
437428

438429
@property
439-
def form(self) -> ufl.BaseForm:
430+
def form(self) -> ufl.Form:
440431
"""Provide the whole form from the labelled form.
441432
442433
Raises
@@ -446,7 +437,7 @@ def form(self) -> ufl.BaseForm:
446437
447438
Returns
448439
-------
449-
ufl.BaseForm
440+
ufl.Form
450441
The whole form corresponding to all the terms.
451442
452443
"""
@@ -488,7 +479,7 @@ def __init__(
488479

489480
def __call__(
490481
self,
491-
target: Union[ufl.BaseForm, Term, LabelledForm],
482+
target: Union[ufl.Form, Term, LabelledForm],
492483
value: Any = None
493484
) -> Union[Term, LabelledForm]:
494485
"""Apply the label to a form or term.
@@ -503,7 +494,7 @@ def __call__(
503494
Raises
504495
------
505496
ValueError
506-
If the `target` is not a ufl.BaseForm, Term or
497+
If the `target` is not a ufl.Form, Term or
507498
LabelledForm.
508499
509500
Returns
@@ -523,7 +514,7 @@ def __call__(
523514
self.value = self.default_value
524515
if isinstance(target, LabelledForm):
525516
return LabelledForm(*(self(t, value) for t in target.terms))
526-
elif isinstance(target, ufl.BaseForm):
517+
elif isinstance(target, ufl.Form):
527518
return LabelledForm(Term(target, {self.label: self.value}))
528519
elif isinstance(target, Term):
529520
new_labels = target.labels.copy()

firedrake/functionspaceimpl.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,19 @@ def make_function_space(cls, mesh, element, name=None):
403403
new = cls.create(new, mesh)
404404
return new
405405

406+
def broken_space(self):
407+
"""Return a :class:`.WithGeometryBase` with a :class:`finat.ufl.BrokenElement`
408+
constructed from this function space's FiniteElement.
409+
410+
Returns
411+
-------
412+
WithGeometryBase :
413+
The new function space with a :class:`~finat.ufl.BrokenElement`.
414+
"""
415+
return type(self).make_function_space(
416+
self.mesh(), finat.ufl.BrokenElement(self.ufl_element()),
417+
name=f"{self.name}_broken" if self.name else None)
418+
406419
def reconstruct(
407420
self,
408421
mesh: MeshGeometry | None = None,

firedrake/mesh.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4756,6 +4756,7 @@ def Submesh(mesh, subdim, subdomain_id, label_name=None, name=None, ignore_halo=
47564756
Whether to reorder the mesh entities.
47574757
comm : PETSc.Comm | None
47584758
An optional sub-communicator to define the submesh.
4759+
By default, the submesh is defined on `mesh.comm`.
47594760
47604761
Returns
47614762
-------
@@ -4817,26 +4818,24 @@ def Submesh(mesh, subdim, subdomain_id, label_name=None, name=None, ignore_halo=
48174818
raise NotImplementedError("Can not create a submesh of a ``VertexOnlyMesh``")
48184819
plex = mesh.topology_dm
48194820
dim = plex.getDimension()
4821+
if subdim not in [dim, dim - 1]:
4822+
raise NotImplementedError(f"Found submesh dim ({subdim}) and parent dim ({dim})")
4823+
if label_name is None:
4824+
if subdim == dim:
4825+
label_name = dmcommon.CELL_SETS_LABEL
4826+
elif subdim == dim - 1:
4827+
label_name = dmcommon.FACE_SETS_LABEL
48204828
if subdomain_id is None:
48214829
# Filter the plex with PETSc's default label (cells owned by comm)
4822-
if label_name is not None:
4823-
raise ValueError("subdomain_id == None requires label_name == None.")
4824-
if subdim != dim:
4825-
raise NotImplementedError(f"Found submesh dim ({subdim}) and parent dim ({dim})")
4826-
subplex, _ = plex.filter(sanitizeSubMesh=True, ignoreHalo=ignore_halo, comm=comm)
4830+
if label_name != dmcommon.CELL_SETS_LABEL:
4831+
raise ValueError("subdomain_id == None requires label_name == CELL_SETS_LABEL.")
4832+
subplex, sf = plex.filter(sanitizeSubMesh=True, ignoreHalo=ignore_halo, comm=comm)
4833+
dmcommon.submesh_update_facet_labels(plex, subplex)
4834+
dmcommon.submesh_correct_entity_classes(plex, subplex, sf)
48274835
else:
4828-
if comm is not None and comm != mesh.comm:
4829-
raise NotImplementedError("Submesh on subcommunicator not implemented on cell subsets.")
4830-
if subdim not in [dim, dim - 1]:
4831-
raise NotImplementedError(f"Found submesh dim ({subdim}) and parent dim ({dim})")
4832-
if label_name is None:
4833-
if subdim == dim:
4834-
label_name = dmcommon.CELL_SETS_LABEL
4835-
elif subdim == dim - 1:
4836-
label_name = dmcommon.FACE_SETS_LABEL
48374836
subplex = dmcommon.submesh_create(plex, subdim, label_name, subdomain_id, ignore_halo, comm=comm)
4838-
comm = mesh.comm
48394837

4838+
comm = comm or mesh.comm
48404839
name = name or _generate_default_submesh_name(mesh.name)
48414840
subplex.setName(_generate_default_mesh_topology_name(name))
48424841
if subplex.getDimension() != subdim:

firedrake/slate/static_condensation/hybridization.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import functools
22

33
import ufl
4-
import finat.ufl
54

65
import firedrake.dmhooks as dmhooks
76
from firedrake.slate.static_condensation.sc_base import SCBase
@@ -90,8 +89,7 @@ def initialize(self, pc):
9089
TraceSpace = FunctionSpace(mesh[self.vidx], "HDiv Trace", tdegree)
9190

9291
# Break the function spaces and define fully discontinuous spaces
93-
broken_elements = finat.ufl.MixedElement([finat.ufl.BrokenElement(Vi.ufl_element()) for Vi in V])
94-
V_d = FunctionSpace(mesh, broken_elements)
92+
V_d = V.broken_space()
9593

9694
# Set up the functions for the original, hybridized
9795
# and schur complement systems

pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ requires = [
155155
"mpi4py>3; python_version >= '3.13'",
156156
"mpi4py; python_version < '3.13'",
157157
"numpy",
158+
# TODO RELEASE
159+
# "petsc4py==3.24.0",
158160
"petsctools",
159161
"pkgconfig",
160162
"pybind11",
161-
"setuptools>=77.0.3",
162-
# TODO RELEASE
163-
# "petsc4py==3.24.0",
164163
"rtree>=1.2",
164+
"setuptools>=77.0.3",
165165
]
166166
build-backend = "setuptools.build_meta"
167167

@@ -178,6 +178,8 @@ script-files = [
178178
# Unless specified these files will not be installed along with the
179179
# rest of the package
180180
firedrake = [
181+
"cython/*.pxi",
182+
"cython/*.pyx",
181183
"evaluate.h",
182184
"locate.c",
183185
"icons/*.png",

0 commit comments

Comments
 (0)