From a47c2fda76dc192987ba5c6018257384a671f565 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 24 Oct 2024 15:11:41 +0100 Subject: [PATCH 1/8] DO NOT MERGE --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0fff428f43..de2170690d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,6 +83,8 @@ jobs: --install defcon \ --install gadopt \ --install asQ \ + --package-branch fiat pbrubeck/h1curl \ + --package-branch finat pbrubeck/hhj \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | From 1b8dc6cf5b6c426537118c49bc3cf5b8a85ce680 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 24 Oct 2024 17:57:37 +0100 Subject: [PATCH 2/8] Test VOM with point variant --- tests/vertexonly/test_interpolation_from_parent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/vertexonly/test_interpolation_from_parent.py b/tests/vertexonly/test_interpolation_from_parent.py index 7016da12c6..1ac9a0a393 100644 --- a/tests/vertexonly/test_interpolation_from_parent.py +++ b/tests/vertexonly/test_interpolation_from_parent.py @@ -102,7 +102,7 @@ def vfs(request, parentmesh): @pytest.fixture(params=[("CG", 2, TensorFunctionSpace), ("BDM", 2, VectorFunctionSpace), - ("Regge", 2, FunctionSpace)], + ("Regge", 2, lambda *args: FunctionSpace(*args, variant="point"))], ids=lambda x: f"{x[2].__name__}({x[0]}{x[1]})") def tfs(request, parentmesh): family = request.param[0] From eec0787449c8fea3eda7a0eeed43e4fac9ac9f64 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 24 Oct 2024 18:00:02 +0100 Subject: [PATCH 3/8] Update .github/workflows/build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de2170690d..f35ef985dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -85,6 +85,7 @@ jobs: --install asQ \ --package-branch fiat pbrubeck/h1curl \ --package-branch finat pbrubeck/hhj \ + --package-branch tsfc pbrubeck/hhj \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | From c097608144bc063c0bb09af99dd49738ecb84544 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Thu, 24 Oct 2024 21:45:37 +0100 Subject: [PATCH 4/8] Test Regge point variant --- tests/regression/test_interpolate_cross_mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/regression/test_interpolate_cross_mesh.py b/tests/regression/test_interpolate_cross_mesh.py index 1bd6ed6226..5dcc6a1d20 100644 --- a/tests/regression/test_interpolate_cross_mesh.py +++ b/tests/regression/test_interpolate_cross_mesh.py @@ -215,7 +215,7 @@ def parameters(request): expected = np.asarray( [np.outer(coords[i], coords[i]) for i in range(len(coords))] ) - V_src = FunctionSpace(m_src, "Regge", 2) # Not point evaluation nodes + V_src = FunctionSpace(m_src, "Regge", 2, variant="point") # Not point evaluation nodes V_dest = TensorFunctionSpace(m_dest, "CG", 4) V_dest_2 = TensorFunctionSpace(m_dest, "DQ", 2) elif request.param == "spheresphere": From 2888162c748acb2d5d8a12f52897f6d17a07b446 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Fri, 25 Oct 2024 12:12:44 +0100 Subject: [PATCH 5/8] add continuity test --- tests/regression/test_tensor_elements.py | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/regression/test_tensor_elements.py diff --git a/tests/regression/test_tensor_elements.py b/tests/regression/test_tensor_elements.py new file mode 100644 index 0000000000..a0bb5352b6 --- /dev/null +++ b/tests/regression/test_tensor_elements.py @@ -0,0 +1,39 @@ +from firedrake import * +import pytest + + +rg = RandomGenerator(PCG64(seed=1)) + + +@pytest.fixture(params=("square", "cube")) +def mesh(request): + if request.param == "square": + return UnitSquareMesh(2, 2) + elif request.param == "cube": + return UnitCubeMesh(2, 2, 2) + else: + raise ValueError("Unrecognized mesh type") + + +@pytest.mark.parametrize("degree", (0, 1, 2)) +@pytest.mark.parametrize("family", ("Regge", "HHJ")) +def test_tensor_continuity(mesh, family, degree): + V = FunctionSpace(mesh, family, degree) + u = rg.beta(V, 1.0, 2.0) + + dim = mesh.topological_dimension() + n = FacetNormal(mesh) + + space = V.ufl_element().sobolev_space + if space == HDivDiv: + utrace = dot(n, dot(u, n)) + elif space == HEin: + if dim == 2: + t = dot(as_matrix([[0, -1], [1, 0]]), n) + utrace = dot(t, dot(u, t)) + 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.T)) + + ujump = utrace('+') - utrace('-') + assert assemble(inner(ujump, ujump)*dS) < 1E-10 From 7b9d1040b8cfa68332f4753371e6c08c8ff16f7e Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Wed, 6 Nov 2024 23:32:19 +0000 Subject: [PATCH 6/8] Test H(curl div) element (#3843) * Test H(curl div) element * test Hu-Zhang --- .github/workflows/build.yml | 1 + ..._stress_els.py => test_stress_elements.py} | 43 ++++++++++--------- tests/regression/test_tensor_elements.py | 26 ++++++++--- 3 files changed, 43 insertions(+), 27 deletions(-) rename tests/regression/{test_stress_els.py => test_stress_elements.py} (81%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f35ef985dd..49a8ba1f71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,6 +86,7 @@ jobs: --package-branch fiat pbrubeck/h1curl \ --package-branch finat pbrubeck/hhj \ --package-branch tsfc pbrubeck/hhj \ + --package-branch ufl pbrubeck/hcurldiv \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | diff --git a/tests/regression/test_stress_els.py b/tests/regression/test_stress_elements.py similarity index 81% rename from tests/regression/test_stress_els.py rename to tests/regression/test_stress_elements.py index 16ca97bc58..35cd8bb521 100755 --- a/tests/regression/test_stress_els.py +++ b/tests/regression/test_stress_elements.py @@ -7,19 +7,21 @@ convergence_orders = lambda x: -np.log2(relative_magnitudes(x)) -@pytest.fixture(scope='module', params=["conforming", "nonconforming", "macro"]) +@pytest.fixture(params=["macro", "nonconforming", "conforming", "high-order"]) def stress_element(request): - if request.param == "conforming": - return FiniteElement("AWc", triangle, 3) + if request.param == "macro": + return FiniteElement("JM", triangle, 1) elif request.param == "nonconforming": return FiniteElement("AWnc", triangle, 2) - elif request.param == "macro": - return FiniteElement("JM", triangle, 1) + elif request.param == "conforming": + return FiniteElement("AWc", triangle, 3) + elif request.param == "high-order": + return FiniteElement("HZ", triangle, 3) else: raise ValueError("Unknown family") -@pytest.fixture(scope='module') +@pytest.fixture def mesh_hierarchy(request): N_base = 2 mesh = UnitSquareMesh(N_base, N_base) @@ -64,7 +66,10 @@ def epsilon(u): l2_u = [] l2_sigma = [] l2_div_sigma = [] - displacement_element = VectorElement("DG", cell=mesh.ufl_cell(), degree=1, variant="integral") + sdegree = stress_element.degree() + sfamily = stress_element.family() + vdegree = sdegree-1 if sfamily == "Hu-Zhang" else 1 + displacement_element = VectorElement("DG", cell=mesh.ufl_cell(), degree=vdegree, variant="integral") element = MixedElement([stress_element, displacement_element]) for msh in mesh_hierarchy[1:]: x, y = SpatialCoordinate(msh) @@ -126,20 +131,18 @@ def epsilon(u): l2_sigma.append(error_sigma) l2_div_sigma.append(error_div_sigma) - if stress_element.family().startswith("Conforming"): - assert min(convergence_orders(l2_u)) > 1.9 - assert min(convergence_orders(l2_sigma)) > 2.9 - assert min(convergence_orders(l2_div_sigma)) > 1.9 - elif stress_element.family().startswith("Nonconforming"): - assert min(convergence_orders(l2_u)) > 1.9 - assert min(convergence_orders(l2_sigma)) > 1 - assert min(convergence_orders(l2_div_sigma)) > 1.9 - elif stress_element.family().startswith("Johnson-Mercier"): - assert min(convergence_orders(l2_u)) > 1.9 - assert min(convergence_orders(l2_sigma)) > 1 - assert min(convergence_orders(l2_div_sigma)) > 0.9 + sdegree = V[0].ufl_element().degree() + vdegree = V[1].ufl_element().degree() + if stress_element.family().startswith("Nonconforming"): + expected_rates = (vdegree+1, sdegree-1, sdegree) + elif stress_element.family().startswith("Conforming"): + expected_rates = (vdegree+1, sdegree, sdegree-1) else: - raise ValueError("Don't know what the convergence should be") + expected_rates = (vdegree+1, sdegree+1, sdegree) + + assert min(convergence_orders(l2_u[1:])) > expected_rates[0] * 0.9 + assert min(convergence_orders(l2_sigma[1:])) > expected_rates[1] * 0.9 + assert min(convergence_orders(l2_div_sigma[1:])) > expected_rates[2] * 0.9 def test_mass_conditioning(stress_element, mesh_hierarchy): diff --git a/tests/regression/test_tensor_elements.py b/tests/regression/test_tensor_elements.py index a0bb5352b6..6c0a6f99ff 100644 --- a/tests/regression/test_tensor_elements.py +++ b/tests/regression/test_tensor_elements.py @@ -15,25 +15,37 @@ def mesh(request): raise ValueError("Unrecognized mesh type") -@pytest.mark.parametrize("degree", (0, 1, 2)) -@pytest.mark.parametrize("family", ("Regge", "HHJ")) +@pytest.mark.parametrize("family, degree", [ + ("Regge", 0), + ("Regge", 1), + ("Regge", 2), + ("HHJ", 0), + ("HHJ", 1), + ("HHJ", 2), + ("GLS", 1), + ("GLS", 2), + ]) def test_tensor_continuity(mesh, family, degree): V = FunctionSpace(mesh, family, degree) u = rg.beta(V, 1.0, 2.0) - dim = mesh.topological_dimension() n = FacetNormal(mesh) space = V.ufl_element().sobolev_space if space == HDivDiv: utrace = dot(n, dot(u, n)) elif space == HEin: - if dim == 2: - t = dot(as_matrix([[0, -1], [1, 0]]), n) - utrace = dot(t, dot(u, t)) + 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.T)) + utrace = dot(t, dot(u, t)) + else: + if mesh.topological_dimension() == 2: + t = perp(n) + utrace = dot(t, dot(u, n)) + else: + utrace = cross(n, dot(u, n)) ujump = utrace('+') - utrace('-') assert assemble(inner(ujump, ujump)*dS) < 1E-10 From ff405e1ac343499a5f4474e4caf5954f166cd9c9 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Mon, 18 Nov 2024 09:06:21 +0000 Subject: [PATCH 7/8] checkout ufl master branch --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49a8ba1f71..f35ef985dd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,7 +86,6 @@ jobs: --package-branch fiat pbrubeck/h1curl \ --package-branch finat pbrubeck/hhj \ --package-branch tsfc pbrubeck/hhj \ - --package-branch ufl pbrubeck/hcurldiv \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: | From 004df7e5aa7dd74165f21a352a10a9c0d6a683f3 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Tue, 19 Nov 2024 17:26:33 +0000 Subject: [PATCH 8/8] checkout master branches --- .github/workflows/build.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f35ef985dd..0fff428f43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -83,9 +83,6 @@ jobs: --install defcon \ --install gadopt \ --install asQ \ - --package-branch fiat pbrubeck/h1curl \ - --package-branch finat pbrubeck/hhj \ - --package-branch tsfc pbrubeck/hhj \ || (cat firedrake-install.log && /bin/false) - name: Install test dependencies run: |