File: test_geometry_dofmap_reconstruction.py

package info (click to toggle)
io4dolfinx 1.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 832 kB
  • sloc: python: 8,419; sh: 34; makefile: 3
file content (40 lines) | stat: -rw-r--r-- 1,213 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from mpi4py import MPI

import basix
import dolfinx
import numpy as np
import pytest

from io4dolfinx.readers import create_geometry_function_space


@pytest.mark.parametrize(
    "cell_type", [dolfinx.mesh.CellType.triangle, dolfinx.mesh.CellType.quadrilateral]
)
@pytest.mark.parametrize("value_shape", [(), (1,), (4,)])
@pytest.mark.parametrize("N", [3, 20])
@pytest.mark.parametrize("M", [8, 9])
@pytest.mark.parametrize(
    "ghost_mode", [dolfinx.mesh.GhostMode.shared_facet, dolfinx.mesh.GhostMode.none]
)
def test_dofmap_construction(cell_type, value_shape, N, M, ghost_mode):
    mesh = dolfinx.mesh.create_unit_square(
        MPI.COMM_WORLD, N, M, cell_type=cell_type, ghost_mode=ghost_mode
    )
    el = basix.ufl.element("Lagrange", mesh.basix_cell(), 1)
    if value_shape == ():
        b_el = el
    else:
        b_el = basix.ufl.blocked_element(el, value_shape)

    MPI.COMM_WORLD.barrier()

    V_ref = dolfinx.fem.functionspace(mesh, b_el)

    MPI.COMM_WORLD.barrier()

    bs = int(np.prod(value_shape))
    V = create_geometry_function_space(mesh, bs)
    assert V.dofmap.bs == V_ref.dofmap.bs
    assert V.dofmap.bs == bs
    np.testing.assert_allclose(V.dofmap.list, V_ref.dofmap.list)