DOLFINx
DOLFINx C++ interface
Topology.h
1// Copyright (C) 2006-2022 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 <memory>
13#include <span>
14#include <vector>
15
16namespace dolfinx::common
17{
18class IndexMap;
19}
20
21namespace dolfinx::graph
22{
23template <typename T>
24class AdjacencyList;
25}
26
27namespace dolfinx::mesh
28{
29enum class GhostMode : int;
30enum class CellType;
31
44{
45public:
47 Topology(MPI_Comm comm, CellType type);
48
50 Topology(const Topology& topology) = default;
51
53 Topology(Topology&& topology) = default;
54
56 ~Topology() = default;
57
59 Topology& operator=(const Topology& topology) = delete;
60
62 Topology& operator=(Topology&& topology) = default;
63
65 int dim() const noexcept;
66
71 void set_index_map(int dim,
72 const std::shared_ptr<const common::IndexMap>& map);
73
80 std::shared_ptr<const common::IndexMap> index_map(int dim) const;
81
90 std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
91 connectivity(int d0, int d1) const;
92
95 void set_connectivity(std::shared_ptr<graph::AdjacencyList<std::int32_t>> c,
96 int d0, int d1);
97
99 const std::vector<std::uint32_t>& get_cell_permutation_info() const;
100
113 const std::vector<std::uint8_t>& get_facet_permutations() const;
114
117 CellType cell_type() const noexcept;
118
123 std::int32_t create_entities(int dim);
124
129 void create_connectivity(int d0, int d1);
130
133
135 std::vector<std::int64_t> original_cell_index;
136
139 MPI_Comm comm() const;
140
141private:
142 // MPI communicator
143 dolfinx::MPI::Comm _comm;
144
145 // Cell type
146 CellType _cell_type;
147
148 // Parallel layout of entities for each dimension
149 std::array<std::shared_ptr<const common::IndexMap>, 4> _index_map;
150
151 // AdjacencyList for pairs [d0][d1] == d0 -> d1 connectivity
152 std::vector<std::vector<std::shared_ptr<graph::AdjacencyList<std::int32_t>>>>
153 _connectivity;
154
155 // The facet permutations (local facet, cell))
156 // [cell0_0, cell0_1, ,cell0_2, cell1_0, cell1_1, ,cell1_2, ...,
157 // celln_0, celln_1, ,celln_2,]
158 std::vector<std::uint8_t> _facet_permutations;
159
160 // Cell permutation info. See the documentation for
161 // get_cell_permutation_info for documentation of how this is encoded.
162 std::vector<std::uint32_t> _cell_permutations;
163};
164
183create_topology(MPI_Comm comm, const graph::AdjacencyList<std::int64_t>& cells,
184 const std::span<const std::int64_t>& original_cell_index,
185 const std::span<const int>& ghost_owners,
186 const CellType& cell_type, GhostMode ghost_mode);
187
198std::vector<std::int32_t>
199entities_to_index(const Topology& topology, int dim,
200 const graph::AdjacencyList<std::int32_t>& entities);
201} // namespace dolfinx::mesh
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:44
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:785
void create_connectivity(int d0, int d1)
Create connectivity between given pair of dimensions, d0 -> d1.
Definition: Topology.cpp:817
std::shared_ptr< const graph::AdjacencyList< std::int32_t > > connectivity(int d0, int d1) const
Return connectivity from entities of dimension d0 to entities of dimension d1.
Definition: Topology.cpp:866
void set_connectivity(std::shared_ptr< graph::AdjacencyList< std::int32_t > > c, int d0, int d1)
Set connectivity for given pair of topological dimensions.
Definition: Topology.cpp:873
void create_entity_permutations()
Compute entity permutations and reflections.
Definition: Topology.cpp:845
std::int32_t create_entities(int dim)
Create entities of given topological dimension.
Definition: Topology.cpp:791
const std::vector< std::uint32_t > & get_cell_permutation_info() const
Returns the permutation information.
Definition: Topology.cpp:881
Topology(MPI_Comm comm, CellType type)
Create empty mesh topology.
Definition: Topology.cpp:766
const std::vector< std::uint8_t > & get_facet_permutations() const
Get the permutation number to apply to a facet.
Definition: Topology.cpp:896
Topology(const Topology &topology)=default
Copy constructor.
~Topology()=default
Destructor.
int dim() const noexcept
Return the topological dimension of the mesh.
Definition: Topology.cpp:776
void set_index_map(int dim, const std::shared_ptr< const common::IndexMap > &map)
Definition: Topology.cpp:778
std::vector< std::int64_t > original_cell_index
Original cell index.
Definition: Topology.h:135
Topology(Topology &&topology)=default
Move constructor.
Topology & operator=(const Topology &topology)=delete
Assignment.
MPI_Comm comm() const
Mesh MPI communicator.
Definition: Topology.cpp:912
CellType cell_type() const noexcept
Cell type.
Definition: Topology.cpp:910
Topology & operator=(Topology &&topology)=default
Assignment.
Miscellaneous classes, functions and types.
Graph data structures and algorithms.
Definition: dofmapbuilder.h:25
Mesh data structures and algorithms on meshes.
Definition: DofMap.h:30
GhostMode
Enum for different partitioning ghost modes.
Definition: utils.h:29
Topology create_topology(MPI_Comm comm, const graph::AdjacencyList< std::int64_t > &cells, const std::span< const std::int64_t > &original_cell_index, const std::span< const int > &ghost_owners, const CellType &cell_type, GhostMode ghost_mode)
Create a distributed mesh topology.
Definition: Topology.cpp:915
std::vector< std::int32_t > entities_to_index(const Topology &topology, int dim, const graph::AdjacencyList< std::int32_t > &entities)
Get entity indices for entities defined by their vertices.
Definition: Topology.cpp:1201
CellType
Cell type identifier.
Definition: cell_types.h:22