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

Function compute_edge_reflections

cpp/dolfinx/mesh/permutationcomputation.cpp:216–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214//-----------------------------------------------------------------------------
215template <int BITSETSIZE>
216std::vector<std::bitset<BITSETSIZE>>
217compute_edge_reflections(const mesh::Topology& topology)
218{
219 mesh::CellType cell_type = topology.cell_type();
220 const int tdim = topology.dim();
221 const int edges_per_cell = cell_num_entities(cell_type, 1);
222
223 const std::int32_t num_cells = topology.connectivity(tdim, 0)->num_nodes();
224
225 auto c_to_v = topology.connectivity(tdim, 0);
226 assert(c_to_v);
227 auto c_to_e = topology.connectivity(tdim, 1);
228 assert(c_to_e);
229 auto e_to_v = topology.connectivity(1, 0);
230 assert(e_to_v);
231
232 auto im = topology.index_map(0);
233 assert(im);
234
235 std::vector<std::bitset<BITSETSIZE>> edge_perm(num_cells, 0);
236 std::vector<std::int64_t> cell_vertices, vertices;
237 for (int c = 0; c < c_to_v->num_nodes(); ++c)
238 {
239 cell_vertices.resize(c_to_v->num_links(c));
240 im->local_to_global(c_to_v->links(c), cell_vertices);
241 auto cell_edges = c_to_e->links(c);
242 for (int i = 0; i < edges_per_cell; ++i)
243 {
244 vertices.resize(e_to_v->links(cell_edges[i]).size());
245 im->local_to_global(e_to_v->links(cell_edges[i]), vertices);
246
247 // If the entity is an interval, it should be oriented pointing
248 // from the lowest numbered vertex to the highest numbered vertex.
249
250 // Find iterators pointing to cell vertex given a vertex on facet
251 auto it0
252 = std::find(cell_vertices.begin(), cell_vertices.end(), vertices[0]);
253 auto it1
254 = std::find(cell_vertices.begin(), cell_vertices.end(), vertices[1]);
255
256 // The number of reflections. Comparing iterators directly instead
257 // of values they point to is sufficient here.
258 edge_perm[c][i] = (it1 < it0) == (vertices[1] > vertices[0]);
259 }
260 }
261
262 return edge_perm;
263}
264//-----------------------------------------------------------------------------
265template <int BITSETSIZE>
266std::vector<std::bitset<BITSETSIZE>>

Callers

nothing calls this directly

Calls 9

num_linksMethod · 0.80
cell_typeMethod · 0.45
dimMethod · 0.45
num_nodesMethod · 0.45
connectivityMethod · 0.45
index_mapMethod · 0.45
local_to_globalMethod · 0.45
linksMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected