-----------------------------------------------------------------------------
| 76 | } |
| 77 | //----------------------------------------------------------------------------- |
| 78 | std::vector<fem::DofMap> fem::create_dofmaps( |
| 79 | MPI_Comm comm, const std::vector<ElementDofLayout>& layouts, |
| 80 | mesh::Topology& topology, |
| 81 | const std::function<void(std::span<std::int32_t>, std::uint32_t)>& |
| 82 | permute_inv, |
| 83 | const std::function<std::vector<int>( |
| 84 | const graph::AdjacencyList<std::int32_t>&)>& reorder_fn) |
| 85 | { |
| 86 | std::int32_t D = topology.dim(); |
| 87 | assert(layouts.size() == topology.entity_types(D).size()); |
| 88 | |
| 89 | // Create required mesh entities |
| 90 | for (std::size_t i = 0; i < layouts.size(); ++i) |
| 91 | { |
| 92 | const auto& entity_dofs = layouts[i].entity_dofs_all(); |
| 93 | for (int dim = 1; dim < topology.dim(); ++dim) |
| 94 | { |
| 95 | // Accumulate count of all dofs on this dimension |
| 96 | int dim_sum |
| 97 | = std::accumulate(entity_dofs[dim].begin(), entity_dofs[dim].end(), 0, |
| 98 | [](int c, auto v) { return c + v.size(); }); |
| 99 | |
| 100 | spdlog::debug("Counting entity dofs, dim={}: {}", dim, dim_sum); |
| 101 | if (dim_sum > 0) |
| 102 | topology.create_entities(dim); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | auto [_index_map, bs, dofmaps] |
| 107 | = build_dofmap_data(comm, topology, layouts, reorder_fn); |
| 108 | auto index_map = std::make_shared<common::IndexMap>(std::move(_index_map)); |
| 109 | |
| 110 | // If the element's DOF transformations are permutations, permute the |
| 111 | // DOF numbering on each cell |
| 112 | if (permute_inv) |
| 113 | { |
| 114 | if (layouts.size() != 1) |
| 115 | { |
| 116 | throw std::runtime_error( |
| 117 | "DOF transformations not yet supported in mixed topology."); |
| 118 | } |
| 119 | std::int32_t num_cells = topology.connectivity(D, 0)->num_nodes(); |
| 120 | topology.create_entity_permutations(); |
| 121 | const std::vector<std::uint32_t>& cell_info |
| 122 | = topology.get_cell_permutation_info(); |
| 123 | std::int32_t dim = layouts.front().num_dofs(); |
| 124 | for (std::int32_t cell = 0; cell < num_cells; ++cell) |
| 125 | { |
| 126 | std::span<std::int32_t> dofs(dofmaps.front().data() + cell * dim, dim); |
| 127 | permute_inv(dofs, cell_info[cell]); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | std::vector<DofMap> dms; |
| 132 | dms.reserve(dofmaps.size()); |
| 133 | for (std::size_t i = 0; i < dofmaps.size(); ++i) |
| 134 | dms.emplace_back(layouts[i], index_map, bs, std::move(dofmaps[i]), bs); |
| 135 |
nothing calls this directly
no test coverage detected