10 #ifndef IFPACK2_USER_PARTITIONER_DEF_HPP
11 #define IFPACK2_USER_PARTITIONER_DEF_HPP
13 #include <Ifpack2_ConfigDefs.hpp>
15 #include <Ifpack2_OverlappingPartitioner.hpp>
20 template <
class GraphType>
24 , userProvidedParts_(false)
25 , userProvidedMap_(false) {}
27 template <
class GraphType>
30 template <
class GraphType>
34 bool globalProvidedParts;
35 userProvidedParts_ = List.
isParameter(
"partitioner: parts");
36 globalProvidedParts = List.
isParameter(
"partitioner: global ID parts");
37 if (userProvidedParts_) partCount++;
38 if (globalProvidedParts) {
40 userProvidedParts_ =
true;
43 userProvidedMap_ = List.
isParameter(
"partitioner: map");
44 if (userProvidedMap_) partCount++;
47 "Ifpack2::UserPartitioner::setPartitionParameters: "
48 "you may specify only one of \"partitioner: parts\", \"partitioner: global ID parts\" and \"partitioner: map\","
51 if (userProvidedMap_) {
52 map_ = List.
get(
"partitioner: map", map_);
54 map_.is_null(), std::runtime_error,
55 "Ifpack2::UserPartitioner::"
56 "setPartitionParameters: map_ is null.");
58 if (userProvidedParts_) {
64 if (globalProvidedParts) {
66 gparts = List.
get<gparts_type>(
"partitioner: global ID parts");
68 map_type OverlapMap = List.
get<map_type>(
"OverlapRowMap");
69 this->Parts_.resize(gparts.size());
70 for (
int ii = 0; ii < (int)gparts.size(); ii++) {
71 this->Parts_[ii].resize(gparts[ii].size());
72 for (
int jj = 0; jj < (int)gparts[ii].size(); jj++) {
73 local_ordinal_type itmp = (int)OverlapMap->getLocalElement(gparts[ii][jj]);
75 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.");
76 this->Parts_[ii][jj] = itmp;
79 List.
remove(
"partitioner: global ID parts");
83 this->Parts_ = List.
get<parts_type>(
"partitioner: parts");
84 List.
remove(
"partitioner: parts");
91 template <
class GraphType>
93 if (userProvidedParts_) {
94 this->NumLocalParts_ = this->Parts_.size();
96 this->Partition_.resize(0);
99 map_.is_null(), std::logic_error,
100 "Ifpack2::UserPartitioner::"
101 "computePartitions: map_ is null.");
102 const size_t localNumRows = this->Graph_->getLocalNumRows();
103 for (
size_t ii = 0; ii < localNumRows; ++ii) {
104 this->Partition_[ii] = map_[ii];
114 #endif // IFPACK2_USERPARTITIONER_DEF_HPP
T & get(const std::string &name, T def_value)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
UserPartitioner(const Teuchos::RCP< const row_graph_type > &graph)
Constructor.
Definition: Ifpack2_Details_UserPartitioner_def.hpp:22
void computePartitions()
Compute the partitions.
Definition: Ifpack2_Details_UserPartitioner_def.hpp:92
Declaration of a user-defined partitioner in which the user can define a partition of the graph...
bool isParameter(const std::string &name) const
bool remove(std::string const &name, bool throwIfNotExists=true)
virtual ~UserPartitioner()
Destructor.
Definition: Ifpack2_Details_UserPartitioner_def.hpp:28
Create overlapping partitions of a local graph.
Definition: Ifpack2_OverlappingPartitioner_decl.hpp:45
void setPartitionParameters(Teuchos::ParameterList &List)
Sets all the parameters for the partitioner. The only valid parameters are:
Definition: Ifpack2_Details_UserPartitioner_def.hpp:32