Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.1.0/v0.9.0/cpp
DOLFINx  0.1.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 
16 namespace dolfinx
17 {
18 namespace common
19 {
20 class IndexMap;
21 }
22 
23 namespace fem
24 {
25 class ElementDofLayout;
26 }
27 
28 namespace graph
29 {
30 template <typename T>
31 class AdjacencyList;
32 }
33 
34 namespace mesh
35 {
36 enum class GhostMode : int;
37 
38 enum class CellType;
39 class Topology;
40 
48 std::vector<bool> compute_boundary_facets(const Topology& topology);
49 
56 class Topology
57 {
58 public:
60  Topology(MPI_Comm comm, mesh::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;
79 
84  void set_index_map(int dim,
85  const std::shared_ptr<const common::IndexMap>& map);
86 
91  std::shared_ptr<const common::IndexMap> index_map(int dim) const;
92 
99  std::shared_ptr<const graph::AdjacencyList<std::int32_t>>
100  connectivity(int d0, int d1) const;
101 
104  void set_connectivity(std::shared_ptr<graph::AdjacencyList<std::int32_t>> c,
105  int d0, int d1);
106 
108  const std::vector<std::uint32_t>& get_cell_permutation_info() const;
109 
119  const std::vector<std::uint8_t>& get_facet_permutations() const;
120 
123  mesh::CellType cell_type() const;
124 
125  // TODO: Rework memory management and associated API
126  // Currently, there is no clear caching policy implemented and no way of
127  // discarding cached data.
128 
129  // creation of entities
134  std::int32_t create_entities(int dim);
135 
139  void create_connectivity(int d0, int d1);
140 
142  void create_entity_permutations();
143 
145  void create_connectivity_all();
146 
149  MPI_Comm mpi_comm() const;
150 
151 private:
152  // MPI communicator
153  dolfinx::MPI::Comm _mpi_comm;
154 
155  // Cell type
156  mesh::CellType _cell_type;
157 
158  // IndexMap to store ghosting for each entity dimension
159  std::array<std::shared_ptr<const common::IndexMap>, 4> _index_map;
160 
161  // AdjacencyList for pairs of topological dimensions
162  std::vector<std::vector<std::shared_ptr<graph::AdjacencyList<std::int32_t>>>>
163  _connectivity;
164 
165  // The facet permutations (local facet, cell))
166  // [cell0_0, cell0_1, ,cell0_2, cell1_0, cell1_1, ,cell1_2, ...,
167  // celln_0, celln_1, ,celln_2,]
168  std::vector<std::uint8_t> _facet_permutations;
169 
170  // Cell permutation info. See the documentation for
171  // get_cell_permutation_info for documentation of how this is encoded.
172  std::vector<std::uint32_t> _cell_permutations;
173 };
174 
192 Topology create_topology(MPI_Comm comm,
194  const std::vector<std::int64_t>& original_cell_index,
195  const std::vector<int>& ghost_owners,
196  const CellType& cell_type, mesh::GhostMode ghost_mode);
197 } // namespace mesh
198 } // namespace dolfinx
dolfinx::mesh::CellType
CellType
Cell type identifier.
Definition: cell_types.h:21
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:46
dolfinx::MPI::Comm
A duplicate MPI communicator and manage lifetime of the communicator.
Definition: MPI.h:35
dolfinx::mesh::Topology
Topology stores the topology of a mesh, consisting of mesh entities and connectivity (incidence relat...
Definition: Topology.h:56
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:120
dolfinx::mesh::create_topology
Topology create_topology(MPI_Comm comm, const graph::AdjacencyList< std::int64_t > &cells, const std::vector< std::int64_t > &original_cell_index, const std::vector< int > &ghost_owners, const CellType &cell_type, mesh::GhostMode ghost_mode)
Create distributed topology.
Definition: Topology.cpp:303