Before running this example, you must install
Basix.UFL:
pip3 install git+https://github.com/FEniCS/basix fenics-ufl
This element can then be created with the following lines of Python:
import basix
import basix.ufl
import numpy as np
# Create Gauss-Legendre degree 1 on a interval
e = basix.ufl.custom_element(
basix.CellType.interval,
(),
np.array([[1.0, 0.0], [0.5, 0.2886751345948128]], dtype=np.float64),
[[np.empty((0, 1), dtype=np.float64), np.empty((0, 1), dtype=np.float64)], [np.array([[0.5], [0.21132486540518713], [0.7886751345948129]], dtype=np.float64)], [], []],
[[np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64)], [np.array([[[[1.0], [0.0], [0.0]]], [[[0.0], [-0.5], [0.5]]]], dtype=np.float64)], [], []],
0,
basix.MapType.identity,
basix.SobolevSpace.H1,
False,
-1,
1,
basix.PolysetType.standard, dtype=np.float64
)
# Create Gauss-Legendre degree 2 on a interval
e = basix.ufl.custom_element(
basix.CellType.interval,
(),
np.array([[0.9999999999999998, 0.0, 0.0], [0.4999999999999999, 0.28867513459481275, 0.0], [0.33333333333333326, 0.2886751345948128, 0.074535599249993]], dtype=np.float64),
[[np.empty((0, 1), dtype=np.float64), np.empty((0, 1), dtype=np.float64)], [np.array([[0.21132486540518713], [0.7886751345948129], [0.1127016653792583], [0.5], [0.8872983346207417]], dtype=np.float64)], [], []],
[[np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64)], [np.array([[[[0.5], [0.5], [0.0], [0.0], [0.0]]], [[[-0.5], [0.5], [0.0], [0.0], [0.0]]], [[[0.0], [0.0], [0.24845199749997662], [-0.49690399499995325], [0.24845199749997662]]]], dtype=np.float64)], [], []],
0,
basix.MapType.identity,
basix.SobolevSpace.H1,
False,
-1,
2,
basix.PolysetType.standard, dtype=np.float64
)
# Create Gauss-Legendre degree 1 on a quadrilateral
e = basix.ufl.custom_element(
basix.CellType.quadrilateral,
(),
np.array([[1.0, 0.0, 0.0, 0.0], [0.5, 0.2886751345948128, 0.0, 0.0], [0.5, 0.0, 0.2886751345948128, 0.0], [0.25, 0.14433756729740643, 0.14433756729740643, 0.08333333333333333]], dtype=np.float64),
[[np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64)], [np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64)], [np.array([[0.5, 0.5], [0.21132486540518713, 0.21132486540518713], [0.21132486540518713, 0.7886751345948129], [0.7886751345948129, 0.21132486540518713], [0.7886751345948129, 0.7886751345948129]], dtype=np.float64)], []],
[[np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64)], [np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64)], [np.array([[[[1.0], [0.0], [0.0], [0.0], [0.0]]], [[[0.0], [-0.25], [0.25], [-0.25], [0.25]]], [[[0.0], [-0.25], [-0.25], [0.25], [0.25]]], [[[0.0], [0.24999999999999997], [-0.25], [-0.24999999999999997], [0.25]]]], dtype=np.float64)], []],
0,
basix.MapType.identity,
basix.SobolevSpace.H1,
False,
-1,
1,
basix.PolysetType.standard, dtype=np.float64
)
# Create Gauss-Legendre degree 2 on a quadrilateral
e = basix.ufl.custom_element(
basix.CellType.quadrilateral,
(),
np.array([[0.9999999999999996, 0.0, 0.0, -2.7755575615628914e-17, 0.0, 0.0, 0.0, 0.0, -8.326672684688674e-17], [0.4999999999999998, 0.28867513459481275, 0.0, 0.0, 0.0, 0.0, 1.3877787807814457e-17, -4.163336342344337e-17, -4.163336342344337e-17], [0.33333333333333315, 0.2886751345948127, 0.07453559924999298, 0.0, 0.0, 0.0, -1.3877787807814457e-17, -4.163336342344337e-17, -1.3877787807814457e-17], [0.49999999999999983, 0.0, -1.3877787807814457e-17, 0.28867513459481275, 0.0, -2.7755575615628914e-17, 0.0, 1.3877787807814457e-17, -4.163336342344337e-17], [0.2499999999999999, 0.14433756729740635, 0.0, 0.14433756729740632, 0.08333333333333329, 0.0, 6.938893903907228e-18, -2.7755575615628914e-17, -1.3877787807814457e-17], [0.16666666666666657, 0.14433756729740638, 0.03726779962499649, 0.09622504486493758, 0.0833333333333333, 0.021516574145596754, 0.0, -2.7755575615628914e-17, -6.938893903907228e-18], [0.33333333333333315, 0.0, -1.3877787807814457e-17, 0.2886751345948127, 0.0, -2.7755575615628914e-17, 0.07453559924999298, 0.0, -2.0816681711721685e-17], [0.16666666666666657, 0.09622504486493756, -1.3877787807814457e-17, 0.14433756729740638, 0.0833333333333333, -1.3877787807814457e-17, 0.03726779962499649, 0.02151657414559674, -6.938893903907228e-18], [0.11111111111111108, 0.09622504486493758, 0.024845199749997656, 0.09622504486493758, 0.08333333333333329, 0.021516574145596754, 0.02484519974999766, 0.02151657414559674, 0.00555555555555555]], dtype=np.float64),
[[np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64)], [np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64), np.empty((0, 2), dtype=np.float64)], [np.array([[0.21132486540518713, 0.21132486540518713], [0.21132486540518713, 0.7886751345948129], [0.7886751345948129, 0.21132486540518713], [0.7886751345948129, 0.7886751345948129], [0.1127016653792583, 0.1127016653792583], [0.1127016653792583, 0.5], [0.1127016653792583, 0.8872983346207417], [0.5, 0.1127016653792583], [0.5, 0.5], [0.5, 0.8872983346207417], [0.8872983346207417, 0.1127016653792583], [0.8872983346207417, 0.5], [0.8872983346207417, 0.8872983346207417]], dtype=np.float64)], []],
[[np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64)], [np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64), np.empty((0, 1, 0, 1), dtype=np.float64)], [np.array([[[[0.25], [0.25], [0.25], [0.25], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0]]], [[[-0.25], [0.25], [-0.25], [0.25], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0]]], [[[0.0], [0.0], [0.0], [0.0], [0.06901444374999348], [-0.13802888749998696], [0.06901444374999348], [0.11042310999998961], [-0.22084621999997922], [0.11042310999998961], [0.06901444374999348], [-0.13802888749998696], [0.06901444374999348]]], [[[-0.25], [-0.25], [0.25], [0.25], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0]]], [[[0.24999999999999997], [-0.25], [-0.24999999999999997], [0.25], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0], [0.0]]], [[[0.0], [0.0], [0.0], [0.0], [-0.09259259259259255], [0.18518518518518512], [-0.09259259259259255], [0.0], [0.0], [0.0], [0.09259259259259255], [-0.18518518518518512], [0.09259259259259255]]], [[[0.0], [0.0], [0.0], [0.0], [0.06901444374999348], [0.11042310999998961], [0.06901444374999348], [-0.13802888749998696], [-0.22084621999997922], [-0.13802888749998696], [0.06901444374999348], [0.11042310999998961], [0.06901444374999348]]], [[[0.0], [0.0], [0.0], [0.0], [-0.09259259259259255], [0.0], [0.09259259259259255], [0.18518518518518512], [0.0], [-0.18518518518518512], [-0.09259259259259255], [0.0], [0.09259259259259255]]], [[[0.0], [0.0], [0.0], [0.0], [0.061728395061728406], [-0.1234567901234568], [0.061728395061728406], [-0.1234567901234568], [0.24691358024691357], [-0.1234567901234568], [0.061728395061728406], [-0.1234567901234568], [0.061728395061728406]]]], dtype=np.float64)], []],
0,
basix.MapType.identity,
basix.SobolevSpace.H1,
False,
-1,
2,
basix.PolysetType.standard, dtype=np.float64
)