| 1 |
from mpi4py import MPI |
| 2 |
|
| 3 |
import basix |
| 4 |
import dolfinx |
| 5 |
import numpy as np |
| 6 |
import pytest |
| 7 |
|
| 8 |
from io4dolfinx.readers import create_geometry_function_space |
| 9 |
|
| 10 |
|
| 11 |
@pytest.mark.parametrize( |
| 12 |
"cell_type", [dolfinx.mesh.CellType.triangle, dolfinx.mesh.CellType.quadrilateral] |
| 13 |
) |
| 14 |
@pytest.mark.parametrize("value_shape", [(), (1,), (4,)]) |
| 15 |
@pytest.mark.parametrize("N", [3, 20]) |
| 16 |
@pytest.mark.parametrize("M", [8, 9]) |
| 17 |
@pytest.mark.parametrize( |
| 18 |
"ghost_mode", [dolfinx.mesh.GhostMode.shared_facet, dolfinx.mesh.GhostMode.none] |
| 19 |
) |
| 20 |
def test_dofmap_construction(cell_type, value_shape, N, M, ghost_mode): |
| 21 |
mesh = dolfinx.mesh.create_unit_square( |
| 22 |
MPI.COMM_WORLD, N, M, cell_type=cell_type, ghost_mode=ghost_mode |
| 23 |
) |
| 24 |
el = basix.ufl.element("Lagrange", mesh.basix_cell(), 1) |
| 25 |
if value_shape == (): |
| 26 |
b_el = el |
| 27 |
else: |
| 28 |
b_el = basix.ufl.blocked_element(el, value_shape) |
| 29 |
|
| 30 |
MPI.COMM_WORLD.barrier() |
| 31 |
|
| 32 |
V_ref = dolfinx.fem.functionspace(mesh, b_el) |
| 33 |
|
| 34 |
MPI.COMM_WORLD.barrier() |
| 35 |
|
| 36 |
bs = int(np.prod(value_shape)) |
| 37 |
V = create_geometry_function_space(mesh, bs) |
| 38 |
assert V.dofmap.bs == V_ref.dofmap.bs |
| 39 |
assert V.dofmap.bs == bs |
| 40 |
np.testing.assert_allclose(V.dofmap.list, V_ref.dofmap.list) |