(theta: float, dtype: np.dtype)
| 15 | @pytest.mark.parametrize("theta", [0.2, 0.4, 0.6, 0.8]) |
| 16 | @pytest.mark.parametrize("dtype", [np.float32, np.float64]) |
| 17 | def 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) |
nothing calls this directly
no test coverage detected