10 #include "Teko_SolveInverseFactory.hpp"
13 #include "Thyra_DefaultLinearOpSource.hpp"
14 #include "Thyra_DefaultInverseLinearOp.hpp"
15 #include "Thyra_DefaultPreconditioner.hpp"
18 #include "Stratimikos_DefaultLinearSolverBuilder.hpp"
22 #include "Teko_BlockPreconditionerFactory.hpp"
23 #include "Teko_Preconditioner.hpp"
24 #include "Teko_PreconditionerLinearOp.hpp"
28 using Teuchos::rcp_const_cast;
29 using Teuchos::rcp_dynamic_cast;
42 SolveInverseFactory::SolveInverseFactory(
43 const Teuchos::RCP<Thyra::LinearOpWithSolveFactoryBase<double> >& lowsFactory)
44 : lowsFactory_(lowsFactory) {}
47 SolveInverseFactory::SolveInverseFactory(
const SolveInverseFactory& siFactory)
48 : lowsFactory_(siFactory.lowsFactory_) {}
59 InverseLinearOp SolveInverseFactory::buildInverse(
const LinearOp& linearOp)
const {
60 Teko_DEBUG_SCOPE(
"SolveInverseFactory::buildInverse(linearOp)", 10);
63 Teuchos::RCP<Thyra::LinearOpWithSolveBase<double> > invLOWS = lowsFactory_->createOp();
64 lowsFactory_->initializeOp(Thyra::defaultLinearOpSource(linearOp), &*invLOWS,
65 Thyra::SUPPORT_SOLVE_FORWARD_ONLY);
67 return Thyra::nonconstInverse<double>(invLOWS);
82 InverseLinearOp SolveInverseFactory::buildInverse(
const LinearOp& linearOp,
83 const LinearOp& precOp)
const {
84 Teko_DEBUG_SCOPE(
"SolveInverseFactory::buildInverse(linearOp,precOp)", 10);
87 Teuchos::RCP<Thyra::LinearOpWithSolveBase<double> > invLOWS = lowsFactory_->createOp();
88 lowsFactory_->initializePreconditionedOp(Thyra::defaultLinearOpSource(linearOp),
89 Thyra::unspecifiedPrec(precOp), &*invLOWS,
90 Thyra::SUPPORT_SOLVE_FORWARD_ONLY);
92 return Thyra::nonconstInverse<double>(invLOWS);
106 void SolveInverseFactory::rebuildInverse(
const LinearOp& source, InverseLinearOp& dest)
const {
107 RCP<Thyra::DefaultInverseLinearOp<double> > invDest =
108 rcp_dynamic_cast<Thyra::DefaultInverseLinearOp<double> >(dest);
109 RCP<Thyra::LinearOpWithSolveBase<double> > lows = invDest->getNonconstLows();
114 lowsFactory_->initializeOp(Thyra::defaultLinearOpSource(source), &*lows);
129 void SolveInverseFactory::rebuildInverse(
const LinearOp& source,
const LinearOp& precOp,
130 InverseLinearOp& dest)
const {
131 RCP<Thyra::DefaultInverseLinearOp<double> > invDest =
132 rcp_dynamic_cast<Thyra::DefaultInverseLinearOp<double> >(dest);
133 RCP<Thyra::LinearOpWithSolveBase<double> > lows = invDest->getNonconstLows();
136 lowsFactory_->initializePreconditionedOp(Thyra::defaultLinearOpSource(source),
137 Thyra::unspecifiedPrec(precOp), &*lows,
138 Thyra::SUPPORT_SOLVE_FORWARD_ONLY);
149 Teuchos::RCP<const Teuchos::ParameterList> SolveInverseFactory::getParameterList()
const {
150 return lowsFactory_->getParameterList();