DOLFINx 0.10.0.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
Topology.h
1// Copyright (C) 2006-2024 Anders Logg and Garth N. Wells
2//
3// This file is part of DOLFINx (https://www.fenicsproject.org)
4//
5// SPDX-License-Identifier: LGPL-3.0-or-later
6
7#pragma once
8
9#include <array>
10#include <cstdint>
11#include <dolfinx/common/MPI.h>
12#include <dolfinx/graph/AdjacencyList.h>
13#include <map>
14#include <memory>
15#include <optional>
16#include <span>
17#include <tuple>
18#include <utility>
19#include <vector>
20
21namespace dolfinx::common
22{
23class IndexMap;
24}
25
26namespace dolfinx::mesh
27{
28enum class CellType;
29
41{
42public:
61 std::vector<CellType> cell_types,
62 std::shared_ptr<const common::IndexMap> vertex_map,
63 std::vector<std::shared_ptr<const common::IndexMap>> cell_maps,
64 std::vector<std::shared_ptr<graph::AdjacencyList<std::int32_t>>> cells,
65 const std::optional<std::vector<std::vector<std::int64_t>>>&
67 = std::nullopt);
68
70 Topology(const Topology& topology) = default;
71
73 Topology(Topology&& topology) = default;
74
76 ~Topology() = default;
77
79 Topology& operator=(const Topology& topology) = delete;
80
82 Topology& operator=(Topology&& topology) = default;
83
85 int dim() const noexcept;
86
90 const std::vector<CellType>& entity_types(int dim) const;
91
97 CellType cell_type() const;
98
104 std::vector<std::shared_ptr<const common::IndexMap>>
105 index_maps(int dim) const;
106
113 std::shared_ptr<const common::IndexMap> index_map(int dim) const;
114
128 std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
129 connectivity(std::array<int, 2> d0, std::array<int, 2> d1) const;
130
140 std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
141 connectivity(int d0, int d1) const;
142
144 const std::vector<std::uint32_t>& get_cell_permutation_info() const;
145
160 const std::vector<std::uint8_t>& get_facet_permutations() const;
161
164 std::vector<CellType> cell_types() const;
165
178 const std::vector<std::int32_t>& interprocess_facets(int index) const;
179
188 const std::vector<std::int32_t>& interprocess_facets() const;
189
194 bool create_entities(int dim);
195
200 void create_connectivity(int d0, int d1);
201
204
206 std::vector<std::vector<std::int64_t>> original_cell_index;
207
210 MPI_Comm comm() const;
211
212private:
213 // Cell types for entities in Topology, where _entity_types_new[d][i]
214 // is the ith entity type of dimension d
215 std::vector<std::vector<CellType>> _entity_types;
216
217 // Parallel layout of entities for each dimension and cell type
218 // flattened in the same layout as _entity_types above.
219 // std::vector<std::shared_ptr<const common::IndexMap>> _index_map;
220
221 // _index_maps[(d, i) is the index map for the ith entity type of
222 // dimension d
223 std::map<std::array<int, 2>, std::shared_ptr<const common::IndexMap>>
224 _index_maps;
225
226 // Connectivity between cell types _connectivity_new[(dim0, i0),
227 // (dim1, i1)] is the connection from (dim0, i0) -> (dim1, i1),
228 // where dim0 and dim1 are topological dimensions and i0 and i1
229 // are the indices of cell types (following the order in _entity_types).
230 std::map<std::pair<std::array<int, 2>, std::array<int, 2>>,
231 std::shared_ptr<graph::AdjacencyList<std::int32_t>>>
232 _connectivity;
233
234 // The facet permutations (local facet, cell))
235 // [cell0_0, cell0_1, ,cell0_2, cell1_0, cell1_1, ,cell1_2, ...,
236 // celln_0, celln_1, ,celln_2,]
237 std::vector<std::uint8_t> _facet_permutations;
238
239 // Cell permutation info. See the documentation for
240 // get_cell_permutation_info for documentation of how this is encoded.
241 std::vector<std::uint32_t> _cell_permutations;
242
243 // List of facets that are on the inter-process boundary for each
244 // facet type. _interprocess_facets[i] is the inter-process facets of
245 // facet type i.
246 std::vector<std::vector<std::int32_t>> _interprocess_facets;
247};
248
277create_topology(MPI_Comm comm, const std::vector<CellType>& cell_types,
278 std::vector<std::span<const std::int64_t>> cells,
279 std::vector<std::span<const std::int64_t>> original_cell_index,
280 std::vector<std::span<const int>> ghost_owners,
281 std::span<const std::int64_t> boundary_vertices);
282
306Topology create_topology(MPI_Comm comm, std::span<const std::int64_t> cells,
307 std::span<const std::int64_t> original_cell_index,
308 std::span<const int> ghost_owners, CellType cell_type,
309 std::span<const std::int64_t> boundary_vertices);
310
323std::tuple<Topology, std::vector<int32_t>, std::vector<int32_t>>
324create_subtopology(const Topology& topology, int dim,
325 std::span<const std::int32_t> entities);
326
336std::vector<std::int32_t>
337entities_to_index(const Topology& topology, int dim,
338 std::span<const std::int32_t> entities);
339
357std::vector<std::vector<std::int32_t>>
358compute_mixed_cell_pairs(const Topology& topology, mesh::CellType facet_type);
359
360} // namespace dolfinx::mesh
Definition IndexMap.h:94
This class provides a static adjacency list data structure.
Definition AdjacencyList.h:37
std::shared_ptr< const common::IndexMap > index_map(int dim) const
Get the IndexMap that described the parallel distribution of the mesh entities.
Definition Topology.cpp:823
void create_connectivity(int d0, int d1)
Create connectivity between given pair of dimensions, d0 / -> d1.
Definition Topology.cpp:950
std::vector< std::vector< std::int64_t > > original_cell_index
Original cell index for each cell type.
Definition Topology.h:206
void create_entity_permutations()
Compute entity permutations and reflections.
Definition Topology.cpp:990
const std::vector< std::uint32_t > & get_cell_permutation_info() const
Returns the permutation information.
Definition Topology.cpp:852
std::shared_ptr< const graph::AdjacencyList< std::int32_t > > connectivity(std::array< int, 2 > d0, std::array< int, 2 > d1) const
Get the connectivity from entities of topological dimension d0 to dimension d1.
Definition Topology.cpp:832
const std::vector< std::uint8_t > & get_facet_permutations() const
Get the numbers that encode the number of permutations to apply to facets.
Definition Topology.cpp:867
Topology(const Topology &topology)=default
Copy constructor.
~Topology()=default
Destructor.
Topology(std::vector< CellType > cell_types, std::shared_ptr< const common::IndexMap > vertex_map, std::vector< std::shared_ptr< const common::IndexMap > > cell_maps, std::vector< std::shared_ptr< graph::AdjacencyList< std::int32_t > > > cells, const std::optional< std::vector< std::vector< std::int64_t > > > &original_cell_index=std::nullopt)
Create a mesh topology.
Definition Topology.cpp:741
const std::vector< CellType > & entity_types(int dim) const
Entity types in the topology for a given dimension.
Definition Topology.cpp:790
int dim() const noexcept
Topological dimension of the mesh.
Definition Topology.cpp:785
const std::vector< std::int32_t > & interprocess_facets(int index) const
List of inter-process facets of a given type.
Definition Topology.cpp:881
Topology(Topology &&topology)=default
Move constructor.
std::vector< CellType > cell_types() const
Get the types of cells in the topology.
Definition Topology.cpp:805
Topology & operator=(const Topology &topology)=delete
Assignment.
MPI_Comm comm() const
Mesh MPI communicator.
Definition Topology.cpp:1010
CellType cell_type() const
Cell type.
Definition Topology.cpp:795
bool create_entities(int dim)
Create entities of given topological dimension.
Definition Topology.cpp:893
Topology & operator=(Topology &&topology)=default
Assignment.
std::vector< std::shared_ptr< const common::IndexMap > > index_maps(int dim) const
Get the index maps that described the parallel distribution of the mesh entities of a given topologic...
Definition Topology.cpp:811
Miscellaneous classes, functions and types.
Definition dolfinx_common.h:8
Graph data structures and algorithms.
Definition AdjacencyList.h:20
Mesh data structures and algorithms on meshes.
Definition DofMap.h:32
Topology create_topology(MPI_Comm comm, const std::vector< CellType > &cell_types, std::vector< std::span< const std::int64_t > > cells, std::vector< std::span< const std::int64_t > > original_cell_index, std::vector< std::span< const int > > ghost_owners, std::span< const std::int64_t > boundary_vertices)
Create a mesh topology.
Definition Topology.cpp:1017
std::tuple< Topology, std::vector< int32_t >, std::vector< int32_t > > create_subtopology(const Topology &topology, int dim, std::span< const std::int32_t > entities)
Create a topology for a subset of entities of a given topological dimension.
Definition Topology.cpp:1303
CellType
Cell type identifier.
Definition cell_types.h:22
std::vector< std::vector< std::int32_t > > compute_mixed_cell_pairs(const Topology &topology, mesh::CellType facet_type)
Compute a list of cell-cell connections for each possible combination in the topology which have the ...
Definition Topology.cpp:1444
std::vector< std::int32_t > entities_to_index(const Topology &topology, int dim, std::span< const std::int32_t > entities)
Get entity indices for entities defined by their vertices.
Definition Topology.cpp:1386