MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / test_collapse

Function test_collapse

python/test/unit/fem/test_function_space.py:170–196  ·  view source on GitHub ↗
(W, V)

Source from the content-addressed store, hash-verified

168
169
170def test_collapse(W, V):
171 with pytest.raises(RuntimeError):
172 Function(W.sub(1))
173
174 Ws = [W.sub(i).collapse() for i in range(W.num_sub_spaces)]
175 for Wi, dofs in Ws:
176 assert np.allclose(Wi.dofmap.index_map.ghosts, W.dofmap.index_map.ghosts)
177
178 # Number of collapsed dofs in W numbering must agree with the number of dofs
179 # of the collapsed space
180 assert Wi.dofmap.index_map.size_local + Wi.dofmap.index_map.num_ghosts == dofs[0].size
181
182 msh = W.mesh
183 cell_imap = msh.topology.index_map(msh.topology.dim)
184 num_cells = cell_imap.size_local + cell_imap.num_ghosts
185 bs = W.dofmap.index_map_bs
186 for c in range(num_cells):
187 cell_dofs = W.dofmap.cell_dofs(c)
188 for i, dof in enumerate(cell_dofs):
189 for k in range(bs):
190 new_dof = Ws[k][0].dofmap.cell_dofs(c)[i]
191 new_to_old = Ws[k][1][0]
192 assert dof * bs + k == new_to_old[new_dof]
193
194 f0 = Function(Ws[0][0])
195 f1 = Function(V)
196 assert f0.x.index_map.size_global == f1.x.index_map.size_global
197
198
199def test_argument_equality(mesh, V, V2, W, W2):

Callers

nothing calls this directly

Calls 5

FunctionClass · 0.90
subMethod · 0.45
collapseMethod · 0.45
index_mapMethod · 0.45
cell_dofsMethod · 0.45

Tested by

no test coverage detected