86#ifdef NIMBLE_HAVE_TRILINOS
88 explicit TpetraMatrixContainer(Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal>> crs_matrix)
89 : crs_matrix_(crs_matrix)
94 SumIntoValue(LocalOrdinal local_row_index, GlobalOrdinal local_col_index,
Scalar value)
96 auto local_row =
static_cast<LocalOrdinal
>(local_row_index);
97 Teuchos::ArrayRCP<LocalOrdinal> local_cols;
98 Teuchos::ArrayRCP<Scalar> values;
100 LocalOrdinal success = crs_matrix_->sumIntoLocalValues(local_row, local_cols(), values());
102 if (success == Teuchos::OrdinalTraits<LocalOrdinal>::invalid()) {
104 "\nError in TpetraMatrixContainer::sumIntoValue(), "
105 "replaceLocalValues() failed.\n");
106 }
else if (success != 1) {
107 NIMBLE_ABORT(
"\nError in TpetraMatrixContainer::sumIntoValue(), invalid index.\n");
109 std::cout <<
"DJL DEBUGGING TpetraMatrixContainer::sumIntoValue() success! " << success << std::endl;
113 Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal>> crs_matrix_;
121#ifdef NIMBLE_HAVE_TRILINOS
122 typedef Tpetra::Map<> map_type;
123 typedef Tpetra::Vector<> vector_type;
124 typedef Tpetra::Vector<>::scalar_type scalar_type;
125 typedef Tpetra::Vector<>::local_ordinal_type local_ordinal_type;
126 typedef Tpetra::Vector<>::global_ordinal_type global_ordinal_type;
127 typedef Tpetra::Import<local_ordinal_type, global_ordinal_type> import_type;
128 typedef Tpetra::Export<local_ordinal_type, global_ordinal_type> export_type;
129 typedef Tpetra::CrsGraph<local_ordinal_type, global_ordinal_type> graph_type;
130 typedef Tpetra::CrsMatrix<scalar_type, local_ordinal_type, global_ordinal_type> matrix_type;
132 template <
typename LocalOrdinal,
typename GlobalOrdinal>
133 class SimpleTieBreak :
public Tpetra::Details::TieBreak<LocalOrdinal, GlobalOrdinal>
136 selectedIndex(GlobalOrdinal GID,
const std::vector<std::pair<int, LocalOrdinal>>& pid_and_lid)
const
138 std::size_t selected_index = 0;
139 int selected_pid = pid_and_lid[0].first;
140 for (
unsigned int i = 0; i < pid_and_lid.size(); i++) {
141 int pid = pid_and_lid[i].first;
142 if (pid < selected_pid) {
147 return selected_index;
158 Initialize(
int d,
unsigned int n,
comm_type comm, std::vector<int>
const& global_node_ids);
172#ifdef NIMBLE_HAVE_TRILINOS
174 GetTpetraMatrixContainer()
176 return crs_matrix_container_;
189#ifdef NIMBLE_HAVE_TRILINOS
191 Teuchos::RCP<vector_type> vec_1d_;
192 Teuchos::RCP<vector_type> vec_1d_one_to_one_;
193 Teuchos::RCP<vector_type> vec_3d_;
194 Teuchos::RCP<vector_type> vec_3d_one_to_one_;
195 Teuchos::RCP<export_type> export_into_vec_1d_one_to_one_;
196 Teuchos::RCP<import_type> import_from_vec_1d_one_to_one_;
197 Teuchos::RCP<export_type> export_into_vec_3d_one_to_one_;
198 Teuchos::RCP<import_type> import_from_vec_3d_one_to_one_;
199 Teuchos::RCP<matrix_type> crs_matrix_;