10 #include "Thyra_AmesosLinearOpWithSolve.hpp"
12 #include "Thyra_MultiVectorStdOps.hpp"
13 #include "Epetra_MultiVector.h"
14 #include "Teuchos_TimeMonitor.hpp"
24 amesosSolverTransp_(Thyra::
NOTRANS),
25 amesosSolverScalar_(1.0)
35 const double amesosSolverScalar
38 this->
initialize(fwdOp,fwdOpSrc,epetraLP,amesosSolver,
39 amesosSolverTransp,amesosSolverScalar);
49 const double amesosSolverScalar
63 amesosSolver_ = amesosSolver;
64 amesosSolverTransp_ = amesosSolverTransp;
65 amesosSolverScalar_ = amesosSolverScalar;
66 const std::string fwdOpLabel = fwdOp_->getObjectLabel();
67 if(fwdOpLabel.length())
76 _fwdOpSrc = fwdOpSrc_;
77 fwdOpSrc_ = Teuchos::null;
88 double *amesosSolverScalar
92 if(fwdOp) *fwdOp = fwdOp_;
93 if(fwdOpSrc) *fwdOpSrc = fwdOpSrc_;
94 if(epetraLP) *epetraLP = epetraLP_;
95 if(amesosSolver) *amesosSolver = amesosSolver_;
96 if(amesosSolverTransp) *amesosSolverTransp = amesosSolverTransp_;
97 if(amesosSolverScalar) *amesosSolverScalar = amesosSolverScalar_;
99 fwdOp_ = Teuchos::null;
100 fwdOpSrc_ = Teuchos::null;
101 epetraLP_ = Teuchos::null;
102 amesosSolver_ = Teuchos::null;
104 amesosSolverScalar_ = 0.0;
115 return ( fwdOp_.get() ? fwdOp_->range() : Teuchos::null );
122 return ( fwdOp_.get() ? fwdOp_->domain() : Teuchos::null );
129 return Teuchos::null;
138 std::ostringstream oss;
142 <<
"{fwdOp="<<fwdOp_->description()
143 <<
",amesosSolver="<<
typeName(*amesosSolver_)<<
"}";
156 using Teuchos::describe;
168 <<
"rangeDim=" << this->
range()->dim()
169 <<
",domainDim="<< this->
domain()->dim() <<
"}\n";
172 out <<
"fwdOp = " <<
describe(*fwdOp_,verbLevel);
175 out <<
"amesosSolver=" <<
typeName(*amesosSolver_) <<
"\n";
193 return ::Thyra::opSupported(*fwdOp_,M_trans);
205 Thyra::apply( *fwdOp_, M_trans, X, Y, alpha, beta );
225 const bool oldUseTranspose = amesosSolver_->
UseTranspose();
226 const bool supportsAdjoint = (amesosSolver_->
SetUseTranspose(
true) == 0);
228 return supportsAdjoint;
248 using Teuchos::rcpFromPtr;
249 using Teuchos::rcpFromRef;
253 totalTimer.
start(
true);
255 THYRA_FUNC_TIME_MONITOR(
"Stratimikos: AmesosLOWS");
259 OSTab tab = this->getOSTab();
261 *out <<
"\nSolving block system using Amesos solver "
262 <<
typeName(*amesosSolver_) <<
" ...\n\n";
270 &opRangeMap = ( amesosOpTransp ==
NOTRANS
272 &opDomainMap = ( amesosOpTransp ==
NOTRANS
286 epetraLP_->
SetLHS(&*epetra_X);
287 epetraLP_->
SetRHS(const_cast<Epetra_MultiVector*>(&*epetra_B));
293 const bool oldUseTranspose = amesosSolver_->
UseTranspose();
295 const int err = amesosSolver_->
Solve();
297 "Error, the function Solve() on the amesos solver of type\n"
298 "\'"<<
typeName(*amesosSolver_)<<
"\' failed with error code "<<err<<
"!"
307 epetra_X = Teuchos::null;
308 epetra_B = Teuchos::null;
313 if(amesosSolverScalar_!=1.0)
314 Thyra::scale(1.0/amesosSolverScalar_, X);
323 std::string(
"Solver ")+
typeName(*amesosSolver_)+std::string(
" converged!");
RCP< Epetra_MultiVector > get_Epetra_MultiVector(const Epetra_Map &map, const RCP< MultiVectorBase< double > > &mv)
void SetLHS(Epetra_MultiVector *X)
Teuchos::RCP< const LinearOpSourceBase< double > > extract_fwdOpSrc()
Extract the LinearOpSourceBase<double> object so that it can be modified.
bool is_null(const boost::shared_ptr< T > &p)
Epetra_MultiVector * GetLHS() const
basic_OSTab< char > OSTab
Epetra_MultiVector * GetRHS() const
void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual bool opSupportedImpl(EOpTransp M_trans) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
std::string description() const
EOpTransp real_trans(EOpTransp transp)
virtual const Epetra_Map & OperatorDomainMap() const =0
virtual bool solveSupportsImpl(EOpTransp M_trans) const
virtual const Epetra_Map & OperatorRangeMap() const =0
void start(bool reset=false)
virtual bool UseTranspose() const =0
SolveStatus< double > solveImpl(const EOpTransp M_trans, const MultiVectorBase< double > &B, const Ptr< MultiVectorBase< double > > &X, const Ptr< const SolveCriteria< double > > solveCriteria) const
Teuchos::RCP< const VectorSpaceBase< double > > range() const
EOpTransp trans_trans(EOpTransp trans1, EOpTransp trans2)
static ScalarMag unknownTolerance()
virtual std::string description() const
virtual void setObjectLabel(const std::string &objectLabel)
virtual bool solveSupportsSolveMeasureTypeImpl(EOpTransp M_trans, const SolveMeasureType &solveMeasureType) const
virtual int SetUseTranspose(bool UseTranspose)=0
void initialize(const Teuchos::RCP< const LinearOpBase< double > > &fwdOp, const Teuchos::RCP< const LinearOpSourceBase< double > > &fwdOpSrc, const Teuchos::RCP< Epetra_LinearProblem > &epetraLP, const Teuchos::RCP< Amesos_BaseSolver > &amesosSolver, const EOpTransp amesosSolverTransp, const double amesosSolverScalar)
First initialization.
void uninitialize(Teuchos::RCP< const LinearOpBase< double > > *fwdOp=NULL, Teuchos::RCP< const LinearOpSourceBase< double > > *fwdOpSrc=NULL, Teuchos::RCP< Epetra_LinearProblem > *epetraLP=NULL, Teuchos::RCP< Amesos_BaseSolver > *amesosSolver=NULL, EOpTransp *amesosSolverTransp=NULL, double *amesosSolverScalar=NULL)
Uninitialize.
void SetRHS(Epetra_MultiVector *B)
virtual void applyImpl(const EOpTransp M_trans, const MultiVectorBase< double > &X, const Ptr< MultiVectorBase< double > > &Y, const double alpha, const double beta) const
Teuchos::RCP< const LinearOpBase< double > > clone() const
double totalElapsedTime(bool readCurrentTime=false) const
Epetra_Operator * GetOperator() const
Teuchos::RCP< const VectorSpaceBase< double > > domain() const
AmesosLinearOpWithSolve()
Construct to uninitialized.
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
std::string typeName(const T &t)