diff --git a/firedrake/checkpointing.py b/firedrake/checkpointing.py index affdf92ad6..985325e25f 100644 --- a/firedrake/checkpointing.py +++ b/firedrake/checkpointing.py @@ -565,7 +565,7 @@ def save_mesh(self, mesh, distribution_name=None, permutation_name=None): :kwarg distribution_name: the name under which distribution is saved; if `None`, auto-generated name will be used. :kwarg permutation_name: the name under which permutation is saved; if `None`, auto-generated name will be used. """ - # TODO: Add general MixedMesh support. + # TODO: Add general MeshSequence support. mesh = mesh.unique() mesh.init() # Handle extruded mesh @@ -838,7 +838,7 @@ def get_timestepping_history(self, mesh, name): @PETSc.Log.EventDecorator("SaveFunctionSpace") def _save_function_space(self, V): mesh = V.mesh() - # TODO: Add general MixedMesh support. + # TODO: Add general MeshSequence support. mesh = mesh.unique() if isinstance(V.topological, impl.MixedFunctionSpace): V_name = self._generate_function_space_name(V) @@ -919,7 +919,7 @@ def save_function(self, f, idx=None, name=None, timestepping_info={}): g = Function(V, val=f.dat, name=name) return self.save_function(g, idx=idx, timestepping_info=timestepping_info) mesh = V.mesh() - # TODO: Add general MixedMesh support. + # TODO: Add general MeshSequence support. mesh = mesh.unique() # -- Save function space -- self._save_function_space(V) @@ -1239,7 +1239,7 @@ def _load_mesh_topology(self, tmesh_name, reorder, distribution_parameters): @PETSc.Log.EventDecorator("LoadFunctionSpace") def _load_function_space(self, mesh, name): - # TODO: Add general MixedMesh support. + # TODO: Add general MeshSequence support. mesh = mesh.unique() mesh.init() mesh_key = self._generate_mesh_key_from_names(mesh.name, @@ -1318,7 +1318,7 @@ def load_function(self, mesh, name, idx=None): be loaded with idx only when it was saved with idx. :returns: the loaded :class:`~.Function`. """ - # TODO: Add general MixedMesh support. + # TODO: Add general MeshSequence support. mesh = mesh.unique() tmesh = mesh.topology if name in self._get_mixed_function_name_mixed_function_space_name_map(mesh.name): diff --git a/firedrake/dmhooks.py b/firedrake/dmhooks.py index fa97a8565a..937f7b99d3 100644 --- a/firedrake/dmhooks.py +++ b/firedrake/dmhooks.py @@ -43,7 +43,7 @@ import firedrake from firedrake.petsc import PETSc -from firedrake.mesh import MixedMeshGeometry +from firedrake.mesh import MeshSequenceGeometry @PETSc.Log.EventDecorator() @@ -58,7 +58,7 @@ def get_function_space(dm): if len(meshref_tuple) == 1: mesh = meshref_tuple[0]() else: - mesh = MixedMeshGeometry([meshref() for meshref in meshref_tuple]) + mesh = MeshSequenceGeometry([meshref() for meshref in meshref_tuple]) if mesh is None: raise RuntimeError("Somehow your mesh was collected, this should never happen") V = firedrake.FunctionSpace(mesh, element, name=name) diff --git a/firedrake/functionspace.py b/firedrake/functionspace.py index 2e305503f6..6608a50e8f 100644 --- a/firedrake/functionspace.py +++ b/firedrake/functionspace.py @@ -259,7 +259,7 @@ def MixedFunctionSpace(spaces, name=None, mesh=None): :class:`finat.ufl.mixedelement.MixedElement`, ignored otherwise. """ - from firedrake.mesh import MixedMeshGeometry + from firedrake.mesh import MeshSequenceGeometry if isinstance(spaces, finat.ufl.FiniteElementBase): # Build the spaces if we got a mixed element @@ -275,7 +275,7 @@ def rec(eles): sub_elements.append(ele) rec(spaces.sub_elements) spaces = [FunctionSpace(mesh, element) for element in sub_elements] - # Flatten MixedMeshes. + # Flatten MeshSequences. meshes = list(itertools.chain(*[space.mesh() for space in spaces])) try: cls, = set(type(s) for s in spaces) @@ -297,7 +297,7 @@ def rec(eles): else: raise ValueError("Can't make mixed space with %s" % type(space)) - mixed_mesh_geometry = MixedMeshGeometry(meshes) + mixed_mesh_geometry = MeshSequenceGeometry(meshes) new = impl.MixedFunctionSpace(spaces, mixed_mesh_geometry.topology, name=name) return cls.create(new, mixed_mesh_geometry) diff --git a/firedrake/functionspaceimpl.py b/firedrake/functionspaceimpl.py index 847648e382..201c030c19 100644 --- a/firedrake/functionspaceimpl.py +++ b/firedrake/functionspaceimpl.py @@ -17,7 +17,7 @@ from pyop2.utils import as_tuple from firedrake import dmhooks, utils -from firedrake.mesh import MeshGeometry, MixedMeshTopology, MixedMeshGeometry +from firedrake.mesh import MeshGeometry, MeshSequenceTopology, MeshSequenceGeometry from firedrake.functionspacedata import get_shared_data, create_element from firedrake.petsc import PETSc @@ -95,8 +95,8 @@ class WithGeometryBase(object): """ def __init__(self, mesh, element, component=None, cargo=None): if type(element) is finat.ufl.MixedElement: - if not isinstance(mesh, MixedMeshGeometry): - raise TypeError(f"Can only use MixedElement with MixedMeshGeometry: got {type(mesh)}") + if not isinstance(mesh, MeshSequenceGeometry): + raise TypeError(f"Can only use MixedElement with MeshSequenceGeometry: got {type(mesh)}") assert component is None or isinstance(component, int) assert cargo is None or isinstance(cargo, FunctionSpaceCargo) super().__init__(mesh, element, label=cargo.topological._label or "") @@ -120,8 +120,8 @@ def create(cls, function_space, mesh, parent=None): """ if isinstance(function_space, MixedFunctionSpace): - if not isinstance(mesh, MixedMeshGeometry): - raise TypeError(f"Can only use MixedFunctionSpace with MixedMeshGeometry: got {type(mesh)}") + if not isinstance(mesh, MeshSequenceGeometry): + raise TypeError(f"Can only use MixedFunctionSpace with MeshSequenceGeometry: got {type(mesh)}") function_space = function_space.topological assert mesh.topology is function_space.mesh() assert mesh.topology is not mesh @@ -372,16 +372,16 @@ def make_function_space(cls, mesh, element, name=None): # Create a new abstract (Mixed/Real)FunctionSpace, these are neither primal nor dual. if type(element) is finat.ufl.MixedElement: if isinstance(mesh, MeshGeometry): - mesh = MixedMeshGeometry([mesh for _ in element.sub_elements]) + mesh = MeshSequenceGeometry([mesh for _ in element.sub_elements]) topology = mesh.topology else: - if not isinstance(mesh, MixedMeshGeometry): - raise TypeError(f"mesh must be MixedMeshGeometry: got {mesh}") + if not isinstance(mesh, MeshSequenceGeometry): + raise TypeError(f"mesh must be MeshSequenceGeometry: got {mesh}") spaces = [cls.make_function_space(topo, e) for topo, e in zip(topology, element.sub_elements, strict=True)] new = MixedFunctionSpace(spaces, topology, name=name) else: - if isinstance(mesh, MixedMeshGeometry): - raise TypeError(f"mesh must not be MixedMeshGeometry: got {mesh}") + if isinstance(mesh, MeshSequenceGeometry): + raise TypeError(f"mesh must not be MeshSequenceGeometry: got {mesh}") # Check that any Vector/Tensor/Mixed modifiers are outermost. check_element(element) if element.family() == "Real": @@ -979,8 +979,8 @@ class MixedFunctionSpace(object): """ def __init__(self, spaces, mesh, name=None): super(MixedFunctionSpace, self).__init__() - if not isinstance(mesh, MixedMeshTopology): - raise TypeError(f"mesh must be MixedMeshTopology: got {mesh}") + if not isinstance(mesh, MeshSequenceTopology): + raise TypeError(f"mesh must be MeshSequenceTopology: got {mesh}") if len(mesh) != len(spaces): raise RuntimeError(f"len(mesh) ({len(mesh)}) != len(spaces) ({len(spaces)})") self._spaces = tuple(IndexedFunctionSpace(i, s, self) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index 72c89d67fa..73b78c0020 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -4691,7 +4691,7 @@ def Submesh(mesh, subdim, subdomain_id, label_name=None, name=None): return submesh -class MixedMeshGeometry(ufl.MixedMesh): +class MeshSequenceGeometry(ufl.MeshSequence): """A representation of mixed mesh geometry.""" def __init__(self, meshes, set_hierarchy=True): @@ -4700,7 +4700,7 @@ def __init__(self, meshes, set_hierarchy=True): Parameters ---------- meshes : tuple or list - `MeshGeometry`s to make `MixedMeshGeometry` with. + `MeshGeometry`s to make `MeshSequenceGeometry` with. set_hierarchy : bool Flag for making hierarchy. @@ -4717,7 +4717,7 @@ def __init__(self, meshes, set_hierarchy=True): @utils.cached_property def topology(self): - return MixedMeshTopology([m.topology for m in self._meshes]) + return MeshSequenceTopology([m.topology for m in self._meshes]) @property def topological(self): @@ -4790,13 +4790,13 @@ def set_hierarchy(self): if ilevel == level: result.append(self) else: - result.append(MixedMeshGeometry([hierarchy[ilevel] for hierarchy in hierarchy_list], set_hierarchy=False)) + result.append(MeshSequenceGeometry([hierarchy[ilevel] for hierarchy in hierarchy_list], set_hierarchy=False)) result = tuple(result) for i, m in enumerate(result): set_level(m, result, i) -class MixedMeshTopology(object): +class MeshSequenceTopology(object): """A representation of mixed mesh topology.""" def __init__(self, meshes): @@ -4805,7 +4805,7 @@ def __init__(self, meshes): Parameters ---------- meshes : tuple or list - `MeshTopology`s to make `MixedMeshTopology` with. + `MeshTopology`s to make `MeshSequenceTopology` with. """ for m in meshes: @@ -4837,8 +4837,8 @@ def ufl_cell(self): def ufl_mesh(self): cell = self.ufl_cell() - return ufl.MixedMesh([ufl.Mesh(finat.ufl.VectorElement("Lagrange", cell, 1, dim=cell.topological_dimension())) - for _ in self._meshes]) + return ufl.MeshSequence([ufl.Mesh(finat.ufl.VectorElement("Lagrange", cell, 1, dim=cell.topological_dimension())) + for _ in self._meshes]) def __eq__(self, other): if type(other) != type(self): diff --git a/firedrake/mg/ufl_utils.py b/firedrake/mg/ufl_utils.py index 11b2b4fb51..ac9f5da50f 100644 --- a/firedrake/mg/ufl_utils.py +++ b/firedrake/mg/ufl_utils.py @@ -62,7 +62,7 @@ def coarsen(expr, self, coefficient_mapping=None): @coarsen.register(ufl.Mesh) -@coarsen.register(ufl.MixedMesh) +@coarsen.register(ufl.MeshSequence) def coarsen_mesh(mesh, self, coefficient_mapping=None): hierarchy, level = utils.get_level(mesh) if hierarchy is None: @@ -133,7 +133,7 @@ def coarsen_function_space(V, self, coefficient_mapping=None): return V._coarse V_fine = V - # Handle MixedFunctionSpace : V_fine.reconstruct requires MixedMesh. + # Handle MixedFunctionSpace : V_fine.reconstruct requires MeshSequence. fine_mesh = V_fine.mesh() if V_fine.index is None else V_fine.parent.mesh() mesh_coarse = self(fine_mesh, self) name = f"coarse_{V.name}" if V.name else None diff --git a/firedrake/ufl_expr.py b/firedrake/ufl_expr.py index a569fdd2a9..3b69f8698b 100644 --- a/firedrake/ufl_expr.py +++ b/firedrake/ufl_expr.py @@ -7,7 +7,7 @@ from ufl.domain import as_domain import firedrake from firedrake import utils, function, cofunction -from firedrake.mesh import MixedMeshGeometry +from firedrake.mesh import MeshSequenceGeometry from firedrake.constant import Constant from firedrake.petsc import PETSc @@ -385,7 +385,7 @@ def extract_domains(f): elif isinstance(f, cofunction.Cofunction): # ufl.domain.extract_domains does not work. mesh = f.function_space().mesh() - if isinstance(mesh, MixedMeshGeometry): + if isinstance(mesh, MeshSequenceGeometry): return list(set(mesh._meshes)) else: return [mesh] diff --git a/tests/tsfc/test_tsfc_182.py b/tests/tsfc/test_tsfc_182.py index 30e818040f..a6208a491c 100644 --- a/tests/tsfc/test_tsfc_182.py +++ b/tests/tsfc/test_tsfc_182.py @@ -1,6 +1,6 @@ import pytest -from ufl import Coefficient, TestFunction, dx, inner, tetrahedron, Mesh, MixedMesh, FunctionSpace +from ufl import Coefficient, TestFunction, dx, inner, tetrahedron, Mesh, MeshSequence, FunctionSpace from finat.ufl import FiniteElement, MixedElement, VectorElement from tsfc import compile_form @@ -20,7 +20,7 @@ def test_delta_elimination(mode): element_chi_lambda = MixedElement(element_eps_p, element_lambda) domain = Mesh(VectorElement("Lagrange", tetrahedron, 1)) - domains = MixedMesh([domain, domain]) + domains = MeshSequence([domain, domain]) space = FunctionSpace(domains, element_chi_lambda) chi_lambda = Coefficient(space) diff --git a/tests/tsfc/test_tsfc_204.py b/tests/tsfc/test_tsfc_204.py index 5653d99df9..fe889e48b8 100644 --- a/tests/tsfc/test_tsfc_204.py +++ b/tests/tsfc/test_tsfc_204.py @@ -1,13 +1,13 @@ from tsfc import compile_form from ufl import (Coefficient, FacetNormal, - FunctionSpace, Mesh, MixedMesh, as_matrix, + FunctionSpace, Mesh, MeshSequence, as_matrix, dot, dS, ds, dx, facet, grad, inner, outer, split, triangle) from finat.ufl import BrokenElement, FiniteElement, MixedElement, VectorElement def test_physically_mapped_facet(): mesh = Mesh(VectorElement("P", triangle, 1)) - meshes = MixedMesh([mesh, mesh, mesh, mesh, mesh]) + meshes = MeshSequence([mesh, mesh, mesh, mesh, mesh]) # set up variational problem U = FiniteElement("Morley", mesh.ufl_cell(), 2) diff --git a/tsfc/kernel_interface/firedrake_loopy.py b/tsfc/kernel_interface/firedrake_loopy.py index 897b8f6b16..b0feaa6ea4 100644 --- a/tsfc/kernel_interface/firedrake_loopy.py +++ b/tsfc/kernel_interface/firedrake_loopy.py @@ -2,7 +2,7 @@ from collections import namedtuple, OrderedDict from ufl import Coefficient, FunctionSpace -from ufl.domain import MixedMesh +from ufl.domain import MeshSequence from finat.ufl import MixedElement as ufl_MixedElement, FiniteElement import gem @@ -360,8 +360,8 @@ def set_coordinates(self, domains): """ # Create a fake coordinate coefficient for a domain. for i, domain in enumerate(domains): - if isinstance(domain, MixedMesh): - raise RuntimeError("Found a MixedMesh") + if isinstance(domain, MeshSequence): + raise RuntimeError("Found a MeshSequence") f = Coefficient(FunctionSpace(domain, domain.ufl_coordinate_element())) self.domain_coordinate[domain] = f self._coefficient(f, f"coords_{i}")