41 auto inputMat = this->matrix;
43 const auto matrixType = coloring_params.get(
"matrixType",
"Jacobian");
44 const auto symmetric = coloring_params.get(
45 "symmetric", (matrixType ==
"Jacobian" ?
false :
true));
51 const auto nzpr = this->matrix->getGlobalMaxNumRowEntries();
54 Teuchos::rcp(
new CrsMatrixType(matrix->getRowMap(), nzpr * nzpr));
56 Tpetra::MatrixMatrix::Add(*(this->matrix),
false, 1.0, *(this->matrix),
59 inputMat->fillComplete();
64 Z2Adapter_t z2_adapter(inputMat);
66 auto z2_params = coloring_params.sublist(
"Zoltan2");
69 z2_params.set(
"color_method",
"D2");
76 auto local_num_colors = z2_solution->getNumColors();
78 auto local_list_of_colors = z2_solution->getColorsRCP();
79 const auto len = local_list_of_colors.size();
82 auto comm = this->graph->getRowMap()->getComm();
83 Teuchos::reduceAll(*comm, Teuchos::REDUCE_MAX, 1, &local_num_colors,
90 colorVecLocal_.getLocalViewHost(Tpetra::Access::ReadWrite);
91 auto local_colors = Kokkos::subview(colors_mv, Kokkos::ALL(), 0);
93 TEUCHOS_TEST_FOR_EXCEPTION(
94 local_colors.extent(0) != list_of_colors_tmp.extent(0),
95 std::logic_error,
"Incorrect length of color list!");
97 for (
size_t i = 0; i < local_colors.extent(0); ++i) {
98 local_colors(i) = list_of_colors_tmp(i);
102 using Import_t = Tpetra::Import<
typename matrix_t::local_ordinal_type,
103 typename matrix_t::global_ordinal_type,
104 typename matrix_t::node_type>;
107 Import_t importer(matrix->getRowMap(), matrix->getColMap());
109 colorVecGlobal_.doImport(colorVecLocal_, importer, Tpetra::INSERT);
113 colorVecGlobal_.getLocalViewHost(Tpetra::Access::ReadOnly);
114 auto local_colors = Kokkos::subview(colors_mv, Kokkos::ALL(), 0);
115 const auto num_cols = this->matrix->getLocalNumCols();
117 TEUCHOS_TEST_FOR_EXCEPTION(local_colors.extent(0) != num_cols,
119 "Incorrect length of color list!");
122 list_of_colors_host = Kokkos::create_mirror_view(list_of_colors);
124 Kokkos::deep_copy(list_of_colors_host, local_colors);
125 Kokkos::deep_copy(list_of_colors, list_of_colors_host);