Tpetra parallel linear algebra Version of the Day
Loading...
Searching...
No Matches
Tpetra_Reindex_LinearProblem_def.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Tpetra: Templated Linear Algebra Services Package
4//
5// Copyright 2008 NTESS and the Tpetra contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef TPETRA_REINDEX_LINEARPROBLEM_DEF_HPP
11#define TPETRA_REINDEX_LINEARPROBLEM_DEF_HPP
12
22
24
25namespace Tpetra {
26
27template <class Scalar,
28 class LocalOrdinal,
29 class GlobalOrdinal,
30 class Node>
33 : ViewTransform<LinearProblem<Scalar, LocalOrdinal, GlobalOrdinal, Node> >()
34 , newRowMap_(newRowMap)
35 , matTrans_(Teuchos::null)
36 , lhsTrans_(Teuchos::null)
37 , rhsTrans_(Teuchos::null) {
38 // Nothing to do
39}
40
41template <class Scalar,
42 class LocalOrdinal,
43 class GlobalOrdinal,
44 class Node>
48
49template <class Scalar,
50 class LocalOrdinal,
51 class GlobalOrdinal,
52 class Node>
53typename Reindex_LinearProblem<Scalar, LocalOrdinal, GlobalOrdinal, Node>::NewType
59
60 // Save original object
61 this->origObj_ = origProblem;
62
63 Teuchos::RCP<cm_t> origMatrix = Teuchos::rcp<cm_t>(dynamic_cast<cm_t *>(origProblem->getMatrix().get()), false);
64 Teuchos::RCP<mv_t> origRHS = origProblem->getRHS();
65 Teuchos::RCP<mv_t> origLHS = origProblem->getLHS();
66 Teuchos::RCP<map_t const> origRowMap = origMatrix->getMap();
67
68 // If no new map has been passed in, create one
69 if (newRowMap_.get() == nullptr) {
70 newRowMap_ = Teuchos::rcp<map_t const>(new map_t(origRowMap->getGlobalNumElements(), origRowMap->getLocalNumElements(), 0, origRowMap->getComm()));
71 }
72
75
76 matTrans_ = Teuchos::rcp<r_cm_t>(new r_cm_t(newRowMap_));
77 lhsTrans_ = Teuchos::rcp<r_mv_t>(new r_mv_t(newRowMap_));
78 rhsTrans_ = Teuchos::rcp<r_mv_t>(new r_mv_t(newRowMap_));
79
80 Teuchos::RCP<cm_t> newMatrix = ((*matTrans_)(origMatrix));
81 Teuchos::RCP<mv_t> newLHS = ((*lhsTrans_)(origLHS));
82 Teuchos::RCP<mv_t> newRHS = ((*rhsTrans_)(origRHS));
83
84 this->newObj_ = Teuchos::rcp<lp_t>(new lp_t(newMatrix, newLHS, newRHS));
85
86 return this->newObj_;
87}
88
89//
90// Explicit instantiation macro
91//
92// Must be expanded from within the Tpetra namespace!
93//
94
95#define TPETRA_REINDEXLINEARPROBLEM_INSTANT(SCALAR, LO, GO, NODE) \
96 template class Reindex_LinearProblem<SCALAR, LO, GO, NODE>;
97
98} // namespace Tpetra
99
100#endif // TPETRA_REINDEX_LINEARPROBLEM_DEF_HPP
Declaration of the Tpetra::Reindex_LinearProblem class.
Struct that holds views of the contents of a CrsMatrix.
Teuchos::RCP< const CrsMatrix< Scalar, LocalOrdinal, GlobalOrdinal, Node > > origMatrix
The original matrix.
Teuchos::RCP< const map_type > origRowMap
Original row map of matrix.
Class that encapulates linear problem (Ax = b).
Reindex_LinearProblem(Teuchos::RCP< Map< LocalOrdinal, GlobalOrdinal, Node > const > newRowMap)
NewType operator()(OriginalType const &origProblem)
Namespace Tpetra contains the class and methods constituting the Tpetra library.