50 auto inputMat = this->matrix;
52 const auto matrixType = coloring_params.get(
"matrixType",
"Jacobian");
53 const auto symmetric = coloring_params.get(
54 "symmetric", (matrixType ==
"Jacobian" ?
false :
true));
60 const auto nzpr = this->matrix->getGlobalMaxNumRowEntries();
63 Teuchos::rcp(
new CrsMatrixType(matrix->getRowMap(), nzpr * nzpr));
65 Tpetra::MatrixMatrix::Add(*(this->matrix),
false, 1.0, *(this->matrix),
68 inputMat->fillComplete();
73 Z2Adapter_t z2_adapter(inputMat);
75 auto z2_params = coloring_params.sublist(
"Zoltan2");
78 z2_params.set(
"color_method",
"D2");
85 auto local_num_colors = z2_solution->getNumColors();
87 auto local_list_of_colors = z2_solution->getColorsRCP();
88 const auto len = local_list_of_colors.size();
91 auto comm = this->graph->getRowMap()->getComm();
92 Teuchos::reduceAll(*comm, Teuchos::REDUCE_MAX, 1, &local_num_colors,
99 colorVecLocal_.getLocalViewHost(Tpetra::Access::ReadWrite);
100 auto local_colors = Kokkos::subview(colors_mv, Kokkos::ALL(), 0);
102 TEUCHOS_TEST_FOR_EXCEPTION(
103 local_colors.extent(0) != list_of_colors_tmp.extent(0),
104 std::logic_error,
"Incorrect length of color list!");
106 for (
size_t i = 0; i < local_colors.extent(0); ++i) {
107 local_colors(i) = list_of_colors_tmp(i);
111 using Import_t = Tpetra::Import<
typename matrix_t::local_ordinal_type,
112 typename matrix_t::global_ordinal_type,
113 typename matrix_t::node_type>;
116 Import_t importer(matrix->getRowMap(), matrix->getColMap());
118 colorVecGlobal_.doImport(colorVecLocal_, importer, Tpetra::INSERT);
122 colorVecGlobal_.getLocalViewHost(Tpetra::Access::ReadOnly);
123 auto local_colors = Kokkos::subview(colors_mv, Kokkos::ALL(), 0);
124 const auto num_cols = this->matrix->getLocalNumCols();
126 TEUCHOS_TEST_FOR_EXCEPTION(local_colors.extent(0) != num_cols,
128 "Incorrect length of color list!");
131 list_of_colors_host = Kokkos::create_mirror_view(list_of_colors);
133 Kokkos::deep_copy(list_of_colors_host, local_colors);
134 Kokkos::deep_copy(list_of_colors, list_of_colors_host);