3#include "Teuchos_ArrayRCP.hpp"
4#include "Teuchos_TestForException.hpp"
6#include "TpetraExt_MatrixMatrix.hpp"
17template <
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()->getLocalNumElements(), 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;
115template <
typename SC,
typename LO,
typename GO,
typename NO>
119 typedef Tpetra::BlockCrsMatrix<SC, LO, GO, NO>
matrix_t;
120 typedef typename matrix_t::crs_graph_type
graph_t;
121 typedef typename matrix_t::node_type
node_t;
128 : matrix(matrix_), graph(
Teuchos::rcp(&(matrix->getCrsGraph()), false))
137 Teuchos::ParameterList &coloring_params,
142 using point_matrix_t = Tpetra::CrsMatrix<SC,LO,GO,NO>;
143 Teuchos::RCP<point_matrix_t> point_matrix = Teuchos::rcp(
new point_matrix_t(graph));
144 point_matrix->setAllToScalar(1.0);
145 point_matrix->fillComplete();
148 list_of_colors_host, list_of_colors);
153 const Teuchos::RCP<matrix_t> matrix;
154 const Teuchos::RCP<const graph_t> graph;
Defines the ColoringProblem class.
Defines the ColoringSolution class.
Defines the XpetraCrsMatrixAdapter class.
ColoringProblem sets up coloring problems for the user.
void solve(bool updateInputData=true)
Direct the problem to create a solution.
ColoringSolution< Adapter > * getSolution()
Get the solution to the problem.
The class containing coloring solution.
ArrayRCP< int > & getColorsRCP()
Get (local) color array by RCP.
int getNumColors()
Get local number of colors. This is computed from the coloring each time, as this is cheap.
Provides access for Zoltan2 to Xpetra::CrsMatrix data.
Kokkos::View< int *, device_t > list_of_colors_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)
matrix_t::crs_graph_type graph_t
list_of_colors_t::HostMirror list_of_colors_host_t
matrix_t::node_type node_t
Zoltan2CrsColorer(const Teuchos::RCP< matrix_t > &matrix_)
node_t::device_type device_t
Tpetra::BlockCrsMatrix< SC, LO, GO, NO > matrix_t
matrix_t::crs_graph_type graph_t
Kokkos::View< int *, device_t > list_of_colors_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)
node_t::device_type device_t
matrix_t::node_type node_t
list_of_colors_t::HostMirror list_of_colors_host_t
Zoltan2CrsColorer(const Teuchos::RCP< matrix_t > &matrix_)
Created by mbenlioglu on Aug 31, 2020.