Skip to content

Commit

Permalink
Don't use rank= in Basix elements (#618)
Browse files Browse the repository at this point in the history
* update tests

* remove rank from demos
  • Loading branch information
mscroggs committed Sep 28, 2023
1 parent a2e7649 commit 1d27238
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion demo/ComplexPoisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ufl import (Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction,
dx, grad, inner)

coords = basix.ufl.element("P", "triangle", 2, rank=1)
coords = basix.ufl.element("P", "triangle", 2, shape=(2, ))
mesh = Mesh(coords)
dx = dx(mesh)

Expand Down
2 changes: 1 addition & 1 deletion demo/Components.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import basix.ufl
from ufl import Coefficient, TestFunction, as_vector, dot, dx

element = basix.ufl.element("Lagrange", "tetrahedron", 1, rank=1)
element = basix.ufl.element("Lagrange", "tetrahedron", 1, shape=(3, ))

v = TestFunction(element)
f = Coefficient(element)
Expand Down
4 changes: 2 additions & 2 deletions demo/ExpressionInterpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

# Define mesh
cell = "triangle"
v_el = basix.ufl.element("Lagrange", cell, 1, rank=1)
v_el = basix.ufl.element("Lagrange", cell, 1, shape=(2, ))
mesh = Mesh(v_el)

# Define mixed function space
el = basix.ufl.element("P", cell, 2)
el_int = basix.ufl.element("Discontinuous Lagrange", cell, 1, rank=1)
el_int = basix.ufl.element("Discontinuous Lagrange", cell, 1, shape=(2, ))
me = basix.ufl.mixed_element([el, el_int])
V = FunctionSpace(mesh, me)
u = Coefficient(V)
Expand Down
4 changes: 2 additions & 2 deletions demo/HyperElasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
x = SpatialCoordinate(cell)

# Elements
u_element = basix.ufl.element("P", cell.cellname(), 2, rank=1)
u_element = basix.ufl.element("P", cell.cellname(), 2, shape=(3, ))
p_element = basix.ufl.element("P", cell.cellname(), 1)
A_element = basix.ufl.element("P", cell.cellname(), 1, rank=2)
A_element = basix.ufl.element("P", cell.cellname(), 1, shape=(3, 3))

# Test and trial functions
v = TestFunction(u_element)
Expand Down
2 changes: 1 addition & 1 deletion demo/MetaData.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ufl import Coefficient, TestFunction, TrialFunction, dx, grad, inner

element = basix.ufl.element("Lagrange", "triangle", 1)
vector_element = basix.ufl.element("Lagrange", "triangle", 1, rank=1)
vector_element = basix.ufl.element("Lagrange", "triangle", 1, shape=(2, ))


u = TrialFunction(element)
Expand Down
2 changes: 1 addition & 1 deletion demo/MixedCoefficient.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import basix.ufl
from ufl import Coefficients, dot, dS, dx

DG = basix.ufl.element("DG", "triangle", 0, rank=1)
DG = basix.ufl.element("DG", "triangle", 0, shape=(2, ))
CG = basix.ufl.element("Lagrange", "triangle", 2)
RT = basix.ufl.element("RT", "triangle", 3)

Expand Down
2 changes: 1 addition & 1 deletion demo/Normals.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

cell = triangle

element = basix.ufl.element("Lagrange", cell.cellname(), 1, rank=1)
element = basix.ufl.element("Lagrange", cell.cellname(), 1, shape=(2, ))

n = FacetNormal(cell)

Expand Down
2 changes: 1 addition & 1 deletion demo/PoissonQuad.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ufl import (Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction,
dx, grad, inner)

coords = basix.ufl.element("P", "triangle", 2, rank=1)
coords = basix.ufl.element("P", "triangle", 2, shape=(2, ))
mesh = Mesh(coords)
dx = dx(mesh)

Expand Down
2 changes: 1 addition & 1 deletion demo/StabilisedStokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ufl import (Coefficient, TestFunctions, TrialFunctions, div, dot, dx,
grad, inner)

vector = basix.ufl.element("Lagrange", "triangle", 1, rank=1)
vector = basix.ufl.element("Lagrange", "triangle", 1, shape=(2, ))
scalar = basix.ufl.element("Lagrange", "triangle", 1)
system = basix.ufl.mixed_element([vector, scalar])

Expand Down
2 changes: 1 addition & 1 deletion demo/VectorConstant.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ufl import (Constant, Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction,
dx, grad, inner)

coords = basix.ufl.element("P", "triangle", 2, rank=1)
coords = basix.ufl.element("P", "triangle", 2, shape=(2, ))
mesh = Mesh(coords)
dx = dx(mesh)

Expand Down
2 changes: 1 addition & 1 deletion demo/VectorPoisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import basix.ufl
from ufl import Coefficient, TestFunction, TrialFunction, dx, grad, inner

element = basix.ufl.element("Lagrange", "triangle", 1, rank=1)
element = basix.ufl.element("Lagrange", "triangle", 1, shape=(2, ))

u = TrialFunction(element)
v = TestFunction(element)
Expand Down
2 changes: 1 addition & 1 deletion test/Poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
TrialFunction, dx, grad, inner)
import basix.ufl

mesh = Mesh(basix.ufl.element('P', "triangle", 2, rank=1))
mesh = Mesh(basix.ufl.element('P', "triangle", 2, shape=(2, )))

e = basix.ufl.element("Lagrange", "triangle", 2)

Expand Down
4 changes: 2 additions & 2 deletions test/test_add_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
])
def test_additive_facet_integral(mode, compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a = ufl.inner(u, v) * ufl.ds
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_additive_facet_integral(mode, compile_args):
@pytest.mark.parametrize("mode", ["double", "float", "long double", "double _Complex", "float _Complex"])
def test_additive_cell_integral(mode, compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a = ufl.inner(ufl.grad(u), ufl.grad(v)) * ufl.dx
Expand Down
4 changes: 2 additions & 2 deletions test/test_blocked_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_finite_element(compile_args):


def test_vector_element(compile_args):
ufl_element = basix.ufl.element("Lagrange", "triangle", 1, rank=1)
ufl_element = basix.ufl.element("Lagrange", "triangle", 1, shape=(2, ))
jit_compiled_elements, module, code = ffcx.codegeneration.jit.compile_elements(
[ufl_element], cffi_extra_compile_args=compile_args)
ufcx_element, ufcx_dofmap = jit_compiled_elements[0]
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_vector_element(compile_args):


def test_tensor_element(compile_args):
ufl_element = basix.ufl.element("Lagrange", "triangle", 1, rank=2)
ufl_element = basix.ufl.element("Lagrange", "triangle", 1, shape=(2, 2))
jit_compiled_elements, module, code = ffcx.codegeneration.jit.compile_elements(
[ufl_element], cffi_extra_compile_args=compile_args)
ufcx_element, ufcx_dofmap = jit_compiled_elements[0]
Expand Down
2 changes: 1 addition & 1 deletion test/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def test_cache_modes(compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a = ufl.inner(ufl.grad(u), ufl.grad(v)) * ufl.dx
Expand Down
6 changes: 3 additions & 3 deletions test/test_jit_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_matvec(compile_args):
of user specified vector-valued finite element function (in P1 space).
"""
e = basix.ufl.element("P", "triangle", 1, rank=1)
e = basix.ufl.element("P", "triangle", 1, shape=(2, ))
mesh = ufl.Mesh(e)
V = ufl.FunctionSpace(mesh, e)
f = ufl.Coefficient(V)
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_rank1(compile_args):
and evaluates expression [u_y, u_x] + grad(u_x) at specified points.
"""
e = basix.ufl.element("P", "triangle", 1, rank=1)
e = basix.ufl.element("P", "triangle", 1, shape=(2, ))
mesh = ufl.Mesh(e)

V = ufl.FunctionSpace(mesh, e)
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_elimiate_zero_tables_tensor(compile_args):
Test elimination of tensor-valued expressions with zero tables
"""
cell = "tetrahedron"
c_el = basix.ufl.element("P", cell, 1, rank=1)
c_el = basix.ufl.element("P", cell, 1, shape=(3, ))
mesh = ufl.Mesh(c_el)

e = basix.ufl.element("P", cell, 1)
Expand Down
34 changes: 17 additions & 17 deletions test/test_jit_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
])
def test_laplace_bilinear_form_2d(mode, expected_result, compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
kappa = ufl.Constant(domain, shape=(2, 2))
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_laplace_bilinear_form_2d(mode, expected_result, compile_args):
])
def test_mass_bilinear_form_2d(mode, expected_result, compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a = ufl.inner(u, v) * ufl.dx
Expand Down Expand Up @@ -155,7 +155,7 @@ def test_mass_bilinear_form_2d(mode, expected_result, compile_args):
])
def test_helmholtz_form_2d(mode, expected_result, compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
if mode == "double":
Expand Down Expand Up @@ -212,7 +212,7 @@ def test_helmholtz_form_2d(mode, expected_result, compile_args):
])
def test_laplace_bilinear_form_3d(mode, expected_result, compile_args):
element = basix.ufl.element("Lagrange", "tetrahedron", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "tetrahedron", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "tetrahedron", 1, shape=(3, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a = ufl.inner(ufl.grad(u), ufl.grad(v)) * ufl.dx
Expand Down Expand Up @@ -250,7 +250,7 @@ def test_laplace_bilinear_form_3d(mode, expected_result, compile_args):

def test_form_coefficient(compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TestFunction(space), ufl.TrialFunction(space)
g = ufl.Coefficient(space)
Expand Down Expand Up @@ -287,7 +287,7 @@ def test_form_coefficient(compile_args):

def test_subdomains(compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a0 = ufl.inner(u, v) * ufl.dx + ufl.inner(u, v) * ufl.dx(2)
Expand Down Expand Up @@ -328,7 +328,7 @@ def test_subdomains(compile_args):
@pytest.mark.parametrize("mode", ["double", "double _Complex"])
def test_interior_facet_integral(mode, compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a0 = ufl.inner(ufl.jump(ufl.grad(u)), ufl.jump(ufl.grad(v))) * ufl.dS
Expand Down Expand Up @@ -375,7 +375,7 @@ def test_interior_facet_integral(mode, compile_args):
@pytest.mark.parametrize("mode", ["double", "double _Complex"])
def test_conditional(mode, compile_args):
element = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
x = ufl.SpatialCoordinate(domain)
Expand Down Expand Up @@ -433,7 +433,7 @@ def test_conditional(mode, compile_args):


def test_custom_quadrature(compile_args):
ve = basix.ufl.element("P", "triangle", 1, rank=1)
ve = basix.ufl.element("P", "triangle", 1, shape=(2, ))
mesh = ufl.Mesh(ve)

e = basix.ufl.element("P", mesh.ufl_cell().cellname(), 2)
Expand Down Expand Up @@ -472,7 +472,7 @@ def test_custom_quadrature(compile_args):

def test_curl_curl(compile_args):
V = basix.ufl.element("N1curl", "triangle", 2)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, V)
u, v = ufl.TrialFunction(space), ufl.TestFunction(space)
a = ufl.inner(ufl.curl(u), ufl.curl(v)) * ufl.dx
Expand Down Expand Up @@ -527,7 +527,7 @@ def lagrange_triangle_symbolic(order, corners=[(1, 0), (2, 0), (0, 1)], fun=lamb
def test_lagrange_triangle(compile_args, order, mode, sym_fun, ufl_fun):
sym = lagrange_triangle_symbolic(order, fun=sym_fun)
element = basix.ufl.element("Lagrange", "triangle", order)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, element)
v = ufl.TestFunction(space)

Expand Down Expand Up @@ -617,7 +617,7 @@ def lagrange_tetrahedron_symbolic(order, corners=[(1, 0, 0), (2, 0, 0), (0, 1, 0
def test_lagrange_tetrahedron(compile_args, order, mode, sym_fun, ufl_fun):
sym = lagrange_tetrahedron_symbolic(order, fun=sym_fun)
element = basix.ufl.element("Lagrange", "tetrahedron", order)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "tetrahedron", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "tetrahedron", 1, shape=(3, )))
space = ufl.FunctionSpace(domain, element)
v = ufl.TestFunction(space)

Expand Down Expand Up @@ -657,7 +657,7 @@ def test_lagrange_tetrahedron(compile_args, order, mode, sym_fun, ufl_fun):

def test_prism(compile_args):
element = basix.ufl.element("Lagrange", "prism", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "prism", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "prism", 1, shape=(3, )))
space = ufl.FunctionSpace(domain, element)
v = ufl.TestFunction(space)

Expand Down Expand Up @@ -691,9 +691,9 @@ def test_prism(compile_args):
def test_complex_operations(compile_args):
mode = "double _Complex"
cell = "triangle"
c_element = basix.ufl.element("Lagrange", cell, 1, rank=1)
c_element = basix.ufl.element("Lagrange", cell, 1, shape=(2, ))
mesh = ufl.Mesh(c_element)
element = basix.ufl.element("DG", cell, 0, rank=1)
element = basix.ufl.element("DG", cell, 0, shape=(2, ))
V = ufl.FunctionSpace(mesh, element)
u = ufl.Coefficient(V)
J1 = ufl.real(u)[0] * ufl.imag(u)[1] * ufl.conj(u)[0] * ufl.dx
Expand Down Expand Up @@ -747,7 +747,7 @@ def test_invalid_function_name(compile_args):
ufl.Coefficient.__str__ = lambda self: "invalid function name"

V = basix.ufl.element("Lagrange", "triangle", 1)
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, rank=1))
domain = ufl.Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
space = ufl.FunctionSpace(domain, V)
u = ufl.Coefficient(space)
a = ufl.inner(u, u) * ufl.dx
Expand All @@ -768,7 +768,7 @@ def test_invalid_function_name(compile_args):

def test_interval_vertex_quadrature(compile_args):

c_el = basix.ufl.element("Lagrange", "interval", 1, rank=1)
c_el = basix.ufl.element("Lagrange", "interval", 1, shape=(1, ))
mesh = ufl.Mesh(c_el)

x = ufl.SpatialCoordinate(mesh)
Expand Down

0 comments on commit 1d27238

Please sign in to comment.