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 <vector>
14#include <xtl/xspan.hpp>
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;
30
31enum class CellType;
32class Topology;
33
43std::vector<std::int8_t> compute_boundary_facets(const Topology& topology);
44
57{
58public:
60 Topology(MPI_Comm comm, CellType type);
61
63 Topology(const Topology& topology) = default;
64
66 Topology(Topology&& topology) = default;
67
69 ~Topology() = default;
70
72 Topology& operator=(const Topology& topology) = delete;
73
75 Topology& operator=(Topology&& topology) = default;
76
78 int dim() const noexcept;
79
84 void set_index_map(int dim,
85 const std::shared_ptr<const common::IndexMap>& map);
86
93 std::shared_ptr<const common::IndexMap> index_map(int dim) const;
94
103 std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
104 connectivity(int d0, int d1) const;
105
108 void set_connectivity(std::shared_ptr<graph::AdjacencyList<std::int32_t>> c,
109 int d0, int d1);
110
112 const std::vector<std::uint32_t>& get_cell_permutation_info() const;
113
126 const std::vector<std::uint8_t>& get_facet_permutations() const;
127
130 CellType cell_type() const noexcept;
131
136 std::int32_t create_entities(int dim);
137
142 void create_connectivity(int d0, int d1);
143
146
148 std::vector<std::int64_t> original_cell_index;
149
152 MPI_Comm comm() const;
153
154private:
155 // MPI communicator
156 dolfinx::MPI::Comm _comm;
157
158 // Cell type
159 CellType _cell_type;
160
161 // Parallel layout of entities for each dimension
162 std::array<std::shared_ptr<const common::IndexMap>, 4> _index_map;
163
164 // AdjacencyList for pairs [d0][d1] == d0 -> d1 connectivity
165 std::vector<std::vector<std::shared_ptr<graph::AdjacencyList<std::int32_t>>>>
166 _connectivity;
167
168 // The facet permutations (local facet, cell))
169 // [cell0_0, cell0_1, ,cell0_2, cell1_0, cell1_1, ,cell1_2, ...,
170 // celln_0, celln_1, ,celln_2,]
171 std::vector<std::uint8_t> _facet_permutations;
172
173 // Cell permutation info. See the documentation for
174 // get_cell_permutation_info for documentation of how this is encoded.
175 std::vector<std::uint32_t> _cell_permutations;
176};
177
196create_topology(MPI_Comm comm, const graph::AdjacencyList<std::int64_t>& cells,
197 const xtl::span<const std::int64_t>& original_cell_index,
198 const xtl::span<const int>& ghost_owners,
199 const CellType& cell_type, GhostMode ghost_mode);
200
211std::vector<std::int32_t>
212entities_to_index(const Topology& topology, int dim,
213 const graph::AdjacencyList<std::int32_t>& entities);
214} // namespace dolfinx::mesh
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:57
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:775
void create_connectivity(int d0, int d1)
Create connectivity between given pair of dimensions, d0 -> d1.
Definition: Topology.cpp:807
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:856
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:863
void create_entity_permutations()
Compute entity permutations and reflections.
Definition: Topology.cpp:835
std::int32_t create_entities(int dim)
Create entities of given topological dimension.
Definition: Topology.cpp:781
const std::vector< std::uint32_t > & get_cell_permutation_info() const
Returns the permutation information.
Definition: Topology.cpp:871
Topology(MPI_Comm comm, CellType type)
Create empty mesh topology.
Definition: Topology.cpp:756
const std::vector< std::uint8_t > & get_facet_permutations() const
Get the permutation number to apply to a facet.
Definition: Topology.cpp:886
Topology(const Topology &topology)=default
Copy constructor.
~Topology()=default
Destructor.
int dim() const noexcept
Return the topological dimension of the mesh.
Definition: Topology.cpp:766
void set_index_map(int dim, const std::shared_ptr< const common::IndexMap > &map)
Definition: Topology.cpp:768
std::vector< std::int64_t > original_cell_index
Original cell index.
Definition: Topology.h:148
Topology(Topology &&topology)=default
Move constructor.
Topology & operator=(const Topology &topology)=delete
Assignment.
MPI_Comm comm() const
Mesh MPI communicator.
Definition: Topology.cpp:902
CellType cell_type() const noexcept
Cell type.
Definition: Topology.cpp:900
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:27
Topology create_topology(MPI_Comm comm, const graph::AdjacencyList< std::int64_t > &cells, const xtl::span< const std::int64_t > &original_cell_index, const xtl::span< const int > &ghost_owners, const CellType &cell_type, GhostMode ghost_mode)
Create a distributed mesh topology.
Definition: Topology.cpp:905
std::vector< std::int8_t > compute_boundary_facets(const Topology &topology)
Compute marker for owned facets that are on the exterior of the domain, i.e. are connected to only on...
Definition: Topology.cpp:702
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:1191
CellType
Cell type identifier.
Definition: cell_types.h:22