From bcb850c63a68c40ca7ae6e56af818890cc63a72f Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 6 Oct 2025 12:17:31 +0100 Subject: [PATCH 1/3] Adapt to UFL changing some methods to properties See https://github.com/FEniCS/ufl/pull/385. --- demos/ma-demo/ma-demo.py.rst | 2 +- docs/notebooks/03-elasticity.ipynb | 6 +- docs/notebooks/08-composable-solvers.ipynb | 2 +- docs/source/petsc-interface.rst | 4 +- firedrake/bcs.py | 4 +- firedrake/checkpointing.py | 6 +- firedrake/cython/supermeshimpl.pyx | 14 ++-- firedrake/embedding.py | 4 +- firedrake/extrusion_utils.py | 2 +- firedrake/function.py | 4 +- firedrake/functionspace.py | 6 +- firedrake/functionspaceimpl.py | 2 +- firedrake/interpolation.py | 12 +-- firedrake/mesh.py | 76 +++++++++---------- firedrake/mg/kernels.py | 14 ++-- firedrake/mg/mesh.py | 4 +- firedrake/mg/utils.py | 2 +- firedrake/output/vtk_output.py | 12 +-- firedrake/pointeval_utils.py | 4 +- firedrake/pointquery_utils.py | 14 ++-- firedrake/preconditioners/bddc.py | 2 +- firedrake/preconditioners/fdm.py | 14 ++-- firedrake/preconditioners/hiptmair.py | 4 +- firedrake/preconditioners/hypre_ads.py | 2 +- firedrake/pyplot/mpl.py | 24 +++--- firedrake/pyplot/pgf.py | 2 +- firedrake/supermeshing.py | 8 +- pyproject.toml | 5 +- .../firedrake/adjoint/test_dynamic_meshes.py | 2 +- .../test_external_operators.py | 2 +- .../extrusion/test_facet_support_dofs.py | 2 +- .../test_steady_advection_3D_extr.py | 2 +- .../macro/test_macro_interp_project.py | 2 +- tests/firedrake/macro/test_macro_multigrid.py | 2 +- .../firedrake/macro/test_macro_quadrature.py | 6 +- tests/firedrake/macro/test_macro_solve.py | 6 +- .../macro/test_stokes_macroelements.py | 4 +- tests/firedrake/multigrid/test_hiptmair.py | 4 +- tests/firedrake/multigrid/test_p_multigrid.py | 8 +- .../output/test_io_backward_compat.py | 2 +- tests/firedrake/output/test_io_function.py | 2 +- tests/firedrake/regression/test_bddc.py | 4 +- .../regression/test_change_coordinates.py | 8 +- tests/firedrake/regression/test_fdm.py | 14 ++-- tests/firedrake/regression/test_helmholtz.py | 2 +- .../regression/test_helmholtz_sphere.py | 4 +- .../regression/test_interpolate_vs_project.py | 2 +- .../regression/test_interpolation_nodes.py | 4 +- .../firedrake/regression/test_linesmoother.py | 4 +- .../firedrake/regression/test_mass_lumping.py | 2 +- .../regression/test_mesh_from_plex.py | 4 +- .../regression/test_multiple_domains.py | 8 +- tests/firedrake/regression/test_p1pc.py | 6 +- .../regression/test_solving_interface.py | 2 +- tests/firedrake/regression/test_star_pc.py | 2 +- .../regression/test_tensor_algebra.py | 4 +- .../regression/test_tensor_elements.py | 4 +- .../firedrake/slate/test_assemble_tensors.py | 4 +- .../firedrake/submesh/test_submesh_basics.py | 2 +- tests/firedrake/submesh/test_submesh_facet.py | 4 +- .../submesh/test_submesh_interpolate.py | 14 ++-- .../test_interpolation_from_parent.py | 22 +++--- tests/firedrake/vertexonly/test_swarm.py | 12 +-- .../vertexonly/test_vertex_only_fs.py | 28 +++---- .../test_vertex_only_mesh_generation.py | 20 ++--- tests/tsfc/test_idempotency.py | 2 +- tests/tsfc/test_impero_loopy_flop_counts.py | 2 +- .../tsfc/test_interpolation_factorisation.py | 4 +- tests/tsfc/test_sum_factorisation.py | 12 +-- tests/tsfc/test_tensor.py | 6 +- tests/tsfc/test_underintegration.py | 4 +- tsfc/fem.py | 4 +- tsfc/kernel_interface/firedrake_loopy.py | 2 +- tsfc/modified_terminals.py | 2 +- 74 files changed, 259 insertions(+), 258 deletions(-) diff --git a/demos/ma-demo/ma-demo.py.rst b/demos/ma-demo/ma-demo.py.rst index f8717d4d6e..432042a20d 100644 --- a/demos/ma-demo/ma-demo.py.rst +++ b/demos/ma-demo/ma-demo.py.rst @@ -111,7 +111,7 @@ a Function, w. :: n = FacetNormal(mesh) - I = Identity(mesh.geometric_dimension()) + I = Identity(mesh.geometric_dimension) L = inner(sigma, tau)*dx L += (inner(div(tau), grad(u))*dx diff --git a/docs/notebooks/03-elasticity.ipynb b/docs/notebooks/03-elasticity.ipynb index 0dab70b83e..f2ed86d199 100644 --- a/docs/notebooks/03-elasticity.ipynb +++ b/docs/notebooks/03-elasticity.ipynb @@ -118,7 +118,7 @@ "f = as_vector([0, -rho*g])\n", "mu = Constant(1)\n", "lambda_ = Constant(0.25)\n", - "Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor" + "Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor" ] }, { @@ -285,7 +285,7 @@ " f = as_vector([0, -rho*g])\n", " mu = Constant(1)\n", " lambda_ = Constant(0.25)\n", - " Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n", + " Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor\n", " \n", " bc = DirichletBC(V, Constant([0, 0]), 1)\n", " u = TrialFunction(V)\n", @@ -393,7 +393,7 @@ " f = as_vector([0, -rho*g])\n", " mu = Constant(1)\n", " lambda_ = Constant(0.25)\n", - " Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n", + " Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor\n", " def epsilon(u):\n", " return 0.5*(grad(u) + grad(u).T)\n", "\n", diff --git a/docs/notebooks/08-composable-solvers.ipynb b/docs/notebooks/08-composable-solvers.ipynb index 78ba106b5f..d13d798bb0 100644 --- a/docs/notebooks/08-composable-solvers.ipynb +++ b/docs/notebooks/08-composable-solvers.ipynb @@ -114,7 +114,7 @@ "bc_value = as_vector([0.25 * x**2 * (2-x)**2 *y**2, 0])\n", "\n", "bcs = [DirichletBC(W.sub(0), bc_value, 4),\n", - " DirichletBC(W.sub(0), zero(mesh.geometric_dimension()), (1, 2, 3))]" + " DirichletBC(W.sub(0), zero(mesh.geometric_dimension), (1, 2, 3))]" ] }, { diff --git a/docs/source/petsc-interface.rst b/docs/source/petsc-interface.rst index 45a874a51e..0a3caf363b 100644 --- a/docs/source/petsc-interface.rst +++ b/docs/source/petsc-interface.rst @@ -375,8 +375,8 @@ Accordingly, set .. code-block:: python3 - dim = mesh.topological_dimension() - gdim = mesh.geometrical_dimension() + dim = mesh.topological_dimension + gdim = mesh.geometric_dimension entity_dofs = np.zeros(dim+1, dtype=np.int32) entity_dofs[0] = gdim entity_dofs[1] = gdim*(p-1) diff --git a/firedrake/bcs.py b/firedrake/bcs.py index e1408da545..5e73536ef2 100644 --- a/firedrake/bcs.py +++ b/firedrake/bcs.py @@ -130,12 +130,12 @@ def nodes(self): # First, we bail out on zany elements. We don't know how to do BC's for them. V = self._function_space if isinstance(V.finat_element, (finat.Argyris, finat.Morley, finat.Bell)) or \ - (isinstance(V.finat_element, finat.Hermite) and V.mesh().topological_dimension() > 1): + (isinstance(V.finat_element, finat.Hermite) and V.mesh().topological_dimension > 1): raise NotImplementedError("Strong BCs not implemented for element %r, use Nitsche-type methods until we figure this out" % V.finat_element) def hermite_stride(bcnodes): fe = self._function_space.finat_element - tdim = self._function_space.mesh().topological_dimension() + tdim = self._function_space.mesh().topological_dimension if isinstance(fe, finat.Hermite) and tdim == 1: bcnodes = bcnodes[::2] # every second dof is the vertex value elif fe.complex.is_macrocell() and self._function_space.ufl_element().sobolev_space == ufl.H1: diff --git a/firedrake/checkpointing.py b/firedrake/checkpointing.py index 6a63b1aaf1..cb93077ce9 100644 --- a/firedrake/checkpointing.py +++ b/firedrake/checkpointing.py @@ -591,7 +591,7 @@ def save_mesh(self, mesh, distribution_name=None, permutation_name=None): # Save tmesh.layers, which contains (start layer, stop layer)-tuple for each cell # Conceptually, we project these integer pairs onto DG0 vector space of dim=2. cell = base_tmesh.ufl_cell() - element = finat.ufl.VectorElement("DP" if cell.is_simplex() else "DQ", cell, 0, dim=2) + element = finat.ufl.VectorElement("DP" if cell.is_simplex else "DQ", cell, 0, dim=2) layers_tV = impl.FunctionSpace(base_tmesh, element) self._save_function_space_topology(layers_tV) # Note that _cell_numbering coincides with DG0 section, so we can use tmesh.layers directly. @@ -1050,7 +1050,7 @@ def load_mesh(self, name=DEFAULT_MESH_NAME, reorder=None, distribution_parameter variable_layers = self.get_attr(path, PREFIX_EXTRUDED + "_variable_layers") if variable_layers: cell = base_tmesh.ufl_cell() - element = finat.ufl.VectorElement("DP" if cell.is_simplex() else "DQ", cell, 0, dim=2) + element = finat.ufl.VectorElement("DP" if cell.is_simplex else "DQ", cell, 0, dim=2) _ = self._load_function_space_topology(base_tmesh, element) base_tmesh_key = self._generate_mesh_key_from_names(base_tmesh.name, base_tmesh._distribution_name, @@ -1113,7 +1113,7 @@ def load_mesh(self, name=DEFAULT_MESH_NAME, reorder=None, distribution_parameter path = self._path_to_mesh_immersed(tmesh.name, name) if path in self.h5pyfile: cell = tmesh.ufl_cell() - element = finat.ufl.FiniteElement("DP" if cell.is_simplex() else "DQ", cell, 0) + element = finat.ufl.FiniteElement("DP" if cell.is_simplex else "DQ", cell, 0) cell_orientations_tV = self._load_function_space_topology(tmesh, element) tmesh_key = self._generate_mesh_key_from_names(tmesh.name, tmesh._distribution_name, diff --git a/firedrake/cython/supermeshimpl.pyx b/firedrake/cython/supermeshimpl.pyx index ad3387cd82..fde3fa6ba9 100644 --- a/firedrake/cython/supermeshimpl.pyx +++ b/firedrake/cython/supermeshimpl.pyx @@ -69,7 +69,7 @@ def assemble_mixed_mass_matrix(V_A, V_B, candidates, vertex_map_B = mesh_B.coordinates.cell_node_map().values_with_halo num_vertices = vertex_map_A.shape[1] - gdim = mesh_A.geometric_dimension() + gdim = mesh_A.geometric_dimension simplex_A = numpy.empty((num_vertices, gdim), dtype=ScalarType) simplex_B = numpy.empty_like(simplex_A, dtype=ScalarType) simplices_C = numpy.empty(MAGIC[gdim], dtype=ScalarType) @@ -119,10 +119,10 @@ def intersection_finder(mesh_A, mesh_B): long nnodes_A, nnodes_B, ncells_A, ncells_B int dim_A, dim_B, loc_A, loc_B - dim = mesh_A.geometric_dimension() - assert dim == mesh_B.geometric_dimension() - assert dim == mesh_A.topological_dimension() - assert dim == mesh_B.topological_dimension() + dim = mesh_A.geometric_dimension + assert dim == mesh_B.geometric_dimension + assert dim == mesh_A.topological_dimension + assert dim == mesh_B.topological_dimension assert mesh_A.coordinates.function_space().ufl_element().degree() == 1 assert mesh_B.coordinates.function_space().ufl_element().degree() == 1 @@ -144,8 +144,8 @@ def intersection_finder(mesh_A, mesh_B): vertex_map_B = mesh_B.coordinates.cell_node_map().values_with_halo.astype(int) nnodes_A = mesh_A.coordinates.dof_dset.total_size nnodes_B = mesh_B.coordinates.dof_dset.total_size - dim_A = mesh_A.geometric_dimension() - dim_B = mesh_B.geometric_dimension() + dim_A = mesh_A.geometric_dimension + dim_B = mesh_B.geometric_dimension ncells_A = mesh_A.num_cells() ncells_B = mesh_B.num_cells() loc_A = vertex_map_A.shape[1] diff --git a/firedrake/embedding.py b/firedrake/embedding.py index 517be9387e..8bbbb5af42 100644 --- a/firedrake/embedding.py +++ b/firedrake/embedding.py @@ -6,14 +6,14 @@ def get_embedding_dg_element(element, value_shape, broken_cg=False): cell = element.cell - family = lambda c: "DG" if c.is_simplex() else "DQ" + family = lambda c: "DG" if c.is_simplex else "DQ" if isinstance(cell, ufl.TensorProductCell): degree = element.degree() if type(degree) is int: scalar_element = finat.ufl.FiniteElement("DQ", cell=cell, degree=degree) else: scalar_element = finat.ufl.TensorProductElement(*(finat.ufl.FiniteElement(family(c), cell=c, degree=d) - for (c, d) in zip(cell.sub_cells(), degree))) + for (c, d) in zip(cell.sub_cells, degree))) else: degree = element.embedded_superdegree scalar_element = finat.ufl.FiniteElement(family(cell), cell=cell, degree=degree) diff --git a/firedrake/extrusion_utils.py b/firedrake/extrusion_utils.py index 0b65f6d11d..b38ea9517a 100644 --- a/firedrake/extrusion_utils.py +++ b/firedrake/extrusion_utils.py @@ -145,7 +145,7 @@ def _get_lp_domains(_inames, _extents): elif extrusion_type == 'radial_hedgehog': # Only implemented for interval in 2D and triangle in 3D. # gdim != tdim already checked in ExtrudedMesh constructor. - tdim = extract_unique_domain(base_coords).ufl_cell().topological_dimension() + tdim = extract_unique_domain(base_coords).ufl_cell().topological_dimension if tdim not in [1, 2]: raise NotImplementedError("Hedgehog extrusion not implemented for %s" % extract_unique_domain(base_coords).ufl_cell()) # tdim == 1: diff --git a/firedrake/function.py b/firedrake/function.py index a628ac6599..1fc8fb2f83 100644 --- a/firedrake/function.py +++ b/firedrake/function.py @@ -606,7 +606,7 @@ def _at(self, arg, *args, **kwargs): raise NotImplementedError("Point evaluation not implemented for variable layers") # Validate geometric dimension - gdim = mesh.geometric_dimension() + gdim = mesh.geometric_dimension if arg.shape[-1] == gdim: pass elif len(arg.shape) == 1 and gdim == 1: @@ -728,7 +728,7 @@ def __init__(self, mesh: MeshGeometry, points: np.ndarray | list, tolerance: flo self.points = np.asarray(points, dtype=utils.ScalarType) if not self.points.shape: self.points = self.points.reshape(-1) - gdim = mesh.geometric_dimension() + gdim = mesh.geometric_dimension if self.points.shape[-1] != gdim and (len(self.points.shape) != 1 or gdim != 1): raise ValueError(f"Point dimension ({self.points.shape[-1]}) does not match geometric dimension ({gdim}).") self.points = self.points.reshape(-1, gdim) diff --git a/firedrake/functionspace.py b/firedrake/functionspace.py index cefa3bf9a4..286e10a45a 100644 --- a/firedrake/functionspace.py +++ b/firedrake/functionspace.py @@ -58,7 +58,7 @@ def make_scalar_element(mesh, family, degree, vfamily, vdegree, variant): if isinstance(cell, ufl.TensorProductCell) \ and vfamily is not None and vdegree is not None: la = finat.ufl.FiniteElement(family, - cell=cell.sub_cells()[0], + cell=cell.sub_cells[0], degree=degree, variant=variant) # If second element was passed in, use it lb = finat.ufl.FiniteElement(vfamily, @@ -180,7 +180,7 @@ def VectorFunctionSpace(mesh, family, degree=None, dim=None, """ sub_element = make_scalar_element(mesh, family, degree, vfamily, vdegree, variant) if dim is None: - dim = mesh.geometric_dimension() + dim = mesh.geometric_dimension if not isinstance(dim, numbers.Integral) and dim > 0: raise ValueError(f"Can't make VectorFunctionSpace with dim={dim}") element = finat.ufl.VectorElement(sub_element, dim=dim) @@ -232,7 +232,7 @@ def TensorFunctionSpace(mesh, family, degree=None, shape=None, """ sub_element = make_scalar_element(mesh, family, degree, vfamily, vdegree, variant) if shape is None: - shape = (mesh.geometric_dimension(),) * 2 + shape = (mesh.geometric_dimension,) * 2 element = finat.ufl.TensorElement(sub_element, shape=shape, symmetry=symmetry) return FunctionSpace(mesh, element, name=name) diff --git a/firedrake/functionspaceimpl.py b/firedrake/functionspaceimpl.py index 4dda3266e1..5e31c86acf 100644 --- a/firedrake/functionspaceimpl.py +++ b/firedrake/functionspaceimpl.py @@ -52,7 +52,7 @@ def check_element(element, top=True): ValueError If the element is illegal. """ - if element.cell.cellname() == "hexahedron" and \ + if element.cell.cellname == "hexahedron" and \ element.family() not in ["Q", "DQ", "Real"]: raise NotImplementedError("Currently can only use 'Q', 'DQ', and/or 'Real' elements on hexahedral meshes, not", element.family()) if type(element) in (finat.ufl.BrokenElement, finat.ufl.RestrictedElement, diff --git a/firedrake/interpolation.py b/firedrake/interpolation.py index 4fb288fb4d..58241c959b 100644 --- a/firedrake/interpolation.py +++ b/firedrake/interpolation.py @@ -277,7 +277,7 @@ def __new__(cls, expr, V, **kwargs): submesh_interp_implemented = \ all(isinstance(m.topology, firedrake.mesh.MeshTopology) for m in [target_mesh, source_mesh]) and \ target_mesh.submesh_ancesters[-1] is source_mesh.submesh_ancesters[-1] and \ - target_mesh.topological_dimension() == source_mesh.topological_dimension() + target_mesh.topological_dimension == source_mesh.topological_dimension if target_mesh is source_mesh or submesh_interp_implemented: return object.__new__(SameMeshInterpolator) else: @@ -498,8 +498,8 @@ def __init__( V_dest = V.function_space() if isinstance(V, firedrake.Function) else V src_mesh = extract_unique_domain(expr) dest_mesh = as_domain(V_dest) - src_mesh_gdim = src_mesh.geometric_dimension() - dest_mesh_gdim = dest_mesh.geometric_dimension() + src_mesh_gdim = src_mesh.geometric_dimension + dest_mesh_gdim = dest_mesh.geometric_dimension if src_mesh_gdim != dest_mesh_gdim: raise ValueError( "geometric dimensions of source and destination meshes must match" @@ -870,7 +870,7 @@ def make_interpolator(expr, V, subset, access, bcs=None, matfree=True): if isinstance(target_mesh.topology, VertexOnlyMeshTopology) and target_mesh is not source_mesh and not vom_onto_other_vom: if not isinstance(target_mesh.topology, VertexOnlyMeshTopology): raise NotImplementedError("Can only interpolate onto a VertexOnlyMesh") - if target_mesh.geometric_dimension() != source_mesh.geometric_dimension(): + if target_mesh.geometric_dimension != source_mesh.geometric_dimension: raise ValueError("Cannot interpolate onto a mesh of a different geometric dimension") if not hasattr(target_mesh, "_parent_mesh") or target_mesh._parent_mesh is not source_mesh: raise ValueError("Can only interpolate across meshes where the source mesh is the parent of the target") @@ -1005,7 +1005,7 @@ def _interpolator(tensor, expr, subset, access, bcs=None): if target_mesh is not source_mesh: if not isinstance(target_mesh.topology, VertexOnlyMeshTopology): raise NotImplementedError("Can only interpolate onto a Vertex Only Mesh") - if target_mesh.geometric_dimension() != source_mesh.geometric_dimension(): + if target_mesh.geometric_dimension != source_mesh.geometric_dimension: raise ValueError("Cannot interpolate onto a mesh of a different geometric dimension") if not hasattr(target_mesh, "_parent_mesh") or target_mesh._parent_mesh is not source_mesh: raise ValueError("Can only interpolate across meshes where the source mesh is the parent of the target") @@ -1239,7 +1239,7 @@ def rebuild_dg(element, expr_cell, rt_var_name): # dual basis. This exists on the same reference cell as the input element # and we can interpolate onto it before mapping the result back onto the # target space. - expr_tdim = expr_cell.topological_dimension() + expr_tdim = expr_cell.topological_dimension # Need point evaluations and matching weights from dual basis. # This could use FIAT's dual basis as below: # num_points = sum(len(dual.get_point_dict()) for dual in element.fiat_equivalent.dual_basis()) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index 87757a2e54..546de46366 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -808,12 +808,12 @@ def size(self, d): def cell_dimension(self): """Returns the cell dimension.""" - return self.ufl_cell().topological_dimension() + return self.ufl_cell().topological_dimension def facet_dimension(self): """Returns the facet dimension.""" # Facets have co-dimension 1 - return self.ufl_cell().topological_dimension() - 1 + return self.ufl_cell().topological_dimension - 1 @property @abc.abstractmethod @@ -1177,7 +1177,7 @@ def _ufl_cell(self): @utils.cached_property def _ufl_mesh(self): cell = self._ufl_cell - return ufl.Mesh(finat.ufl.VectorElement("Lagrange", cell, 1, dim=cell.topological_dimension())) + return ufl.Mesh(finat.ufl.VectorElement("Lagrange", cell, 1, dim=cell.topological_dimension)) @property def _default_reordering(self): @@ -1214,9 +1214,9 @@ def cell_closure(self): vertex_numbering = self._vertex_numbering.createGlobalSection(plex.getPointSF()) cell = self.ufl_cell() - assert tdim == cell.topological_dimension() + assert tdim == cell.topological_dimension if self.submesh_parent is not None and \ - not (self.submesh_parent.ufl_cell().cellname() == "hexahedron" and cell.cellname() == "quadrilateral"): + not (self.submesh_parent.ufl_cell().cellname == "hexahedron" and cell.cellname == "quadrilateral"): # Codim-1 submesh of a hex mesh (i.e. a quad submesh) can not # inherit cell_closure from the hex mesh as the cell_closure # must follow the special orientation restriction. This means @@ -1235,7 +1235,7 @@ def cell_closure(self): self.submesh_parent.cell_closure, entity_per_cell, ) - elif cell.is_simplex(): + elif cell.is_simplex: topology = FIAT.ufc_cell(cell).get_topology() entity_per_cell = np.zeros(len(topology), dtype=IntType) for d, ents in topology.items(): @@ -1244,7 +1244,7 @@ def cell_closure(self): return dmcommon.closure_ordering(plex, vertex_numbering, cell_numbering, entity_per_cell) - elif cell.cellname() == "quadrilateral": + elif cell.cellname == "quadrilateral": petsctools.cite("Homolya2016") petsctools.cite("McRae2016") # Quadrilateral mesh @@ -1263,7 +1263,7 @@ def cell_closure(self): return dmcommon.quadrilateral_closure_ordering( plex, vertex_numbering, cell_numbering, cell_orientations) - elif cell.cellname() == "hexahedron": + elif cell.cellname == "hexahedron": # TODO: Should change and use create_cell_closure() for all cell types. topology = FIAT.ufc_cell(cell).get_topology() closureSize = sum([len(ents) for _, ents in topology.items()]) @@ -1451,7 +1451,7 @@ def mark_entities(self, tf, label_value, label_name=None): label_name = label_name or dmcommon.CELL_SETS_LABEL elif (elem.family() == "HDiv Trace" and elem.degree() == 0 and self.cell_dimension() > 1) or \ (elem.family() == "Lagrange" and elem.degree() == 1 and self.cell_dimension() == 1) or \ - (elem.family() == "Q" and elem.degree() == 2 and self.ufl_cell().cellname() == "hexahedron"): + (elem.family() == "Q" and elem.degree() == 2 and self.ufl_cell().cellname == "hexahedron"): # facets height = 1 label_name = label_name or dmcommon.FACE_SETS_LABEL @@ -1706,7 +1706,7 @@ def _ufl_cell(self): @utils.cached_property def _ufl_mesh(self): cell = self._ufl_cell - return ufl.Mesh(finat.ufl.VectorElement("Lagrange", cell, 1, dim=cell.topological_dimension())) + return ufl.Mesh(finat.ufl.VectorElement("Lagrange", cell, 1, dim=cell.topological_dimension)) @property def dm_cell_types(self): @@ -1929,7 +1929,7 @@ def _ufl_cell(self): @utils.cached_property def _ufl_mesh(self): cell = self._ufl_cell - return ufl.Mesh(finat.ufl.VectorElement("DG", cell, 0, dim=cell.topological_dimension())) + return ufl.Mesh(finat.ufl.VectorElement("DG", cell, 0, dim=cell.topological_dimension)) def _renumber_entities(self, reorder): if reorder: @@ -1970,8 +1970,8 @@ def cell_closure(self): vertex_numbering = self._vertex_numbering.createGlobalSection(swarm.getPointSF()) cell = self.ufl_cell() - assert tdim == cell.topological_dimension() - assert cell.is_simplex() + assert tdim == cell.topological_dimension + assert cell.is_simplex import FIAT topology = FIAT.ufc_cell(cell).get_topology() @@ -2268,7 +2268,7 @@ def _init_topology(self, topology): self._topology = topology coordinates_fs = functionspace.FunctionSpace(self.topology, self.ufl_coordinate_element()) coordinates_data = dmcommon.reordered_coords(topology.topology_dm, coordinates_fs.dm.getDefaultSection(), - (self.num_vertices(), self.geometric_dimension())) + (self.num_vertices(), self.geometric_dimension)) coordinates = function.CoordinatelessFunction(coordinates_fs, val=coordinates_data, name=_generate_default_mesh_coordinates_name(self.name)) @@ -2435,7 +2435,7 @@ def bounding_box_coords(self) -> Tuple[np.ndarray, np.ndarray] | None: from firedrake import function, functionspace from firedrake.parloops import par_loop, READ, MIN, MAX - gdim = self.geometric_dimension() + gdim = self.geometric_dimension if gdim <= 1: info_red("libspatialindex does not support 1-dimension, falling back on brute force.") return None @@ -2594,9 +2594,9 @@ def locate_cell_and_reference_coordinate(self, x, tolerance=None, cell_ignore=No or, when point is not in the domain, (None, None). """ x = np.asarray(x) - if x.size != self.geometric_dimension(): + if x.size != self.geometric_dimension: raise ValueError("Point must have the same geometric dimension as the mesh") - x = x.reshape((1, self.geometric_dimension())) + x = x.reshape((1, self.geometric_dimension)) cells, ref_coords, _ = self.locate_cells_ref_coords_and_dists(x, tolerance=tolerance, cells_ignore=[[cell_ignore]]) if cells[0] == -1: return None, None @@ -2632,7 +2632,7 @@ def locate_cells_ref_coords_and_dists(self, xs, tolerance=None, cells_ignore=Non self.tolerance = tolerance xs = np.asarray(xs, dtype=utils.ScalarType) xs = xs.real.copy() - if xs.shape[1] != self.geometric_dimension(): + if xs.shape[1] != self.geometric_dimension: raise ValueError("Point coordinate dimension does not match mesh geometric dimension") Xs = np.empty_like(xs) npoints = len(xs) @@ -2645,7 +2645,7 @@ def locate_cells_ref_coords_and_dists(self, xs, tolerance=None, cells_ignore=Non assert cells_ignore.shape == (npoints, cells_ignore.shape[1]) ref_cell_dists_l1 = np.empty(npoints, dtype=utils.RealType) cells = np.empty(npoints, dtype=IntType) - assert xs.size == npoints * self.geometric_dimension() + assert xs.size == npoints * self.geometric_dimension self._c_locator(tolerance=tolerance)(self.coordinates._ctypes, xs.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), Xs.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), @@ -2684,9 +2684,9 @@ def _c_locator(self, tolerance=None): not run at c-loop speed. */ /* cells_ignore has shape (npoints, ncells_ignore) - find the ith row */ int *cells_ignore_i = cells_ignore + i*ncells_ignore; - cells[i] = locate_cell(f, &x[j], {self.geometric_dimension()}, &to_reference_coords, &to_reference_coords_xtr, &temp_reference_coords, &found_reference_coords, &ref_cell_dists_l1[i], ncells_ignore, cells_ignore_i); + cells[i] = locate_cell(f, &x[j], {self.geometric_dimension}, &to_reference_coords, &to_reference_coords_xtr, &temp_reference_coords, &found_reference_coords, &ref_cell_dists_l1[i], ncells_ignore, cells_ignore_i); - for (int k = 0; k < {self.geometric_dimension()}; k++) {{ + for (int k = 0; k < {self.geometric_dimension}; k++) {{ X[j] = found_reference_coords.X[k]; j++; }} @@ -2780,7 +2780,7 @@ def init_cell_orientations(self, expr): import firedrake.function as function import firedrake.functionspace as functionspace - if (self.ufl_cell().cellname(), self.geometric_dimension()) not in _supported_embedded_cell_types_and_gdims: + if (self.ufl_cell().cellname, self.geometric_dimension) not in _supported_embedded_cell_types_and_gdims: raise NotImplementedError('Only implemented for intervals embedded in 2d and triangles and quadrilaterals embedded in 3d') if hasattr(self, '_cell_orientations'): @@ -2789,16 +2789,16 @@ def init_cell_orientations(self, expr): if not isinstance(expr, ufl.classes.Expr): raise TypeError("UFL expression expected!") - if expr.ufl_shape != (self.geometric_dimension(), ): - raise ValueError(f"Mismatching shapes: expr.ufl_shape ({expr.ufl_shape}) != (self.geometric_dimension(), ) (({self.geometric_dimension}, ))") + if expr.ufl_shape != (self.geometric_dimension, ): + raise ValueError(f"Mismatching shapes: expr.ufl_shape ({expr.ufl_shape}) != (self.geometric_dimension, ) (({self.geometric_dimension}, ))") fs = functionspace.FunctionSpace(self, 'DG', 0) x = ufl.SpatialCoordinate(self) f = function.Function(fs) - if self.topological_dimension() == 1: + if self.topological_dimension == 1: normal = ufl.as_vector((-ReferenceGrad(x)[1, 0], ReferenceGrad(x)[0, 0])) - else: # self.topological_dimension() == 2 + else: # self.topological_dimension == 2 normal = ufl.cross(ReferenceGrad(x)[:, 0], ReferenceGrad(x)[:, 1]) f.interpolate(ufl.dot(expr, normal)) @@ -2865,7 +2865,7 @@ def make_mesh_from_coordinates(coordinates, name, tolerance=0.5): element = coordinates.ufl_element() if V.rank != 1 or len(element.reference_value_shape) != 1: raise ValueError("Coordinates must be from a rank-1 FunctionSpace with rank-1 value_shape.") - assert V.mesh().ufl_cell().topological_dimension() <= V.value_size + assert V.mesh().ufl_cell().topological_dimension <= V.value_size mesh = MeshGeometry.__new__(MeshGeometry, element, coordinates.comm) mesh.__init__(coordinates) @@ -2938,7 +2938,7 @@ def make_vom_from_vom_topology(topology, name, tolerance=0.5): vmesh = MeshGeometry.__new__(MeshGeometry, element, topology.comm) vmesh._init_topology(topology) # Save vertex reference coordinate (within reference cell) in function - parent_tdim = topology._parent_mesh.ufl_cell().topological_dimension() + parent_tdim = topology._parent_mesh.ufl_cell().topological_dimension if parent_tdim > 0: reference_coordinates_fs = functionspace.VectorFunctionSpace(topology, "DG", 0, dim=parent_tdim) reference_coordinates_data = dmcommon.reordered_coords(topology.topology_dm, reference_coordinates_fs.dm.getDefaultSection(), @@ -3229,7 +3229,7 @@ def ExtrudedMesh(mesh, layers, layer_height=None, extrusion_type='uniform', peri pass elif extrusion_type in ("radial", "radial_hedgehog"): # do not allow radial extrusion if tdim = gdim - if mesh.geometric_dimension() == mesh.topological_dimension(): + if mesh.geometric_dimension == mesh.topological_dimension: raise RuntimeError("Cannot radially-extrude a mesh with equal geometric and topological dimension") else: # check for kernel @@ -3249,7 +3249,7 @@ def ExtrudedMesh(mesh, layers, layer_height=None, extrusion_type='uniform', peri element = finat.ufl.TensorProductElement(helement, velement) if gdim is None: - gdim = mesh.geometric_dimension() + (extrusion_type == "uniform") + gdim = mesh.geometric_dimension + (extrusion_type == "uniform") coordinates_fs = functionspace.VectorFunctionSpace(topology, element, dim=gdim) coordinates = function.CoordinatelessFunction(coordinates_fs, name=_generate_default_mesh_coordinates_name(name)) @@ -3360,7 +3360,7 @@ def VertexOnlyMesh(mesh, vertexcoords, reorder=None, missing_points_behaviour='e vertexcoords = np.asarray(vertexcoords, dtype=RealType) if reorder is None: reorder = parameters["reorder_meshes"] - gdim = mesh.geometric_dimension() + gdim = mesh.geometric_dimension _, pdim = vertexcoords.shape if not np.isclose(np.sum(abs(vertexcoords.imag)), 0): raise ValueError("Point coordinates must have zero imaginary part") @@ -3581,8 +3581,8 @@ def _pic_swarm_in_mesh( coords = np.asarray(coords, dtype=RealType) plex = parent_mesh.topology.topology_dm - tdim = parent_mesh.topological_dimension() - gdim = parent_mesh.geometric_dimension() + tdim = parent_mesh.topological_dimension + gdim = parent_mesh.geometric_dimension ( coords_local, @@ -4158,10 +4158,10 @@ def _parent_mesh_embedding( assert len(reference_coords) == ncoords_global assert len(ref_cell_dists_l1) == ncoords_global - if parent_mesh.geometric_dimension() > parent_mesh.topological_dimension(): + if parent_mesh.geometric_dimension > parent_mesh.topological_dimension: # The reference coordinates contain an extra unnecessary dimension # which we can safely delete - reference_coords = reference_coords[:, : parent_mesh.topological_dimension()] + reference_coords = reference_coords[:, : parent_mesh.topological_dimension] locally_visible[:] = parent_cell_nums != -1 ranks[locally_visible] = visible_ranks[parent_cell_nums[locally_visible]] @@ -4228,8 +4228,8 @@ def _parent_mesh_embedding( cells_ignore=cells_ignore_T.T[changed_ranks_tied, :], ) # delete extra dimension if necessary - if parent_mesh.geometric_dimension() > parent_mesh.topological_dimension(): - new_reference_coords = new_reference_coords[:, : parent_mesh.topological_dimension()] + if parent_mesh.geometric_dimension > parent_mesh.topological_dimension: + new_reference_coords = new_reference_coords[:, : parent_mesh.topological_dimension] reference_coords[changed_ranks_tied, :] = new_reference_coords # remove newly lost points locally_visible[changed_ranks_tied] = ( @@ -4545,7 +4545,7 @@ def RelabeledMesh(mesh, indicator_functions, subdomain_ids, **kwargs): dmlabel_name = dmcommon.CELL_SETS_LABEL elif (elem.family() == "HDiv Trace" and elem.degree() == 0 and mesh.topological_dimension() > 1) or \ (elem.family() == "Lagrange" and elem.degree() == 1 and mesh.topological_dimension() == 1) or \ - (elem.family() == "Q" and elem.degree() == 2 and mesh.topology.ufl_cell().cellname() == "hexahedron"): + (elem.family() == "Q" and elem.degree() == 2 and mesh.topology.ufl_cell().cellname == "hexahedron"): # facets height = 1 dmlabel_name = dmcommon.FACE_SETS_LABEL diff --git a/firedrake/mg/kernels.py b/firedrake/mg/kernels.py index 09436bdbbd..754b793847 100644 --- a/firedrake/mg/kernels.py +++ b/firedrake/mg/kernels.py @@ -51,13 +51,13 @@ def to_reference_coordinates(ufl_coordinate_element, parameters=None): code = { "geometric_dimension": gdim, - "topological_dimension": cell.topological_dimension(), + "topological_dimension": cell.topological_dimension, "to_reference_coords_newton_step": to_reference_coords_newton_step_body(ufl_coordinate_element, parameters, x0_dtype=ScalarType, dX_dtype="double"), "init_X": init_X(element.cell, parameters), "max_iteration_count": 1 if is_affine(ufl_coordinate_element) else 16, "convergence_epsilon": 1e-12, - "dX_norm_square": dX_norm_square(cell.topological_dimension()), - "X_isub_dX": X_isub_dX(cell.topological_dimension()), + "dX_norm_square": dX_norm_square(cell.topological_dimension), + "X_isub_dX": X_isub_dX(cell.topological_dimension), "IntType": as_cstr(IntType), } @@ -137,7 +137,7 @@ def compile_element(expression, dual_space=None, parameters=None, domain = extract_unique_domain(expression) # Translate to GEM cell = domain.ufl_cell() - dim = cell.topological_dimension() + dim = cell.topological_dimension point = gem.Variable('X', (dim,)) point_arg = lp.GlobalArg("X", dtype=ScalarType, shape=(dim,)) @@ -288,7 +288,7 @@ def prolong_kernel(expression): "celldist_l1_c_expr": celldist_l1_c_expr(element.cell, X="Xref"), "Xc_cell_inc": coords_element.space_dimension(), "coarse_cell_inc": element.space_dimension(), - "tdim": mesh.topological_dimension()} + "tdim": mesh.topological_dimension} return cache.setdefault(key, op2.Kernel(my_kernel, name="pyop2_kernel_prolong")) @@ -374,7 +374,7 @@ def restrict_kernel(Vf, Vc): "Xc_cell_inc": coords_element.space_dimension(), "coarse_cell_inc": element.space_dimension(), "spacedim": element.cell.get_spatial_dimension(), - "tdim": mesh.topological_dimension()} + "tdim": mesh.topological_dimension} return cache.setdefault(key, op2.Kernel(my_kernel, name="pyop2_kernel_restrict")) @@ -462,7 +462,7 @@ def inject_kernel(Vf, Vc): "inside_cell": inside_check(Vc.finat_element.cell, eps=1e-8, X="Xref"), "spacedim": Vc.finat_element.cell.get_spatial_dimension(), "celldist_l1_c_expr": celldist_l1_c_expr(Vc.finat_element.cell, X="Xref"), - "tdim": Vc.mesh().topological_dimension(), + "tdim": Vc.mesh().topological_dimension, "ncandidate": ncandidate, "Rdim": numpy.prod(Vf.value_shape), "Xf_cell_inc": coords_element.space_dimension(), diff --git a/firedrake/mg/mesh.py b/firedrake/mg/mesh.py index 791775054d..a646189776 100644 --- a/firedrake/mg/mesh.py +++ b/firedrake/mg/mesh.py @@ -160,7 +160,7 @@ def MeshHierarchy(mesh, refinement_levels, # of the boundary we're trying to conform to. This # doesn't DTRT really for cubed sphere meshes (the # refined meshes are no longer gnonomic). - coords = cdm.getCoordinatesLocal().array.reshape(-1, mesh.geometric_dimension()) + coords = cdm.getCoordinatesLocal().array.reshape(-1, mesh.geometric_dimension) scale = mesh._radius / np.linalg.norm(coords, axis=1).reshape(-1, 1) coords *= scale lgmaps_without_overlap = [impl.create_lgmap(dm) for dm in dms] @@ -173,7 +173,7 @@ def MeshHierarchy(mesh, refinement_levels, meshes = [mesh] + [ mesh_builder( dm, - dim=mesh.geometric_dimension(), + dim=mesh.geometric_dimension, distribution_parameters=parameters, reorder=reorder, comm=mesh.comm, diff --git a/firedrake/mg/utils.py b/firedrake/mg/utils.py index 37832b64dc..c1a05cd7ff 100644 --- a/firedrake/mg/utils.py +++ b/firedrake/mg/utils.py @@ -140,7 +140,7 @@ def physical_node_locations(V): try: return cache[key] except KeyError: - Vc = V.collapse().reconstruct(element=finat.ufl.VectorElement(element, dim=mesh.geometric_dimension())) + Vc = V.collapse().reconstruct(element=finat.ufl.VectorElement(element, dim=mesh.geometric_dimension)) # FIXME: This is unsafe for DG coordinates and CG target spaces. locations = firedrake.assemble(firedrake.Interpolate(firedrake.SpatialCoordinate(mesh), Vc)) diff --git a/firedrake/output/vtk_output.py b/firedrake/output/vtk_output.py index 7f71a16cbe..6b56467fe9 100644 --- a/firedrake/output/vtk_output.py +++ b/firedrake/output/vtk_output.py @@ -66,7 +66,7 @@ def is_cg(V): :arg V: A FunctionSpace. """ - nvertex = V.mesh().ufl_cell().num_vertices() + nvertex = V.mesh().ufl_cell().num_vertices entity_dofs = V.finat_element.entity_dofs() # If there are as many dofs on vertices as there are vertices, # assume a continuous space. @@ -89,7 +89,7 @@ def is_linear(V): :arg V: A FunctionSpace. """ - nvertex = V.mesh().ufl_cell().num_vertices() + nvertex = V.mesh().ufl_cell().num_vertices return V.finat_element.space_dimension() == nvertex @@ -108,7 +108,7 @@ def get_sup_element(*elements, continuous=False, max_degree=None): if continuous: family = "CG" else: - if cell.cellname() in {"interval", "triangle", "tetrahedron"}: + if cell.cellname in {"interval", "triangle", "tetrahedron"}: family = "DG" else: family = "DQ" @@ -215,9 +215,9 @@ def vrange(cell_layers): con = connectivity + offsets connectivity = con.flatten() if not nonLinear: - offsets_into_con = numpy.arange(start=cell.num_vertices(), - stop=cell.num_vertices() * (num_cells + 1), - step=cell.num_vertices(), + offsets_into_con = numpy.arange(start=cell.num_vertices, + stop=cell.num_vertices * (num_cells + 1), + step=cell.num_vertices, dtype=IntType) else: offsets_into_con = numpy.arange(start=basis_dim, diff --git a/firedrake/pointeval_utils.py b/firedrake/pointeval_utils.py index 2c14656329..fff23b240d 100644 --- a/firedrake/pointeval_utils.py +++ b/firedrake/pointeval_utils.py @@ -65,7 +65,7 @@ def compile_element(expression, coordinates, parameters=None): # Translate to GEM cell = domain.ufl_cell() - dim = cell.topological_dimension() + dim = cell.topological_dimension point = gem.Variable('X', (dim,)) point_arg = lp.GlobalArg("X", dtype=utils.ScalarType, shape=(dim,)) @@ -116,7 +116,7 @@ def predicate(index): extruded = isinstance(cell, TensorProductCell) code = { - "geometric_dimension": domain.geometric_dimension(), + "geometric_dimension": domain.geometric_dimension, "layers_arg": f", {as_cstr(IntType)} const *__restrict__ layers" if extruded else "", "layers": ", layers" if extruded else "", "extruded_define": "1" if extruded else "0", diff --git a/firedrake/pointquery_utils.py b/firedrake/pointquery_utils.py index c425356267..7cdf179089 100644 --- a/firedrake/pointquery_utils.py +++ b/firedrake/pointquery_utils.py @@ -58,7 +58,7 @@ def X_isub_dX(topological_dimension): def is_affine(ufl_element): - return ufl_element.cell.is_simplex() and ufl_element.degree() <= 1 and ufl_element.family() in ["Discontinuous Lagrange", "Lagrange"] + return ufl_element.cell.is_simplex and ufl_element.degree() <= 1 and ufl_element.family() in ["Discontinuous Lagrange", "Lagrange"] def inside_check(fiat_cell, eps, X="X"): @@ -130,7 +130,7 @@ def to_reference_coords_newton_step(ufl_coordinate_element, parameters, x0_dtype # Set up UFL form cell = ufl_coordinate_element.cell domain = ufl.Mesh(ufl_coordinate_element) - gdim = domain.geometric_dimension() + gdim = domain.geometric_dimension K = ufl.JacobianInverse(domain) x = ufl.SpatialCoordinate(domain) x0_element = finat.ufl.VectorElement("Real", cell, 0, dim=gdim) @@ -156,7 +156,7 @@ def to_reference_coords_newton_step(ufl_coordinate_element, parameters, x0_dtype ), ] - dim = cell.topological_dimension() + dim = cell.topological_dimension point = gem.Variable('X', (dim,)) loopy_args.append(lp.GlobalArg("X", dtype=ScalarType, shape=(dim,))) context = tsfc.fem.GemPointContext( @@ -224,15 +224,15 @@ def compile_coordinate_element(mesh: MeshGeometry, contains_eps: float, paramete element = finat.element_factory.create_element(ufl_coordinate_element) code = { - "geometric_dimension": mesh.geometric_dimension(), - "topological_dimension": mesh.topological_dimension(), + "geometric_dimension": mesh.geometric_dimension, + "topological_dimension": mesh.topological_dimension, "celldist_l1_c_expr": celldist_l1_c_expr(element.cell, "X"), "to_reference_coords_newton_step": to_reference_coords_newton_step(ufl_coordinate_element, parameters), "init_X": init_X(element.cell, parameters), "max_iteration_count": 1 if is_affine(ufl_coordinate_element) else 16, "convergence_epsilon": 1e-12, - "dX_norm_square": dX_norm_square(mesh.topological_dimension()), - "X_isub_dX": X_isub_dX(mesh.topological_dimension()), + "dX_norm_square": dX_norm_square(mesh.topological_dimension), + "X_isub_dX": X_isub_dX(mesh.topological_dimension), "extruded_arg": f", {as_cstr(IntType)} const *__restrict__ layers" if mesh.extruded else "", "extr_comment_out": "//" if mesh.extruded else "", "non_extr_comment_out": "//" if not mesh.extruded else "", diff --git a/firedrake/preconditioners/bddc.py b/firedrake/preconditioners/bddc.py index c2b3afffde..8800b77d79 100644 --- a/firedrake/preconditioners/bddc.py +++ b/firedrake/preconditioners/bddc.py @@ -80,7 +80,7 @@ def initialize(self, pc): appctx = self.get_appctx(pc) sobolev_space = V.ufl_element().sobolev_space - tdim = V.mesh().topological_dimension() + tdim = V.mesh().topological_dimension degree = max(as_tuple(V.ufl_element().degree())) if tdim >= 2 and V.finat_element.formdegree == tdim-1: B = appctx.get("divergence_mat", None) diff --git a/firedrake/preconditioners/fdm.py b/firedrake/preconditioners/fdm.py index 24cf2c4e94..15f23ea652 100644 --- a/firedrake/preconditioners/fdm.py +++ b/firedrake/preconditioners/fdm.py @@ -481,7 +481,7 @@ def assemble_coefficients(self, J, fcp, block_diagonal=False): args_J = J.arguments() e = args_J[0].ufl_element() mesh = args_J[0].function_space().mesh() - tdim = mesh.topological_dimension() + tdim = mesh.topological_dimension if isinstance(e, (finat.ufl.VectorElement, finat.ufl.TensorElement)): e = e._sub_element e = unrestrict_element(e) @@ -1673,7 +1673,7 @@ def tabulate_exterior_derivative(Vc, Vf, cbcs=[], fbcs=[], comm=None): if ef.formdegree - ec.formdegree != 1: raise ValueError("Expecting Vf = d(Vc)") - if Vf.mesh().ufl_cell().is_simplex(): + if Vf.mesh().ufl_cell().is_simplex: c0 = ec.fiat_equivalent f1 = ef.fiat_equivalent derivative = {ufl.H1: "grad", ufl.HCurl: "curl", ufl.HDiv: "div"}[Vc.ufl_element().sobolev_space] @@ -1688,7 +1688,7 @@ def tabulate_exterior_derivative(Vc, Vf, cbcs=[], fbcs=[], comm=None): if c1.formdegree != 1: c1 = None - tdim = Vc.mesh().topological_dimension() + tdim = Vc.mesh().topological_dimension zero = PETSc.Mat() A00 = petsc_sparse(evaluate_dual(c0, f0), comm=COMM_SELF) if f0 else zero A11 = petsc_sparse(evaluate_dual(c1, f1), comm=COMM_SELF) if c1 else zero @@ -1970,7 +1970,7 @@ def cell_to_global(lgmap, cell_to_local, cell_index, result=None): bsize = V.block_size ncomp = V.ufl_element().reference_value_size sdim = (V.finat_element.space_dimension() * bsize) // ncomp # dimension of a single component - tdim = V.mesh().topological_dimension() + tdim = V.mesh().topological_dimension shift = axes_shifts * bsize index_coef, _ = extrude_node_map((Gq or Bq).cell_node_map()) @@ -2073,7 +2073,7 @@ def cell_to_global(lgmap, cell_to_local, cell_index, result=None): if any(Dk is not None for Dk in Dfdm): if static_condensation: raise NotImplementedError("Static condensation for SIPG not implemented") - if tdim < V.mesh().geometric_dimension(): + if tdim < V.mesh().geometric_dimension: raise NotImplementedError("SIPG on immersed meshes is not implemented") eta = float(self.appctx.get("eta")) @@ -2172,7 +2172,7 @@ def assemble_coefficients(self, J, fcp): args_J = J.arguments() V = args_J[-1].function_space() mesh = V.mesh() - tdim = mesh.topological_dimension() + tdim = mesh.topological_dimension Finv = ufl.JacobianInverse(mesh) degree, = set(as_tuple(V.ufl_element().degree())) @@ -2288,7 +2288,7 @@ def assemble_coefficients(self, J, fcp): def get_piola_tensor(mapping, domain): - tdim = domain.topological_dimension() + tdim = domain.topological_dimension if mapping == 'identity': return None elif mapping == 'covariant piola': diff --git a/firedrake/preconditioners/hiptmair.py b/firedrake/preconditioners/hiptmair.py index 14ec77fe1a..1ee54fcf41 100644 --- a/firedrake/preconditioners/hiptmair.py +++ b/firedrake/preconditioners/hiptmair.py @@ -230,7 +230,7 @@ def curl_to_grad(ele): degree = degree + 1 family = "CG" if isinstance(degree, tuple) and isinstance(cell, ufl.TensorProductCell): - cells = ele.cell.sub_cells() + cells = ele.cell.sub_cells elems = [finat.ufl.FiniteElement(family, cell=c, degree=d, variant=variant) for c, d in zip(cells, degree)] return finat.ufl.TensorProductElement(*elems, cell=cell) return finat.ufl.FiniteElement(family, cell=cell, degree=degree, variant=variant) @@ -261,7 +261,7 @@ def div_to_curl(ele): degree = ele.degree() family = ele.family() if family in ["Lagrange", "CG", "Q"]: - family = "DG" if ele.cell.is_simplex() else "DQ" + family = "DG" if ele.cell.is_simplex else "DQ" degree = degree - 1 elif family in ["Discontinuous Lagrange", "DG", "DQ"]: family = "CG" diff --git a/firedrake/preconditioners/hypre_ads.py b/firedrake/preconditioners/hypre_ads.py index 89c10dc438..e22ce4b277 100644 --- a/firedrake/preconditioners/hypre_ads.py +++ b/firedrake/preconditioners/hypre_ads.py @@ -28,7 +28,7 @@ def initialize(self, obj): raise ValueError("Hypre ADS requires lowest order RT elements! (not %s of degree %d)" % (family, degree)) P1 = V.reconstruct(family="Lagrange", degree=1) - NC1 = V.reconstruct(family="N1curl" if mesh.ufl_cell().is_simplex() else "NCE", degree=1) + NC1 = V.reconstruct(family="N1curl" if mesh.ufl_cell().is_simplex else "NCE", degree=1) G_callback = appctx.get("get_gradient", None) if G_callback is None: G = chop(assemble(interpolate(grad(TestFunction(P1)), NC1)).petscmat) diff --git a/firedrake/pyplot/mpl.py b/firedrake/pyplot/mpl.py index 3cf010a1c9..c2a8286aae 100644 --- a/firedrake/pyplot/mpl.py +++ b/firedrake/pyplot/mpl.py @@ -100,10 +100,10 @@ def triplot(mesh, axes=None, interior_kw={}, boundary_kw={}): :arg boundary_kw: keyword arguments to apply when plotting the mesh boundary :return: list of matplotlib :class:`Collection ` objects """ - gdim = mesh.geometric_dimension() - tdim = mesh.topological_dimension() + gdim = mesh.geometric_dimension + tdim = mesh.topological_dimension BoundaryCollection, InteriorCollection = _get_collection_types(gdim, tdim) - quad = mesh.ufl_cell().cellname() == "quadrilateral" + quad = mesh.ufl_cell().cellname == "quadrilateral" if mesh.extruded: raise NotImplementedError("Visualizing extruded meshes not implemented yet!") @@ -319,7 +319,7 @@ def trisurf(function, *args, complex_component="real", **kwargs): Q = function.function_space() mesh = Q.mesh() - if mesh.geometric_dimension() == 3: + if mesh.geometric_dimension == 3: return _trisurf_3d(axes, function, *args, complex_component=complex_component, **_kwargs) _kwargs.update({"shade": False}) @@ -471,7 +471,7 @@ def __init__(self, function, resolution, min_length, max_time, tolerance, coords = toreal(mesh.coordinates.dat.data_ro, "real") self._xmin = coords.min(axis=0) xmax = coords.max(axis=0) - self._r = self.resolution / np.sqrt(mesh.geometric_dimension()) + self._r = self.resolution / np.sqrt(mesh.geometric_dimension) shape = tuple(((xmax - self._xmin) / self._r).astype(int) + 2) self._grid = np.full(shape, 4 * self.resolution) @@ -752,7 +752,7 @@ def plot(function, *args, num_sample_points=10, complex_component="real", **kwar if isinstance(line, MeshGeometry): raise TypeError("Expected Function, not Mesh; see firedrake.triplot") - if extract_unique_domain(line).geometric_dimension() > 1: + if extract_unique_domain(line).geometric_dimension > 1: raise ValueError("Expected 1D Function; for plotting higher-dimensional fields, " "see tricontourf, tripcolor, quiver, trisurf") @@ -905,7 +905,7 @@ def __init__(self, mesh, num_sample_points): # num_sample_points must be of the form 3k + 1 for cubic Bezier plotting if num_sample_points % 3 != 1: num_sample_points = (num_sample_points // 3) * 3 + 1 - if mesh.topological_dimension() == 1: + if mesh.topological_dimension == 1: self._setup_1d(mesh, num_sample_points) else: self._setup_nd(mesh, num_sample_points) @@ -914,7 +914,7 @@ def _setup_1d(self, mesh, num_sample_points): self._reference_points = np.linspace(0.0, 1.0, num_sample_points).reshape(-1, 1) def _setup_nd(self, mesh, num_sample_points): - cell_name = mesh.ufl_cell().cellname() + cell_name = mesh.ufl_cell().cellname if cell_name == "triangle": x = np.array([0, 0, 1]) y = np.array([0, 1, 0]) @@ -943,13 +943,13 @@ def _setup_nd(self, mesh, num_sample_points): all_triangles = (triangles + add_idx).reshape(-1, 3) coordinate_values = self(mesh.coordinates) - X = coordinate_values.reshape(-1, mesh.geometric_dimension()) + X = coordinate_values.reshape(-1, mesh.geometric_dimension) coords = toreal(X, "real") - if mesh.geometric_dimension() == 2: + if mesh.geometric_dimension == 2: x, y = coords[:, 0], coords[:, 1] self.triangulation = matplotlib.tri.Triangulation(x, y, triangles=all_triangles) - elif mesh.geometric_dimension() == 3: + elif mesh.geometric_dimension == 3: self.coordinates = coords self.triangles = all_triangles @@ -958,7 +958,7 @@ def __call__(self, function): # if the function space is the same as the last one Q = function.function_space() mesh = Q.mesh() - dimension = mesh.topological_dimension() + dimension = mesh.topological_dimension keys = {1: (0,), 2: (0, 0)} fiat_element = Q.finat_element.fiat_equivalent diff --git a/firedrake/pyplot/pgf.py b/firedrake/pyplot/pgf.py index 6640454679..7ad41bb659 100644 --- a/firedrake/pyplot/pgf.py +++ b/firedrake/pyplot/pgf.py @@ -212,7 +212,7 @@ def pgfplot(f, filename, degree=1, complex_component='real', print_latex_example V = f.function_space() elem = V.ufl_element() mesh = V.ufl_domain() - dim = mesh.geometric_dimension() + dim = mesh.geometric_dimension if dim not in (2, 3): raise NotImplementedError(f"Not yet implemented for functions in spatial dimension {dim}") if mesh.extruded: diff --git a/firedrake/supermeshing.py b/firedrake/supermeshing.py index ec037aa283..5cd23f84e1 100644 --- a/firedrake/supermeshing.py +++ b/firedrake/supermeshing.py @@ -79,10 +79,10 @@ def assemble_mixed_mass_matrix(V_A, V_B): mesh_A = V_A.mesh() mesh_B = V_B.mesh() - dim = mesh_A.geometric_dimension() - assert dim == mesh_B.geometric_dimension() - assert dim == mesh_A.topological_dimension() - assert dim == mesh_B.topological_dimension() + dim = mesh_A.geometric_dimension + assert dim == mesh_B.geometric_dimension + assert dim == mesh_A.topological_dimension + assert dim == mesh_B.topological_dimension (mh_A, level_A) = get_level(mesh_A) (mh_B, level_B) = get_level(mesh_B) diff --git a/pyproject.toml b/pyproject.toml index b37a3fa69f..916bde09d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,8 +21,9 @@ dependencies = [ "mpi4py>3; python_version >= '3.13'", "mpi4py; python_version < '3.13'", # TODO RELEASE: use releases - "fenics-ufl @ git+https://github.com/FEniCS/ufl.git@main", - "firedrake-fiat @ git+https://github.com/firedrakeproject/fiat.git", + # UNDO ME + "fenics-ufl @ git+https://github.com/FEniCS/ufl.git@schnellerhase/fix_169", + "firedrake-fiat @ git+https://github.com/firedrakeproject/fiat.git@connorjward/ufl-cell-fix", "h5py>3.12.1", "libsupermesh", "loopy>2024.1", diff --git a/tests/firedrake/adjoint/test_dynamic_meshes.py b/tests/firedrake/adjoint/test_dynamic_meshes.py index c4c4c0058d..15287e74bc 100644 --- a/tests/firedrake/adjoint/test_dynamic_meshes.py +++ b/tests/firedrake/adjoint/test_dynamic_meshes.py @@ -83,7 +83,7 @@ def test_dynamic_meshes_3D(mesh): mesh.coordinates.assign(mesh.coordinates + s[0]) x = SpatialCoordinate(mesh) - if mesh.cell_dimension() != mesh.geometric_dimension(): + if mesh.cell_dimension() != mesh.geometric_dimension: mesh.init_cell_orientations(x) V = FunctionSpace(mesh, "CG", 1) diff --git a/tests/firedrake/external_operators/test_external_operators.py b/tests/firedrake/external_operators/test_external_operators.py index b6153f3d1f..b7aac1e81b 100644 --- a/tests/firedrake/external_operators/test_external_operators.py +++ b/tests/firedrake/external_operators/test_external_operators.py @@ -49,7 +49,7 @@ def f(mesh, V): fi.interpolate(as_vector([(2 * pi ** 2 + 1) * sin(pi * x) * sin(pi * y)] * V.value_size)) elif fs_i.rank == 2: fi.interpolate(as_tensor([[(2 * pi ** 2 + 1) * sin(pi * x) * sin(pi * y) - for _ in range(fs_i.mesh().geometric_dimension())] + for _ in range(fs_i.mesh().geometric_dimension)] for _ in range(fs_i.rank)])) else: fi.interpolate((2 * pi ** 2 + 1) * sin(pi * x) * sin(pi * y)) diff --git a/tests/firedrake/extrusion/test_facet_support_dofs.py b/tests/firedrake/extrusion/test_facet_support_dofs.py index c9ba7c1559..50aaf45ee0 100644 --- a/tests/firedrake/extrusion/test_facet_support_dofs.py +++ b/tests/firedrake/extrusion/test_facet_support_dofs.py @@ -40,7 +40,7 @@ def test_hex(hex_mesh, args, kwargs, horiz_expected, vert_expected): if not kwargs: fe = FiniteElement(args[0], hex_mesh.ufl_cell(), args[1], variant='equispaced') else: - A, B = hex_mesh.ufl_cell().sub_cells() + A, B = hex_mesh.ufl_cell().sub_cells hfe = FiniteElement(args[0], A, args[1], variant='equispaced') vfe = FiniteElement(kwargs["vfamily"], B, kwargs['vdegree'], variant='equispaced') fe = TensorProductElement(hfe, vfe) diff --git a/tests/firedrake/extrusion/test_steady_advection_3D_extr.py b/tests/firedrake/extrusion/test_steady_advection_3D_extr.py index 780ef5c6fc..0bd4744b19 100644 --- a/tests/firedrake/extrusion/test_steady_advection_3D_extr.py +++ b/tests/firedrake/extrusion/test_steady_advection_3D_extr.py @@ -33,7 +33,7 @@ def DGDPC1(request, mesh): @pytest.fixture def W(mesh): - if mesh.ufl_cell().sub_cells()[0].cellname() == "quadrilateral": + if mesh.ufl_cell().sub_cells[0].cellname == "quadrilateral": # RTCF1 element on a hexahedron W0_h = FiniteElement("RTCF", "quadrilateral", 1) W1_h = FiniteElement("DQ", "quadrilateral", 0) diff --git a/tests/firedrake/macro/test_macro_interp_project.py b/tests/firedrake/macro/test_macro_interp_project.py index 48ddea6946..47e0201314 100644 --- a/tests/firedrake/macro/test_macro_interp_project.py +++ b/tests/firedrake/macro/test_macro_interp_project.py @@ -56,7 +56,7 @@ def mesh(request): @pytest.mark.parametrize('op', (interp, proj, proj_bc, h1_proj, h1_proj_bc)) def test_projection_scalar_monomial(op, mesh, degree, variant): if degree == 'd': - degree = mesh.geometric_dimension() + degree = mesh.geometric_dimension V = FunctionSpace(mesh, "CG", degree=degree, variant=variant) u = Function(V) x = SpatialCoordinate(mesh) diff --git a/tests/firedrake/macro/test_macro_multigrid.py b/tests/firedrake/macro/test_macro_multigrid.py index c9d921cf27..d128d417b1 100644 --- a/tests/firedrake/macro/test_macro_multigrid.py +++ b/tests/firedrake/macro/test_macro_multigrid.py @@ -158,7 +158,7 @@ def test_macro_multigrid_poisson(hierarchy, degree, variant, petsc_raises): solver.solve() expected = 10 - if mesh.geometric_dimension() == 3 and variant == "alfeld": + if mesh.geometric_dimension == 3 and variant == "alfeld": expected = 14 assert solver.snes.ksp.getIterationNumber() <= expected diff --git a/tests/firedrake/macro/test_macro_quadrature.py b/tests/firedrake/macro/test_macro_quadrature.py index 7330965d4f..86c004c1dc 100644 --- a/tests/firedrake/macro/test_macro_quadrature.py +++ b/tests/firedrake/macro/test_macro_quadrature.py @@ -5,7 +5,7 @@ def alfeld_split(msh): - dim = msh.geometric_dimension() + dim = msh.geometric_dimension coords = msh.coordinates.dat.data.reshape((-1, dim)) coords = numpy.vstack((coords, numpy.average(coords, 0))) cells = [list(map(lambda i: dim+1 if i == j else i, range(dim+1))) for j in range(dim+1)] @@ -39,7 +39,7 @@ def meshes(variant, base_mesh): @pytest.mark.parametrize("degree", (1, 4,)) def test_macro_quadrature_monomial(degree, variant, meshes): msh = meshes[0] - gdim = msh.geometric_dimension() + gdim = msh.geometric_dimension x = SpatialCoordinate(msh) c = Constant(numpy.arange(1, gdim+1)) expr = dot(c, x) ** degree @@ -59,7 +59,7 @@ def test_macro_quadrature_monomial(degree, variant, meshes): def test_macro_quadrature_piecewise(degree, variant, meshes): results = [] for msh, v in zip(meshes, (variant, None)): - gdim = msh.geometric_dimension() + gdim = msh.geometric_dimension x = SpatialCoordinate(msh) if variant == "alfeld": diff --git a/tests/firedrake/macro/test_macro_solve.py b/tests/firedrake/macro/test_macro_solve.py index b30c2a74c1..5d9e313fce 100644 --- a/tests/firedrake/macro/test_macro_solve.py +++ b/tests/firedrake/macro/test_macro_solve.py @@ -24,7 +24,7 @@ def mixed_element(mh, variant): Vel = FiniteElement("CG", cell, degree=1, variant="iso") Pel = FiniteElement("CG", cell, degree=1) elif variant == "alfeld": - dim = mh[0].topological_dimension() + dim = mh[0].topological_dimension Vel = FiniteElement("CG", cell, degree=dim, variant="alfeld") Pel = FiniteElement("DG", cell, degree=dim-1, variant="alfeld") elif variant == "th": @@ -63,7 +63,7 @@ def riesz_map(Z, gamma=None): def test_riesz(mh, variant, mixed_element): - dim = mh[0].geometric_dimension() + dim = mh[0].geometric_dimension u_err = [] p_err = [] el1, el2 = mixed_element @@ -121,7 +121,7 @@ def errornormL2_0(pexact, ph): def test_stokes(mh, variant, mixed_element): - dim = mh[0].geometric_dimension() + dim = mh[0].geometric_dimension u_err = [] p_err = [] div_err = [] diff --git a/tests/firedrake/macro/test_stokes_macroelements.py b/tests/firedrake/macro/test_stokes_macroelements.py index c3f9b6e5c2..1fd7c5b54b 100644 --- a/tests/firedrake/macro/test_stokes_macroelements.py +++ b/tests/firedrake/macro/test_stokes_macroelements.py @@ -15,7 +15,7 @@ def mesh(request): @pytest.fixture(params=("SV", "GN", "GN2", "GNH1div")) def space(request, mesh): family = request.param - dim = mesh.topological_dimension() + dim = mesh.topological_dimension if family == "GN": V = FunctionSpace(mesh, "GN", 1) Q = FunctionSpace(mesh, "DG", 0) @@ -48,7 +48,7 @@ def test_stokes_complex(mesh, space): # Test that DirichletBC does not set derivative nodes of supersmooth H1 functions def test_supersmooth_bcs(mesh): - tdim = mesh.topological_dimension() + tdim = mesh.topological_dimension if tdim == 3: V = FunctionSpace(mesh, "GNH1div", 3) else: diff --git a/tests/firedrake/multigrid/test_hiptmair.py b/tests/firedrake/multigrid/test_hiptmair.py index 99ab52fe33..d6f0bfbca1 100644 --- a/tests/firedrake/multigrid/test_hiptmair.py +++ b/tests/firedrake/multigrid/test_hiptmair.py @@ -136,7 +136,7 @@ def run_riesz_map(V, mat_type, max_it, solver_type="gmg"): @pytest.mark.parametrize("mat_type", ["aij", "matfree"]) def test_gmg_hiptmair_hcurl(mesh_hierarchy, mat_type): mesh = mesh_hierarchy[-1] - if mesh.ufl_cell().is_simplex(): + if mesh.ufl_cell().is_simplex: family = "N1curl" max_it = 14 else: @@ -150,7 +150,7 @@ def test_gmg_hiptmair_hcurl(mesh_hierarchy, mat_type): @pytest.mark.parametrize("mat_type", ["aij", "matfree"]) def test_gmg_hiptmair_hdiv(mesh_hierarchy, mat_type): mesh = mesh_hierarchy[-1] - if mesh.ufl_cell().is_simplex(): + if mesh.ufl_cell().is_simplex: family = "N1div" max_it = 14 else: diff --git a/tests/firedrake/multigrid/test_p_multigrid.py b/tests/firedrake/multigrid/test_p_multigrid.py index 8e57633214..949d7190ab 100644 --- a/tests/firedrake/multigrid/test_p_multigrid.py +++ b/tests/firedrake/multigrid/test_p_multigrid.py @@ -27,7 +27,7 @@ def tp_mesh(request): @pytest.fixture(params=[0, 1, 2], ids=["H1", "HCurl", "HDiv"]) def tp_family(tp_mesh, request): - tdim = tp_mesh.topological_dimension() + tdim = tp_mesh.topological_dimension if tdim == 3: families = ["Q", "NCE", "NCF"] else: @@ -47,7 +47,7 @@ def mixed_family(tp_mesh, request): if request.param == 0: Vfamily = "Q" else: - tdim = tp_mesh.topological_dimension() + tdim = tp_mesh.topological_dimension Vfamily = "NCF" if tdim == 3 else "RTCF" Qfamily = "DQ" return Vfamily, Qfamily @@ -78,7 +78,7 @@ def test_prolong_basic(tp_mesh, family): """ Interpolate a constant function between low-order and high-order spaces """ from firedrake.preconditioners.pmg import prolongation_matrix_matfree - if tp_mesh.topological_dimension() == 2: + if tp_mesh.topological_dimension == 2: family = family.replace("N", "RT") fs = [FunctionSpace(tp_mesh, family, degree) for degree in (1, 2)] @@ -96,7 +96,7 @@ def test_prolong_de_rham(tp_mesh): """ from firedrake.preconditioners.pmg import prolongation_matrix_matfree - tdim = tp_mesh.topological_dimension() + tdim = tp_mesh.topological_dimension b = Constant(list(range(tdim))) if tp_mesh.extruded_periodic: expr = b diff --git a/tests/firedrake/output/test_io_backward_compat.py b/tests/firedrake/output/test_io_backward_compat.py index 337441363f..9de3ea70f7 100644 --- a/tests/firedrake/output/test_io_backward_compat.py +++ b/tests/firedrake/output/test_io_backward_compat.py @@ -151,7 +151,7 @@ def _get_mesh_and_V(params): def _get_expr(V): mesh = V.mesh() - dim = mesh.geometric_dimension() + dim = mesh.geometric_dimension shape = V.value_shape if dim == 2: x, y = SpatialCoordinate(mesh) diff --git a/tests/firedrake/output/test_io_function.py b/tests/firedrake/output/test_io_function.py index e84d778733..7651011759 100644 --- a/tests/firedrake/output/test_io_function.py +++ b/tests/firedrake/output/test_io_function.py @@ -67,7 +67,7 @@ def _get_mesh(cell_type, comm): def _get_expr(V): mesh = V.mesh() - dim = mesh.geometric_dimension() + dim = mesh.geometric_dimension shape = V.value_shape if dim == 2: x, y = SpatialCoordinate(mesh) diff --git a/tests/firedrake/regression/test_bddc.py b/tests/firedrake/regression/test_bddc.py index ff82094ba9..57f5d42d52 100644 --- a/tests/firedrake/regression/test_bddc.py +++ b/tests/firedrake/regression/test_bddc.py @@ -69,7 +69,7 @@ def solve_riesz_map(mesh, family, degree, bcs, condense): if hasattr(mesh, "extruded") and mesh.extruded: dirichlet_ids.extend(["bottom", "top"]) - tdim = mesh.topological_dimension() + tdim = mesh.topological_dimension if family.endswith("E"): family = "RTCE" if tdim == 2 else "NCE" if family.endswith("F"): @@ -125,6 +125,6 @@ def mesh(request): @pytest.mark.parametrize("condense", (False, True)) def test_bddc_fdm(mesh, family, degree, condense): bcs = True - tdim = mesh.topological_dimension() + tdim = mesh.topological_dimension expected = 7 if tdim == 2 else 11 assert solve_riesz_map(mesh, family, degree, bcs, condense) <= expected diff --git a/tests/firedrake/regression/test_change_coordinates.py b/tests/firedrake/regression/test_change_coordinates.py index a712ffd6d5..adfa185b78 100644 --- a/tests/firedrake/regression/test_change_coordinates.py +++ b/tests/firedrake/regression/test_change_coordinates.py @@ -13,7 +13,7 @@ def test_immerse_1d(dim): m = Mesh(new_coords) - assert m.geometric_dimension() == dim + assert m.geometric_dimension == dim def test_immerse_2d(): @@ -23,7 +23,7 @@ def test_immerse_2d(): m = Mesh(new_coords) - assert m.geometric_dimension() == 3 + assert m.geometric_dimension == 3 def test_project_2d(): @@ -33,7 +33,7 @@ def test_project_2d(): m = Mesh(new_coords) - assert m.geometric_dimension() == 1 + assert m.geometric_dimension == 1 def test_immerse_extruded(): @@ -44,4 +44,4 @@ def test_immerse_extruded(): m = Mesh(new_coords) - assert m.geometric_dimension() == 3 + assert m.geometric_dimension == 3 diff --git a/tests/firedrake/regression/test_fdm.py b/tests/firedrake/regression/test_fdm.py index 947ae43fbc..90c7095666 100644 --- a/tests/firedrake/regression/test_fdm.py +++ b/tests/firedrake/regression/test_fdm.py @@ -138,7 +138,7 @@ def variant(request): @pytest.mark.skipcomplex def test_p_independence_hgrad(mesh, variant): family = "Lagrange" - expected = [16, 12] if mesh.topological_dimension() == 3 else [9, 7] + expected = [16, 12] if mesh.topological_dimension == 3 else [9, 7] solvers = [fdmstar] if variant is None else [fdmstar, facetstar] for degree in range(3, 6): V = FunctionSpace(mesh, family, degree, variant=variant) @@ -150,8 +150,8 @@ def test_p_independence_hgrad(mesh, variant): @pytest.mark.skipmumps @pytest.mark.skipcomplex def test_p_independence_hcurl(mesh): - family = "NCE" if mesh.topological_dimension() == 3 else "RTCE" - expected = [13, 10] if mesh.topological_dimension() == 3 else [6, 6] + family = "NCE" if mesh.topological_dimension == 3 else "RTCE" + expected = [13, 10] if mesh.topological_dimension == 3 else [6, 6] solvers = [fdmstar, facetstar] for degree in range(3, 6): V = FunctionSpace(mesh, family, degree, variant="fdm") @@ -163,7 +163,7 @@ def test_p_independence_hcurl(mesh): @pytest.mark.skipmumps @pytest.mark.skipcomplex def test_p_independence_hdiv(mesh): - family = "NCF" if mesh.topological_dimension() == 3 else "RTCF" + family = "NCF" if mesh.topological_dimension == 3 else "RTCF" expected = [6, 6] solvers = [fdmstar, facetstar] for degree in range(3, 6): @@ -175,7 +175,7 @@ def test_p_independence_hdiv(mesh): @pytest.mark.skipcomplex def test_variable_coefficient(mesh): - gdim = mesh.geometric_dimension() + gdim = mesh.geometric_dimension k = 4 V = FunctionSpace(mesh, "Lagrange", k) u = TrialFunction(V) @@ -209,7 +209,7 @@ def test_variable_coefficient(mesh): ids=["cg", "dg", "rt"]) def fs(request, mesh): degree = 3 - tdim = mesh.topological_dimension() + tdim = mesh.topological_dimension element = request.param variant = "fdm_ipdg" if element == "rt": @@ -227,7 +227,7 @@ def fs(request, mesh): def test_ipdg_direct_solver(fs): mesh = fs.mesh() x = SpatialCoordinate(mesh) - gdim = mesh.geometric_dimension() + gdim = mesh.geometric_dimension ncomp = fs.value_size homogenize = gdim > 2 diff --git a/tests/firedrake/regression/test_helmholtz.py b/tests/firedrake/regression/test_helmholtz.py index 6eeba6e71a..f9d25d4bbb 100644 --- a/tests/firedrake/regression/test_helmholtz.py +++ b/tests/firedrake/regression/test_helmholtz.py @@ -26,7 +26,7 @@ def helmholtz(r, quadrilateral=False, degree=2, mesh=None): mesh = UnitSquareMesh(2 ** r, 2 ** r, quadrilateral=quadrilateral) V = FunctionSpace(mesh, "CG", degree) # Define variational problem - dim = mesh.ufl_cell().topological_dimension() + dim = mesh.ufl_cell().topological_dimension lmbda = 1 u = TrialFunction(V) v = TestFunction(V) diff --git a/tests/firedrake/regression/test_helmholtz_sphere.py b/tests/firedrake/regression/test_helmholtz_sphere.py index 403db5afee..95b3a32d72 100644 --- a/tests/firedrake/regression/test_helmholtz_sphere.py +++ b/tests/firedrake/regression/test_helmholtz_sphere.py @@ -30,9 +30,9 @@ def run_helmholtz_mixed_sphere(MeshClass, r, meshd, eltd): m = MeshClass(refinement_level=r, degree=meshd) x = SpatialCoordinate(m) m.init_cell_orientations(x) - if m.ufl_cell().cellname() == "triangle": + if m.ufl_cell().cellname == "triangle": V = FunctionSpace(m, 'RT', eltd+1) - elif m.ufl_cell().cellname() == "quadrilateral": + elif m.ufl_cell().cellname == "quadrilateral": V = FunctionSpace(m, 'RTCF', eltd+1) Q = FunctionSpace(m, 'DG', eltd) W = V*Q diff --git a/tests/firedrake/regression/test_interpolate_vs_project.py b/tests/firedrake/regression/test_interpolate_vs_project.py index 3a0fcc571f..41d335d39a 100644 --- a/tests/firedrake/regression/test_interpolate_vs_project.py +++ b/tests/firedrake/regression/test_interpolate_vs_project.py @@ -30,7 +30,7 @@ def V(request, mesh): def test_interpolate_vs_project(V): mesh = V.mesh() - dim = mesh.geometric_dimension() + dim = mesh.geometric_dimension if dim == 2: x, y = SpatialCoordinate(mesh) elif dim == 3: diff --git a/tests/firedrake/regression/test_interpolation_nodes.py b/tests/firedrake/regression/test_interpolation_nodes.py index 13b52aa193..581bd69df6 100644 --- a/tests/firedrake/regression/test_interpolation_nodes.py +++ b/tests/firedrake/regression/test_interpolation_nodes.py @@ -40,7 +40,7 @@ def V(request, mesh, degree): def test_div_curl_preserving(V): mesh = V.mesh() - dim = mesh.geometric_dimension() + dim = mesh.geometric_dimension if dim == 2: x, y = SpatialCoordinate(mesh) elif dim == 3: @@ -66,7 +66,7 @@ def test_div_curl_preserving(V): def compute_interpolation_error(baseMesh, nref, space, degree): mh = MeshHierarchy(baseMesh, nref) - dim = mh[0].geometric_dimension() + dim = mh[0].geometric_dimension error = np.zeros((nref+1, 2)) for i, mesh in enumerate(mh): diff --git a/tests/firedrake/regression/test_linesmoother.py b/tests/firedrake/regression/test_linesmoother.py index 049421ddcc..720a084e07 100644 --- a/tests/firedrake/regression/test_linesmoother.py +++ b/tests/firedrake/regression/test_linesmoother.py @@ -46,8 +46,8 @@ def backend(request): @pytest.mark.parametrize("rhs", ["form_rhs", "cofunc_rhs"]) def test_linesmoother(mesh, S1family, expected, backend, rhs): base_cell = mesh._base_mesh.ufl_cell() - S2family = "DG" if base_cell.is_simplex() else "DQ" - DGfamily = "DG" if mesh.ufl_cell().is_simplex() else "DQ" + S2family = "DG" if base_cell.is_simplex else "DQ" + DGfamily = "DG" if mesh.ufl_cell().is_simplex else "DQ" nits = [] for degree in range(2): S1 = FiniteElement(S1family, base_cell, degree+1) diff --git a/tests/firedrake/regression/test_mass_lumping.py b/tests/firedrake/regression/test_mass_lumping.py index 2712568c94..f81888e3ba 100644 --- a/tests/firedrake/regression/test_mass_lumping.py +++ b/tests/firedrake/regression/test_mass_lumping.py @@ -43,7 +43,7 @@ def mesh(request): def test_spectral_mass_lumping(mesh, degree): V = FunctionSpace(mesh, "Lagrange", degree) - dimension = mesh.topological_dimension() + dimension = mesh.topological_dimension quad_rule = gauss_lobatto_legendre_cube_rule(dimension=dimension, degree=degree) u = TrialFunction(V) diff --git a/tests/firedrake/regression/test_mesh_from_plex.py b/tests/firedrake/regression/test_mesh_from_plex.py index f639187ebc..d1bc7d494e 100644 --- a/tests/firedrake/regression/test_mesh_from_plex.py +++ b/tests/firedrake/regression/test_mesh_from_plex.py @@ -13,8 +13,8 @@ def get_plex_with_update_coordinates(mesh): """ Update the coordinates of the dmplex in mesh and return a copy of the dmplex """ - tdim = mesh.topological_dimension() - gdim = mesh.geometric_dimension() + tdim = mesh.topological_dimension + gdim = mesh.geometric_dimension entity_dofs = np.zeros(tdim + 1, dtype=np.int32) entity_dofs[0] = gdim coord_section, _ = mesh.create_section(entity_dofs) diff --git a/tests/firedrake/regression/test_multiple_domains.py b/tests/firedrake/regression/test_multiple_domains.py index 86766aba79..a3557bebc1 100644 --- a/tests/firedrake/regression/test_multiple_domains.py +++ b/tests/firedrake/regression/test_multiple_domains.py @@ -73,11 +73,11 @@ def test_functional(mesh1, mesh2): val = assemble(c*dx(domain=mesh2)) - assert np.allclose(val, cell_volume * (0.5**mesh1.topological_dimension())) + assert np.allclose(val, cell_volume * (0.5**mesh1.topological_dimension)) val = assemble(c*dx(domain=mesh1) + c*dx(domain=mesh2)) - assert np.allclose(val, cell_volume * (1 + 0.5**mesh1.topological_dimension())) + assert np.allclose(val, cell_volume * (1 + 0.5**mesh1.topological_dimension)) @pytest.mark.parametrize("form,expect", [ @@ -91,7 +91,7 @@ def test_one_form(mesh1, mesh2, form, expect): v = TestFunction(V) cell_volume = mesh1.coordinates.function_space().finat_element.cell.volume() - dim = mesh1.topological_dimension() + dim = mesh1.topological_dimension form = form(v, mesh1, mesh2) expect = expect(cell_volume, dim) @@ -112,7 +112,7 @@ def test_two_form(mesh1, mesh2, form, expect): u = TrialFunction(V) cell_volume = mesh1.coordinates.function_space().finat_element.cell.volume() - dim = mesh1.topological_dimension() + dim = mesh1.topological_dimension form = form(u, v, mesh1, mesh2) expect = expect(cell_volume, dim) diff --git a/tests/firedrake/regression/test_p1pc.py b/tests/firedrake/regression/test_p1pc.py index 7f1d27e2d2..3658e7228c 100644 --- a/tests/firedrake/regression/test_p1pc.py +++ b/tests/firedrake/regression/test_p1pc.py @@ -16,11 +16,11 @@ def mesh(request): @pytest.fixture def expected(mesh): - if mesh.geometric_dimension() == 1: + if mesh.geometric_dimension == 1: return [2, 2, 2] - elif mesh.geometric_dimension() == 2: + elif mesh.geometric_dimension == 2: return [5, 5, 5] - elif mesh.geometric_dimension() == 3: + elif mesh.geometric_dimension == 3: return [7, 7, 7] diff --git a/tests/firedrake/regression/test_solving_interface.py b/tests/firedrake/regression/test_solving_interface.py index 91093f84b6..4df72c68e4 100644 --- a/tests/firedrake/regression/test_solving_interface.py +++ b/tests/firedrake/regression/test_solving_interface.py @@ -337,7 +337,7 @@ def test_solve_pre_apply_bcs(mesh, mixed): # Hyperelastic energy functional lam = Constant(1E3) - dim = mesh.geometric_dimension() + dim = mesh.geometric_dimension F = grad(u) + Identity(dim) J = det(F) logJ = 0.5*ln(J**2) diff --git a/tests/firedrake/regression/test_star_pc.py b/tests/firedrake/regression/test_star_pc.py index c78455f9e5..d6e1383163 100644 --- a/tests/firedrake/regression/test_star_pc.py +++ b/tests/firedrake/regression/test_star_pc.py @@ -371,7 +371,7 @@ def base(request): @pytest.mark.parametrize("periodic", (False, True), ids=("extruded", "extruded-periodic")) def test_asm_extruded_star(base, periodic, family, degree): mesh = ExtrudedMesh(base, 5, periodic=periodic) - if mesh.topological_dimension() == 2: + if mesh.topological_dimension == 2: family = family.replace("N", "RT") V = FunctionSpace(mesh, family, degree) space = V.ufl_element().sobolev_space diff --git a/tests/firedrake/regression/test_tensor_algebra.py b/tests/firedrake/regression/test_tensor_algebra.py index 61871d4ef2..3306c6252a 100644 --- a/tests/firedrake/regression/test_tensor_algebra.py +++ b/tests/firedrake/regression/test_tensor_algebra.py @@ -34,8 +34,8 @@ def mesh(request): "-2*mu_s*inner(grad(u), outer(conj(v), n)) * ds")], ids=lambda x: x[0]) def form_expect(request, mesh): - dim = mesh.geometric_dimension() - if mesh.ufl_cell().cellname() == "quadrilateral": + dim = mesh.geometric_dimension + if mesh.ufl_cell().cellname == "quadrilateral": V = FunctionSpace(mesh, "RTCF", 1) else: V = FunctionSpace(mesh, "RT", 1) diff --git a/tests/firedrake/regression/test_tensor_elements.py b/tests/firedrake/regression/test_tensor_elements.py index 6c0a6f99ff..27cb7b5a0b 100644 --- a/tests/firedrake/regression/test_tensor_elements.py +++ b/tests/firedrake/regression/test_tensor_elements.py @@ -35,13 +35,13 @@ def test_tensor_continuity(mesh, family, degree): if space == HDivDiv: utrace = dot(n, dot(u, n)) elif space == HEin: - if mesh.topological_dimension() == 2: + if mesh.topological_dimension == 2: t = perp(n) else: t = as_matrix([[0, n[2], -n[1]], [-n[2], 0, n[0]], [n[1], -n[0], 0]]) utrace = dot(t, dot(u, t)) else: - if mesh.topological_dimension() == 2: + if mesh.topological_dimension == 2: t = perp(n) utrace = dot(t, dot(u, n)) else: diff --git a/tests/firedrake/slate/test_assemble_tensors.py b/tests/firedrake/slate/test_assemble_tensors.py index c35d43e27e..40830118d1 100644 --- a/tests/firedrake/slate/test_assemble_tensors.py +++ b/tests/firedrake/slate/test_assemble_tensors.py @@ -45,7 +45,7 @@ def f(function_space): if fs_i.rank == 1: fi.interpolate(as_vector((x[0]*x[1],) * fs_i.value_size)) elif fs_i.rank == 2: - fi.interpolate(as_tensor([[x[0]*x[1] for i in range(fs_i.mesh().geometric_dimension())] + fi.interpolate(as_tensor([[x[0]*x[1] for i in range(fs_i.mesh().geometric_dimension)] for j in range(fs_i.rank)])) else: fi.interpolate(x[0]*x[1]) @@ -66,7 +66,7 @@ def g(function_space): if fs_i.rank == 1: gi.interpolate(as_vector((x[0]*sin(x[1]),) * fs_i.value_size)) elif fs_i.rank == 2: - gi.interpolate(as_tensor([[x[0]*sin(x[1]) for i in range(fs_i.mesh().geometric_dimension())] + gi.interpolate(as_tensor([[x[0]*sin(x[1]) for i in range(fs_i.mesh().geometric_dimension)] for j in range(fs_i.rank)])) else: gi.interpolate(x[0]*sin(x[1])) diff --git a/tests/firedrake/submesh/test_submesh_basics.py b/tests/firedrake/submesh/test_submesh_basics.py index 480105834f..ccd2500e88 100644 --- a/tests/firedrake/submesh/test_submesh_basics.py +++ b/tests/firedrake/submesh/test_submesh_basics.py @@ -11,6 +11,6 @@ def test_submesh_parent(): cell_marker = 100 parent = RelabeledMesh(mesh, [m], [cell_marker]) - submesh = Submesh(parent, parent.topological_dimension(), cell_marker) + submesh = Submesh(parent, parent.topological_dimension, cell_marker) assert submesh.topology.submesh_parent is parent.topology assert submesh.submesh_parent is parent diff --git a/tests/firedrake/submesh/test_submesh_facet.py b/tests/firedrake/submesh/test_submesh_facet.py index 1e9554c0c6..f344fa6a59 100644 --- a/tests/firedrake/submesh/test_submesh_facet.py +++ b/tests/firedrake/submesh/test_submesh_facet.py @@ -85,7 +85,7 @@ def test_submesh_facet_corner_case_1(): V = FunctionSpace(mesh, "Q", 2) f = Function(V).interpolate(conditional(Or(facet0, facet1), 1, 0)) mesh = RelabeledMesh(mesh, [f], [999]) - subm = Submesh(mesh, mesh.topological_dimension() - 1, 999) + subm = Submesh(mesh, mesh.topological_dimension - 1, 999) v = assemble(Constant(1.) * dx(domain=subm)) assert abs(v - 2.) < 2.e-15 @@ -121,4 +121,4 @@ def test_submesh_facet_corner_case_2(): ) facet_value = 999 mesh = RelabeledMesh(mesh, [facet_function], [facet_value]) - _ = Submesh(mesh, mesh.topological_dimension() - 1, facet_value) + _ = Submesh(mesh, mesh.topological_dimension - 1, facet_value) diff --git a/tests/firedrake/submesh/test_submesh_interpolate.py b/tests/firedrake/submesh/test_submesh_interpolate.py index a26c1acb08..92b5cf650b 100644 --- a/tests/firedrake/submesh/test_submesh_interpolate.py +++ b/tests/firedrake/submesh/test_submesh_interpolate.py @@ -10,14 +10,14 @@ def _get_expr(V): m = V.ufl_domain() - if m.geometric_dimension() == 1: + if m.geometric_dimension == 1: x, = SpatialCoordinate(m) y = x * x z = x + y - elif m.geometric_dimension() == 2: + elif m.geometric_dimension == 2: x, y = SpatialCoordinate(m) z = x + y - elif m.geometric_dimension() == 3: + elif m.geometric_dimension == 3: x, y, z = SpatialCoordinate(m) else: raise NotImplementedError("Not implemented") @@ -28,7 +28,7 @@ def _get_expr(V): def make_submesh(mesh, subdomain_cond, label_value): - dim = mesh.topological_dimension() + dim = mesh.topological_dimension DG0 = FunctionSpace(mesh, "DG", 0) indicator_function = Function(DG0).interpolate(subdomain_cond) mesh.mark_entities(indicator_function, label_value) @@ -145,7 +145,7 @@ def test_submesh_interpolate_subcell_subcell_2_processes(): mesh = RectangleMesh( 3, 1, 3., 1., quadrilateral=True, distribution_parameters={"partitioner_type": "simple"}, ) - dim = mesh.topological_dimension() + dim = mesh.topological_dimension x, _ = SpatialCoordinate(mesh) DG0 = FunctionSpace(mesh, "DG", 0) f_l = Function(DG0).interpolate(conditional(x < 2.0, 1, 0)) @@ -210,7 +210,7 @@ def expr(m): ) facet_value = 999 mesh = RelabeledMesh(mesh, [facet_function], [facet_value]) - subm = Submesh(mesh, mesh.topological_dimension() - 1, facet_value) + subm = Submesh(mesh, mesh.topological_dimension - 1, facet_value) DG3d = FunctionSpace(mesh, "DG", degree) dg3d = Function(DG3d).interpolate(expr(mesh)) DG2d = FunctionSpace(subm, "DG", degree) @@ -258,7 +258,7 @@ def expr(m): facet_function = Function(V).interpolate(Constant(1.)) facet_value = 999 mesh = RelabeledMesh(mesh, [facet_function], [facet_value]) - subm = Submesh(mesh, mesh.topological_dimension() - 1, facet_value) + subm = Submesh(mesh, mesh.topological_dimension - 1, facet_value) HDivT3d = FunctionSpace(mesh, "HDiv Trace", degree) hdivt3d = Function(HDivT3d).interpolate(expr(mesh)) DG2d = FunctionSpace(subm, "DG", degree) diff --git a/tests/firedrake/vertexonly/test_interpolation_from_parent.py b/tests/firedrake/vertexonly/test_interpolation_from_parent.py index 606b4bea13..81dce16f4c 100644 --- a/tests/firedrake/vertexonly/test_interpolation_from_parent.py +++ b/tests/firedrake/vertexonly/test_interpolation_from_parent.py @@ -54,7 +54,7 @@ def parentmesh(request): @pytest.fixture(params=[0, 1, 100], ids=lambda x: f"{x}-coords") def vertexcoords(request, parentmesh): - size = (request.param, parentmesh.geometric_dimension()) + size = (request.param, parentmesh.geometric_dimension) return pseudo_random_coords(size) @@ -81,10 +81,10 @@ def vfs(request, parentmesh): family = request.param[0] # skip where the element doesn't support the cell type if family != "CG": - if parentmesh.ufl_cell().cellname() == "quadrilateral": + if parentmesh.ufl_cell().cellname == "quadrilateral": if not (family == "RTCE" or family == "RTCF"): pytest.skip(f"{family} does not support {parentmesh.ufl_cell()} cells") - elif parentmesh.ufl_cell().cellname() == "triangle" or parentmesh.ufl_cell().cellname() == "tetrahedron": + elif parentmesh.ufl_cell().cellname == "triangle" or parentmesh.ufl_cell().cellname == "tetrahedron": if (not (family == "N1curl" or family == "N2curl" or family == "N1div" or family == "N2div")): pytest.skip(f"{family} does not support {parentmesh.ufl_cell()} cells") @@ -106,8 +106,8 @@ def vfs(request, parentmesh): def tfs(request, parentmesh): family = request.param[0] # skip where the element doesn't support the cell type - if (family != "CG" and parentmesh.ufl_cell().cellname() != "triangle" - and parentmesh.ufl_cell().cellname() != "tetrahedron"): + if (family != "CG" and parentmesh.ufl_cell().cellname != "triangle" + and parentmesh.ufl_cell().cellname != "tetrahedron"): pytest.skip(f"{family} does not support {parentmesh.ufl_cell()} cells") if parentmesh.name == "immersedsphere": # See https://github.com/firedrakeproject/firedrake/issues/3089 @@ -162,7 +162,7 @@ def test_scalar_spatialcoordinate_interpolation(parentmesh, vertexcoords): # Reshaping because for all meshes, we want (-1, gdim) but # when gdim == 1 PyOP2 doesn't distinguish between dats with shape # () and shape (1,). - vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension()) + vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension) W = FunctionSpace(vm, "DG", 0) expr = reduce(add, SpatialCoordinate(parentmesh)) w_expr = assemble(interpolate(expr, W)) @@ -173,7 +173,7 @@ def test_scalar_function_interpolation(parentmesh, vertexcoords, fs): if parentmesh.name == "immersedsphere": vertexcoords = immersed_sphere_vertexcoords(parentmesh, vertexcoords) vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour="ignore") - vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension()) + vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension) fs_fam, fs_deg, fs_typ = fs if ( parentmesh.coordinates.function_space().ufl_element().family() @@ -227,7 +227,7 @@ def test_tensor_spatialcoordinate_interpolation(parentmesh, vertexcoords): vertexcoords = vm.coordinates.dat.data_ro W = TensorFunctionSpace(vm, "DG", 0) x = SpatialCoordinate(parentmesh) - gdim = parentmesh.geometric_dimension() + gdim = parentmesh.geometric_dimension expr = 2 * as_tensor([x]*gdim) assert W.shape == expr.ufl_shape w_expr = assemble(interpolate(expr, W)) @@ -257,7 +257,7 @@ def test_tensor_function_interpolation(parentmesh, vertexcoords, tfs): v = Function(V).interpolate(expr) result = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))]) if len(result) == 0: - result = result.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),)) + result = result.reshape(vertexcoords.shape + (parentmesh.geometric_dimension,)) w_v = assemble(interpolate(v, W)) assert np.allclose(w_v.dat.data_ro.reshape(result.shape), result) @@ -268,7 +268,7 @@ def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs): tfs_fam, tfs_deg, tfs_typ = tfs vm = VertexOnlyMesh(parentmesh, vertexcoords, missing_points_behaviour="ignore") - vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension()) + vertexcoords = vm.coordinates.dat.data_ro.reshape(-1, parentmesh.geometric_dimension) if ( parentmesh.coordinates.function_space().ufl_element().family() == "Discontinuous Lagrange" @@ -291,7 +291,7 @@ def test_mixed_function_interpolation(parentmesh, vertexcoords, tfs): v1.interpolate(expr1) result1 = np.asarray([np.outer(vertexcoords[i], vertexcoords[i]) for i in range(len(vertexcoords))]) if len(result1) == 0: - result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension(),)) + result1 = result1.reshape(vertexcoords.shape + (parentmesh.geometric_dimension,)) # Get Function in V2 expr2 = reduce(add, SpatialCoordinate(parentmesh)) v2.interpolate(expr2) diff --git a/tests/firedrake/vertexonly/test_swarm.py b/tests/firedrake/vertexonly/test_swarm.py index 96c4602511..548a69e8bc 100644 --- a/tests/firedrake/vertexonly/test_swarm.py +++ b/tests/firedrake/vertexonly/test_swarm.py @@ -25,11 +25,11 @@ def cell_midpoints(m): num_cells_local = len(f.dat.data_ro) num_cells = MPI.COMM_WORLD.allreduce(num_cells_local, op=MPI.SUM) # reshape is for 1D case where f.dat.data_ro has shape (num_cells_local,) - local_midpoints = f.dat.data_ro.reshape(num_cells_local, m.geometric_dimension()) + local_midpoints = f.dat.data_ro.reshape(num_cells_local, m.geometric_dimension) local_midpoints_size = np.array(local_midpoints.size) local_midpoints_sizes = np.empty(MPI.COMM_WORLD.size, dtype=int) MPI.COMM_WORLD.Allgatherv(local_midpoints_size, local_midpoints_sizes) - midpoints = np.empty((num_cells, m.geometric_dimension()), dtype=local_midpoints.dtype) + midpoints = np.empty((num_cells, m.geometric_dimension), dtype=local_midpoints.dtype) MPI.COMM_WORLD.Allgatherv(local_midpoints, (midpoints, local_midpoints_sizes)) assert len(np.unique(midpoints, axis=0)) == len(midpoints) return midpoints, local_midpoints @@ -70,7 +70,7 @@ def point_ownership(m, points, localpoints): m.locate_cell(point). """ - out_of_mesh_point = np.full((1, m.geometric_dimension()), np.inf) + out_of_mesh_point = np.full((1, m.geometric_dimension), np.inf) cell_numbers = np.empty(len(localpoints), dtype=int) i = 0 for point in points: @@ -238,12 +238,12 @@ def test_pic_swarm_in_mesh(parentmesh, redundant, exclude_halos): assert plex.comm.size == swarm.comm.size # Check swarm fields are correct default_fields = [ - ("DMSwarmPIC_coor", parentmesh.geometric_dimension(), RealType), + ("DMSwarmPIC_coor", parentmesh.geometric_dimension, RealType), ("DMSwarm_rank", 1, IntType), ] default_extra_fields = [ ("parentcellnum", 1, IntType), - ("refcoord", parentmesh.topological_dimension(), RealType), + ("refcoord", parentmesh.topological_dimension, RealType), ("globalindex", 1, IntType), ("inputrank", 1, IntType), ("inputindex", 1, IntType), @@ -368,7 +368,7 @@ def test_pic_swarm_in_mesh(parentmesh, redundant, exclude_halos): # Now have DMPLex compute the cell IDs in cases where it can: if ( parentmesh.coordinates.ufl_element().family() != "Discontinuous Lagrange" - and parentmesh.geometric_dimension() == parentmesh.topological_dimension() + and parentmesh.geometric_dimension == parentmesh.topological_dimension and not parentmesh.extruded and not parentmesh.coordinates.dat.dat_version > 0 # shifted mesh ): diff --git a/tests/firedrake/vertexonly/test_vertex_only_fs.py b/tests/firedrake/vertexonly/test_vertex_only_fs.py index 99c651876c..a2f68c0e5f 100644 --- a/tests/firedrake/vertexonly/test_vertex_only_fs.py +++ b/tests/firedrake/vertexonly/test_vertex_only_fs.py @@ -50,7 +50,7 @@ def parentmesh(request): @pytest.fixture(params=[0, 1, 100], ids=lambda x: f"{x}-coords") def vertexcoords(request, parentmesh): - size = (request.param, parentmesh.geometric_dimension()) + size = (request.param, parentmesh.geometric_dimension) return pseudo_random_coords(size) @@ -96,7 +96,7 @@ def functionspace_tests(vm, petsc_raises): # Reshaping because for all meshes, we want (-1, gdim) but # when gdim == 1 PyOP2 doesn't distinguish between dats with shape # () and shape (1,). - assert np.allclose(f.dat.data_ro, np.prod(vm.coordinates.dat.data_ro.reshape(-1, vm.geometric_dimension()), axis=1)) + assert np.allclose(f.dat.data_ro, np.prod(vm.coordinates.dat.data_ro.reshape(-1, vm.geometric_dimension), axis=1)) # Galerkin Projection of expression is the same as interpolation of # that expression since both exactly point evaluate the expression. assert np.allclose(f.dat.data_ro, g.dat.data_ro) @@ -118,7 +118,7 @@ def functionspace_tests(vm, petsc_raises): input_ordering_parent_cell_nums = vm.input_ordering.topology_dm.getField("parentcellnum").ravel() vm.input_ordering.topology_dm.restoreField("parentcellnum") idxs_to_include = input_ordering_parent_cell_nums != -1 - assert np.allclose(h.dat.data_ro_with_halos[idxs_to_include], np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension()), axis=1)) + assert np.allclose(h.dat.data_ro_with_halos[idxs_to_include], np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension), axis=1)) assert np.all(h.dat.data_ro_with_halos[~idxs_to_include] == -1) # Using permutation matrix perm_mat = assemble(interpolate(TrialFunction(V), W, matfree=False)) @@ -129,44 +129,44 @@ def functionspace_tests(vm, petsc_raises): # check we can interpolate expressions h2 = Function(W) h2.interpolate(2*g) - assert np.allclose(h2.dat.data_ro_with_halos[idxs_to_include], 2*np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension()), axis=1)) + assert np.allclose(h2.dat.data_ro_with_halos[idxs_to_include], 2*np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension), axis=1)) # Check that the opposite works g.dat.data_wo_with_halos[:] = -1 g.interpolate(h) - assert np.allclose(g.dat.data_ro_with_halos, np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension()), axis=1)) + assert np.allclose(g.dat.data_ro_with_halos, np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension), axis=1)) h = assemble(interpolate(g, W)) - assert np.allclose(h.dat.data_ro_with_halos[idxs_to_include], np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension()), axis=1)) + assert np.allclose(h.dat.data_ro_with_halos[idxs_to_include], np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension), axis=1)) assert np.all(h.dat.data_ro_with_halos[~idxs_to_include] == 0) h2 = assemble(interpolate(2*g, W)) - assert np.allclose(h2.dat.data_ro_with_halos[idxs_to_include], 2*np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension()), axis=1)) + assert np.allclose(h2.dat.data_ro_with_halos[idxs_to_include], 2*np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension), axis=1)) h_star = h.riesz_representation(riesz_map="l2") g = assemble(interpolate(TestFunction(V), h_star)) - assert np.allclose(g.dat.data_ro_with_halos, np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension()), axis=1)) + assert np.allclose(g.dat.data_ro_with_halos, np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension), axis=1)) with petsc_raises(NotImplementedError): # Can't use adjoint on interpolates with expressions yet g2 = assemble(interpolate(2 * TestFunction(V), h_star)) - assert np.allclose(g2.dat.data_ro_with_halos, 2*np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension()), axis=1)) + assert np.allclose(g2.dat.data_ro_with_halos, 2*np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension), axis=1)) h_star = assemble(interpolate(TestFunction(W), g)) h = h_star.riesz_representation(riesz_map="l2") - assert np.allclose(h.dat.data_ro_with_halos[idxs_to_include], np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension()), axis=1)) + assert np.allclose(h.dat.data_ro_with_halos[idxs_to_include], np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension), axis=1)) assert np.all(h.dat.data_ro_with_halos[~idxs_to_include] == 0) with petsc_raises(NotImplementedError): # Can't use adjoint on interpolates with expressions yet h2 = assemble(interpolate(2 * TestFunction(W), g)) - assert np.allclose(h2.dat.data_ro_with_halos[idxs_to_include], 2*np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension()), axis=1)) + assert np.allclose(h2.dat.data_ro_with_halos[idxs_to_include], 2*np.prod(vm.input_ordering.coordinates.dat.data_ro_with_halos[idxs_to_include].reshape(-1, vm.input_ordering.geometric_dimension), axis=1)) g = assemble(interpolate(h, V)) - assert np.allclose(g.dat.data_ro_with_halos, np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension()), axis=1)) + assert np.allclose(g.dat.data_ro_with_halos, np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension), axis=1)) g2 = assemble(interpolate(2 * h, V)) - assert np.allclose(g2.dat.data_ro_with_halos, 2*np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension()), axis=1)) + assert np.allclose(g2.dat.data_ro_with_halos, 2*np.prod(vm.coordinates.dat.data_ro_with_halos.reshape(-1, vm.geometric_dimension), axis=1)) def vectorfunctionspace_tests(vm, petsc_raises): # Prep - gdim = vm.geometric_dimension() + gdim = vm.geometric_dimension num_cells = len(vm.coordinates.dat.data_ro) num_cells_mpi_global = MPI.COMM_WORLD.allreduce(num_cells, op=MPI.SUM) num_cells_halo = len(vm.coordinates.dat.data_ro_with_halos) - num_cells diff --git a/tests/firedrake/vertexonly/test_vertex_only_mesh_generation.py b/tests/firedrake/vertexonly/test_vertex_only_mesh_generation.py index 4fec737690..2ca7acda3f 100644 --- a/tests/firedrake/vertexonly/test_vertex_only_mesh_generation.py +++ b/tests/firedrake/vertexonly/test_vertex_only_mesh_generation.py @@ -25,11 +25,11 @@ def cell_midpoints(m): num_cells_local = len(f.dat.data_ro) num_cells = MPI.COMM_WORLD.allreduce(num_cells_local, op=MPI.SUM) # reshape is for 1D case where f.dat.data_ro has shape (num_cells_local,) - local_midpoints = f.dat.data_ro.reshape(num_cells_local, m.geometric_dimension()) + local_midpoints = f.dat.data_ro.reshape(num_cells_local, m.geometric_dimension) local_midpoints_size = np.array(local_midpoints.size) local_midpoints_sizes = np.empty(MPI.COMM_WORLD.size, dtype=int) MPI.COMM_WORLD.Allgatherv(local_midpoints_size, local_midpoints_sizes) - midpoints = np.empty((num_cells, m.geometric_dimension()), dtype=local_midpoints.dtype) + midpoints = np.empty((num_cells, m.geometric_dimension), dtype=local_midpoints.dtype) MPI.COMM_WORLD.Allgatherv(local_midpoints, (midpoints, local_midpoints_sizes)) assert len(np.unique(midpoints, axis=0)) == len(midpoints) return midpoints, local_midpoints @@ -90,7 +90,7 @@ def redundant(request): @pytest.fixture(params=[0, 1, 100], ids=lambda x: f"{x}-coords") def vertexcoords(request, parentmesh): - size = (request.param, parentmesh.geometric_dimension()) + size = (request.param, parentmesh.geometric_dimension) return pseudo_random_coords(size) @@ -115,10 +115,10 @@ def verify_vertexonly_mesh(m, vm, inputvertexcoords, name): `inputvertexcoords` should be the same for all MPI ranks to avoid hanging. """ - gdim = m.geometric_dimension() + gdim = m.geometric_dimension # Correct dims - assert vm.geometric_dimension() == gdim - assert vm.topological_dimension() == 0 + assert vm.geometric_dimension == gdim + assert vm.topological_dimension == 0 # Can initialise # has correct name assert vm.name == name @@ -276,7 +276,7 @@ def test_generate_cell_midpoints(parentmesh, redundant): # Check size of biggest len(vm.coordinates.dat.data_ro) so # locate_cell can be called on every processor max_len = MPI.COMM_WORLD.allreduce(len(vm.coordinates.dat.data_ro), op=MPI.MAX) - out_of_mesh_point = np.full((1, parentmesh.geometric_dimension()), np.inf) + out_of_mesh_point = np.full((1, parentmesh.geometric_dimension), np.inf) for i in range(max_len): if i < len(vm.coordinates.dat.data_ro): # [*here] @@ -378,7 +378,7 @@ def test_missing_points_behaviour(parentmesh): Generate points outside of the parentmesh and check we get the expected error behaviour """ - inputcoord = np.full((1, parentmesh.geometric_dimension()), np.inf) + inputcoord = np.full((1, parentmesh.geometric_dimension), np.inf) assert len(inputcoord) == 1 # Can surpress error vm = VertexOnlyMesh(parentmesh, inputcoord, missing_points_behaviour="ignore") @@ -416,7 +416,7 @@ def test_outside_boundary_behaviour(parentmesh): if parentmesh.name == "immersedsphereextruded" or parentmesh.name == "immersedsphere": # except here! edge_point = negative_coord_furthest_from_origin(parentmesh) - inputcoord = np.full((1, parentmesh.geometric_dimension()), edge_point-1e-15) + inputcoord = np.full((1, parentmesh.geometric_dimension), edge_point-1e-15) assert len(inputcoord) == 1 # Tolerance is too small to pick up point vm = VertexOnlyMesh(parentmesh, inputcoord, tolerance=1e-16, missing_points_behaviour="ignore") @@ -468,7 +468,7 @@ def test_inside_boundary_behaviour(parentmesh): if parentmesh.name == "immersedsphereextruded" or parentmesh.name == "immersedsphere": # except here! edge_point = negative_coord_furthest_from_origin(parentmesh) - inputcoord = np.full((1, parentmesh.geometric_dimension()), edge_point+1e-15) + inputcoord = np.full((1, parentmesh.geometric_dimension), edge_point+1e-15) assert len(inputcoord) == 1 # Tolerance is large enough to pick up point vm = VertexOnlyMesh(parentmesh, inputcoord, tolerance=1e-14, missing_points_behaviour="ignore") diff --git a/tests/tsfc/test_idempotency.py b/tests/tsfc/test_idempotency.py index cf554f4641..152f406848 100644 --- a/tests/tsfc/test_idempotency.py +++ b/tests/tsfc/test_idempotency.py @@ -9,7 +9,7 @@ ufl.triangle, ufl.quadrilateral, ufl.tetrahedron], - ids=lambda x: x.cellname()) + ids=lambda x: x.cellname) def cell(request): return request.param diff --git a/tests/tsfc/test_impero_loopy_flop_counts.py b/tests/tsfc/test_impero_loopy_flop_counts.py index 76bdad96e3..240067bd6e 100644 --- a/tests/tsfc/test_impero_loopy_flop_counts.py +++ b/tests/tsfc/test_impero_loopy_flop_counts.py @@ -32,7 +32,7 @@ def count_loopy_flops(kernel): @pytest.fixture(params=[interval, triangle, quadrilateral, TensorProductCell(triangle, interval)], - ids=lambda cell: cell.cellname()) + ids=lambda cell: cell.cellname) def cell(request): return request.param diff --git a/tests/tsfc/test_interpolation_factorisation.py b/tests/tsfc/test_interpolation_factorisation.py index 4355c24b1f..0f5d366484 100644 --- a/tests/tsfc/test_interpolation_factorisation.py +++ b/tests/tsfc/test_interpolation_factorisation.py @@ -11,7 +11,7 @@ @pytest.fixture(params=[interval, quadrilateral, hexahedron], - ids=lambda x: x.cellname()) + ids=lambda x: x.cellname) def mesh(request): return Mesh(VectorElement("P", request.param, 1)) @@ -44,7 +44,7 @@ def test_sum_factorisation(mesh, element): flops.append(flop_count(mesh, element(int(lo)), element(int(hi)))) flops = numpy.asarray(flops) rates = numpy.diff(numpy.log(flops)) / numpy.diff(numpy.log(degrees)) - assert (rates < (mesh.topological_dimension()+1)).all() + assert (rates < (mesh.topological_dimension+1)).all() def test_sum_factorisation_scalar_tensor(mesh, element): diff --git a/tests/tsfc/test_sum_factorisation.py b/tests/tsfc/test_sum_factorisation.py index 3e785c5b26..891cf1c6cc 100644 --- a/tests/tsfc/test_sum_factorisation.py +++ b/tests/tsfc/test_sum_factorisation.py @@ -20,9 +20,9 @@ def helmholtz(cell, degree): def split_mixed_poisson(cell, degree): m = Mesh(VectorElement('CG', cell, 1)) - if cell.cellname() in ['interval * interval', 'quadrilateral']: + if cell.cellname in ['interval * interval', 'quadrilateral']: hdiv_element = FiniteElement('RTCF', cell, degree) - elif cell.cellname() == 'triangle * interval': + elif cell.cellname == 'triangle * interval': U0 = FiniteElement('RT', triangle, degree) U1 = FiniteElement('DG', triangle, degree - 1) V0 = FiniteElement('CG', interval, degree) @@ -30,7 +30,7 @@ def split_mixed_poisson(cell, degree): Wa = HDivElement(TensorProductElement(U0, V1)) Wb = HDivElement(TensorProductElement(U1, V0)) hdiv_element = EnrichedElement(Wa, Wb) - elif cell.cellname() == 'quadrilateral * interval': + elif cell.cellname == 'quadrilateral * interval': hdiv_element = FiniteElement('NCF', cell, degree) RT = FunctionSpace(m, hdiv_element) DG = FunctionSpace(m, FiniteElement('DQ', cell, degree - 1)) @@ -43,9 +43,9 @@ def split_mixed_poisson(cell, degree): def split_vector_laplace(cell, degree): m = Mesh(VectorElement('CG', cell, 1)) - if cell.cellname() in ['interval * interval', 'quadrilateral']: + if cell.cellname in ['interval * interval', 'quadrilateral']: hcurl_element = FiniteElement('RTCE', cell, degree) - elif cell.cellname() == 'triangle * interval': + elif cell.cellname == 'triangle * interval': U0 = FiniteElement('RT', triangle, degree) U1 = FiniteElement('CG', triangle, degree) V0 = FiniteElement('CG', interval, degree) @@ -53,7 +53,7 @@ def split_vector_laplace(cell, degree): Wa = HCurlElement(TensorProductElement(U0, V0)) Wb = HCurlElement(TensorProductElement(U1, V1)) hcurl_element = EnrichedElement(Wa, Wb) - elif cell.cellname() == 'quadrilateral * interval': + elif cell.cellname == 'quadrilateral * interval': hcurl_element = FiniteElement('NCE', cell, degree) RT = FunctionSpace(m, hcurl_element) CG = FunctionSpace(m, FiniteElement('Q', cell, degree)) diff --git a/tests/tsfc/test_tensor.py b/tests/tsfc/test_tensor.py index 9d09a467fb..7e2d4de06b 100644 --- a/tests/tsfc/test_tensor.py +++ b/tests/tsfc/test_tensor.py @@ -55,7 +55,7 @@ def count_flops(form): (triangle, 4), (tetrahedron, 6)]) def test_bilinear(form, cell, order): - degrees = numpy.arange(1, 9 - 2 * cell.topological_dimension()) + degrees = numpy.arange(1, 9 - 2 * cell.topological_dimension) flops = [count_flops(form(cell, int(degree))) for degree in degrees] rates = numpy.diff(numpy.log(flops)) / numpy.diff(numpy.log(degrees + 1)) @@ -73,7 +73,7 @@ def form(cell, degree): v = TestFunction(V) return v*dx - degrees = numpy.arange(2, 9 - 1.5 * cell.topological_dimension()) + degrees = numpy.arange(2, 9 - 1.5 * cell.topological_dimension) flops = [count_flops(form(cell, int(degree))) for degree in degrees] rates = numpy.diff(numpy.log(flops)) / numpy.diff(numpy.log(degrees + 1)) @@ -91,7 +91,7 @@ def form(cell, degree): f = Coefficient(V) return div(f)*dx - dim = cell.topological_dimension() + dim = cell.topological_dimension degrees = numpy.arange(2, 8 - dim) + (3 - dim) flops = [count_flops(form(cell, int(degree))) for degree in degrees] diff --git a/tests/tsfc/test_underintegration.py b/tests/tsfc/test_underintegration.py index 24221e05a7..cb9cfb78b7 100644 --- a/tests/tsfc/test_underintegration.py +++ b/tests/tsfc/test_underintegration.py @@ -21,7 +21,7 @@ def gll_quadrature_rule(cell, elem_deg): fiat_rule = GaussLobattoLegendreQuadratureLineRule(fiat_cell, elem_deg + 1) line_rules = [QuadratureRule(GaussLobattoLegendrePointSet(fiat_rule.get_points()), fiat_rule.get_weights()) - for _ in range(cell.topological_dimension())] + for _ in range(cell.topological_dimension)] finat_rule = reduce(lambda a, b: TensorProductQuadratureRule([a, b]), line_rules) return finat_rule @@ -31,7 +31,7 @@ def gl_quadrature_rule(cell, elem_deg): fiat_rule = GaussLegendreQuadratureLineRule(fiat_cell, elem_deg + 1) line_rules = [QuadratureRule(GaussLegendrePointSet(fiat_rule.get_points()), fiat_rule.get_weights()) - for _ in range(cell.topological_dimension())] + for _ in range(cell.topological_dimension)] finat_rule = reduce(lambda a, b: TensorProductQuadratureRule([a, b]), line_rules) return finat_rule diff --git a/tsfc/fem.py b/tsfc/fem.py index 9166b4b8f0..17e3e0a04f 100644 --- a/tsfc/fem.py +++ b/tsfc/fem.py @@ -235,7 +235,7 @@ def physical_points(self, point_set, entity=None): e, _ = entity assert point_shape == e else: - assert point_shape == extract_unique_domain(expr).topological_dimension() + assert point_shape == extract_unique_domain(expr).topological_dimension if self.mt.restriction == '+': expr = PositiveRestricted(expr) elif self.mt.restriction == '-': @@ -566,7 +566,7 @@ def translate_cellorigin(terminal, mt, ctx): domain = extract_unique_domain(terminal) coords = SpatialCoordinate(domain) expression = construct_modified_terminal(mt, coords) - point_set = PointSingleton((0.0,) * domain.topological_dimension()) + point_set = PointSingleton((0.0,) * domain.topological_dimension) config = {name: getattr(ctx, name) for name in ["ufl_cell", "index_cache", "scalar_type"]} diff --git a/tsfc/kernel_interface/firedrake_loopy.py b/tsfc/kernel_interface/firedrake_loopy.py index f13a7d1e33..366d458300 100644 --- a/tsfc/kernel_interface/firedrake_loopy.py +++ b/tsfc/kernel_interface/firedrake_loopy.py @@ -121,7 +121,7 @@ def set_cell_sizes(self, domain): Should the domain have topological dimension 0 this does nothing. """ - if domain.ufl_cell().topological_dimension() > 0: + if domain.ufl_cell().topological_dimension > 0: # Can't create P1 since only P0 is a valid finite element if # topological_dimension is 0 and the concept of "cell size" # is not useful for a vertex. diff --git a/tsfc/modified_terminals.py b/tsfc/modified_terminals.py index 8c5162bf97..a26e5c2980 100644 --- a/tsfc/modified_terminals.py +++ b/tsfc/modified_terminals.py @@ -158,7 +158,7 @@ def construct_modified_terminal(mt, terminal): if mt.reference_value: expr = ReferenceValue(expr) - dim = extract_unique_domain(expr).topological_dimension() + dim = extract_unique_domain(expr).topological_dimension for n in range(mt.local_derivatives): # Return zero if expression is trivially constant. This has to # happen here because ReferenceGrad has no access to the From 48b0a9d0b5e9ba45ccb90fd8b121a47f449640a8 Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 6 Oct 2025 15:55:25 +0100 Subject: [PATCH 2/3] fixup --- firedrake/mesh.py | 4 ++-- firedrake/preconditioners/asm.py | 2 +- tests/firedrake/regression/test_interpolate_zany.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index 546de46366..4b9c4aa0bc 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -4543,8 +4543,8 @@ def RelabeledMesh(mesh, indicator_functions, subdomain_ids, **kwargs): # cells height = 0 dmlabel_name = dmcommon.CELL_SETS_LABEL - elif (elem.family() == "HDiv Trace" and elem.degree() == 0 and mesh.topological_dimension() > 1) or \ - (elem.family() == "Lagrange" and elem.degree() == 1 and mesh.topological_dimension() == 1) or \ + elif (elem.family() == "HDiv Trace" and elem.degree() == 0 and mesh.topological_dimension > 1) or \ + (elem.family() == "Lagrange" and elem.degree() == 1 and mesh.topological_dimension == 1) or \ (elem.family() == "Q" and elem.degree() == 2 and mesh.topology.ufl_cell().cellname == "hexahedron"): # facets height = 1 diff --git a/firedrake/preconditioners/asm.py b/firedrake/preconditioners/asm.py index 7bff0e35de..d3e9df7c52 100644 --- a/firedrake/preconditioners/asm.py +++ b/firedrake/preconditioners/asm.py @@ -381,7 +381,7 @@ def get_basemesh_nodes(W): if W.mesh().extruded_periodic: # Account for missing dofs from the top layer - for dim in range(W.mesh().topological_dimension()): + for dim in range(W.mesh().topological_dimension): qstart, qend = W.mesh().topology_dm.getDepthStratum(dim) quotient = len(W.finat_element.entity_dofs()[(dim, 0)][0]) basemeshdof[qstart-pstart:qend-pstart] += quotient diff --git a/tests/firedrake/regression/test_interpolate_zany.py b/tests/firedrake/regression/test_interpolate_zany.py index b2054843cd..03d6136acf 100644 --- a/tests/firedrake/regression/test_interpolate_zany.py +++ b/tests/firedrake/regression/test_interpolate_zany.py @@ -92,7 +92,7 @@ def expr_at_vom(V, which, vom): P0 = VectorFunctionSpace(vom, "DG", 0) fvom = Function(P0) - point = Constant([0] * mesh.geometric_dimension()) + point = Constant([0] * mesh.geometric_dimension) expr_at_pt = ufl.replace(expr, {SpatialCoordinate(mesh): point}) for i, pt in enumerate(vom.coordinates.dat.data_ro): point.assign(pt) From a40244dc51e682635b7f290625cf0073876f79ee Mon Sep 17 00:00:00 2001 From: Connor Ward Date: Mon, 6 Oct 2025 19:20:47 +0100 Subject: [PATCH 3/3] More API fixes --- .github/workflows/core.yml | 3 ++- firedrake/assemble.py | 4 ++-- firedrake/cython/extrusion_numbering.pyx | 2 +- firedrake/slate/slac/kernel_builder.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml index 55df1c8e01..aba3ce4c46 100644 --- a/.github/workflows/core.yml +++ b/.github/workflows/core.yml @@ -194,7 +194,8 @@ jobs: : # because they rely on non-PyPI versions of petsc4py. pip install --no-build-isolation --no-deps \ "$PETSC_DIR"/"$PETSC_ARCH"/externalpackages/git.slepc/src/binding/slepc4py - pip install --no-deps git+https://github.com/NGSolve/ngsPETSc.git netgen-mesher netgen-occt + # UNDO ME + pip install --no-deps git+https://github.com/NGSolve/ngsPETSc.git@connorjward/ufl-cell-fix netgen-mesher netgen-occt : # We have to pass '--no-build-isolation' to use a custom petsc4py EXTRA_BUILD_ARGS='--no-isolation' diff --git a/firedrake/assemble.py b/firedrake/assemble.py index 2c3707cb74..1d37784c69 100644 --- a/firedrake/assemble.py +++ b/firedrake/assemble.py @@ -1808,9 +1808,9 @@ def _as_global_kernel_arg_interior_facet_orientation(_, self): @_as_global_kernel_arg.register(CellFacetKernelArg) def _as_global_kernel_arg_cell_facet(_, self): if self._mesh.extruded: - num_facets = self._mesh._base_mesh.ufl_cell().num_facets() + num_facets = self._mesh._base_mesh.ufl_cell().num_facets else: - num_facets = self._mesh.ufl_cell().num_facets() + num_facets = self._mesh.ufl_cell().num_facets return op2.DatKernelArg((num_facets, 2)) diff --git a/firedrake/cython/extrusion_numbering.pyx b/firedrake/cython/extrusion_numbering.pyx index 86167ed20b..c408fe2fae 100644 --- a/firedrake/cython/extrusion_numbering.pyx +++ b/firedrake/cython/extrusion_numbering.pyx @@ -564,7 +564,7 @@ def top_bottom_boundary_nodes(mesh, layer_extents = mesh.layer_extents cell_closure = mesh.cell_closure ncell, nclosure = mesh.cell_closure.shape - n_vert_facet = mesh._base_mesh.ufl_cell().num_facets() + n_vert_facet = mesh._base_mesh.ufl_cell().num_facets assert facet_points.shape[0] == n_vert_facet + 2 bottom_facet = facet_points[n_vert_facet] diff --git a/firedrake/slate/slac/kernel_builder.py b/firedrake/slate/slac/kernel_builder.py index 8cf27b5298..ec00cd57a2 100644 --- a/firedrake/slate/slac/kernel_builder.py +++ b/firedrake/slate/slac/kernel_builder.py @@ -194,9 +194,9 @@ def facet_integral_predicates(self, mesh, integral_type, kinfo, subdomain_id): self.bag.needs_cell_facets = True # Number of recerence cell facets if mesh.cell_set._extruded: - self.num_facets = mesh._base_mesh.ufl_cell().num_facets() + self.num_facets = mesh._base_mesh.ufl_cell().num_facets else: - self.num_facets = mesh.ufl_cell().num_facets() + self.num_facets = mesh.ufl_cell().num_facets # Index for loop over cell faces of reference cell fidx = self.bag.index_creator((self.num_facets,))