Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.3.0/v0.9.0/cpp
DOLFINx  0.3.0
DOLFINx C++ interface
Topology.h
1 // Copyright (C) 2006-2019 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 "cell_types.h"
10 #include <array>
11 #include <cstdint>
12 #include <dolfinx/common/MPI.h>
13 #include <memory>
14 #include <vector>
15 #include <xtl/xspan.hpp>
16 
17 namespace dolfinx::common
18 {
19 class IndexMap;
20 }
21 
22 namespace dolfinx::fem
23 {
24 class ElementDofLayout;
25 }
26 
27 namespace dolfinx::graph
28 {
29 template <typename T>
30 class AdjacencyList;
31 }
32 
33 namespace dolfinx::mesh
34 {
35 enum class GhostMode : int;
36 
37 enum class CellType;
38 class Topology;
39 
47 std::vector<bool> compute_boundary_facets(const Topology& topology);
48 
55 class Topology
56 {
57 public:
59  Topology(MPI_Comm comm, mesh::CellType type);
60 
62  Topology(const Topology& topology) = default;
63 
65  Topology(Topology&& topology) = default;
66 
68  ~Topology() = default;
69 
71  Topology& operator=(const Topology& topology) = delete;
72 
74  Topology& operator=(Topology&& topology) = default;
75 
77  int dim() const noexcept;
78 
83  void set_index_map(int dim,
84  const std::shared_ptr<const common::IndexMap>& map);
85 
91  std::shared_ptr<const common::IndexMap> index_map(int dim) const;
92 
100  std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
101  connectivity(int d0, int d1) const;
102 
105  void set_connectivity(std::shared_ptr<graph::AdjacencyList<std::int32_t>> c,
106  int d0, int d1);
107 
109  const std::vector<std::uint32_t>& get_cell_permutation_info() const;
110 
122  const std::vector<std::uint8_t>& get_facet_permutations() const;
123 
126  mesh::CellType cell_type() const noexcept;
127 
128  // TODO: Rework memory management and associated API
129  // Currently, there is no clear caching policy implemented and no way of
130  // discarding cached data.
131 
136  std::int32_t create_entities(int dim);
137 
141  void create_connectivity(int d0, int d1);
142 
144  void create_entity_permutations();
145 
148  MPI_Comm mpi_comm() const;
149 
150 private:
151  // MPI communicator
152  dolfinx::MPI::Comm _mpi_comm;
153 
154  // Cell type
155  mesh::CellType _cell_type;
156 
157  // Parallel layout of entities for each dimension
158  std::array<std::shared_ptr<const common::IndexMap>, 4> _index_map;
159 
160  // AdjacencyList for pairs [d0][d1] == d0 -> d1 connectivity
161  std::vector<std::vector<std::shared_ptr<graph::AdjacencyList<std::int32_t>>>>
162  _connectivity;
163 
164  // The facet permutations (local facet, cell))
165  // [cell0_0, cell0_1, ,cell0_2, cell1_0, cell1_1, ,cell1_2, ...,
166  // celln_0, celln_1, ,celln_2,]
167  std::vector<std::uint8_t> _facet_permutations;
168 
169  // Cell permutation info. See the documentation for
170  // get_cell_permutation_info for documentation of how this is encoded.
171  std::vector<std::uint32_t> _cell_permutations;
172 };
173 
191 Topology
192 create_topology(MPI_Comm comm, const graph::AdjacencyList<std::int64_t>& cells,
193  const xtl::span<const std::int64_t>& original_cell_index,
194  const xtl::span<const int>& ghost_owners,
195  const CellType& cell_type, mesh::GhostMode ghost_mode);
196 } // namespace dolfinx::mesh
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:56
Topology & operator=(const Topology &topology)=delete
Assignment.
Topology & operator=(Topology &&topology)=default
Assignment.
Topology(Topology &&topology)=default
Move constructor.
Topology(const Topology &topology)=default
Copy constructor.
~Topology()=default
Destructor.
Miscellaneous classes, functions and types.
Finite element method functionality.
Definition: assemble_matrix_impl.h:23
Graph data structures and algorithms.
Definition: AdjacencyList.h:19
Mesh data structures and algorithms on meshes.
Definition: DirichletBC.h:20
std::vector< bool > 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:121
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, mesh::GhostMode ghost_mode)
Create distributed topology.
Definition: Topology.cpp:293
CellType
Cell type identifier.
Definition: cell_types.h:22
GhostMode
Enum for different partitioning ghost modes.
Definition: Mesh.h:44