Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.2.0a0/v0.9.0/cpp
DOLFINx  0.2.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;
78 
83  void set_index_map(int dim,
84  const std::shared_ptr<const common::IndexMap>& map);
85 
90  std::shared_ptr<const common::IndexMap> index_map(int dim) const;
91 
98  std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
99  connectivity(int d0, int d1) const;
100 
103  void set_connectivity(std::shared_ptr<graph::AdjacencyList<std::int32_t>> c,
104  int d0, int d1);
105 
107  const std::vector<std::uint32_t>& get_cell_permutation_info() const;
108 
118  const std::vector<std::uint8_t>& get_facet_permutations() const;
119 
122  mesh::CellType cell_type() const;
123 
124  // TODO: Rework memory management and associated API
125  // Currently, there is no clear caching policy implemented and no way of
126  // discarding cached data.
127 
128  // creation of entities
133  std::int32_t create_entities(int dim);
134 
138  void create_connectivity(int d0, int d1);
139 
141  void create_entity_permutations();
142 
144  void create_connectivity_all();
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  // IndexMap to store ghosting for each entity dimension
158  std::array<std::shared_ptr<const common::IndexMap>, 4> _index_map;
159 
160  // AdjacencyList for pairs of topological dimensions
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
dolfinx::mesh
Mesh data structures and algorithms on meshes.
Definition: DirichletBC.h:19
dolfinx::mesh::CellType
CellType
Cell type identifier.
Definition: cell_types.h:21
dolfinx::graph
Graph data structures and algorithms.
Definition: AdjacencyList.h:18
dolfinx::graph::AdjacencyList
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:46
dolfinx::mesh::GhostMode
GhostMode
Enum for different partitioning ghost modes.
Definition: Mesh.h:43
dolfinx::mesh::create_topology
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:308
dolfinx::common
Miscellaneous classes, functions and types.
dolfinx::MPI::Comm
A duplicate MPI communicator and manage lifetime of the communicator.
Definition: MPI.h:31
dolfinx::fem
Finite element method functionality.
Definition: assemble_matrix_impl.h:22
dolfinx::mesh::Topology
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:55
dolfinx::mesh::compute_boundary_facets
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:124