Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/dd/d37/partition_8h_source.html
DOLFINx  0.5.1
DOLFINx C++ interface
partition.h
1 // Copyright (C) 2020 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 <algorithm>
10 #include <cstdint>
11 #include <dolfinx/graph/AdjacencyList.h>
12 #include <functional>
13 #include <mpi.h>
14 #include <span>
15 #include <utility>
16 #include <vector>
17 
18 #include <iostream>
19 
20 namespace dolfinx::graph
21 {
22 
33 using partition_fn = std::function<graph::AdjacencyList<std::int32_t>(
34  MPI_Comm, int, const AdjacencyList<std::int64_t>&, bool)>;
35 
46 partition_graph(MPI_Comm comm, int nparts,
47  const AdjacencyList<std::int64_t>& local_graph, bool ghosting);
48 
52 namespace build
53 {
68 std::tuple<graph::AdjacencyList<std::int64_t>, std::vector<int>,
69  std::vector<std::int64_t>, std::vector<int>>
70 distribute(MPI_Comm comm, const graph::AdjacencyList<std::int64_t>& list,
71  const graph::AdjacencyList<std::int32_t>& destinations);
72 
96 std::vector<std::int64_t>
97 compute_ghost_indices(MPI_Comm comm,
98  const std::span<const std::int64_t>& owned_indices,
99  const std::span<const std::int64_t>& ghost_indices,
100  const std::span<const int>& ghost_owners);
101 
112 std::vector<std::int64_t>
115 
124 std::vector<std::int32_t>
125 compute_local_to_local(const std::span<const std::int64_t>& local0_to_global,
126  const std::span<const std::int64_t>& local1_to_global);
127 } // namespace build
128 
129 } // namespace dolfinx::graph
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition: AdjacencyList.h:26
std::vector< std::int64_t > compute_local_to_global_links(const graph::AdjacencyList< std::int64_t > &global, const graph::AdjacencyList< std::int32_t > &local)
Given an adjacency list with global, possibly non-contiguous, link indices and a local adjacency list...
Definition: partition.cpp:369
std::vector< std::int64_t > compute_ghost_indices(MPI_Comm comm, const std::span< const std::int64_t > &owned_indices, const std::span< const std::int64_t > &ghost_indices, const std::span< const int > &ghost_owners)
Take a set of distributed input global indices, including ghosts, and determine the new global indice...
Definition: partition.cpp:227
std::vector< std::int32_t > compute_local_to_local(const std::span< const std::int64_t > &local0_to_global, const std::span< const std::int64_t > &local1_to_global)
Compute a local0-to-local1 map from two local-to-global maps with common global indices.
Definition: partition.cpp:407
std::tuple< graph::AdjacencyList< std::int64_t >, std::vector< int >, std::vector< std::int64_t >, std::vector< int > > distribute(MPI_Comm comm, const graph::AdjacencyList< std::int64_t > &list, const graph::AdjacencyList< std::int32_t > &destinations)
Distribute adjacency list nodes to destination ranks.
Definition: partition.cpp:38
Graph data structures and algorithms.
Definition: dofmapbuilder.h:25
std::function< graph::AdjacencyList< std::int32_t >(MPI_Comm, int, const AdjacencyList< std::int64_t > &, bool)> partition_fn
Signature of functions for computing the parallel partitioning of a distributed graph.
Definition: partition.h:34
AdjacencyList< std::int32_t > partition_graph(MPI_Comm comm, int nparts, const AdjacencyList< std::int64_t > &local_graph, bool ghosting)
Partition graph across processes using the default graph partitioner.
Definition: partition.cpp:21