Stratimikos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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_Map.hpp>
50 #include <Tpetra_MultiVector.hpp>
51 #include <Tpetra_CrsMatrix.hpp>
52 
53 #include "Thyra_TpetraLinearOp.hpp"
55 #include "Thyra_DefaultDiagonalLinearOp.hpp"
56 #include "Thyra_LinearOpTester.hpp"
57 
58 #include "Amesos2.hpp"
59 #include "Amesos2_Version.hpp"
60 #include "Amesos2_Solver.hpp"
61 
62 namespace Thyra {
63 
71 template<typename Scalar>
72 class Amesos2LinearOpWithSolve: virtual public LinearOpWithSolveBase<Scalar>
73 {
74 public:
75  using MAT = Tpetra::CrsMatrix<Scalar>;
76  using Op = Tpetra::Operator<Scalar>;
77  using MV = Tpetra::MultiVector<Scalar>;
78  using Solver = ::Amesos2::Solver<MAT, MV>;
80 
83 
86 
89  const Teuchos::RCP<const LinearOpBase<Scalar> > &fwdOp,
90  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
91  const Teuchos::RCP< Solver > &amesos2Solver,
92  const EOpTransp amesos2SolverTransp,
93  const Scalar amesos2SolverScalar
94  );
95 
97  void initialize(
98  const Teuchos::RCP<const LinearOpBase<Scalar> > &fwdOp,
99  const Teuchos::RCP<const LinearOpSourceBase<Scalar> > &fwdOpSrc,
100  const Teuchos::RCP< Solver > &amesos2Solver
101  );
102 
112 
115 
118 
121 
131 
135  std::string description() const;
137  void describe(
139  const Teuchos::EVerbosityLevel verbLevel
140  ) const;
142 
143 protected:
144 
148  virtual bool opSupportedImpl(EOpTransp M_trans) const;
150  virtual void applyImpl(
151  const EOpTransp M_trans,
152  const MultiVectorBase<Scalar> &X,
153  const Ptr<MultiVectorBase<Scalar> > &Y,
154  const Scalar alpha,
155  const Scalar beta
156  ) const;
158 
162  virtual bool solveSupportsImpl(EOpTransp M_trans) const;
165  EOpTransp M_trans, const SolveMeasureType& solveMeasureType
166  ) const;
168  SolveStatus<Scalar> solveImpl(
169  const EOpTransp M_trans,
170  const MultiVectorBase<Scalar> &B,
171  const Ptr<MultiVectorBase<Scalar> > &X,
172  const Ptr<const SolveCriteria<Scalar> > solveCriteria
173  ) const;
175 
176 private:
177 
181 
182  void assertInitialized() const;
183 
184 };
185 
186 // ///////////////////////////
187 // Inline members
188 
189 template<typename Scalar>
190 inline
193 {
194  return fwdOp_;
195 }
196 
197 template<typename Scalar>
198 inline
201 {
202  return amesos2Solver_;
203 }
204 
205 template<typename Scalar>
206 inline
209 {
210  return fwdOpSrc_;
211 }
212 
213 } // namespace Thyra
214 
215 #endif // THYRA_AMESOS2_LINEAR_OP_WITH_SOLVE_HPP
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
void initialize(const Teuchos::RCP< const LinearOpBase< Scalar > > &fwdOp, const Teuchos::RCP< const LinearOpSourceBase< Scalar > > &fwdOpSrc, const Teuchos::RCP< Solver > &amesos2Solver)
Initialize after construction.
SolveStatus< Scalar > solveImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &B, const Ptr< MultiVectorBase< Scalar > > &X, const Ptr< const SolveCriteria< Scalar > > solveCriteria) const
virtual void applyImpl(const EOpTransp M_trans, const MultiVectorBase< Scalar > &X, const Ptr< MultiVectorBase< Scalar > > &Y, const Scalar alpha, const Scalar beta) const
Concrete LinearOpWithSolveBase subclass in terms of Amesos2.
Teuchos::RCP< const LinearOpBase< Scalar > > fwdOp_
virtual bool opSupportedImpl(EOpTransp M_trans) const
Teuchos::RCP< const LinearOpSourceBase< Scalar > > fwdOpSrc_
Teuchos::RCP< const VectorSpaceBase< Scalar > > domain() const
Teuchos::RCP< const LinearOpBase< Scalar > > clone() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::RCP< const LinearOpBase< Scalar > > get_fwdOp() const
Teuchos::RCP< const VectorSpaceBase< Scalar > > range() const
virtual bool solveSupportsImpl(EOpTransp M_trans) const
Teuchos::RCP< const LinearOpSourceBase< Scalar > > get_fwdOpSrc() const
Amesos2LinearOpWithSolve()
Construct to uninitialized.
Teuchos::RCP< const LinearOpSourceBase< Scalar > > extract_fwdOpSrc()
Extract the forward LinearOpSourceBase&lt;double&gt; object so that it can be modified and remove it from t...