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

Function test_mark_maximum

python/test/unit/refinement/test_mark.py:17–33  ·  view source on GitHub ↗
(theta: float, dtype: np.dtype)

Source from the content-addressed store, hash-verified

15@pytest.mark.parametrize("theta", [0.2, 0.4, 0.6, 0.8])
16@pytest.mark.parametrize("dtype", [np.float32, np.float64])
17def test_mark_maximum(theta: float, dtype: np.dtype) -> None:
18 msh = mesh.create_unit_square(comm := MPI.COMM_WORLD, n := 10, n, dtype=dtype)
19
20 tdim = msh.topology.dim
21 cell_count = (cell_im := msh.topology.index_map(tdim)).size_local + cell_im.num_ghosts
22 marker = np.random.default_rng(0).random(cell_count)
23
24 marked_cells = mesh.mark_maximum(marker, theta, comm)
25
26 assert np.allclose(
27 marked_cells,
28 np.argwhere(marker > theta * comm.allreduce(np.max(marker), MPI.MAX)).flatten(),
29 )
30
31 msh.topology.create_entities(1)
32 marked_edges = mesh.compute_incident_entities(msh.topology, marked_cells, tdim, 1)
33 mesh.refine(msh, marked_edges)

Callers

nothing calls this directly

Calls 3

index_mapMethod · 0.45
create_entitiesMethod · 0.45

Tested by

no test coverage detected