Skip to content

Commit 66b5ef6

Browse files
authored
Merge branch 'main' into michal/link-libm
2 parents f6af519 + e9abf9e commit 66b5ef6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2585
-1488
lines changed

.flake8

-8
This file was deleted.

.github/workflows/pythonapp.yml

+4-7
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,13 @@ jobs:
4242
pip install git+https://github.com/FEniCS/basix.git
4343
- name: Install FFCx
4444
run: pip install .[ci]
45-
- name: Lint with flake8
46-
run: flake8 --statistics ffcx/ test/
4745
- name: Static check with mypy
4846
run: mypy ffcx/
4947
if: matrix.python-version != '3.12'
50-
- name: isort checks (non-blocking)
51-
continue-on-error: true
52-
run: isort --check .
53-
- name: Check documentation style
54-
run: pydocstyle .
48+
- name: ruff checks
49+
run: |
50+
ruff check .
51+
ruff format --check .
5552
- name: Run units tests
5653
run: python -m pytest -n auto --cov=ffcx/ --junitxml=junit/test-results-${{ matrix.os }}-${{ matrix.python-version }}.xml test/
5754
- name: Upload to Coveralls

.isort.cfg

-5
This file was deleted.

demo/BiharmonicHHJ.py

+23-8
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@
66
"""
77

88
import basix.ufl
9-
from ufl import (Coefficient, FacetNormal, FunctionSpace, Mesh, TestFunctions,
10-
TrialFunctions, dot, dS, ds, dx, grad, inner, jump)
11-
12-
HHJ = basix.ufl.element('HHJ', "triangle", 2)
13-
P = basix.ufl.element('P', "triangle", 3)
9+
from ufl import (
10+
Coefficient,
11+
FacetNormal,
12+
FunctionSpace,
13+
Mesh,
14+
TestFunctions,
15+
TrialFunctions,
16+
dot,
17+
dS,
18+
ds,
19+
dx,
20+
grad,
21+
inner,
22+
jump,
23+
)
24+
25+
HHJ = basix.ufl.element("HHJ", "triangle", 2)
26+
P = basix.ufl.element("P", "triangle", 3)
1427
mixed_element = basix.ufl.mixed_element([HHJ, P])
15-
domain = Mesh(basix.ufl.element("P", "triangle", 1, shape=(2, )))
28+
domain = Mesh(basix.ufl.element("P", "triangle", 1, shape=(2,)))
1629
mixed_space = FunctionSpace(domain, mixed_element)
1730
p_space = FunctionSpace(domain, P)
1831

@@ -24,9 +37,11 @@
2437
def b(sigma, v):
2538
"""The form b."""
2639
n = FacetNormal(domain)
27-
return inner(sigma, grad(grad(v))) * dx \
28-
- dot(dot(sigma('+'), n('+')), n('+')) * jump(grad(v), n) * dS \
40+
return (
41+
inner(sigma, grad(grad(v))) * dx
42+
- dot(dot(sigma("+"), n("+")), n("+")) * jump(grad(v), n) * dS
2943
- dot(dot(sigma, n), n) * dot(grad(v), n) * ds
44+
)
3045

3146

3247
a = inner(sigma, tau) * dx - b(tau, u) + b(sigma, v)

demo/BiharmonicRegge.py

+22-6
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,28 @@
44
The bilinear form a(u, v) and linear form L(v) for Biharmonic equation in Regge formulation.
55
"""
66
import basix.ufl
7-
from ufl import (Coefficient, FacetNormal, FunctionSpace, Identity, Mesh,
8-
TestFunctions, TrialFunctions, dot, dS, ds, dx, grad, inner,
9-
jump, tr)
7+
from ufl import (
8+
Coefficient,
9+
FacetNormal,
10+
FunctionSpace,
11+
Identity,
12+
Mesh,
13+
TestFunctions,
14+
TrialFunctions,
15+
dot,
16+
dS,
17+
ds,
18+
dx,
19+
grad,
20+
inner,
21+
jump,
22+
tr,
23+
)
1024

1125
REG = basix.ufl.element("Regge", "tetrahedron", 1)
1226
P = basix.ufl.element("Lagrange", "tetrahedron", 2)
1327
mixed_element = basix.ufl.mixed_element([REG, P])
14-
domain = Mesh(basix.ufl.element("P", "tetrahedron", 1, shape=(3, )))
28+
domain = Mesh(basix.ufl.element("P", "tetrahedron", 1, shape=(3,)))
1529
mixed_space = FunctionSpace(domain, mixed_element)
1630
p_space = FunctionSpace(domain, P)
1731

@@ -28,9 +42,11 @@ def S(mu):
2842
def b(mu, v):
2943
"""The form b."""
3044
n = FacetNormal(domain)
31-
return inner(S(mu), grad(grad(v))) * dx \
32-
- dot(dot(S(mu('+')), n('+')), n('+')) * jump(grad(v), n) * dS \
45+
return (
46+
inner(S(mu), grad(grad(v))) * dx
47+
- dot(dot(S(mu("+")), n("+")), n("+")) * jump(grad(v), n) * dS
3348
- dot(dot(S(mu), n), n) * dot(grad(v), n) * ds
49+
)
3450

3551

3652
a = inner(S(sigma), S(tau)) * dx - b(tau, u) + b(sigma, v)

demo/CellGeometry.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,35 @@
55
"""
66

77
import basix.ufl
8-
from ufl import (CellVolume, Circumradius, Coefficient, FacetArea, FacetNormal,
9-
FunctionSpace, Mesh, SpatialCoordinate, TrialFunction, ds, dx)
8+
from ufl import (
9+
CellVolume,
10+
Circumradius,
11+
Coefficient,
12+
FacetArea,
13+
FacetNormal,
14+
FunctionSpace,
15+
Mesh,
16+
SpatialCoordinate,
17+
TrialFunction,
18+
ds,
19+
dx,
20+
)
1021
from ufl.geometry import FacetEdgeVectors
1122

1223
V = basix.ufl.element("P", "tetrahedron", 1)
13-
domain = Mesh(basix.ufl.element("P", "tetrahedron", 1, shape=(3, )))
24+
domain = Mesh(basix.ufl.element("P", "tetrahedron", 1, shape=(3,)))
1425
space = FunctionSpace(domain, V)
1526
u = Coefficient(space)
1627

17-
# TODO: Add all geometry for all cell types to this and other demo files, need for regression test.
28+
# TODO: Add all geometry for all cell types to this and other demo
29+
# files, need for regression test.
1830
x = SpatialCoordinate(domain)
1931
n = FacetNormal(domain)
2032
vol = CellVolume(domain)
2133
rad = Circumradius(domain)
2234
area = FacetArea(domain)
2335

24-
M = u * (x[0] * vol * rad) * dx + u * (x[0] * vol * rad * area) * ds # + u*area*avg(n[0]*x[0]*vol*rad)*dS
36+
M = u * (x[0] * vol * rad) * dx + u * (x[0] * vol * rad * area) * ds
2537

2638
# Test some obscure functionality
2739
fev = FacetEdgeVectors(domain)

demo/ComplexPoisson.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@
2121
"""
2222

2323
import basix.ufl
24-
from ufl import (Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction,
25-
dx, grad, inner)
24+
from ufl import Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction, dx, grad, inner
2625

27-
coords = basix.ufl.element("P", "triangle", 2, shape=(2, ))
26+
coords = basix.ufl.element("P", "triangle", 2, shape=(2,))
2827
mesh = Mesh(coords)
2928
dx = dx(mesh)
3029

demo/Components.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
"""
2121

2222
import basix.ufl
23-
from ufl import (Coefficient, FunctionSpace, Mesh, TestFunction, as_vector, dx,
24-
inner)
23+
from ufl import Coefficient, FunctionSpace, Mesh, TestFunction, as_vector, dx, inner
2524

26-
element = basix.ufl.element("Lagrange", "tetrahedron", 1, shape=(3, ))
25+
element = basix.ufl.element("Lagrange", "tetrahedron", 1, shape=(3,))
2726
domain = Mesh(element)
2827
space = FunctionSpace(domain, element)
2928

demo/Conditional.py

+20-6
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,34 @@
2020
"""
2121

2222
import basix.ufl
23-
from ufl import (And, Constant, FunctionSpace, Mesh, Not, Or,
24-
SpatialCoordinate, TestFunction, conditional, dx, ge, gt,
25-
inner, le, lt)
23+
from ufl import (
24+
And,
25+
Constant,
26+
FunctionSpace,
27+
Mesh,
28+
Not,
29+
Or,
30+
SpatialCoordinate,
31+
TestFunction,
32+
conditional,
33+
dx,
34+
ge,
35+
gt,
36+
inner,
37+
le,
38+
lt,
39+
)
2640

2741
element = basix.ufl.element("Lagrange", "triangle", 2)
28-
domain = Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
42+
domain = Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2,)))
2943
space = FunctionSpace(domain, element)
3044

3145
v = TestFunction(space)
3246
g = Constant(domain)
3347

3448
x = SpatialCoordinate(domain)
35-
c0 = conditional(le((x[0] - 0.33)**2 + (x[1] - 0.67)**2, 0.015), -1.0, 5.0)
36-
c = conditional(le((x[0] - 0.33)**2 + (x[1] - 0.67)**2, 0.025), c0, 0.0)
49+
c0 = conditional(le((x[0] - 0.33) ** 2 + (x[1] - 0.67) ** 2, 0.015), -1.0, 5.0)
50+
c = conditional(le((x[0] - 0.33) ** 2 + (x[1] - 0.67) ** 2, 0.025), c0, 0.0)
3751

3852
t0 = And(ge(x[0], 0.55), le(x[0], 0.95))
3953
t1 = Or(lt(x[1], 0.05), gt(x[1], 0.45))

demo/ExpressionInterpolation.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626

2727
# Define mesh
2828
cell = "triangle"
29-
v_el = basix.ufl.element("Lagrange", cell, 1, shape=(2, ))
29+
v_el = basix.ufl.element("Lagrange", cell, 1, shape=(2,))
3030
mesh = Mesh(v_el)
3131

3232
# Define mixed function space
3333
el = basix.ufl.element("P", cell, 2)
34-
el_int = basix.ufl.element("Discontinuous Lagrange", cell, 1, shape=(2, ))
34+
el_int = basix.ufl.element("Discontinuous Lagrange", cell, 1, shape=(2,))
3535
me = basix.ufl.mixed_element([el, el_int])
3636
V = FunctionSpace(mesh, me)
3737
u = Coefficient(V)
@@ -57,9 +57,10 @@
5757

5858
# Get interpolation points for output space
5959
family = basix.finite_element.string_to_family("Lagrange", cell)
60-
b_element = basix.create_element(family, b_cell, 4, basix.LagrangeVariant.gll_warped, discontinuous=True)
60+
b_element = basix.create_element(
61+
family, b_cell, 4, basix.LagrangeVariant.gll_warped, discontinuous=True
62+
)
6163
interpolation_points = b_element.points
6264

6365
# Create expressions that can be used for interpolation
64-
expressions = [(du0, interpolation_points), (du1, interpolation_points),
65-
(powq, quadrature_points)]
66+
expressions = [(du0, interpolation_points), (du1, interpolation_points), (powq, quadrature_points)]

demo/FacetIntegrals.py

+19-6
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,32 @@
2020
"""
2121

2222
import basix.ufl
23-
from ufl import (FacetNormal, FunctionSpace, Mesh, TestFunction, TrialFunction,
24-
avg, ds, dS, grad, inner, jump)
23+
from ufl import (
24+
FacetNormal,
25+
FunctionSpace,
26+
Mesh,
27+
TestFunction,
28+
TrialFunction,
29+
avg,
30+
dS,
31+
ds,
32+
grad,
33+
inner,
34+
jump,
35+
)
2536

2637
element = basix.ufl.element("Discontinuous Lagrange", "triangle", 1)
27-
domain = Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
38+
domain = Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2,)))
2839
space = FunctionSpace(domain, element)
2940

3041
u = TrialFunction(space)
3142
v = TestFunction(space)
3243

3344
n = FacetNormal(domain)
3445

35-
a = inner(u, v) * ds \
36-
+ inner(u('+'), v('-')) * dS \
37-
+ inner(jump(u, n), avg(grad(v))) * dS \
46+
a = (
47+
inner(u, v) * ds
48+
+ inner(u("+"), v("-")) * dS
49+
+ inner(jump(u, n), avg(grad(v))) * dS
3850
+ inner(avg(grad(u)), jump(v, n)) * dS
51+
)

demo/FacetRestrictionAD.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@
1717
"""Facet restriction demo."""
1818

1919
import basix.ufl
20-
from ufl import (Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction,
21-
avg, derivative, dS, dx, grad, inner)
20+
from ufl import (
21+
Coefficient,
22+
FunctionSpace,
23+
Mesh,
24+
TestFunction,
25+
TrialFunction,
26+
avg,
27+
derivative,
28+
dS,
29+
dx,
30+
grad,
31+
inner,
32+
)
2233

2334
element = basix.ufl.element("Discontinuous Lagrange", "triangle", 1)
24-
domain = Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2, )))
35+
domain = Mesh(basix.ufl.element("Lagrange", "triangle", 1, shape=(2,)))
2536
space = FunctionSpace(domain, element)
2637

2738
v = TestFunction(space)

0 commit comments

Comments
 (0)