10 #ifndef TPETRA_BLOCKCRSMATRIX_HELPERS_DEF_HPP
11 #define TPETRA_BLOCKCRSMATRIX_HELPERS_DEF_HPP
15 #include "Tpetra_BlockCrsMatrix.hpp"
16 #include "Tpetra_CrsMatrix.hpp"
17 #include "Tpetra_HashTable.hpp"
18 #include "Tpetra_Import.hpp"
19 #include "Tpetra_Map.hpp"
20 #include "Tpetra_MultiVector.hpp"
21 #include "Teuchos_ParameterList.hpp"
22 #include "Teuchos_ScalarTraits.hpp"
28 template<
class Scalar,
class LO,
class GO,
class Node>
30 Teuchos::ParameterList pl;
32 out.open(fileName.c_str());
36 template<
class Scalar,
class LO,
class GO,
class Node>
39 out.open(fileName.c_str());
43 template<
class Scalar,
class LO,
class GO,
class Node>
45 Teuchos::ParameterList pl;
49 template<
class Scalar,
class LO,
class GO,
class Node>
55 typedef Teuchos::OrdinalTraits<GO> TOT;
62 RCP<const map_type>
const rowMap = A.
getRowMap();
63 RCP<const Teuchos::Comm<int> > comm = rowMap->getComm();
64 const int myRank = comm->getRank();
65 const size_t numProcs = comm->getSize();
68 bool alwaysUseParallelAlgorithm =
false;
69 if (params.isParameter(
"always use parallel algorithm"))
70 alwaysUseParallelAlgorithm = params.get<
bool>(
"always use parallel algorithm");
71 bool printMatrixMarketHeader =
true;
72 if (params.isParameter(
"print MatrixMarket header"))
73 printMatrixMarketHeader = params.get<
bool>(
"print MatrixMarket header");
75 if (printMatrixMarketHeader && myRank==0) {
76 std::time_t now = std::time(NULL);
78 const std::string dataTypeStr =
79 Teuchos::ScalarTraits<Scalar>::isComplex ?
"complex" :
"real";
89 os <<
"%%MatrixMarket matrix coordinate " << dataTypeStr <<
" general" << std::endl;
90 os <<
"% time stamp: " << ctime(&now);
91 os <<
"% written from " << numProcs <<
" processes" << std::endl;
92 os <<
"% point representation of Tpetra::BlockCrsMatrix" << std::endl;
95 os <<
"% " << numRows <<
" block rows, " << numCols <<
" block columns" << std::endl;
97 os <<
"% block size " << blockSize << std::endl;
98 os << numRows*blockSize <<
" " << numCols*blockSize <<
" " << A.
getGlobalNumEntries()*blockSize*blockSize << std::endl;
101 if (numProcs==1 && !alwaysUseParallelAlgorithm) {
104 size_t numRows = rowMap->getLocalNumElements();
107 RCP<const map_type> allMeshGidsMap = rcp(
new map_type(TOT::invalid(), numRows, A.
getIndexBase(), comm));
110 mv_type allMeshGids(allMeshGidsMap,1);
111 Teuchos::ArrayRCP<GO> allMeshGidsData = allMeshGids.getDataNonConst(0);
113 for (
size_t i=0; i<numRows; i++)
114 allMeshGidsData[i] = rowMap->getGlobalElement(i);
115 allMeshGidsData = Teuchos::null;
118 size_t stripSize = allMeshGids.getGlobalLength() / numProcs;
119 size_t remainder = allMeshGids.getGlobalLength() % numProcs;
121 size_t curStripSize = 0;
122 Teuchos::Array<GO> importMeshGidList;
123 for (
size_t i=0; i<numProcs; i++) {
125 curStripSize = stripSize;
126 if (i<remainder) curStripSize++;
127 importMeshGidList.resize(curStripSize);
128 for (
size_t j=0; j<curStripSize; j++) importMeshGidList[j] = j + curStart + A.
getIndexBase();
129 curStart += curStripSize;
132 TEUCHOS_TEST_FOR_EXCEPTION(myRank>0 && curStripSize!=0,
133 std::runtime_error,
"Tpetra::blockCrsMatrixWriter: (pid "
134 << myRank <<
") map size should be zero, but is " << curStripSize);
135 RCP<map_type> importMeshGidMap = rcp(
new map_type(TOT::invalid(), importMeshGidList(), A.
getIndexBase(), comm));
136 import_type gidImporter(allMeshGidsMap, importMeshGidMap);
137 mv_type importMeshGids(importMeshGidMap, 1);
138 importMeshGids.doImport(allMeshGids, gidImporter,
INSERT);
144 Teuchos::ArrayRCP<const GO> importMeshGidsData = importMeshGids.getData(0);
145 Teuchos::Array<GO> importMeshGidsGO;
146 importMeshGidsGO.reserve(importMeshGidsData.size());
147 for (
typename Teuchos::ArrayRCP<const GO>::size_type j=0; j<importMeshGidsData.size(); ++j)
148 importMeshGidsGO.push_back(importMeshGidsData[j]);
149 RCP<const map_type> importMap = rcp(
new map_type(TOT::invalid(), importMeshGidsGO(), rowMap->getIndexBase(), comm) );
151 import_type importer(rowMap,importMap );
153 RCP<crs_graph_type> graph =
createCrsGraph(importMap,numEntriesPerRow);
154 RCP<const map_type> domainMap = A.getCrsGraph().
getDomainMap();
155 graph->doImport(A.getCrsGraph(), importer,
INSERT);
156 graph->fillComplete(domainMap, importMap);
158 block_crs_matrix_type importA(*graph, A.
getBlockSize());
159 importA.doImport(A, importer,
INSERT);
167 template<
class Scalar,
class LO,
class GO,
class Node>
172 using bcrs_local_inds_host_view_type =
typename bcrs_type::local_inds_host_view_type;
173 using bcrs_values_host_view_type =
typename bcrs_type::values_host_view_type;
174 using impl_scalar_type =
typename bcrs_type::impl_scalar_type;
177 RCP<const map_type> rowMap = A.
getRowMap();
178 RCP<const map_type> colMap = A.
getColMap();
179 RCP<const Teuchos::Comm<int> > comm = rowMap->getComm();
180 const int myRank = comm->getRank();
182 const size_t meshRowOffset = rowMap->getIndexBase();
183 const size_t meshColOffset = colMap->getIndexBase();
184 TEUCHOS_TEST_FOR_EXCEPTION(meshRowOffset != meshColOffset,
185 std::runtime_error,
"Tpetra::writeMatrixStrip: "
186 "mesh row index base != mesh column index base");
191 std::runtime_error,
"Tpetra::writeMatrixStrip: pid "
194 std::runtime_error,
"Tpetra::writeMatrixStrip: pid "
195 << myRank <<
" should have 0 columns but has " << A.
getLocalNumCols());
200 std::runtime_error,
"Tpetra::writeMatrixStrip: "
201 "number of rows on pid 0 does not match global number of rows");
207 bool precisionChanged=
false;
208 int oldPrecision = 0;
209 if (params.isParameter(
"precision")) {
210 oldPrecision = os.precision(params.get<
int>(
"precision"));
211 precisionChanged=
true;
214 if (params.isParameter(
"zero-based indexing")) {
215 if (params.get<
bool>(
"zero-based indexing") ==
true)
220 for (localRowInd = 0; localRowInd < numLocalRows; ++localRowInd) {
223 bcrs_local_inds_host_view_type localColInds;
224 bcrs_values_host_view_type vals;
226 A.
getLocalRowView (localRowInd, localColInds, vals); numEntries = localColInds.extent(0);
227 GO globalMeshRowID = rowMap->getGlobalElement(localRowInd) - meshRowOffset;
229 for (LO k = 0; k < numEntries; ++k) {
230 GO globalMeshColID = colMap->getGlobalElement(localColInds[k]) - meshColOffset;
231 const impl_scalar_type* curBlock = vals.data() + blockSize * blockSize * k;
233 for (LO j = 0; j < blockSize; ++j) {
234 GO globalPointRowID = globalMeshRowID * blockSize + j + pointOffset;
235 for (LO i = 0; i < blockSize; ++i) {
236 GO globalPointColID = globalMeshColID * blockSize + i + pointOffset;
237 const impl_scalar_type curVal = curBlock[i + j * blockSize];
239 os << globalPointRowID <<
" " << globalPointColID <<
" ";
240 if (Teuchos::ScalarTraits<impl_scalar_type>::isComplex) {
243 os << Teuchos::ScalarTraits<impl_scalar_type>::real (curVal) <<
" "
244 << Teuchos::ScalarTraits<impl_scalar_type>::imag (curVal);
254 if (precisionChanged)
255 os.precision(oldPrecision);
256 TEUCHOS_TEST_FOR_EXCEPTION(err != 0,
257 std::runtime_error,
"Tpetra::writeMatrixStrip: "
258 "error getting view of local row " << localRowInd);
264 template<
class Scalar,
class LO,
class GO,
class Node>
265 Teuchos::RCP<Tpetra::CrsGraph<LO, GO, Node> >
268 TEUCHOS_FUNC_TIME_MONITOR_DIFF(
"Tpetra::getBlockCrsGraph", getBlockCrsGraph0);
277 using Teuchos::Array;
278 using Teuchos::ArrayView;
285 using local_graph_device_type =
typename crs_matrix_type::local_graph_device_type;
286 using row_map_type =
typename local_graph_device_type::row_map_type::non_const_type;
287 using entries_type =
typename local_graph_device_type::entries_type::non_const_type;
289 using offset_type =
typename row_map_type::non_const_value_type;
291 using execution_space =
typename Node::execution_space;
292 using range_type = Kokkos::RangePolicy<execution_space, LO>;
294 const map_type &pointRowMap = *(pointMatrix.
getRowMap());
295 RCP<const map_type> meshRowMap, meshColMap, meshDomainMap, meshRangeMap;
297 const map_type &pointColMap = *(pointMatrix.
getColMap());
298 const map_type &pointDomainMap = *(pointMatrix.
getDomainMap());
299 const map_type &pointRangeMap = *(pointMatrix.
getRangeMap());
302 TEUCHOS_FUNC_TIME_MONITOR_DIFF(
"Tpetra::getBlockCrsGraph::createMeshMaps", getBlockCrsGraph1);
303 meshRowMap = createMeshMap<LO,GO,Node>(blockSize, pointRowMap, use_LID);
304 meshColMap = createMeshMap<LO,GO,Node>(blockSize, pointColMap, use_LID);
305 meshDomainMap = createMeshMap<LO,GO,Node>(blockSize, pointDomainMap, use_LID);
306 meshRangeMap = createMeshMap<LO,GO,Node>(blockSize, pointRangeMap, use_LID);
307 Kokkos::DefaultExecutionSpace().fence();
310 if(meshColMap.is_null())
throw std::runtime_error(
"ERROR: Cannot create mesh colmap");
312 auto localMeshColMap = meshColMap->getLocalMap();
313 auto localPointColMap = pointColMap.getLocalMap();
314 auto localPointRowMap = pointRowMap.getLocalMap();
316 RCP<crs_graph_type> meshCrsGraph;
318 const offset_type bs2 = blockSize * blockSize;
321 TEUCHOS_FUNC_TIME_MONITOR_DIFF(
"Tpetra::getBlockCrsGraph::LID", getBlockCrsGraph2);
322 auto pointLocalGraph = pointMatrix.
getCrsGraph()->getLocalGraphDevice();
323 auto pointRowptr = pointLocalGraph.row_map;
324 auto pointColind = pointLocalGraph.entries;
326 TEUCHOS_TEST_FOR_EXCEPTION(pointColind.extent(0) % bs2 != 0,
327 std::runtime_error,
"Tpetra::getBlockCrsGraph: "
328 "local number of non zero entries is not a multiple of blockSize^2 ");
330 LO block_rows = pointRowptr.extent(0) == 0 ? 0 : (pointRowptr.extent(0)-1)/blockSize;
331 row_map_type blockRowptr(
"blockRowptr", block_rows+1);
332 entries_type blockColind(
"blockColind", pointColind.extent(0)/(bs2));
334 Kokkos::parallel_for(
"fillMesh",range_type(0,block_rows), KOKKOS_LAMBDA(
const LO i) {
336 const LO offset_b = pointRowptr(i*blockSize)/bs2;
337 const LO offset_b_max = pointRowptr((i+1)*blockSize)/bs2;
340 blockRowptr(i+1) = offset_b_max;
341 blockRowptr(i) = offset_b;
343 const LO offset_p = pointRowptr(i*blockSize);
345 for (LO k=0; k<offset_b_max-offset_b; ++k) {
346 blockColind(offset_b + k) = pointColind(offset_p + k * blockSize)/blockSize;
350 meshCrsGraph = rcp(
new crs_graph_type(meshRowMap, meshColMap, blockRowptr, blockColind));
351 meshCrsGraph->fillComplete(meshDomainMap,meshRangeMap);
352 Kokkos::DefaultExecutionSpace().fence();
355 TEUCHOS_FUNC_TIME_MONITOR_DIFF(
"Tpetra::getBlockCrsGraph::GID", getBlockCrsGraph3);
356 auto pointLocalGraph = pointMatrix.
getCrsGraph()->getLocalGraphDevice();
357 auto pointRowptr = pointLocalGraph.row_map;
358 auto pointColind = pointLocalGraph.entries;
360 TEUCHOS_TEST_FOR_EXCEPTION(pointColind.extent(0) % bs2 != 0,
361 std::runtime_error,
"Tpetra::getBlockCrsGraph: "
362 "local number of non zero entries is not a multiple of blockSize^2 ");
364 LO block_rows = pointRowptr.extent(0) == 0 ? 0 : (pointRowptr.extent(0)-1)/blockSize;
365 row_map_type blockRowptr(
"blockRowptr", block_rows+1);
366 entries_type blockColind(
"blockColind", pointColind.extent(0)/(bs2));
368 Kokkos::parallel_for(
"fillMesh",range_type(0,block_rows), KOKKOS_LAMBDA(
const LO i) {
370 const LO offset_b = pointRowptr(i*blockSize)/bs2;
371 const LO offset_b_max = pointRowptr((i+1)*blockSize)/bs2;
374 blockRowptr(i+1) = offset_b_max;
375 blockRowptr(i) = offset_b;
377 const LO offset_p = pointRowptr(i*blockSize);
378 const LO offset_p_max = pointRowptr((i+1)*blockSize);
381 for (LO p_i=0; p_i<offset_p_max-offset_p; ++p_i) {
382 auto bcol_GID = localPointColMap.getGlobalElement(pointColind(offset_p + p_i))/blockSize;
383 auto bcol_LID = localMeshColMap.getLocalElement(bcol_GID);
385 bool visited =
false;
386 for (LO k=0; k<filled_block; ++k) {
387 if (blockColind(offset_b + k) == bcol_LID)
391 blockColind(offset_b + filled_block) = bcol_LID;
397 meshCrsGraph = rcp(
new crs_graph_type(meshRowMap, meshColMap, blockRowptr, blockColind));
398 meshCrsGraph->fillComplete(meshDomainMap,meshRangeMap);
399 Kokkos::DefaultExecutionSpace().fence();
405 template<
class Scalar,
class LO,
class GO,
class Node>
406 Teuchos::RCP<BlockCrsMatrix<Scalar, LO, GO, Node> >
409 TEUCHOS_FUNC_TIME_MONITOR_DIFF(
"Tpetra::convertToBlockCrsMatrix", convertToBlockCrsMatrix0);
418 using Teuchos::Array;
419 using Teuchos::ArrayView;
425 using local_graph_device_type =
typename crs_matrix_type::local_graph_device_type;
426 using local_matrix_device_type =
typename crs_matrix_type::local_matrix_device_type;
427 using row_map_type =
typename local_graph_device_type::row_map_type::non_const_type;
428 using values_type =
typename local_matrix_device_type::values_type::non_const_type;
430 using offset_type =
typename row_map_type::non_const_value_type;
432 using execution_space =
typename Node::execution_space;
433 using range_type = Kokkos::RangePolicy<execution_space, LO>;
435 RCP<block_crs_matrix_type> blockMatrix;
437 const offset_type bs2 = blockSize * blockSize;
442 TEUCHOS_FUNC_TIME_MONITOR_DIFF(
"Tpetra::convertToBlockCrsMatrix::LID", convertToBlockCrsMatrix1);
443 auto pointLocalGraph = pointMatrix.
getCrsGraph()->getLocalGraphDevice();
444 auto pointRowptr = pointLocalGraph.row_map;
445 auto pointColind = pointLocalGraph.entries;
447 offset_type block_rows = pointRowptr.extent(0) == 0 ? 0 : (pointRowptr.extent(0)-1)/blockSize;
448 values_type blockValues(
"values", meshCrsGraph->getLocalNumEntries()*bs2);
450 auto blockRowptr = meshCrsGraph->getLocalGraphDevice().row_map;
452 Kokkos::parallel_for(
"copyblockValues",range_type(0,block_rows),KOKKOS_LAMBDA(
const LO i) {
453 const offset_type blkBeg = blockRowptr[i];
454 const offset_type numBlocks = blockRowptr[i+1] - blkBeg;
457 for (offset_type block=0; block < numBlocks; block++) {
460 for(LO little_row=0; little_row<blockSize; little_row++) {
461 offset_type point_row_offset = pointRowptr[i*blockSize + little_row];
462 for(LO little_col=0; little_col<blockSize; little_col++) {
463 blockValues((blkBeg+block) * bs2 + little_row * blockSize + little_col) =
464 pointValues[point_row_offset + block*blockSize + little_col];
470 blockMatrix = rcp(
new block_crs_matrix_type(*meshCrsGraph, blockValues, blockSize));
471 Kokkos::DefaultExecutionSpace().fence();
474 TEUCHOS_FUNC_TIME_MONITOR_DIFF(
"Tpetra::convertToBlockCrsMatrix::GID", convertToBlockCrsMatrix2);
475 auto localMeshColMap = meshCrsGraph->getColMap()->getLocalMap();
476 auto localPointColMap = pointMatrix.
getColMap()->getLocalMap();
478 values_type blockValues(
"values", meshCrsGraph->getLocalNumEntries()*bs2);
480 auto pointLocalGraph = pointMatrix.
getCrsGraph()->getLocalGraphDevice();
481 auto pointRowptr = pointLocalGraph.row_map;
482 auto pointColind = pointLocalGraph.entries;
484 offset_type block_rows = pointRowptr.extent(0) == 0 ? 0 : (pointRowptr.extent(0)-1)/blockSize;
486 auto blockRowptr = meshCrsGraph->getLocalGraphDevice().row_map;
487 auto blockColind = meshCrsGraph->getLocalGraphDevice().entries;
489 row_map_type pointGColind(
"pointGColind", pointColind.extent(0));
491 Kokkos::parallel_for(
"computePointGColind",range_type(0,pointColind.extent(0)),KOKKOS_LAMBDA(
const LO i) {
492 pointGColind(i) = localPointColMap.getGlobalElement(pointColind(i));
495 row_map_type blockGColind(
"blockGColind", blockColind.extent(0));
497 Kokkos::parallel_for(
"computeBlockGColind",range_type(0,blockGColind.extent(0)),KOKKOS_LAMBDA(
const LO i) {
498 blockGColind(i) = localMeshColMap.getGlobalElement(blockColind(i));
501 Kokkos::parallel_for(
"copyblockValues",range_type(0,block_rows),KOKKOS_LAMBDA(
const LO i) {
502 const offset_type blkBeg = blockRowptr[i];
503 const offset_type numBlocks = blockRowptr[i+1] - blkBeg;
505 for (offset_type point_i=0; point_i < pointRowptr[i*blockSize + 1] - pointRowptr[i*blockSize]; point_i++) {
507 offset_type block_inv=
static_cast<offset_type
>(-1);
508 offset_type little_col_inv=
static_cast<offset_type
>(-1);
509 for (offset_type block_2=0; block_2 < numBlocks; block_2++) {
510 for (LO little_col_2=0; little_col_2 < blockSize; little_col_2++) {
511 if (blockGColind(blkBeg+block_2)*blockSize + little_col_2 == pointGColind(pointRowptr[i*blockSize] + point_i)) {
513 little_col_inv = little_col_2;
517 if (block_inv!=static_cast<offset_type>(-1))
521 for(LO little_row=0; little_row<blockSize; little_row++) {
522 blockValues((blkBeg+block_inv) * bs2 + little_row * blockSize + little_col_inv) = pointValues[pointRowptr[i*blockSize+little_row] + point_i];
527 blockMatrix = rcp(
new block_crs_matrix_type(*meshCrsGraph, blockValues, blockSize));
528 Kokkos::DefaultExecutionSpace().fence();
535 template<
class Scalar,
class LO,
class GO,
class Node>
536 Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LO, GO, Node>>
540 using execution_space =
typename Node::execution_space;
541 using dev_row_view_t =
typename crs_t::local_graph_device_type::row_map_type::non_const_type;
542 using dev_col_view_t =
typename crs_t::local_graph_device_type::entries_type::non_const_type;
543 using dev_val_view_t =
typename crs_t::local_matrix_device_type::values_type::non_const_type;
544 using range_type = Kokkos::RangePolicy<execution_space, size_t>;
545 using team_policy = Kokkos::TeamPolicy<execution_space>;
546 using member_type =
typename team_policy::member_type;
547 using scratch_view = Kokkos::View<bool*, typename execution_space::scratch_memory_space>;
548 using Ordinal =
typename dev_row_view_t::non_const_value_type;
552 auto row_ptrs = local.graph.row_map;
553 auto col_inds = local.graph.entries;
554 auto values = local.values;
562 dev_row_view_t new_rowmap(
"new_rowmap", nrows+1);
563 const auto blocks_per_row = nrows / blockSize;
564 dev_row_view_t active_block_row_map(
"active_block_row_map", blocks_per_row + 1);
565 const int max_threads = execution_space().concurrency();
566 assert(blockSize > 1);
567 assert(nrows % blockSize == 0);
568 const int mem_level = 1;
569 const int bytes = scratch_view::shmem_size(blocks_per_row);
571 if (max_threads >= blockSize) {
573 team_policy tp(blocks_per_row, blockSize);
576 Kokkos::parallel_for(
"countActiveBlocks", tp.set_scratch_size(mem_level, Kokkos::PerTeam(bytes)), KOKKOS_LAMBDA(
const member_type& team) {
577 Ordinal block_row = team.league_rank();
579 scratch_view row_block_active(team.team_scratch(mem_level), blocks_per_row);
581 Kokkos::PerTeam(team), [&] () {
582 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
583 row_block_active(row_block_idx) =
false;
590 Kokkos::parallel_for(
591 Kokkos::TeamThreadRange(team, blockSize), [&] (Ordinal block_offset) {
593 Ordinal row = block_row*blockSize + block_offset;
594 Ordinal row_itr = row_ptrs(row);
595 Ordinal row_end = row_ptrs(row+1);
597 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
598 const Ordinal first_possible_col_in_block = row_block_idx * blockSize;
599 const Ordinal first_possible_col_in_next_block = (row_block_idx+1) * blockSize;
600 Ordinal curr_nnz_col = col_inds(row_itr);
601 while (curr_nnz_col >= first_possible_col_in_block && curr_nnz_col < first_possible_col_in_next_block && row_itr < row_end) {
603 row_block_active(row_block_idx) =
true;
605 if (row_itr == row_end)
break;
606 curr_nnz_col = col_inds(row_itr);
614 Kokkos::PerTeam(team), [&] () {
616 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
617 if (row_block_active(row_block_idx)) {
621 active_block_row_map(block_row) = count;
628 team_policy tp(blocks_per_row, 1);
631 Kokkos::parallel_for(
"countActiveBlocks", tp.set_scratch_size(mem_level, Kokkos::PerTeam(bytes)), KOKKOS_LAMBDA(
const member_type& team) {
632 Ordinal block_row = team.league_rank();
634 scratch_view row_block_active(team.team_scratch(mem_level), blocks_per_row);
635 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
636 row_block_active(row_block_idx) =
false;
640 for (
int block_offset=0; block_offset < blockSize; ++block_offset) {
641 Ordinal row = block_row*blockSize + block_offset;
642 Ordinal row_itr = row_ptrs(row);
643 Ordinal row_end = row_ptrs(row+1);
645 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
646 const Ordinal first_possible_col_in_block = row_block_idx * blockSize;
647 const Ordinal first_possible_col_in_next_block = (row_block_idx+1) * blockSize;
648 Ordinal curr_nnz_col = col_inds(row_itr);
649 while (curr_nnz_col >= first_possible_col_in_block && curr_nnz_col < first_possible_col_in_next_block && row_itr < row_end) {
651 row_block_active(row_block_idx) =
true;
653 if (row_itr == row_end)
break;
654 curr_nnz_col = col_inds(row_itr);
660 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
661 if (row_block_active(row_block_idx)) {
665 active_block_row_map(block_row) = count;
669 Ordinal nnz_block_count = 0;
670 KokkosKernels::Impl::kk_exclusive_parallel_prefix_sum<
671 execution_space>(active_block_row_map.extent(0), active_block_row_map, nnz_block_count);
672 dev_col_view_t block_col_ids(
"block_col_ids", nnz_block_count);
675 if (max_threads >= blockSize) {
677 team_policy tp(blocks_per_row, blockSize);
679 Kokkos::parallel_for(
"findActiveBlocks", tp.set_scratch_size(mem_level, Kokkos::PerTeam(bytes)), KOKKOS_LAMBDA(
const member_type& team) {
680 Ordinal block_row = team.league_rank();
682 scratch_view row_block_active(team.team_scratch(mem_level), blocks_per_row);
684 Kokkos::PerTeam(team), [&] () {
685 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
686 row_block_active(row_block_idx) =
false;
693 Kokkos::parallel_for(
694 Kokkos::TeamThreadRange(team, blockSize), [&] (Ordinal block_offset) {
696 Ordinal row = block_row*blockSize + block_offset;
697 Ordinal row_itr = row_ptrs(row);
698 Ordinal row_end = row_ptrs(row+1);
700 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
701 const Ordinal first_possible_col_in_block = row_block_idx * blockSize;
702 const Ordinal first_possible_col_in_next_block = (row_block_idx+1) * blockSize;
703 Ordinal curr_nnz_col = col_inds(row_itr);
704 while (curr_nnz_col >= first_possible_col_in_block && curr_nnz_col < first_possible_col_in_next_block && row_itr < row_end) {
706 row_block_active(row_block_idx) =
true;
708 if (row_itr == row_end)
break;
709 curr_nnz_col = col_inds(row_itr);
717 Kokkos::PerTeam(team), [&] () {
718 Ordinal offset = active_block_row_map[block_row];
719 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
720 if (row_block_active(row_block_idx)) {
721 block_col_ids(offset) = row_block_idx;
729 team_policy tp(blocks_per_row, 1);
731 Kokkos::parallel_for(
"findActiveBlocks", tp.set_scratch_size(mem_level, Kokkos::PerTeam(bytes)), KOKKOS_LAMBDA(
const member_type& team) {
732 Ordinal block_row = team.league_rank();
734 scratch_view row_block_active(team.team_scratch(mem_level), blocks_per_row);
735 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
736 row_block_active(row_block_idx) =
false;
740 for (
int block_offset=0; block_offset < blockSize; ++block_offset) {
741 Ordinal row = block_row*blockSize + block_offset;
742 Ordinal row_itr = row_ptrs(row);
743 Ordinal row_end = row_ptrs(row+1);
745 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
746 const Ordinal first_possible_col_in_block = row_block_idx * blockSize;
747 const Ordinal first_possible_col_in_next_block = (row_block_idx+1) * blockSize;
748 Ordinal curr_nnz_col = col_inds(row_itr);
749 while (curr_nnz_col >= first_possible_col_in_block && curr_nnz_col < first_possible_col_in_next_block && row_itr < row_end) {
751 row_block_active(row_block_idx) =
true;
753 if (row_itr == row_end)
break;
754 curr_nnz_col = col_inds(row_itr);
759 Ordinal offset = active_block_row_map[block_row];
760 for (
size_t row_block_idx = 0; row_block_idx < blocks_per_row; ++row_block_idx) {
761 if (row_block_active(row_block_idx)) {
762 block_col_ids(offset) = row_block_idx;
770 Kokkos::parallel_for(
"sizing", range_type(0, nrows), KOKKOS_LAMBDA(
const size_t row) {
771 const auto block_row = row / blockSize;
772 const Ordinal block_row_begin = active_block_row_map(block_row);
773 const Ordinal block_row_end = active_block_row_map(block_row+1);
774 const Ordinal row_nnz = (block_row_end - block_row_begin) * blockSize;
775 new_rowmap(row) = row_nnz;
778 Ordinal new_nnz_count = 0;
779 KokkosKernels::Impl::kk_exclusive_parallel_prefix_sum<
780 execution_space>(new_rowmap.extent(0), new_rowmap, new_nnz_count);
782 dev_col_view_t new_col_ids(
"new_col_ids", new_nnz_count);
783 dev_val_view_t new_vals(
"new_vals", new_nnz_count);
784 Kokkos::parallel_for(
"entries", range_type(0, nrows), KOKKOS_LAMBDA(
const size_t row) {
785 Ordinal row_itr = row_ptrs(row);
786 Ordinal row_end = row_ptrs(row+1);
787 Ordinal row_itr_new = new_rowmap(row);
789 Ordinal block_row = row / blockSize;
790 Ordinal block_row_begin = active_block_row_map(block_row);
791 Ordinal block_row_end = active_block_row_map(block_row+1);
793 for (Ordinal row_block_idx = block_row_begin; row_block_idx < block_row_end; ++row_block_idx) {
794 const Ordinal block_col = block_col_ids(row_block_idx);
795 const Ordinal first_possible_col_in_block = block_col * blockSize;
796 const Ordinal first_possible_col_in_next_block = (block_col+1) * blockSize;
797 for (Ordinal possible_col = first_possible_col_in_block; possible_col < first_possible_col_in_next_block; ++possible_col, ++row_itr_new) {
798 new_col_ids(row_itr_new) = possible_col;
799 Ordinal curr_nnz_col = col_inds(row_itr);
800 if (possible_col == curr_nnz_col && row_itr < row_end) {
802 new_vals(row_itr_new) = values(row_itr);
810 auto crs_row_map = pointMatrix.
getRowMap();
811 auto crs_col_map = pointMatrix.
getColMap();
812 Teuchos::RCP<crs_t> result = Teuchos::rcp(
new crs_t(crs_row_map, crs_col_map, new_rowmap, new_col_ids, new_vals));
813 result->fillComplete();
817 template<
class Scalar,
class LO,
class GO,
class Node>
818 Teuchos::RCP<Tpetra::CrsMatrix<Scalar, LO, GO, Node>>
822 using dev_row_view_t =
typename crs_t::local_graph_device_type::row_map_type::non_const_type;
823 using dev_col_view_t =
typename crs_t::local_graph_device_type::entries_type::non_const_type;
824 using dev_val_view_t =
typename crs_t::local_matrix_device_type::values_type::non_const_type;
825 using impl_scalar_t =
typename Kokkos::ArithTraits<Scalar>::val_type;
826 using STS = Kokkos::ArithTraits<impl_scalar_t>;
827 using Ordinal =
typename dev_row_view_t::non_const_value_type;
828 using execution_space =
typename Node::execution_space;
829 using range_type = Kokkos::RangePolicy<execution_space, size_t>;
832 auto local = pointMatrix.getLocalMatrixHost();
833 auto row_ptrs = local.graph.row_map;
834 auto col_inds = local.graph.entries;
835 auto values = local.values;
839 dev_row_view_t new_rowmap(
"new_rowmap", nrows+1);
840 const impl_scalar_t zero = STS::zero();
841 Kokkos::parallel_for(
"sizing", range_type(0, nrows), KOKKOS_LAMBDA(
const size_t row) {
842 const Ordinal row_nnz_begin = row_ptrs(row);
843 Ordinal row_nnzs = 0;
844 for (Ordinal row_nnz = row_nnz_begin; row_nnz < row_ptrs(row+1); ++row_nnz) {
845 const impl_scalar_t value = values(row_nnz);
850 new_rowmap(row) = row_nnzs;
853 Ordinal real_nnzs = 0;
854 KokkosKernels::Impl::kk_exclusive_parallel_prefix_sum<
855 execution_space>(new_rowmap.extent(0), new_rowmap, real_nnzs);
857 dev_col_view_t new_col_ids(
"new_col_ids", real_nnzs);
858 dev_val_view_t new_vals(
"new_vals", real_nnzs);
859 Kokkos::parallel_for(
"entries", range_type(0, nrows), KOKKOS_LAMBDA(
const size_t row) {
860 Ordinal row_nnzs = 0;
861 const Ordinal old_row_nnz_begin = row_ptrs(row);
862 const Ordinal new_row_nnz_begin = new_rowmap(row);
863 for (Ordinal old_row_nnz = old_row_nnz_begin; old_row_nnz < row_ptrs(row+1); ++old_row_nnz) {
864 const impl_scalar_t value = values(old_row_nnz);
866 new_col_ids(new_row_nnz_begin + row_nnzs) = col_inds(old_row_nnz);
867 new_vals(new_row_nnz_begin + row_nnzs) = value;
874 auto crs_row_map = pointMatrix.
getRowMap();
875 auto crs_col_map = pointMatrix.
getColMap();
876 Teuchos::RCP<crs_t> result = Teuchos::rcp(
new crs_t(crs_row_map, crs_col_map, new_rowmap, new_col_ids, new_vals));
877 result->fillComplete();
881 template<
class LO,
class GO,
class Node>
882 Teuchos::RCP<const Tpetra::Map<LO,GO,Node> >
885 typedef Teuchos::OrdinalTraits<Tpetra::global_size_t> TOT;
890 using execution_space =
typename Node::execution_space;
891 using range_type = Kokkos::RangePolicy<execution_space, size_t>;
894 LO block_rows = pointGlobalID.extent(0)/blockSize;
895 Kokkos::View<GO*, typename map_type::device_type> meshGlobalID(
"meshGlobalID", block_rows);
897 Kokkos::parallel_for(
"fillMeshMap",range_type(0,block_rows), KOKKOS_LAMBDA(
const LO i) {
898 meshGlobalID(i) = pointGlobalID(i*blockSize)/blockSize;
901 Teuchos::RCP<const map_type> meshMap = Teuchos::rcp(
new map_type(TOT::invalid(), meshGlobalID, 0, pointMap.
getComm()) );
907 Teuchos::Array<GO> meshGids;
913 meshGids.reserve(pointGids.size());
915 for (
int i=0; i<pointGids.size(); ++i) {
916 GO meshGid = (pointGids[i]-indexBase) / blockSize + indexBase;
917 if (hashTable.get(meshGid) == -1) {
918 hashTable.
add(meshGid,1);
919 meshGids.push_back(meshGid);
923 Teuchos::RCP<const map_type> meshMap = Teuchos::rcp(
new map_type(TOT::invalid(), meshGids(), 0, pointMap.
getComm()) );
929 template<
class LO,
class GO,
class Node>
930 Teuchos::RCP<const Tpetra::Map<LO,GO,Node> >
933 typedef Teuchos::OrdinalTraits<Tpetra::global_size_t> TOT;
938 Teuchos::Array<GO> pointGids(blockGids.size() * blockSize);
941 for(LO i=0, ct=0; i<(LO)blockGids.size(); i++) {
942 GO base = (blockGids[i] - indexBase)* blockSize + indexBase;
943 for(LO j=0; j<blockSize; j++, ct++)
944 pointGids[i*blockSize+j] = base+j;
947 Teuchos::RCP<const map_type> pointMap = Teuchos::rcp(
new map_type(TOT::invalid(), pointGids(), 0, blockMap.
getComm()) );
953 template<
class Scalar,
class LO,
class GO,
class Node>
954 Teuchos::RCP<CrsMatrix<Scalar, LO, GO, Node> >
957 using Teuchos::Array;
958 using Teuchos::ArrayView;
965 using crs_graph_type =
typename block_crs_matrix_type::crs_graph_type;
966 using local_graph_device_type =
typename crs_matrix_type::local_graph_device_type;
967 using local_matrix_device_type =
typename crs_matrix_type::local_matrix_device_type;
968 using row_map_type =
typename local_graph_device_type::row_map_type::non_const_type;
969 using entries_type =
typename local_graph_device_type::entries_type::non_const_type;
970 using values_type =
typename local_matrix_device_type::values_type::non_const_type;
972 using row_map_type_const =
typename local_graph_device_type::row_map_type;
973 using entries_type_const =
typename local_graph_device_type::entries_type;
975 using little_block_type =
typename block_crs_matrix_type::const_little_block_type;
976 using offset_type =
typename row_map_type::non_const_value_type;
977 using column_type =
typename entries_type::non_const_value_type;
979 using execution_space =
typename Node::execution_space;
980 using range_type = Kokkos::RangePolicy<execution_space, LO>;
984 const offset_type bs2 = blocksize * blocksize;
986 size_t point_nnz = block_nnz * bs2;
989 RCP<const map_type> pointDomainMap = blockMatrix.
getDomainMap();
990 RCP<const map_type> pointRangeMap = blockMatrix.
getRangeMap();
993 RCP<const map_type> blockRowMap = blockMatrix.
getRowMap();
994 RCP<const map_type> pointRowMap = createPointMap<LO,GO,Node>(blocksize, *blockRowMap);
996 RCP<const map_type> blockColMap = blockMatrix.
getColMap();
997 RCP<const map_type> pointColMap = createPointMap<LO,GO,Node>(blocksize, *blockColMap);
1001 const crs_graph_type & blockGraph = blockMatrix.getCrsGraph();
1002 LO point_rows = (LO) pointRowMap->getLocalNumElements();
1003 LO block_rows = (LO) blockRowMap->getLocalNumElements();
1004 auto blockValues = blockMatrix.getValuesDevice();
1005 auto blockLocalGraph = blockGraph.getLocalGraphDevice();
1006 row_map_type_const blockRowptr = blockLocalGraph.row_map;
1007 entries_type_const blockColind = blockLocalGraph.entries;
1010 row_map_type rowptr(
"row_map", point_rows+1);
1011 entries_type colind(
"entries", point_nnz);
1012 values_type values(
"values", point_nnz);
1015 Kokkos::parallel_for(
"fillRowPtr",range_type(0,block_rows),KOKKOS_LAMBDA(
const LO i) {
1016 offset_type base = blockRowptr[i];
1017 offset_type diff = blockRowptr[i+1] - base;
1018 for(LO j=0; j<blocksize; j++) {
1019 rowptr[i*blocksize +j] = base*bs2 + j*diff*blocksize;
1023 if(i==block_rows-1) {
1024 rowptr[block_rows*blocksize] = blockRowptr[i+1] * bs2;
1029 Kokkos::parallel_for(
"copyEntriesAndValues",range_type(0,block_rows),KOKKOS_LAMBDA(
const LO i) {
1030 const offset_type blkBeg = blockRowptr[i];
1031 const offset_type numBlocks = blockRowptr[i+1] - blkBeg;
1034 for (offset_type block=0; block < numBlocks; block++) {
1035 column_type point_col_base = blockColind[blkBeg + block] * blocksize;
1036 little_block_type my_block(blockValues.data () + (blkBeg+block) * bs2, blocksize, blocksize);
1039 for(LO little_row=0; little_row<blocksize; little_row++) {
1040 offset_type point_row_offset = rowptr[i*blocksize + little_row];
1041 for(LO little_col=0; little_col<blocksize; little_col++) {
1042 colind[point_row_offset + block*blocksize + little_col] = point_col_base + little_col;
1043 values[point_row_offset + block*blocksize + little_col] = my_block(little_row,little_col);
1051 RCP<crs_matrix_type> pointCrsMatrix = rcp(
new crs_matrix_type(pointRowMap, pointColMap, 0));
1052 pointCrsMatrix->setAllValues(rowptr,colind,values);
1055 pointCrsMatrix->expertStaticFillComplete(pointDomainMap,pointRangeMap);
1057 return pointCrsMatrix;
1069 #define TPETRA_BLOCKCRSMATRIX_HELPERS_INSTANT(S,LO,GO,NODE) \
1070 template void blockCrsMatrixWriter(BlockCrsMatrix<S,LO,GO,NODE> const &A, std::string const &fileName); \
1071 template void blockCrsMatrixWriter(BlockCrsMatrix<S,LO,GO,NODE> const &A, std::string const &fileName, Teuchos::ParameterList const ¶ms); \
1072 template void blockCrsMatrixWriter(BlockCrsMatrix<S,LO,GO,NODE> const &A, std::ostream &os); \
1073 template void blockCrsMatrixWriter(BlockCrsMatrix<S,LO,GO,NODE> const &A, std::ostream &os, Teuchos::ParameterList const ¶ms); \
1074 template void writeMatrixStrip(BlockCrsMatrix<S,LO,GO,NODE> const &A, std::ostream &os, Teuchos::ParameterList const ¶ms); \
1075 template Teuchos::RCP<BlockCrsMatrix<S, LO, GO, NODE> > convertToBlockCrsMatrix(const CrsMatrix<S, LO, GO, NODE>& pointMatrix, const LO &blockSize, bool use_LID); \
1076 template Teuchos::RCP<CrsMatrix<S, LO, GO, NODE> > fillLogicalBlocks(const CrsMatrix<S, LO, GO, NODE>& pointMatrix, const LO &blockSize); \
1077 template Teuchos::RCP<CrsMatrix<S, LO, GO, NODE> > unfillFormerBlockCrs(const CrsMatrix<S, LO, GO, NODE>& pointMatrix); \
1078 template Teuchos::RCP<CrsMatrix<S, LO, GO, NODE> > convertToCrsMatrix(const BlockCrsMatrix<S, LO, GO, NODE>& blockMatrix); \
1079 template Teuchos::RCP<CrsGraph<LO, GO, NODE>> getBlockCrsGraph(const Tpetra::CrsMatrix<S, LO, GO, NODE>& pointMatrix, const LO &blockSize, bool use_local_ID);
1084 #define TPETRA_CREATEMESHMAP_INSTANT(LO,GO,NODE) \
1085 template Teuchos::RCP<const Map<LO,GO,NODE> > createMeshMap (const LO& blockSize, const Map<LO,GO,NODE>& pointMap, bool use_local_ID); \
1086 template Teuchos::RCP<const Map<LO,GO,NODE> > createPointMap (const LO& blockSize, const Map<LO,GO,NODE>& blockMap);
1088 #endif // TPETRA_BLOCKCRSMATRIX_HELPERS_DEF_HPP
Teuchos::RCP< const Tpetra::Map< LO, GO, Node > > createPointMap(LO const &blockSize, const Tpetra::Map< LO, GO, Node > &blockMap)
Helper function to generate a point map from a block map (with a given block size) GIDs associated wi...
Communication plan for data redistribution from a uniquely-owned to a (possibly) multiply-owned distr...
virtual size_t getLocalNumEntries() const override
The local number of stored (structurally nonzero) entries.
virtual global_size_t getGlobalNumCols() const override
The global number of columns of this matrix.
void blockCrsMatrixWriter(BlockCrsMatrix< Scalar, LO, GO, Node > const &A, std::string const &fileName)
Helper function to write a BlockCrsMatrix. Calls the 3-argument version.
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
virtual LO getBlockSize() const override
The number of degrees of freedom per mesh point.
Teuchos::RCP< Tpetra::CrsMatrix< Scalar, LO, GO, Node > > unfillFormerBlockCrs(const Tpetra::CrsMatrix< Scalar, LO, GO, Node > &pointMatrix)
Unfill all point entries in a logical block of a CrsMatrix with zeroes. This can be called after conv...
Sparse matrix whose entries are small dense square blocks, all of the same dimensions.
Teuchos::RCP< const Tpetra::Map< LO, GO, Node > > createMeshMap(LO const &blockSize, const Tpetra::Map< LO, GO, Node > &pointMap, bool use_local_ID=false)
Helper function to generate a mesh map from a point map. Important! It's assumed that point GIDs asso...
Teuchos::RCP< const map_type > getRangeMap() const override
The range Map of this matrix.
One or more distributed dense vectors.
Teuchos::RCP< const map_type > getDomainMap() const override
Returns the Map associated with the domain of this graph.
size_t getGlobalMaxNumRowEntries() const override
Maximum number of entries in any row of the graph, over all processes in the graph's communicator...
global_indices_array_device_type getMyGlobalIndicesDevice() const
Return a view of the global indices owned by this process on the Map's device.
Teuchos::RCP< const Teuchos::Comm< int > > getComm() const
Accessors for the Teuchos::Comm and Kokkos Node objects.
Teuchos::RCP< const crs_graph_type > getCrsGraph() const
This matrix's graph, as a CrsGraph.
size_t getLocalNumRows() const override
get the local number of block rows
void writeMatrixStrip(BlockCrsMatrix< Scalar, LO, GO, Node > const &A, std::ostream &os, Teuchos::ParameterList const ¶ms)
Helper function called by blockCrsMatrixWriter.
void getLocalRowView(LO LocalRow, local_inds_host_view_type &indices, values_host_view_type &values) const override
Get a view of the (mesh, i.e., block) row, using local (mesh, i.e., block) indices.
Teuchos::RCP< const map_type > getColMap() const override
get the (mesh) map for the columns of this block matrix.
Teuchos::ArrayView< const global_ordinal_type > getLocalElementList() const
Return a NONOWNING view of the global indices owned by this process.
Teuchos::RCP< const map_type > getDomainMap() const override
Get the (point) domain Map of this matrix.
Teuchos::RCP< const map_type > getRowMap() const override
get the (mesh) map for the rows of this block matrix.
Insert new values that don't currently exist.
global_ordinal_type getIndexBase() const
The index base for this Map.
global_size_t getGlobalNumRows() const override
get the global number of block rows
TPETRA_DETAILS_ALWAYS_INLINE local_matrix_device_type getLocalMatrixDevice() const
The local sparse matrix.
virtual GO getIndexBase() const override
The index base for global indices in this matrix.
virtual global_size_t getGlobalNumEntries() const override
The global number of stored (structurally nonzero) entries.
Teuchos::RCP< Tpetra::CrsMatrix< Scalar, LO, GO, Node > > fillLogicalBlocks(const Tpetra::CrsMatrix< Scalar, LO, GO, Node > &pointMatrix, const LO &blockSize)
Fill all point entries in a logical block of a CrsMatrix with zeroes. This should be called before co...
Teuchos::RCP< const map_type > getRangeMap() const override
Get the (point) range Map of this matrix.
Teuchos::RCP< CrsMatrix< Scalar, LO, GO, Node > > convertToCrsMatrix(const Tpetra::BlockCrsMatrix< Scalar, LO, GO, Node > &blockMatrix)
Non-member constructor that creates a point CrsMatrix from an existing BlockCrsMatrix.
Teuchos::RCP< CrsGraph< LocalOrdinal, GlobalOrdinal, Node > > createCrsGraph(const Teuchos::RCP< const Map< LocalOrdinal, GlobalOrdinal, Node >> &map, size_t maxNumEntriesPerRow=0, const Teuchos::RCP< Teuchos::ParameterList > ¶ms=Teuchos::null)
Nonmember function to create an empty CrsGraph given a row Map and the max number of entries allowed ...
A distributed graph accessed by rows (adjacency lists) and stored sparsely.
Teuchos::RCP< Tpetra::CrsGraph< LO, GO, Node > > getBlockCrsGraph(const Tpetra::CrsMatrix< Scalar, LO, GO, Node > &pointMatrix, const LO &blockSize, bool use_local_ID=true)
Non-member constructor that creates the CrsGraph of a BlockCrsMatrix from an existing point CrsMatrix...
Teuchos::RCP< const map_type > getDomainMap() const override
The domain Map of this matrix.
void add(const KeyType key, const ValueType value)
Add a key and its value to the hash table.
Teuchos::RCP< BlockCrsMatrix< Scalar, LO, GO, Node > > convertToBlockCrsMatrix(const Tpetra::CrsMatrix< Scalar, LO, GO, Node > &pointMatrix, const LO &blockSize, bool use_local_ID=true)
Non-member constructor that creates a BlockCrsMatrix from an existing point CrsMatrix.
local_matrix_device_type::values_type::const_type getLocalValuesDevice(Access::ReadOnlyStruct s) const
Get the Kokkos local values on device, read only.
Teuchos::RCP< const map_type > getColMap() const override
The Map that describes the column distribution in this matrix.
virtual size_t getLocalNumCols() const override
The number of columns needed to apply the forward operator on this node.
size_t getLocalNumRows() const override
The number of matrix rows owned by the calling process.
Teuchos::RCP< const map_type > getRowMap() const override
The Map that describes the row distribution in this matrix.