Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
Thyra_Amesos2LinearOpWithSolve_decl.hpp
Go to the documentation of this file.
1 /*
2 // @HEADER
3 // ***********************************************************************
4 //
5 // Stratimikos: Thyra-based strategies for linear solvers
6 // Copyright (2006) Sandia Corporation
7 //
8 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9 // license for use of this work by or on behalf of the U.S. Government.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
39 //
40 // ***********************************************************************
41 // @HEADER
42 */
43 
44 #ifndef THYRA_AMESOS2_LINEAR_OP_WITH_SOLVE_DECL_HPP
45 #define THYRA_AMESOS2_LINEAR_OP_WITH_SOLVE_DECL_HPP
46 
47 #include "Thyra_LinearOpWithSolveBase.hpp"
48 #include "Thyra_LinearOpSourceBase.hpp"
49 #include <Tpetra_DefaultPlatform.hpp>
50 #include <Tpetra_Map.hpp>
51 #include <Tpetra_MultiVector.hpp>
52 #include <Tpetra_CrsMatrix.hpp>
53 
54 #include "Thyra_TpetraLinearOp.hpp"
56 #include "Thyra_DefaultDiagonalLinearOp.hpp"
57 #include "Thyra_LinearOpTester.hpp"
58 
59 #include "Amesos2.hpp"
60 #include "Amesos2_Version.hpp"
61 #include "Amesos2_Solver.hpp"
62 
63 namespace Thyra {
64 
72 template<typename Scalar>
73 class Amesos2LinearOpWithSolve: virtual public LinearOpWithSolveBase<Scalar>
74 {
75 public:
76  using MAT = Tpetra::CrsMatrix<Scalar>;
77  using Op = Tpetra::Operator<Scalar>;
78  using MV = Tpetra::MultiVector<Scalar>;
79  using Solver = ::Amesos2::Solver<MAT, MV>;
81 
84 
87 
90  const Teuchos::RCP<const LinearOpBase<Scalar> > &fwdOp,
91  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
92  const Teuchos::RCP< Solver > &amesos2Solver,
93  const EOpTransp amesos2SolverTransp,
94  const Scalar amesos2SolverScalar
95  );
96 
98  void initialize(
99  const Teuchos::RCP<const LinearOpBase<Scalar> > &fwdOp,
100  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
101  const Teuchos::RCP< Solver > &amesos2Solver
102  );
103 
113 
116 
119 
122 
132 
136  std::string description() const;
138  void describe(
140  const Teuchos::EVerbosityLevel verbLevel
141  ) const;
143 
144 protected:
145 
149  virtual bool opSupportedImpl(EOpTransp M_trans) const;
151  virtual void applyImpl(
152  const EOpTransp M_trans,
153  const MultiVectorBase<Scalar> &X,
154  const Ptr<MultiVectorBase<Scalar> > &Y,
155  const Scalar alpha,
156  const Scalar beta
157  ) const;
159 
163  virtual bool solveSupportsImpl(EOpTransp M_trans) const;
166  EOpTransp M_trans, const SolveMeasureType& solveMeasureType
167  ) const;
169  SolveStatus<Scalar> solveImpl(
170  const EOpTransp M_trans,
171  const MultiVectorBase<Scalar> &B,
172  const Ptr<MultiVectorBase<Scalar> > &X,
173  const Ptr<const SolveCriteria<Scalar> > solveCriteria
174  ) const;
176 
177 private:
178 
182 
183  void assertInitialized() const;
184 
185 };
186 
187 // ///////////////////////////
188 // Inline members
189 
190 template<typename Scalar>
191 inline
194 {
195  return fwdOp_;
196 }
197 
198 template<typename Scalar>
199 inline
202 {
203  return amesos2Solver_;
204 }
205 
206 template<typename Scalar>
207 inline
210 {
211  return fwdOpSrc_;
212 }
213 
214 } // namespace Thyra
215 
216 #endif // THYRA_AMESOS2_LINEAR_OP_WITH_SOLVE_HPP
Thyra::Amesos2LinearOpWithSolve::assertInitialized
void assertInitialized() const
Thyra::Amesos2LinearOpWithSolve::clone
Teuchos::RCP< const LinearOpBase< Scalar > > clone() const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:122
Thyra::Amesos2LinearOpWithSolve::get_fwdOpSrc
Teuchos::RCP< const LinearOpSourceBase< Scalar > > get_fwdOpSrc() const
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:209
Teuchos::EVerbosityLevel
EVerbosityLevel
Thyra::Amesos2LinearOpWithSolve::Op
Tpetra::Operator< Scalar > Op
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:77
Thyra::Amesos2LinearOpWithSolve::description
std::string description() const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:132
Thyra::Amesos2LinearOpWithSolve::amesos2Solver_
Teuchos::RCP< Solver > amesos2Solver_
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:181
Thyra::Amesos2LinearOpWithSolve::describe
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:146
Thyra::Amesos2LinearOpWithSolve::fwdOp_
Teuchos::RCP< const LinearOpBase< Scalar > > fwdOp_
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:179
Thyra_TpetraLinearOp.hpp
Thyra::TpetraOperatorVectorExtraction
Teuchos::RCP
Thyra::Amesos2LinearOpWithSolve::MV
Tpetra::MultiVector< Scalar > MV
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:78
Thyra::Amesos2LinearOpWithSolve::fwdOpSrc_
Teuchos::RCP< const LinearOpSourceBase< Scalar > > fwdOpSrc_
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:180
Thyra::Amesos2LinearOpWithSolve::solveSupportsImpl
virtual bool solveSupportsImpl(EOpTransp M_trans) const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:211
Thyra::Amesos2LinearOpWithSolve::solveImpl
SolveStatus< Scalar > solveImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:233
Thyra::Amesos2LinearOpWithSolve::range
Teuchos::RCP< const VectorSpaceBase< Scalar > > range() const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:106
Teuchos::basic_FancyOStream
Thyra::Amesos2LinearOpWithSolve::applyImpl
virtual void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:196
Thyra::Amesos2LinearOpWithSolve::get_fwdOp
Teuchos::RCP< const LinearOpBase< Scalar > > get_fwdOp() const
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:193
Thyra::Amesos2LinearOpWithSolve::Amesos2LinearOpWithSolve
Amesos2LinearOpWithSolve()
Construct to uninitialized.
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:57
Thyra::Amesos2LinearOpWithSolve::Solver
::Amesos2::Solver< MAT, MV > Solver
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:79
Thyra::Amesos2LinearOpWithSolve::MAT
Tpetra::CrsMatrix< Scalar > MAT
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:76
Thyra::Amesos2LinearOpWithSolve::domain
Teuchos::RCP< const VectorSpaceBase< Scalar > > domain() const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:114
Thyra::Amesos2LinearOpWithSolve::initialize
void initialize(const Teuchos::RCP< const LinearOpBase< Scalar > > &fwdOp, const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const Teuchos::RCP< Solver > &amesos2Solver)
Initialize after construction.
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:75
Thyra_TpetraThyraWrappers.hpp
Thyra::Amesos2LinearOpWithSolve::opSupportedImpl
virtual bool opSupportedImpl(EOpTransp M_trans) const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:189
Thyra::Amesos2LinearOpWithSolve::extract_fwdOpSrc
Teuchos::RCP< const LinearOpSourceBase< Scalar > > extract_fwdOpSrc()
Extract the forward LinearOpSourceBase<double> object so that it can be modified and remove it from t...
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:92
Thyra::Amesos2LinearOpWithSolve::solveSupportsSolveMeasureTypeImpl
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
Definition: Thyra_Amesos2LinearOpWithSolve_def.hpp:223
Thyra::Amesos2LinearOpWithSolve
Concrete LinearOpWithSolveBase subclass in terms of Amesos2.
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:73
Thyra
B
Thyra::Amesos2LinearOpWithSolve::get_amesos2Solver
Teuchos::RCP< Solver > get_amesos2Solver()
Definition: Thyra_Amesos2LinearOpWithSolve_decl.hpp:201