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.7.3
DOLFINx C++ interface
Loading...
Searching...
No Matches
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
20namespace dolfinx::graph
21{
22
25// See https://github.com/doxygen/doxygen/issues/9552
35using partition_fn = std::function<graph::AdjacencyList<std::int32_t>(
36 MPI_Comm, int, const AdjacencyList<std::int64_t>&, bool)>;
37
49partition_graph(MPI_Comm comm, int nparts,
50 const AdjacencyList<std::int64_t>& local_graph, bool ghosting);
51
55namespace build
56{
71std::tuple<graph::AdjacencyList<std::int64_t>, std::vector<int>,
72 std::vector<std::int64_t>, std::vector<int>>
73distribute(MPI_Comm comm, const graph::AdjacencyList<std::int64_t>& list,
74 const graph::AdjacencyList<std::int32_t>& destinations);
75
99std::vector<std::int64_t>
100compute_ghost_indices(MPI_Comm comm,
101 std::span<const std::int64_t> owned_indices,
102 std::span<const std::int64_t> ghost_indices,
103 std::span<const int> ghost_owners);
104
115std::vector<std::int64_t>
116compute_local_to_global(std::span<const std::int64_t> global,
117 std::span<const std::int32_t> local);
118
127std::vector<std::int32_t>
128compute_local_to_local(std::span<const std::int64_t> local0_to_global,
129 std::span<const std::int64_t> local1_to_global);
130} // namespace build
131
132} // namespace dolfinx::graph
This class provides a static adjacency list data structure. It is commonly used to store directed gra...
Definition AdjacencyList.h:28
std::vector< std::int64_t > compute_ghost_indices(MPI_Comm comm, std::span< const std::int64_t > owned_indices, std::span< const std::int64_t > ghost_indices, 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:228
std::vector< std::int64_t > compute_local_to_global(std::span< const std::int64_t > global, std::span< const std::int32_t > local)
Given an adjacency list with global, possibly non-contiguous, link indices and a local adjacency list...
Definition partition.cpp:378
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
std::vector< std::int32_t > compute_local_to_local(std::span< const std::int64_t > local0_to_global, 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:401
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:36
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