Ifpack2 Templated Preconditioning Package  Version 1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Ifpack2_LinearPartitioner_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_LINEAR_PARTITIONER_DEF_HPP
11 #define IFPACK2_LINEAR_PARTITIONER_DEF_HPP
12 #include "Ifpack2_ConfigDefs.hpp"
13 #include "Ifpack2_LinearPartitioner_decl.hpp"
14 
15 namespace Ifpack2 {
16 
17 //==============================================================================
18 // Constructor
19 template<class GraphType>
22  OverlappingPartitioner<GraphType> (graph)
23 {}
24 
25 
26 template<class GraphType>
28 
29 
30 template<class GraphType>
31 void
34 
35 
36 template<class GraphType>
38 {
39  using Teuchos::as;
40  // Partition_ is an array of local_ordinal_type. local_ordinal_type
41  // may be signed or unsigned. NumLocalParts_ is int, and needs to
42  // be signed, since negative values are significant. Comparisons
43  // between signed and unsigned integers often result in compiler
44  // warnings, which is why we use as() for explicit conversions
45  // below. We also use as() because in a debug build, it checks for
46  // overflow.
47  const int mod = as<int> (this->Graph_->getLocalNumRows () /
48  this->NumLocalParts_);
49  for (size_t i = 0; i < this->Graph_->getLocalNumRows (); ++i) {
50  this->Partition_[i] = as<local_ordinal_type> (i / mod);
51  if (this->Partition_[i] >= as<local_ordinal_type> (this->NumLocalParts_)) {
52  this->Partition_[i] = this->NumLocalParts_ - 1;
53  }
54  }
55 }
56 
57 
58 }// namespace Ifpack2
59 
60 #define IFPACK2_LINEARPARTITIONER_INSTANT(LO,GO,N) \
61  template class Ifpack2::LinearPartitioner<Tpetra::CrsGraph< LO, GO, N > >; \
62  template class Ifpack2::LinearPartitioner<Tpetra::RowGraph< LO, GO, N > >;
63 
64 #endif // IFPACK2_LINEARPARTITIONER_DEF_HPP
void computePartitions()
Compute the partitions.
Definition: Ifpack2_LinearPartitioner_def.hpp:37
virtual ~LinearPartitioner()
Destructor.
Definition: Ifpack2_LinearPartitioner_def.hpp:27
LinearPartitioner(const Teuchos::RCP< const row_graph_type > &graph)
Constructor.
Definition: Ifpack2_LinearPartitioner_def.hpp:21
void setPartitionParameters(Teuchos::ParameterList &List)
Set the partitioner&#39;s parameters (none for linear partitioning).
Definition: Ifpack2_LinearPartitioner_def.hpp:33
TypeTo as(const TypeFrom &t)
Create overlapping partitions of a local graph.
Definition: Ifpack2_OverlappingPartitioner_decl.hpp:45