| 34 | /// cell indices. |
| 35 | template <std::floating_point T> |
| 36 | std::tuple<graph::AdjacencyList<std::int64_t>, std::vector<T>, |
| 37 | std::array<std::size_t, 2>, std::optional<std::vector<std::int32_t>>, |
| 38 | std::optional<std::vector<std::int8_t>>> |
| 39 | compute_refinement_data(const mesh::Mesh<T>& mesh, |
| 40 | std::optional<std::span<const std::int32_t>> cells, |
| 41 | Option option) |
| 42 | { |
| 43 | bool compute_parent_facet = option_parent_facet(option); |
| 44 | bool compute_parent_cell = option_parent_cell(option); |
| 45 | |
| 46 | if (compute_parent_facet) |
| 47 | throw std::runtime_error("Parent facet computation not yet supported!"); |
| 48 | |
| 49 | auto topology = mesh.topology(); |
| 50 | assert(topology); |
| 51 | assert(topology->dim() == 1); |
| 52 | auto map_c = topology->index_map(1); |
| 53 | assert(map_c); |
| 54 | |
| 55 | // TODO: creation of sharing ranks in external function? Also same |
| 56 | // code in use for plaza |
| 57 | // Get sharing ranks for each cell |
| 58 | graph::AdjacencyList<int> cell_ranks = map_c->index_to_dest_ranks(); |
| 59 | |
| 60 | // Create unique list of ranks that share cells (owners of ghosts plus |
| 61 | // ranks that ghost owned indices) |
| 62 | std::vector<int> ranks = cell_ranks.array(); |
| 63 | std::ranges::sort(ranks); |
| 64 | auto to_remove = std::ranges::unique(ranks); |
| 65 | ranks.erase(to_remove.begin(), to_remove.end()); |
| 66 | |
| 67 | // Convert cell_ranks from global rank to to neighbourhood ranks |
| 68 | std::ranges::transform(cell_ranks.array(), cell_ranks.array().begin(), |
| 69 | [&ranks](auto r) |
| 70 | { |
| 71 | auto it = std::lower_bound(ranks.begin(), |
| 72 | ranks.end(), r); |
| 73 | assert(it != ranks.end() and *it == r); |
| 74 | return std::distance(ranks.begin(), it); |
| 75 | }); |
| 76 | |
| 77 | // Create refinement flag for cells |
| 78 | std::vector<std::int8_t> refinement_marker( |
| 79 | map_c->size_local() + map_c->num_ghosts(), !cells.has_value()); |
| 80 | |
| 81 | // Mark cells for refinement |
| 82 | std::vector<std::vector<std::int32_t>> marked_for_update(ranks.size()); |
| 83 | if (cells) |
| 84 | { |
| 85 | std::ranges::for_each( |
| 86 | cells.value(), |
| 87 | [&refinement_marker, &cell_ranks, &marked_for_update](auto cell) |
| 88 | { |
| 89 | if (!refinement_marker[cell]) |
| 90 | { |
| 91 | refinement_marker[cell] = true; |
| 92 | for (int rank : cell_ranks.links(cell)) |
| 93 | marked_for_update[rank].push_back(cell); |
nothing calls this directly
no test coverage detected