43#ifndef IFPACK2_USER_PARTITIONER_DEF_HPP
44#define IFPACK2_USER_PARTITIONER_DEF_HPP
46#include <Ifpack2_ConfigDefs.hpp>
48#include <Ifpack2_OverlappingPartitioner.hpp>
53template<
class GraphType>
57 userProvidedParts_(false),
58 userProvidedMap_(false)
61template<
class GraphType>
64template<
class GraphType>
70 bool globalProvidedParts;
71 userProvidedParts_ = List.isParameter(
"partitioner: parts");
72 globalProvidedParts = List.isParameter(
"partitioner: global ID parts");
73 if ( userProvidedParts_) partCount++;
74 if (globalProvidedParts ) { partCount++; userProvidedParts_ =
true; }
76 userProvidedMap_ = List.isParameter(
"partitioner: map");
77 if ( userProvidedMap_) partCount++;
79 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::runtime_error,
"Ifpack2::UserPartitioner::setPartitionParameters: "
80 "you may specify only one of \"partitioner: parts\", \"partitioner: global ID parts\" and \"partitioner: map\","
83 if (userProvidedMap_) {
84 map_ = List.get (
"partitioner: map", map_);
85 TEUCHOS_TEST_FOR_EXCEPTION(
86 map_.is_null (), std::runtime_error,
"Ifpack2::UserPartitioner::"
87 "setPartitionParameters: map_ is null.");
89 if (userProvidedParts_) {
90 typedef Teuchos::Array<typename Teuchos::ArrayRCP<typename GraphType::local_ordinal_type>> parts_type;
91 typedef Teuchos::Array<typename Teuchos::ArrayRCP<typename GraphType::global_ordinal_type>> gparts_type;
95 if (globalProvidedParts ) {
97 gparts = List.get<gparts_type>(
"partitioner: global ID parts");
98 typedef Teuchos::RCP< Tpetra::Map<typename GraphType::local_ordinal_type, typename GraphType::global_ordinal_type, typename GraphType::node_type>
const > map_type;
99 map_type OverlapMap = List.get<map_type>(
"OverlapRowMap");
100 this->Parts_.resize(gparts.size());
101 for (
int ii = 0; ii < (int) gparts.size(); ii++) {
102 this->Parts_[ii].resize(gparts[ii].size());
103 for (
int jj = 0; jj < (int) gparts[ii].size(); jj++) {
104 local_ordinal_type itmp = (int) OverlapMap->getLocalElement( gparts[ii][jj] );
105 if (itmp == Teuchos::OrdinalTraits<local_ordinal_type>::invalid()) printf(
"global id %d (%d,%d) not found\n",(
int) gparts[ii][jj],(int) ii, (
int) jj);
106 TEUCHOS_TEST_FOR_EXCEPTION(itmp == Teuchos::OrdinalTraits<local_ordinal_type>::invalid(), std::runtime_error,
" \"partitioner: global ID parts\" requires that all global IDs within a block reside on the MPI rank owning the block. This can be done using overlapping Schwarz with a BLOCK_RELAXATION subdomain solver making sure that \"schwarz: overlap level\" is sufficient. Note: zeroed out Dirichlet columns will never be included in overlap parts of domains.");
107 this->Parts_[ii][jj] = itmp;
110 List.remove(
"partitioner: global ID parts");
115 this->Parts_ = List.get<parts_type>(
"partitioner: parts");
116 List.remove(
"partitioner: parts");
124template<
class GraphType>
127 if (userProvidedParts_) {
128 this->NumLocalParts_ = this->Parts_.size();
130 this->Partition_.resize(0);
132 TEUCHOS_TEST_FOR_EXCEPTION(
133 map_.is_null (), std::logic_error,
"Ifpack2::UserPartitioner::"
134 "computePartitions: map_ is null.");
135 const size_t localNumRows = this->Graph_->getLocalNumRows ();
136 for (
size_t ii = 0; ii < localNumRows; ++ii) {
137 this->Partition_[ii] = map_[ii];
Declaration of a user-defined partitioner in which the user can define a partition of the graph....
virtual ~UserPartitioner()
Destructor.
Definition: Ifpack2_Details_UserPartitioner_def.hpp:62
void computePartitions()
Compute the partitions.
Definition: Ifpack2_Details_UserPartitioner_def.hpp:125
void setPartitionParameters(Teuchos::ParameterList &List)
Sets all the parameters for the partitioner. The only valid parameters are:
Definition: Ifpack2_Details_UserPartitioner_def.hpp:67
UserPartitioner(const Teuchos::RCP< const row_graph_type > &graph)
Constructor.
Definition: Ifpack2_Details_UserPartitioner_def.hpp:55
Create overlapping partitions of a local graph.
Definition: Ifpack2_OverlappingPartitioner_decl.hpp:78
Ifpack2 implementation details.
Preconditioners and smoothers for Tpetra sparse matrices.
Definition: Ifpack2_AdditiveSchwarz_decl.hpp:74