Tpetra parallel linear algebra  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tpetra_SolverMap_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_SOLVERMAP_LINEARPROBLEM_DEF_HPP
11 #define TPETRA_SOLVERMAP_LINEARPROBLEM_DEF_HPP
12 
22 
24 
25 namespace Tpetra {
26 
27 template <class Scalar,
28  class LocalOrdinal,
29  class GlobalOrdinal,
30  class Node>
32  : StructuralSameTypeTransform<LinearProblem<Scalar, LocalOrdinal, GlobalOrdinal, Node> >()
33  , solverMapCrsMatrixTrans_() {
34  // Nothing to do
35 }
36 
37 template <class Scalar,
38  class LocalOrdinal,
39  class GlobalOrdinal,
40  class Node>
42  // Nothing to do
43 }
44 
45 template <class Scalar,
46  class LocalOrdinal,
47  class GlobalOrdinal,
48  class Node>
49 typename SolverMap_LinearProblem<Scalar, LocalOrdinal, GlobalOrdinal, Node>::NewType
51 operator()(OriginalType const &origProblem) {
55 
56  this->origObj_ = origProblem;
57 
58  cm_t *oldMatrix = dynamic_cast<cm_t *>(origProblem->getMatrix().get());
59  Teuchos::RCP<mv_t> oldRHS = origProblem->getRHS();
60  Teuchos::RCP<mv_t> oldLHS = origProblem->getLHS();
61  Teuchos::RCP<cm_t> newMatrix = solverMapCrsMatrixTrans_(Teuchos::rcp<cm_t>(oldMatrix, false));
62 
63  if (newMatrix.get() == oldMatrix) {
64  // Same matrix, so use same problem
65  this->newObj_ = this->origObj_;
66  } else {
67  this->newObj_ = Teuchos::rcp<lp_t>(new lp_t(newMatrix, oldLHS, oldRHS));
68  }
69 
70  return this->newObj_;
71 }
72 
73 //
74 // Explicit instantiation macro
75 //
76 // Must be expanded from within the Tpetra namespace!
77 //
78 
79 #define TPETRA_SOLVERMAPLINEARPROBLEM_INSTANT(SCALAR, LO, GO, NODE) \
80  template class SolverMap_LinearProblem<SCALAR, LO, GO, NODE>;
81 
82 } // namespace Tpetra
83 
84 #endif // TPETRA_SOLVERMAP_LINEARPROBLEM_DEF_HPP
Class that encapulates linear problem (Ax = b).
Sparse matrix that presents a row-oriented interface that lets users read or modify entries...
Declaration of the Tpetra::SolverMap_LinearProblem class.
NewType operator()(OriginalType const &origProblem)
Teuchos::RCP< multivector_type > getRHS() const
Get an RCP to the right-hand-side B.