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

Method compute_entity_permutations

cpp/dolfinx/mesh/permutationcomputation.cpp:287–344  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

285
286//-----------------------------------------------------------------------------
287std::pair<std::vector<std::uint8_t>, std::vector<std::uint32_t>>
288mesh::compute_entity_permutations(const mesh::Topology& topology)
289{
290 common::Timer t_perm("Compute entity permutations");
291 const int tdim = topology.dim();
292 CellType cell_type = topology.cell_type();
293 const std::int32_t num_cells = topology.connectivity(tdim, 0)->num_nodes();
294 // Point meshes have no facets per cell and cell_num_entities(vertex, -1) is
295 // undefined
296 int facets_per_cell = (tdim > 0) ? cell_num_entities(cell_type, tdim - 1) : 0;
297
298 std::vector<std::uint32_t> cell_permutation_info(num_cells, 0);
299 std::vector<std::uint8_t> facet_permutations(num_cells * facets_per_cell);
300 std::int32_t used_bits = 0;
301 if (tdim > 2)
302 {
303 spdlog::info("Compute face permutations");
304 const int faces_per_cell = cell_num_entities(cell_type, 2);
305 const auto face_perm = compute_face_permutations<_BITSETSIZE>(topology);
306 for (int c = 0; c < num_cells; ++c)
307 cell_permutation_info[c] = face_perm[c].to_ulong();
308
309 // Currently, 3 bits are used for each face. If faces with more than
310 // 4 sides are implemented, this will need to be increased.
311 used_bits += faces_per_cell * 3;
312 assert(tdim == 3);
313 for (int c = 0; c < num_cells; ++c)
314 {
315 for (int i = 0; i < facets_per_cell; ++i)
316 {
317 facet_permutations[c * facets_per_cell + i]
318 = (cell_permutation_info[c] >> (3 * i)) & 7;
319 }
320 }
321 }
322
323 if (tdim > 1)
324 {
325 spdlog::info("Compute edge permutations");
326 const int edges_per_cell = cell_num_entities(cell_type, 1);
327 const auto edge_perm = compute_edge_reflections<_BITSETSIZE>(topology);
328 for (int c = 0; c < num_cells; ++c)
329 cell_permutation_info[c] |= edge_perm[c].to_ulong() << used_bits;
330
331 used_bits += edges_per_cell;
332 if (tdim == 2)
333 {
334 for (int c = 0; c < num_cells; ++c)
335 {
336 for (int i = 0; i < facets_per_cell; ++i)
337 facet_permutations[c * facets_per_cell + i] = edge_perm[c][i];
338 }
339 }
340 }
341 assert(used_bits < _BITSETSIZE);
342
343 return {std::move(facet_permutations), std::move(cell_permutation_info)};
344}

Callers

nothing calls this directly

Calls 4

dimMethod · 0.45
cell_typeMethod · 0.45
num_nodesMethod · 0.45
connectivityMethod · 0.45

Tested by

no test coverage detected