|
3 | 3 | import numpy as np |
4 | 4 |
|
5 | 5 | import basix |
6 | | -import dolfinx.cpp as _cpp |
7 | 6 | from dolfinx.cpp.mesh import Mesh_float64, create_geometry, create_topology |
8 | | -from dolfinx.fem import coordinate_element |
9 | | -from dolfinx.fem.dofmap import DofMap |
| 7 | +from dolfinx.fem import coordinate_element, create_dofmaps |
| 8 | +from dolfinx.fem.element import finiteelement |
10 | 9 | from dolfinx.log import LogLevel, set_log_level |
11 | | -from dolfinx.mesh import CellType |
| 10 | +from dolfinx.mesh import CellType, Topology |
12 | 11 |
|
13 | 12 |
|
14 | 13 | def create_element_dofmap(mesh, cell_types, degree): |
15 | | - cpp_elements = [] |
16 | | - for cell_type in cell_types: |
17 | | - ufl_e = basix.ufl.element("P", cell_type, degree, dtype=np.float64) |
18 | | - cpp_elements += [_cpp.fem.FiniteElement_float64(ufl_e.basix_element._e, None, False)] |
19 | | - |
20 | | - cpp_dofmaps = _cpp.fem.create_dofmaps(mesh.comm, mesh.topology, cpp_elements) |
21 | | - |
22 | | - return (cpp_elements, cpp_dofmaps) |
| 14 | + elements = [ |
| 15 | + finiteelement(ct, basix.ufl.element("P", ct, degree), np.float64) for ct in cell_types |
| 16 | + ] |
| 17 | + dofmaps = create_dofmaps(mesh.comm, Topology(mesh.topology), elements) |
| 18 | + return (elements, dofmaps) |
23 | 19 |
|
24 | 20 |
|
25 | 21 | def test_dofmap_mixed_topology(): |
@@ -72,8 +68,7 @@ def test_dofmap_mixed_topology(): |
72 | 68 | assert elements[1].basix_element.cell_type.name == "quadrilateral" |
73 | 69 |
|
74 | 70 | assert len(dofmaps) == 2 |
75 | | - q0 = DofMap(dofmaps[0]) |
76 | | - q1 = DofMap(dofmaps[1]) |
| 71 | + q0, q1 = dofmaps |
77 | 72 | assert q0.index_map.size_local == q1.index_map.size_local |
78 | 73 | # Triangles |
79 | 74 | print(q0.list) |
@@ -121,10 +116,9 @@ def test_dofmap_prism_mesh(): |
121 | 116 | mesh = Mesh_float64(MPI.COMM_WORLD, topology, geom) |
122 | 117 |
|
123 | 118 | elements, dofmaps = create_element_dofmap(mesh, [basix.CellType.prism], 2) |
124 | | - print() |
125 | 119 | assert len(elements) == 1 |
126 | 120 | assert len(dofmaps) == 1 |
127 | | - q = DofMap(dofmaps[0]) |
| 121 | + q = dofmaps[0] |
128 | 122 | assert q.index_map.size_local == 18 |
129 | 123 | print(q.list) |
130 | 124 | facet_dofs = [] |
|
0 commit comments