From dfe20bc2640bcbdccb3b470f592227afc7e9664b Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 22 Jan 2024 16:55:36 +0000 Subject: [PATCH 01/11] geometric -> topological --- tsfc/finatinterface.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tsfc/finatinterface.py b/tsfc/finatinterface.py index 6442e4b9..1e548cc1 100644 --- a/tsfc/finatinterface.py +++ b/tsfc/finatinterface.py @@ -191,14 +191,14 @@ def convert_finiteelement(element, **kwargs): else: raise ValueError("Variant %r not supported on %s" % (kind, element.cell)) elif element.family() == ["DPC", "DPC L2"]: - if element.cell.geometric_dimension() == 2: + if element.cell.topological_dimension() == 2: element = element.reconstruct(cell=ufl.cell.hypercube(2)) - elif element.cell.geometric_dimension() == 3: + elif element.cell.topological_dimension() == 3: element = element.reconstruct(cell=ufl.cell.hypercube(3)) elif element.family() == "S": - if element.cell.geometric_dimension() == 2: + if element.cell.topological_dimension() == 2: element = element.reconstruct(cell=ufl.cell.hypercube(2)) - elif element.cell.geometric_dimension() == 3: + elif element.cell.topological_dimension() == 3: element = element.reconstruct(cell=ufl.cell.hypercube(3)) return lmbda(cell, element.degree()), set() From 25fe671f96a7729848c13425cab337611488cc59 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 22 Jan 2024 16:56:07 +0000 Subject: [PATCH 02/11] branches --- requirements-git.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-git.txt b/requirements-git.txt index b6e78108..a13e3b3a 100644 --- a/requirements-git.txt +++ b/requirements-git.txt @@ -1,4 +1,4 @@ -git+https://github.com/firedrakeproject/ufl.git#egg=fenics-ufl +git+https://github.com/firedrakeproject/ufl.git@mscroggs/gdim#egg=fenics-ufl git+https://github.com/firedrakeproject/fiat.git#egg=fenics-fiat -git+https://github.com/FInAT/FInAT.git#egg=finat +git+https://github.com/FInAT/FInAT.git@mscroggs/gdim#egg=finat git+https://github.com/firedrakeproject/loopy.git#egg=loopy From edd2515c18189e1bcc7886d2705b2e48b145fc61 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 22 Jan 2024 17:35:38 +0000 Subject: [PATCH 03/11] value_shape(mesh) --- tsfc/ufl_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tsfc/ufl_utils.py b/tsfc/ufl_utils.py index 0cec4dbf..25817c1d 100644 --- a/tsfc/ufl_utils.py +++ b/tsfc/ufl_utils.py @@ -412,8 +412,8 @@ def apply_mapping(expression, element, domain): mesh = domain if domain is not None and mesh != domain: raise NotImplementedError("Multiple domains not supported") - if expression.ufl_shape != element.value_shape: - raise ValueError(f"Mismatching shapes, got {expression.ufl_shape}, expected {element.value_shape}") + if expression.ufl_shape != element.value_shape(mesh): + raise ValueError(f"Mismatching shapes, got {expression.ufl_shape}, expected {element.value_shape(mesh)}") mapping = element.mapping().lower() if mapping == "identity": rexpression = expression @@ -451,7 +451,7 @@ def apply_mapping(expression, element, domain): sub_elem = element.sub_elements[0] shape = expression.ufl_shape flat = ufl.as_vector([expression[i] for i in numpy.ndindex(shape)]) - vs = sub_elem.value_shape + vs = sub_elem.value_shape(mesh) rvs = sub_elem.reference_value_shape seen = set() rpieces = [] @@ -472,7 +472,7 @@ def apply_mapping(expression, element, domain): # And reshape rexpression = as_tensor(numpy.asarray(rpieces).reshape(element.reference_value_shape)) else: - raise NotImplementedError(f"Don't know how to handle mapping type {mapping} for expression of rank {element.value_shape}") + raise NotImplementedError(f"Don't know how to handle mapping type {mapping} for expression of rank {element.value_shape(mesh)}") if rexpression.ufl_shape != element.reference_value_shape: raise ValueError(f"Mismatching reference shapes, got {rexpression.ufl_shape} expected {element.reference_value_shape}") return rexpression From 7ca866a307cae4928721d8d5a04f936c3309d03a Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 22 Jan 2024 17:41:41 +0000 Subject: [PATCH 04/11] fix tests --- tests/test_interpolation_factorisation.py | 2 +- tests/test_tsfc_204.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_interpolation_factorisation.py b/tests/test_interpolation_factorisation.py index f2404a84..1c58ed2b 100644 --- a/tests/test_interpolation_factorisation.py +++ b/tests/test_interpolation_factorisation.py @@ -54,7 +54,7 @@ def test_sum_factorisation_scalar_tensor(mesh, element): source = element(degree - 1) target = element(degree) tensor_flops = flop_count(mesh, source, target) - expect = numpy.prod(target.value_shape) + expect = numpy.prod(target.value_shape(mesh)) if isinstance(target, FiniteElement): scalar_flops = tensor_flops else: diff --git a/tests/test_tsfc_204.py b/tests/test_tsfc_204.py index f6108c7c..35e2caa0 100644 --- a/tests/test_tsfc_204.py +++ b/tests/test_tsfc_204.py @@ -13,8 +13,8 @@ def test_physically_mapped_facet(): V = FiniteElement("P", mesh.ufl_cell(), 1) R = FiniteElement("P", mesh.ufl_cell(), 1) Vv = VectorElement(BrokenElement(V)) - Qhat = VectorElement(BrokenElement(V[facet])) - Vhat = VectorElement(V[facet]) + Qhat = VectorElement(BrokenElement(V[facet]), dim=2) + Vhat = VectorElement(V[facet], dim=2) Z = FunctionSpace(mesh, MixedElement(U, Vv, Qhat, Vhat, R)) z = Coefficient(Z) From b3e64a1359f57e444031041d78d133eb0b5087c3 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 22 Jan 2024 17:50:20 +0000 Subject: [PATCH 05/11] run tests with FEniCS UFL --- requirements-git.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-git.txt b/requirements-git.txt index a13e3b3a..eed8d1cc 100644 --- a/requirements-git.txt +++ b/requirements-git.txt @@ -1,4 +1,4 @@ -git+https://github.com/firedrakeproject/ufl.git@mscroggs/gdim#egg=fenics-ufl +git+https://github.com/FEniCS/ufl.git@mscroggs/gdim#egg=fenics-ufl git+https://github.com/firedrakeproject/fiat.git#egg=fenics-fiat git+https://github.com/FInAT/FInAT.git@mscroggs/gdim#egg=finat git+https://github.com/firedrakeproject/loopy.git#egg=loopy From 4c0f306d36c6b9367043d83b16245e4b61e6bed0 Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 29 Jan 2024 16:38:41 +0000 Subject: [PATCH 06/11] move value_shape to function space --- tests/test_interpolation_factorisation.py | 2 +- tsfc/ufl_utils.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/test_interpolation_factorisation.py b/tests/test_interpolation_factorisation.py index 1c58ed2b..13fe85d3 100644 --- a/tests/test_interpolation_factorisation.py +++ b/tests/test_interpolation_factorisation.py @@ -54,7 +54,7 @@ def test_sum_factorisation_scalar_tensor(mesh, element): source = element(degree - 1) target = element(degree) tensor_flops = flop_count(mesh, source, target) - expect = numpy.prod(target.value_shape(mesh)) + expect =FunctionSpace(mesh, target).value_size if isinstance(target, FiniteElement): scalar_flops = tensor_flops else: diff --git a/tsfc/ufl_utils.py b/tsfc/ufl_utils.py index 25817c1d..cbc0ed49 100644 --- a/tsfc/ufl_utils.py +++ b/tsfc/ufl_utils.py @@ -412,8 +412,9 @@ def apply_mapping(expression, element, domain): mesh = domain if domain is not None and mesh != domain: raise NotImplementedError("Multiple domains not supported") - if expression.ufl_shape != element.value_shape(mesh): - raise ValueError(f"Mismatching shapes, got {expression.ufl_shape}, expected {element.value_shape(mesh)}") + if expression.ufl_shape != ufl.FunctionSpace(mesh, element).value_shape: + raise ValueError(f"Mismatching shapes, got {expression.ufl_shape}, " + f"expected {ufl.FunctionSpace(mesh, element).value_shape}") mapping = element.mapping().lower() if mapping == "identity": rexpression = expression @@ -451,7 +452,7 @@ def apply_mapping(expression, element, domain): sub_elem = element.sub_elements[0] shape = expression.ufl_shape flat = ufl.as_vector([expression[i] for i in numpy.ndindex(shape)]) - vs = sub_elem.value_shape(mesh) + vs = ufl.FunctionSpace(mesh, sub_elem).value_shape rvs = sub_elem.reference_value_shape seen = set() rpieces = [] @@ -472,7 +473,7 @@ def apply_mapping(expression, element, domain): # And reshape rexpression = as_tensor(numpy.asarray(rpieces).reshape(element.reference_value_shape)) else: - raise NotImplementedError(f"Don't know how to handle mapping type {mapping} for expression of rank {element.value_shape(mesh)}") + raise NotImplementedError(f"Don't know how to handle mapping type {mapping} for expression of rank {ufl.FunctionSpace(mesh, element).value_shape}") if rexpression.ufl_shape != element.reference_value_shape: raise ValueError(f"Mismatching reference shapes, got {rexpression.ufl_shape} expected {element.reference_value_shape}") return rexpression From ed7d269c67234483e3958e8a799add79c1ebc62f Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 29 Jan 2024 16:51:43 +0000 Subject: [PATCH 07/11] missing space --- tests/test_interpolation_factorisation.py | 2 +- tests/test_tsfc_204.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_interpolation_factorisation.py b/tests/test_interpolation_factorisation.py index 13fe85d3..b3d4e328 100644 --- a/tests/test_interpolation_factorisation.py +++ b/tests/test_interpolation_factorisation.py @@ -54,7 +54,7 @@ def test_sum_factorisation_scalar_tensor(mesh, element): source = element(degree - 1) target = element(degree) tensor_flops = flop_count(mesh, source, target) - expect =FunctionSpace(mesh, target).value_size + expect = FunctionSpace(mesh, target).value_size if isinstance(target, FiniteElement): scalar_flops = tensor_flops else: diff --git a/tests/test_tsfc_204.py b/tests/test_tsfc_204.py index 35e2caa0..455e019a 100644 --- a/tests/test_tsfc_204.py +++ b/tests/test_tsfc_204.py @@ -1,3 +1,4 @@ +import pytest from tsfc import compile_form from ufl import (Coefficient, FacetNormal, FunctionSpace, Mesh, as_matrix, From 25b94fa5906dc8551aff6fa1ba962158f957472d Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Mon, 29 Jan 2024 16:53:45 +0000 Subject: [PATCH 08/11] didn't mean to commit that line --- tests/test_tsfc_204.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_tsfc_204.py b/tests/test_tsfc_204.py index 455e019a..35e2caa0 100644 --- a/tests/test_tsfc_204.py +++ b/tests/test_tsfc_204.py @@ -1,4 +1,3 @@ -import pytest from tsfc import compile_form from ufl import (Coefficient, FacetNormal, FunctionSpace, Mesh, as_matrix, From f6a627865b2aaf043837225730d5b3362335c7f7 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Wed, 13 Nov 2024 12:33:49 +0000 Subject: [PATCH 09/11] Get value_value size from FunctionSpace --- tsfc/kernel_interface/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsfc/kernel_interface/common.py b/tsfc/kernel_interface/common.py index 945e367e..df7e879f 100644 --- a/tsfc/kernel_interface/common.py +++ b/tsfc/kernel_interface/common.py @@ -472,7 +472,7 @@ def prepare_coefficient(coefficient, name, interior_facet=False): if coefficient.ufl_element().family() == 'Real': # Constant - value_size = coefficient.ufl_element().value_size + value_size = coefficient.ufl_function_space().value_size expression = gem.reshape(gem.Variable(name, (value_size,)), coefficient.ufl_shape) return expression From cc06ee0fcc70db38f9163135ac9d3a3ec28de8a2 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Wed, 13 Nov 2024 17:31:03 +0000 Subject: [PATCH 10/11] get physical_value_shape from ufl.pullback --- tsfc/ufl_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tsfc/ufl_utils.py b/tsfc/ufl_utils.py index cbc0ed49..46192663 100644 --- a/tsfc/ufl_utils.py +++ b/tsfc/ufl_utils.py @@ -412,9 +412,9 @@ def apply_mapping(expression, element, domain): mesh = domain if domain is not None and mesh != domain: raise NotImplementedError("Multiple domains not supported") - if expression.ufl_shape != ufl.FunctionSpace(mesh, element).value_shape: - raise ValueError(f"Mismatching shapes, got {expression.ufl_shape}, " - f"expected {ufl.FunctionSpace(mesh, element).value_shape}") + pvs = element.pullback.physical_value_shape(element, mesh) + if expression.ufl_shape != pvs: + raise ValueError(f"Mismatching shapes, got {expression.ufl_shape}, expected {pvs}") mapping = element.mapping().lower() if mapping == "identity": rexpression = expression @@ -452,7 +452,7 @@ def apply_mapping(expression, element, domain): sub_elem = element.sub_elements[0] shape = expression.ufl_shape flat = ufl.as_vector([expression[i] for i in numpy.ndindex(shape)]) - vs = ufl.FunctionSpace(mesh, sub_elem).value_shape + vs = sub_elem.pullback.physical_value_shape(sub_elem, mesh) rvs = sub_elem.reference_value_shape seen = set() rpieces = [] From 947d74f7c69dc2e95a6a4f3736380379cc1cba64 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Fri, 15 Nov 2024 14:29:59 +0000 Subject: [PATCH 11/11] restore requirements-git.txt --- requirements-git.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-git.txt b/requirements-git.txt index eed8d1cc..b6e78108 100644 --- a/requirements-git.txt +++ b/requirements-git.txt @@ -1,4 +1,4 @@ -git+https://github.com/FEniCS/ufl.git@mscroggs/gdim#egg=fenics-ufl +git+https://github.com/firedrakeproject/ufl.git#egg=fenics-ufl git+https://github.com/firedrakeproject/fiat.git#egg=fenics-fiat -git+https://github.com/FInAT/FInAT.git@mscroggs/gdim#egg=finat +git+https://github.com/FInAT/FInAT.git#egg=finat git+https://github.com/firedrakeproject/loopy.git#egg=loopy