9 #ifndef Tempus_StepperImplicit_impl_hpp
10 #define Tempus_StepperImplicit_impl_hpp
19 #include "NOX_Thyra.H"
25 template<
class Scalar>
27 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& appModel)
29 this->validImplicitODE_DAE(appModel);
35 template<
class Scalar>
37 const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& appModel)
39 this->setModel(appModel);
49 template<
class Scalar>
52 Teuchos::RCP<Teuchos::ParameterList> solverPL =
53 Teuchos::sublist(stepperPL_, solverName,
true);
54 this->setSolver(solverPL);
64 template<
class Scalar>
66 Teuchos::RCP<Teuchos::ParameterList> solverPL)
69 using Teuchos::ParameterList;
71 std::string solverName = stepperPL_->get<std::string>(
"Solver Name");
72 if (is_null(solverPL)) {
73 if ( stepperPL_->isSublist(solverName) )
74 solverPL = Teuchos::sublist(stepperPL_, solverName,
true);
76 solverPL = this->defaultSolverParameters();
78 if (solverName == solverPL->name()) {
79 RCP<Teuchos::FancyOStream> out = this->getOStream();
80 Teuchos::OSTab ostab(out,1,
"StepperImplicit::setSolver()");
81 *out <<
"Warning - Replacing the solver ParameterList.\n"
82 <<
" Stepper Type = "<< stepperPL_->get<std::string>(
"Stepper Type")
83 <<
"\n Solver PL = " << solverName << std::endl;
84 stepperPL_->remove(solverName);
88 solverName = solverPL->name();
89 stepperPL_->set(
"Solver Name", solverName);
90 stepperPL_->set(solverName, *solverPL);
91 RCP<ParameterList> noxPL = Teuchos::sublist(solverPL,
"NOX",
true);
93 solver_ = rcp(
new Thyra::NOXNonlinearSolver());
94 solver_->setParameterList(noxPL);
96 TEUCHOS_TEST_FOR_EXCEPTION(wrapperModel_ == Teuchos::null, std::logic_error,
97 "Error - StepperImplicit<Scalar>::setSolver() wrapperModel_ is unset!\n"
98 <<
" Should call setModel(...) first.\n");
99 solver_->setModel(wrapperModel_);
108 template<
class Scalar>
110 Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver)
112 Teuchos::RCP<Teuchos::ParameterList> solverPL =
113 solver->getNonconstParameterList();
114 this->setSolver(solverPL);
118 template<
class Scalar>
119 const Thyra::SolveStatus<Scalar>
121 const Teuchos::RCP<Thyra::VectorBase<Scalar> > & x)
123 if (getZeroInitialGuess())
124 Thyra::assign(x.ptr(), Teuchos::ScalarTraits<Scalar>::zero());
126 const Thyra::SolveStatus<Scalar> sStatus = (*solver_).solve(&*x);
133 #endif // Tempus_StepperImplicit_impl_hpp