DOLFINx 0.12.0.0
DOLFINx C++
Loading...
Searching...
No Matches
integration_domains.h
Go to the documentation of this file.
1// Copyright (C) 2013-2026 Johan Hake, Jan Blechta, Garth N. Wells and Paul T.
2// Kühner
3//
4// This file is part of DOLFINx (https://www.fenicsproject.org)
5//
6// SPDX-License-Identifier: LGPL-3.0-or-later
7
8#pragma once
9
10#include "Form.h"
11#include <algorithm>
12#include <array>
13#include <cassert>
14#include <cstdint>
15#include <dolfinx/graph/AdjacencyList.h>
16#include <dolfinx/mesh/Topology.h>
17#include <ranges>
18#include <span>
19#include <vector>
20
23
24namespace dolfinx::fem
25{
26namespace impl
27{
34template <int num_cells>
35std::array<std::int32_t, 2 * num_cells>
36get_cell_facet_pairs(std::int32_t f, std::span<const std::int32_t> cells,
38{
39 // Loop over cells sharing facet
40 assert(cells.size() == num_cells);
41 std::array<std::int32_t, 2 * num_cells> cell_local_facet_pairs;
42 for (int c = 0; c < num_cells; ++c)
43 {
44 // Get local index of facet with respect to the cell
45 std::int32_t cell = cells[c];
46 auto cell_facets = c_to_f.links(cell);
47 auto facet_it = std::find(cell_facets.begin(), cell_facets.end(), f);
48 assert(facet_it != cell_facets.end());
49 int local_f = std::ranges::distance(cell_facets.begin(), facet_it);
50 cell_local_facet_pairs[2 * c] = cell;
51 cell_local_facet_pairs[2 * c + 1] = local_f;
52 }
53
54 return cell_local_facet_pairs;
55}
56
64template <int num_cells>
65std::array<std::int32_t, 2 * num_cells>
66get_cell_entity_pairs(std::int32_t e, std::span<const std::int32_t> cells,
68{
69 static_assert(num_cells == 1); // Patch assembly not supported.
70
71 assert(cells.size() > 0);
72
73 // Use first cell for assembly over by default
74 std::int32_t cell = cells[0];
75
76 // Find local index of entity within cell
77 auto cell_entities = c_to_e.links(cell);
78 auto it = std::ranges::find(cell_entities, e);
79 assert(it != cell_entities.end());
80 std::int32_t local_index = std::ranges::distance(cell_entities.begin(), it);
81
82 return {cell, local_index};
83}
84
85} // namespace impl
86
120std::vector<std::int32_t>
122 const mesh::Topology& topology,
123 std::span<const std::int32_t> entities);
124} // namespace dolfinx::fem
This class provides a static adjacency list data structure.
Definition AdjacencyList.h:41
std::span< LinkData > links(std::size_t node)
Get the links (edges) for given node.
Definition AdjacencyList.h:169
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition Topology.h:49
std::array< std::int32_t, 2 *num_cells > get_cell_facet_pairs(std::int32_t f, std::span< const std::int32_t > cells, const graph::AdjacencyList< std::int32_t > &c_to_f)
Definition integration_domains.h:36
std::array< std::int32_t, 2 *num_cells > get_cell_entity_pairs(std::int32_t e, std::span< const std::int32_t > cells, const graph::AdjacencyList< std::int32_t > &c_to_e)
Definition integration_domains.h:66
Finite element method functionality.
Definition assemble_expression_impl.h:22
std::vector< std::int32_t > compute_integration_domains(IntegralType integral_type, const mesh::Topology &topology, std::span< const std::int32_t > entities)
Given an integral type and a set of entities, computes and return data for the entities that should b...
Definition utils.cpp:156
IntegralType
Type of integral.
Definition Form.h:43
@ cell
Cell.
Definition Form.h:44