From b76ee5ee7bf440e9db037ef15bcb27f263090ce0 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Wed, 13 Nov 2024 15:56:58 +0000 Subject: [PATCH] fix tests --- firedrake/formmanipulation.py | 2 +- firedrake/function.py | 2 +- firedrake/mesh.py | 2 +- tests/output/test_io_backward_compat.py | 5 ++--- tests/regression/test_2dcohomology.py | 8 ++++---- tests/submesh/test_submesh_interpolate.py | 6 +++--- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/firedrake/formmanipulation.py b/firedrake/formmanipulation.py index 394fdcca95..35a6789107 100644 --- a/firedrake/formmanipulation.py +++ b/firedrake/formmanipulation.py @@ -124,7 +124,7 @@ def argument(self, o): args += [a_[j] for j in numpy.ndindex(a_.ufl_shape)] else: args += [Zero() - for j in numpy.ndindex(V_is[i].block_size)] + for j in numpy.ndindex(V_is[i].value_shape)] return self._arg_cache.setdefault(o, as_vector(args)) diff --git a/firedrake/function.py b/firedrake/function.py index ddedebad10..83136407ea 100644 --- a/firedrake/function.py +++ b/firedrake/function.py @@ -633,7 +633,7 @@ def at(self, arg, *args, **kwargs): raise NotImplementedError("Point evaluation not implemented for variable layers") # Validate geometric dimension - gdim = mesh.ufl_cell().geometric_dimension() + gdim = mesh.geometric_dimension() if arg.shape[-1] == gdim: pass elif len(arg.shape) == 1 and gdim == 1: diff --git a/firedrake/mesh.py b/firedrake/mesh.py index 8624240421..fd37e7b575 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -2920,7 +2920,7 @@ def make_vom_from_vom_topology(topology, name, tolerance=0.5): gdim = topology.topology_dm.getCoordinateDim() cell = topology.ufl_cell() element = finat.ufl.VectorElement("DG", cell, 0, dim=gdim) - vmesh = MeshGeometry.__new__(MeshGeometry, element) + 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() diff --git a/tests/output/test_io_backward_compat.py b/tests/output/test_io_backward_compat.py index 67cf0d6dff..0e43326a2a 100644 --- a/tests/output/test_io_backward_compat.py +++ b/tests/output/test_io_backward_compat.py @@ -150,7 +150,7 @@ def _get_mesh_and_V(params): def _get_expr(V): mesh = V.mesh() dim = mesh.geometric_dimension() - shape = V.ufl_element().value_shape + shape = V.value_shape if dim == 2: x, y = SpatialCoordinate(mesh) z = x + y @@ -240,9 +240,8 @@ def test_io_backward_compat_base_load(version, params): def _get_expr_timestepping(V, i): mesh = V.mesh() - element = V.ufl_element() x, y = SpatialCoordinate(mesh) - shape = element.value_shape + shape = V.value_shape if shape == (4, ): return as_vector([x + i, y + i, x * y + i, i * i]) else: diff --git a/tests/regression/test_2dcohomology.py b/tests/regression/test_2dcohomology.py index 73bf409538..85ad069924 100644 --- a/tests/regression/test_2dcohomology.py +++ b/tests/regression/test_2dcohomology.py @@ -51,7 +51,7 @@ def test_betti0(space, mesh): L = assemble(inner(nabla_grad(u), nabla_grad(v))*dx) - bc0 = DirichletBC(V0, Constant(0.0), 9) + bc0 = DirichletBC(V0, 0, 9) L0 = assemble(inner(nabla_grad(u), nabla_grad(v))*dx, bcs=[bc0]) u, s, v = linalg.svd(L.M.values) @@ -94,8 +94,8 @@ def test_betti1(space, mesh): L = assemble((inner(sigma, tau) - inner(u, rot(tau)) + inner(rot(sigma), v) + inner(div(u), div(v))) * dx) - bc0 = DirichletBC(W.sub(0), Constant(0.0), 9) - bc1 = DirichletBC(W.sub(1), Constant((0.0, 0.0)), 9) + bc0 = DirichletBC(W.sub(0), 0, 9) + bc1 = DirichletBC(W.sub(1), 0, 9) L0 = assemble((inner(sigma, tau) - inner(u, rot(tau)) + inner(rot(sigma), v) + inner(div(u), div(v))) * dx, bcs=[bc0, bc1]) @@ -155,7 +155,7 @@ def test_betti2(space, mesh): L = assemble((inner(sigma, tau) - inner(u, div(tau)) + inner(div(sigma), v))*dx) - bc1 = DirichletBC(W.sub(0), Constant((0.0, 0.0)), 9) + bc1 = DirichletBC(W.sub(0), 0, 9) L0 = assemble((inner(sigma, tau) - inner(u, div(tau)) + inner(div(sigma), v))*dx, bcs=[bc1]) dV1 = V1.dof_count diff --git a/tests/submesh/test_submesh_interpolate.py b/tests/submesh/test_submesh_interpolate.py index f2d94459e3..27c7414d4a 100644 --- a/tests/submesh/test_submesh_interpolate.py +++ b/tests/submesh/test_submesh_interpolate.py @@ -21,9 +21,9 @@ def _get_expr(V): x, y, z = SpatialCoordinate(m) else: raise NotImplementedError("Not implemented") - if V.ufl_element().value_shape == (): + if V.value_shape == (): return cos(x) + x * exp(y) + sin(z) - elif V.ufl_element().value_shape == (2, ): + elif V.value_shape == (2, ): return as_vector([cos(x), sin(y)]) @@ -50,7 +50,7 @@ def _test_submesh_interpolate_cell_cell(mesh, subdomain_cond, fe_fesub): # if there is no ambiguity on the subdomain boundary. # For testing, the following suffices. g.interpolate(f) - temp = Constant(999.) if V.ufl_element().value_shape == () else as_vector([Constant(999.)] * np.prod(V.ufl_element().value_shape, dtype=int)) + temp = Constant(999.*np.ones(V.value_shape)) g.interpolate(temp, subset=mesh.topology.cell_subset(label_value)) # pollute the data g.interpolate(gsub, subset=mesh.topology.cell_subset(label_value)) assert assemble(inner(g - f, g - f) * dx(label_value)).real < 1e-14