Ifpack2 Templated Preconditioning Package
Version 1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Ifpack2_Zoltan2Partitioner_def.hpp
1
// @HEADER
2
// *****************************************************************************
3
// Ifpack2: Templated Object-Oriented Algebraic Preconditioner Package
4
//
5
// Copyright 2009 NTESS and the Ifpack2 contributors.
6
// SPDX-License-Identifier: BSD-3-Clause
7
// *****************************************************************************
8
// @HEADER
9
10
#ifndef IFPACK2_ZOLTAN2_PARTITIONER_DEF_HPP
11
#define IFPACK2_ZOLTAN2_PARTITIONER_DEF_HPP
12
13
#if defined(HAVE_IFPACK2_ZOLTAN2)
14
#include "Ifpack2_ConfigDefs.hpp"
15
#include "Ifpack2_Zoltan2Partitioner_decl.hpp"
16
17
namespace
Ifpack2
{
18
19
//==============================================================================
20
// Constructor
21
template
<
class
GraphType>
22
Zoltan2Partitioner<GraphType>::
23
Zoltan2Partitioner(
const
Teuchos::RCP<const row_graph_type>& graph)
24
:
OverlappingPartitioner
<GraphType>(graph)
25
, zoltan2AlgoName_(
"phg"
) {}
26
27
template
<
class
GraphType>
28
Zoltan2Partitioner<GraphType>::~Zoltan2Partitioner() {}
29
30
template
<
class
GraphType>
31
void
Zoltan2Partitioner<GraphType>::
32
setPartitionParameters(Teuchos::ParameterList& List) {
33
// Default is Parallel Hypergraph
34
zoltan2AlgoName_ = List.get<std::string>(
"zoltan2: algorithm"
, zoltan2AlgoName_);
35
}
36
37
template
<
class
GraphType>
38
void
Zoltan2Partitioner<GraphType>::computePartitions() {
39
// Create an input adapter for the Tpetra matrix.
40
Zoltan2GraphAdapterType zoltan2_graph(this->Graph_);
41
42
// Specify partitioning parameters
43
Teuchos::ParameterList zoltan2_params;
44
zoltan2_params.set(
"partitioning_approach"
,
"partition"
);
45
zoltan2_params.set(
"num_local_parts"
, this->NumLocalParts_);
46
if
(zoltan2AlgoName_ ==
"parmetis"
) {
47
zoltan2_params.set(
"algorithm"
,
"parmetis"
);
48
zoltan2_params.set(
"symmetrize_input"
,
"transpose"
);
// not sure if this does anything, and may fail with non-symm graph
49
zoltan2_params.set(
"partitioning_objective"
,
"minimize_cut_edge_weight"
);
50
}
else
{
51
zoltan2_params.set(
"algorithm"
, zoltan2AlgoName_);
52
}
53
54
// Create and solve partitioning problem
55
Zoltan2::PartitioningProblem<Zoltan2GraphAdapterType>
56
problem(&zoltan2_graph, &zoltan2_params, this->Graph_->getComm());
57
problem.solve();
58
59
// Save partition
60
auto
parts = problem.getSolution().getPartListView();
61
for
(
size_t
i = 0; i < this->Graph_->getLocalNumRows(); ++i) {
62
this->Partition_[i] = parts[i];
63
}
64
}
65
66
}
// namespace Ifpack2
67
68
#define IFPACK2_ZOLTAN2PARTITIONER_INSTANT(LO, GO, N) \
69
template class Ifpack2::Zoltan2Partitioner<Tpetra::CrsGraph<LO, GO, N> >; \
70
template class Ifpack2::Zoltan2Partitioner<Tpetra::RowGraph<LO, GO, N> >;
71
72
#endif
// HAVE_IFPACK2_ZOLTAN2
73
#endif
// IFPACK2_ZOLTAN2PARTITIONER_DEF_HPP
Ifpack2::OverlappingPartitioner
Create overlapping partitions of a local graph.
Definition
Ifpack2_OverlappingPartitioner_decl.hpp:45
Ifpack2
Preconditioners and smoothers for Tpetra sparse matrices.
Definition
Ifpack2_AdditiveSchwarz_decl.hpp:40
Generated by
1.17.0