Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Feb 8, 2023
2 parents abee682 + d84d5d6 commit 5739073
Show file tree
Hide file tree
Showing 108 changed files with 785 additions and 284 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
schedule:
- cron: '0 0 * * 0'

concurrency:
# Cancels jobs running if new commits are pushed
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: "Build Firedrake"
Expand Down
10 changes: 5 additions & 5 deletions demos/camassa-holm/camassaholm.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ two variables. ::
W = MixedFunctionSpace((V, V))

We construct a :class:`~.Function` to store the two variables at time
level ``n``, and :meth:`~.Function.split` it so that we can
level ``n``, and :attr:`~.Function.subfunctions` it so that we can
interpolate the initial condition into the two components. ::

w0 = Function(W)
m0, u0 = w0.split()
m0, u0 = w0.subfunctions

Then we interpolate the initial condition,

Expand Down Expand Up @@ -161,12 +161,12 @@ rather than blocked system. ::
'ksp_type': 'preonly',
'pc_type': 'lu'})

Next we use the other form of :meth:`~.Function.split`, ``w0.split()``,
Next we use the other form of :attr:`~.Function.subfunctions`, ``w0.subfunctions``,
which is the way to split up a Function in order to access its data
e.g. for output. ::

m0, u0 = w0.split()
m1, u1 = w1.split()
m0, u0 = w0.subfunctions
m1, u1 = w1.subfunctions

We choose a final time, and initialise a :class:`~.File` object for
storing ``u``. as well as an array for storing the function to be visualised::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ space, along with the degree of the element and construct the quadrature rule::

Then we make a new Measure object that uses this rule::

dxlump=dx(rule=quad_rule)
dxlump=dx(scheme=quad_rule)

To discretize :math:`\partial_{t}^2 u` we use a central scheme

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ In the end, we proceed with the actual computation loop::
# symplectic Euler scheme
LVS_phi_f.solve()
LVS_U_phi.solve()
tmp_f, tmp_s = result_mixed.split()
tmp_f, tmp_s = result_mixed.subfunctions
phi.assign(tmp_f)
U.assign(tmp_s)
LVS_eta.solve()
Expand Down
2 changes: 1 addition & 1 deletion demos/ma-demo/ma-demo.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ We then put all of these options into the iterative solver, ::

and output the solution to a file. ::

u, sigma = w.split()
u, sigma = w.subfunctions
u_solv.solve()
File("u.pvd").write(u)

Expand Down
2 changes: 1 addition & 1 deletion demos/matrix_free/navier_stokes.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ find the Reynolds number. ::

And finally we write the results to a file for visualisation. ::

u, p = up.split()
u, p = up.subfunctions
u.rename("Velocity")
p.rename("Pressure")

Expand Down
2 changes: 1 addition & 1 deletion demos/matrix_free/rayleigh-benard.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ them, although doing so would be quite easy.::

Finally, we'll output the results for visualisation. ::

u, p, T = upT.split()
u, p, T = upT.subfunctions
u.rename("Velocity")
p.rename("Pressure")
T.rename("Temperature")
Expand Down
2 changes: 1 addition & 1 deletion demos/matrix_free/stokes.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ visualisation. We split the function into its velocity and pressure
parts and give them reasonable names, then write them to a paraview
file.::

u, p = up.split()
u, p = up.subfunctions
u.rename("Velocity")
p.rename("Pressure")

Expand Down
2 changes: 1 addition & 1 deletion demos/multigrid/geometric_multigrid.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ approximations.

Finally, we'll write the solution for visualisation with Paraview. ::

u, p = u.split()
u, p = u.subfunctions
u.rename("Velocity")
p.rename("Pressure")

Expand Down
2 changes: 1 addition & 1 deletion demos/poisson/poisson_mixed.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ solver parameters. Afterwards we extract the components ``sigma`` and ``u``
on each of the subspaces with ``split``. ::

solve(a == L, w, bcs=[bc0, bc1])
sigma, u = w.split()
sigma, u = w.subfunctions

Lastly we write the component of the solution corresponding to the primal
variable on the DG space to a file in VTK format for later inspection with a
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/05-mixed-poisson.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1755,7 +1755,7 @@
],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"sigmah, uh = wh.split()\n",
"sigmah, uh = wh.subfunctions\n",
"fig, axes = plt.subplots(ncols=2, sharex=True, sharey=True)\n",
"\n",
"quiver(sigmah, axes=axes[0])\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/06-pde-constrained-optimisation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@
],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"u_init, p_init = w.split()\n",
"u_init, p_init = w.subfunctions\n",
"\n",
"fig, axes = plt.subplots(nrows=2, sharex=True, sharey=True)\n",
"streamlines = streamplot(u_init, resolution=1/3, seed=0, axes=axes[0])\n",
Expand Down Expand Up @@ -4330,7 +4330,7 @@
],
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"u_opt, p_opt = w_opt.split()\n",
"u_opt, p_opt = w_opt.subfunctions\n",
"\n",
"fig, axes = plt.subplots(nrows=2, sharex=True, sharey=True)\n",
"streamlines = streamplot(u_opt, resolution=1/3, seed=0, axes=axes[0])\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/07-geometric-multigrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@
"source": [
"# NBVAL_IGNORE_OUTPUT\n",
"w = solver._problem.u\n",
"u, p = w.split()\n",
"u, p = w.subfunctions\n",
"fig, axes = plt.subplots(ncols=2, sharex=True, sharey=True)\n",
"streamlines = streamplot(u, resolution=1/30, seed=4, axes=axes[0])\n",
"axes[0].set_aspect(\"equal\")\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/08-composable-solvers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@
"source": [
"%matplotlib notebook\n",
"import matplotlib.pyplot as plt\n",
"u_h, p_h = w.split()\n",
"u_h, p_h = w.subfunctions\n",
"fig, axes = plt.subplots()\n",
"streamlines = streamplot(u_h, resolution=1/30, seed=0, axes=axes)\n",
"fig.colorbar(streamlines);"
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/10-sum-factorisation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
"outputs": [],
"source": [
"gll_quadrature_rule = gauss_lobatto_legendre_cube_rule(dimension=3, degree=p)\n",
"a_gll = dot(grad(u), grad(v)) *dx(rule=gll_quadrature_rule)"
"a_gll = dot(grad(u), grad(v)) *dx(scheme=gll_quadrature_rule)"
]
},
{
Expand Down Expand Up @@ -326,7 +326,7 @@
" V = FunctionSpace(mesh, element)\n",
" u = TrialFunction(V)\n",
" v = TestFunction(V)\n",
" a = dot(grad(u), grad(v))*dx(rule=modes[mode]['rule'](3, p))\n",
" a = dot(grad(u), grad(v))*dx(scheme=modes[mode]['rule'](3, p))\n",
" kernel, = compile_form(a, parameters={\"mode\": modes[mode]['mode']})\n",
" flops[mode].append(EstimateFlops().visit(kernel.ast))"
]
Expand Down Expand Up @@ -1163,7 +1163,7 @@
" V = FunctionSpace(mesh, element)\n",
" u = TrialFunction(V)\n",
" v = TestFunction(V)\n",
" a = dot(curl(u), curl(v))*dx(rule=modes[mode]['rule'](3, p))\n",
" a = dot(curl(u), curl(v))*dx(scheme=modes[mode]['rule'](3, p))\n",
" kernel, = compile_form(a, parameters={\"mode\": modes[mode]['mode']})\n",
" flops_curl[mode].append(EstimateFlops().visit(kernel.ast))"
]
Expand Down
2 changes: 1 addition & 1 deletion firedrake/adjoint/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def __init__(self, func, idx, ad_block_tag=None):
def evaluate_adj_component(self, inputs, adj_inputs, block_variable, idx,
prepared=None):
if idx == 0:
return adj_inputs[0].split()[self.idx].vector()
return adj_inputs[0].subfunctions[self.idx].vector()
else:
return adj_inputs[0]

Expand Down
30 changes: 18 additions & 12 deletions firedrake/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,14 @@ def _global_kernel_cache_key(form, local_knl, all_integer_subdomain_ids, **kwarg
subdomain_key = []
for val in form.subdomain_data().values():
for k, v in val.items():
if v is not None:
extruded = v._extruded
constant_layers = extruded and v.constant_layers
subset = isinstance(v, op2.Subset)
subdomain_key.append((k, extruded, constant_layers, subset))
else:
subdomain_key.append((k,))
for i, vi in enumerate(v):
if vi is not None:
extruded = vi._extruded
constant_layers = extruded and vi.constant_layers
subset = isinstance(vi, op2.Subset)
subdomain_key.append((k, i, extruded, constant_layers, subset))
else:
subdomain_key.append((k, i))

return ((sig,)
+ tuple(subdomain_key)
Expand Down Expand Up @@ -812,7 +813,7 @@ def _mesh(self):
@cached_property
def _needs_subset(self):
subdomain_data = self._form.subdomain_data()[self._mesh]
if subdomain_data.get(self._integral_type, None) is not None:
if not all(sd is None for sd in subdomain_data.get(self._integral_type, [None])):
return True

if self._kinfo.subdomain_id == "everywhere":
Expand Down Expand Up @@ -1072,9 +1073,14 @@ def _iterset(self):
try:
subdomain_data = self._form.subdomain_data()[self._mesh][self._integral_type]
except KeyError:
subdomain_data = None

if subdomain_data is not None:
subdomain_data = [None]

subdomain_data = [sd for sd in subdomain_data if sd is not None]
if subdomain_data:
try:
subdomain_data, = subdomain_data
except ValueError:
raise NotImplementedError("Assembly with multiple subdomain data values is not supported")
if self._integral_type != "cell":
raise NotImplementedError("subdomain_data only supported with cell integrals")
if self._kinfo.subdomain_id not in ["everywhere", "otherwise"]:
Expand Down Expand Up @@ -1205,7 +1211,7 @@ def iter_active_coefficients(form, kinfo):
"""Yield the form coefficients referenced in ``kinfo``."""
for idx, subidxs in kinfo.coefficient_map:
for subidx in subidxs:
yield form.coefficients()[idx].split()[subidx]
yield form.coefficients()[idx].subfunctions[subidx]

@staticmethod
def index_function_spaces(form, indices):
Expand Down
7 changes: 5 additions & 2 deletions firedrake/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ def set(self, r, val):
:arg r: the :class:`Function` to which the value should be applied.
:arg val: the prescribed value.
"""

for idx in self._indices:
r = r.sub(idx)
val = val.sub(idx)
if not np.isscalar(val):
for idx in self._indices:
val = val.sub(idx)
r.assign(val, subset=self.node_set)

def integrals(self):
Expand All @@ -215,7 +218,7 @@ def as_subspace(self, field, V, use_split):
if len(field) == 1:
W = V
else:
W = V.split()[field_renumbering[index]] if use_split else V.sub(field_renumbering[index])
W = V.subfunctions[field_renumbering[index]] if use_split else V.sub(field_renumbering[index])
if cmpt is not None:
W = W.sub(cmpt)
return W
Expand Down
2 changes: 1 addition & 1 deletion firedrake/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def save_function(self, f, idx=None, name=None):
if isinstance(V.topological, impl.MixedFunctionSpace):
base_path = self._path_to_mixed_function(mesh.name, V_name, f.name())
self.require_group(base_path)
for i, fsub in enumerate(f.split()):
for i, fsub in enumerate(f.subfunctions):
path = os.path.join(base_path, str(i))
self.require_group(path)
self.set_attr(path, PREFIX + "_function", fsub.name())
Expand Down
8 changes: 7 additions & 1 deletion firedrake/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,15 @@ def function_space(self):
"""Return a null function space."""
return None

def split(self):
@utils.cached_property
def subfunctions(self):
return (self,)

def split(self):
import warnings
warnings.warn("The .split() method is deprecated, please use the .subfunctions property instead", category=FutureWarning)
return self.subfunctions

def cell_node_map(self, bcs=None):
"""Return a null cell to node map."""
if bcs is not None:
Expand Down
14 changes: 7 additions & 7 deletions firedrake/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def iallreduce(self, f, f_reduced, op=MPI.SUM):
:arg f: The a :class:`.Function` to allreduce.
:arg f_reduced: the result of the reduction.
:arg op: MPI reduction operator. Defaults to MPI.SUM.
:returns: list of MPI.Request objects (one for each of f.split()).
:returns: list of MPI.Request objects (one for each of f.subfunctions).
:raises ValueError: if function communicators mismatch each other or the ensemble
spatial communicator, or if the functions are in different spaces
"""
Expand Down Expand Up @@ -141,7 +141,7 @@ def ireduce(self, f, f_reduced, op=MPI.SUM, root=0):
:arg f_reduced: the result of the reduction on rank root.
:arg op: MPI reduction operator. Defaults to MPI.SUM.
:arg root: rank to reduce to. Defaults to 0.
:returns: list of MPI.Request objects (one for each of f.split()).
:returns: list of MPI.Request objects (one for each of f.subfunctions).
:raises ValueError: if function communicators mismatch each other or the ensemble
spatial communicator, or is the functions are in different spaces
"""
Expand Down Expand Up @@ -172,7 +172,7 @@ def ibcast(self, f, root=0):
:arg f: The :class:`.Function` to broadcast.
:arg root: rank to broadcast from. Defaults to 0.
:returns: list of MPI.Request objects (one for each of f.split()).
:returns: list of MPI.Request objects (one for each of f.subfunctions).
:raises ValueError: if function communicator mismatches the ensemble spatial communicator.
"""
self._check_function(f)
Expand Down Expand Up @@ -204,7 +204,7 @@ def recv(self, f, source=MPI.ANY_SOURCE, tag=MPI.ANY_TAG, statuses=None):
:arg f: The a :class:`.Function` to receive into
:arg source: the rank to receive from. Defaults to MPI.ANY_SOURCE.
:arg tag: the tag of the message. Defaults to MPI.ANY_TAG.
:arg statuses: MPI.Status objects (one for each of f.split() or None).
:arg statuses: MPI.Status objects (one for each of f.subfunctions or None).
:raises ValueError: if function communicator mismatches the ensemble spatial communicator.
"""
self._check_function(f)
Expand All @@ -222,7 +222,7 @@ def isend(self, f, dest, tag=0):
:arg f: The a :class:`.Function` to send
:arg dest: the rank to send to
:arg tag: the tag of the message. Defaults to 0.
:returns: list of MPI.Request objects (one for each of f.split()).
:returns: list of MPI.Request objects (one for each of f.subfunctions).
:raises ValueError: if function communicator mismatches the ensemble spatial communicator.
"""
self._check_function(f)
Expand All @@ -238,7 +238,7 @@ def irecv(self, f, source=MPI.ANY_SOURCE, tag=MPI.ANY_TAG):
:arg f: The a :class:`.Function` to receive into
:arg source: the rank to receive from. Defaults to MPI.ANY_SOURCE.
:arg tag: the tag of the message. Defaults to MPI.ANY_TAG.
:returns: list of MPI.Request objects (one for each of f.split()).
:returns: list of MPI.Request objects (one for each of f.subfunctions).
:raises ValueError: if function communicator mismatches the ensemble spatial communicator.
"""
self._check_function(f)
Expand Down Expand Up @@ -280,7 +280,7 @@ def isendrecv(self, fsend, dest, sendtag=0, frecv=None, source=MPI.ANY_SOURCE, r
:arg frecv: The a :class:`.Function` to receive into.
:arg source: the rank to receive from. Defaults to MPI.ANY_SOURCE.
:arg recvtag: the tag of the received message. Defaults to MPI.ANY_TAG.
:returns: list of MPI.Request objects (one for each of fsend.split() and frecv.split()).
:returns: list of MPI.Request objects (one for each of fsend.subfunctions and frecv.subfunctions).
:raises ValueError: if function communicator mismatches the ensemble spatial communicator.
"""
# functions don't necessarily have to match
Expand Down
2 changes: 1 addition & 1 deletion firedrake/formmanipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def argument(self, o):
if o in self._arg_cache:
return self._arg_cache[o]

V_is = V.split()
V_is = V.subfunctions
indices = self.blocks[o.number()]

try:
Expand Down
Loading

0 comments on commit 5739073

Please sign in to comment.