3 #include "Teuchos_ArrayRCP.hpp" 4 #include "Teuchos_TestForException.hpp" 6 #include "TpetraExt_MatrixMatrix.hpp" 17 template <
typename CrsMatrixType>
22 typedef typename matrix_t::crs_graph_type
graph_t;
23 typedef typename matrix_t::node_type
node_t;
30 : matrix(matrix_), graph(matrix_->getCrsGraph())
39 Teuchos::ParameterList &coloring_params,
58 this->matrix->setAllToScalar(1.0);
60 if (!this->matrix->isFillComplete())
61 this->matrix->fillComplete();
63 const size_t nzpr = this->matrix->getGlobalMaxNumRowEntries();
64 matrix_t C(this->matrix->getRowMap(), nzpr * nzpr);
66 Tpetra::MatrixMatrix::Multiply(*(this->matrix),
true,
67 *(this->matrix),
false, C);
71 Z2Adapter_t z2_adapter(rcp(&C,
false));
73 Teuchos::ParameterList z2_params = coloring_params.sublist(
"Zoltan2");
82 Teuchos::ArrayRCP<int> local_list_of_colors = z2_solution->
getColorsRCP();
83 const size_t len = local_list_of_colors.size();
85 TEUCHOS_TEST_FOR_EXCEPTION(
86 len != this->graph->getColMap()->getNodeNumElements(), std::logic_error,
87 "Incorrect length of color list!");
90 local_list_of_colors.getRawPtr(), len);
93 list_of_colors_host = Kokkos::create_mirror_view(list_of_colors);
95 Kokkos::deep_copy(list_of_colors_host, list_of_colors_tmp);
96 Kokkos::deep_copy(list_of_colors, list_of_colors_host);
99 Teuchos::RCP<const Teuchos::Comm<int>> comm =
100 this->graph->getRowMap()->getComm();
101 Teuchos::reduceAll(*comm, Teuchos::REDUCE_MAX, 1,
102 &local_num_colors, &num_colors);
107 const Teuchos::RCP<matrix_t> matrix;
108 const Teuchos::RCP<const graph_t> graph;
114 template <
typename SC,
typename LO,
typename GO,
typename NO>
118 typedef Tpetra::BlockCrsMatrix<SC, LO, GO, NO>
matrix_t;
119 typedef typename matrix_t::crs_graph_type
graph_t;
123 : matrix(matrix_), graph(matrix_->getCrsGraph())
133 TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
134 "Zoltan2 colorer does not support " 135 "Tpetra::BlockCrsMatrix!");
140 const Teuchos::RCP<matrix_t> matrix;
141 const Teuchos::RCP<const graph_t> graph;
Tpetra::BlockCrsMatrix< SC, LO, GO, NO > matrix_t
matrix_t::node_type node_t
Created by mbenlioglu on Aug 31, 2020.
ColoringProblem sets up coloring problems for the user.
Defines the ColoringProblem class.
Provides access for Zoltan2 to Xpetra::CrsMatrix data.
void solve(bool updateInputData=true)
Direct the problem to create a solution.
ColoringSolution< Adapter > * getSolution()
Get the solution to the problem.
matrix_t::crs_graph_type graph_t
void computeColoring(Teuchos::ParameterList &coloring_params, int &num_colors, list_of_colors_host_t &list_of_colors_host, list_of_colors_t &list_of_colors)
int getNumColors()
Get local number of colors. This is computed from the coloring each time, as this is cheap...
Defines the XpetraCrsMatrixAdapter class.
ArrayRCP< int > & getColorsRCP()
Get (local) color array by RCP.
Zoltan2CrsColorer(const Teuchos::RCP< matrix_t > &matrix_)
Kokkos::View< int *, device_t > list_of_colors_t
void computeColoring(Teuchos::ParameterList &coloring_params)
node_t::device_type device_t
Defines the ColoringSolution class.
matrix_t::crs_graph_type graph_t
list_of_colors_t::HostMirror list_of_colors_host_t
Zoltan2CrsColorer(const Teuchos::RCP< matrix_t > &matrix_)
The class containing coloring solution.