Loading...
Searching...
No Matches
partition.h
// Copyright (C) 2020 Garth N. Wells
//
// This file is part of DOLFINx (https://www.fenicsproject.org)
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include "AdjacencyList.h"
#include <algorithm>
#include <cstdint>
#include <functional>
#include <mpi.h>
#include <span>
#include <utility>
#include <vector>
#include <iostream>
namespace dolfinx::graph
{
using partition_fn = std::function<graph::AdjacencyList<std::int32_t>(
MPI_Comm, int, const AdjacencyList<std::int64_t>&, bool)>;
AdjacencyList<std::int32_t>
partition_graph(MPI_Comm comm, int nparts,
const AdjacencyList<std::int64_t>& local_graph, bool ghosting);
namespace build
{
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);
std::tuple<std::vector<std::int64_t>, std::vector<int>,
std::vector<std::int64_t>, std::vector<int>>
distribute(MPI_Comm comm, std::span<const std::int64_t> list,
std::array<std::size_t, 2> shape,
const graph::AdjacencyList<std::int32_t>& destinations);
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);
std::vector<std::int64_t>
compute_local_to_global(std::span<const std::int64_t> global,
std::span<const std::int32_t> local);
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);
} // namespace build
} // namespace dolfinx::graph
dolfinx::graph::AdjacencyList
This class provides a static adjacency list data structure.
Definition AdjacencyList.h:38
dolfinx::graph::build
Definition partition.h:52
dolfinx::graph::build::compute_ghost_indices
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:394
dolfinx::graph::build::compute_local_to_global
std::vector< std::int64_t > compute_local_to_global(std::span< const std::int64_t > global, std::span< const std::int32_t > local)
Definition partition.cpp:534
dolfinx::graph::build::distribute
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
dolfinx::graph::build::compute_local_to_local
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:556
dolfinx::graph
Graph data structures and algorithms.
Definition AdjacencyList.h:20
dolfinx::graph::partition_fn
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:31
dolfinx::graph::partition_graph
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