9 #ifndef Tempus_Stepper_hpp
10 #define Tempus_Stepper_hpp
13 #include "Teuchos_VerboseObject.hpp"
14 #include "Teuchos_Describable.hpp"
15 #include "Teuchos_ParameterList.hpp"
16 #include "Teuchos_StandardParameterEntryValidators.hpp"
17 #include "Teuchos_TimeMonitor.hpp"
20 #include "Thyra_ModelEvaluator.hpp"
21 #include "Thyra_NonlinearSolverBase.hpp"
24 #include "Tempus_config.hpp"
25 #include "Tempus_SolutionHistory.hpp"
66 template<
class Scalar>
68 :
virtual public Teuchos::Describable,
69 virtual public Teuchos::VerboseObject<Stepper<Scalar> >,
70 virtual public Teuchos::ParameterListAcceptor
77 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& appModel) = 0;
79 const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& appModel) = 0;
80 virtual Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >
getModel() = 0;
83 virtual void setSolver(std::string solverName) = 0;
86 Teuchos::RCP<Teuchos::ParameterList> solverPL=Teuchos::null) = 0;
89 Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> > solver) = 0;
91 virtual Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> >
96 Teuchos::RCP<StepperObserver<Scalar> > obs = Teuchos::null) = 0;
107 Teuchos::RCP<
const Thyra::VectorBase<Scalar> > initial_guess = Teuchos::null) = 0;
111 virtual Teuchos::RCP<Tempus::StepperState<Scalar> >
113 virtual Scalar
getOrder()
const = 0;
117 const Teuchos::RCP<SolutionHistory<Scalar> >&
solutionHistory)
const = 0;
131 std::vector<Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> > > models){}
142 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
const
144 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
145 typedef Thyra::ModelEvaluatorBase MEB;
146 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
147 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
148 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
149 outArgs.supports(MEB::OUT_ARG_f);
151 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
152 model->description() <<
"can not support an explicit ODE with\n"
153 <<
" IN_ARG_x = " << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
154 <<
" OUT_ARG_f = " << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
155 <<
"Explicit ODE requires:\n"
156 <<
" IN_ARG_x = true\n"
157 <<
" OUT_ARG_f = true\n"
159 <<
"NOTE: Currently the convention to evaluate f(x,t) is to set\n"
160 <<
"xdot=null! There is no InArgs support to test if xdot is null,\n"
161 <<
"so we set xdot=null and hope the ModelEvaluator can handle it.\n");
172 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
const
174 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
175 typedef Thyra::ModelEvaluatorBase MEB;
176 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
177 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
178 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
179 inArgs.supports(MEB::IN_ARG_x_dot) and
180 outArgs.supports(MEB::OUT_ARG_f);
182 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
183 model->description() <<
"can not support an explicit ODE with\n"
184 <<
" IN_ARG_x = " << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
185 <<
" IN_ARG_x_dot = " << inArgs.supports(MEB::IN_ARG_x_dot) <<
"\n"
186 <<
" OUT_ARG_f = " << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
187 <<
"Explicit ODE requires:\n"
188 <<
" IN_ARG_x = true\n"
189 <<
" IN_ARG_x_dot = true\n"
190 <<
" OUT_ARG_f = true\n"
192 <<
"NOTE: Currently the convention to evaluate f(x, xdot, t) is to\n"
193 <<
"set xdotdot=null! There is no InArgs support to test if xdotdot\n"
194 <<
"is null, so we set xdotdot=null and hope the ModelEvaluator can\n"
203 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
const
205 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
206 typedef Thyra::ModelEvaluatorBase MEB;
207 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
208 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
209 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
210 inArgs.supports(MEB::IN_ARG_x_dot) and
211 inArgs.supports(MEB::IN_ARG_alpha) and
212 inArgs.supports(MEB::IN_ARG_beta) and
213 !inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) and
214 outArgs.supports(MEB::OUT_ARG_f) and
215 outArgs.supports(MEB::OUT_ARG_W);
217 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
218 model->description() <<
" can not support an implicit ODE with\n"
220 << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
221 <<
" IN_ARG_x_dot = "
222 << inArgs.supports(MEB::IN_ARG_x_dot) <<
"\n"
223 <<
" IN_ARG_alpha = "
224 << inArgs.supports(MEB::IN_ARG_alpha) <<
"\n"
226 << inArgs.supports(MEB::IN_ARG_beta) <<
"\n"
227 <<
" IN_ARG_W_x_dot_dot_coeff = "
228 << inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) <<
"\n"
230 << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
232 << outArgs.supports(MEB::OUT_ARG_W) <<
"\n"
233 <<
"Implicit ODE requires:\n"
234 <<
" IN_ARG_x = true\n"
235 <<
" IN_ARG_x_dot = true\n"
236 <<
" IN_ARG_alpha = true\n"
237 <<
" IN_ARG_beta = true\n"
238 <<
" IN_ARG_W_x_dot_dot_coeff = false\n"
239 <<
" OUT_ARG_f = true\n"
240 <<
" OUT_ARG_W = true\n");
247 const Teuchos::RCP<
const Thyra::ModelEvaluator<Scalar> >& model)
const
249 TEUCHOS_TEST_FOR_EXCEPT( is_null(model) );
250 typedef Thyra::ModelEvaluatorBase MEB;
251 const MEB::InArgs<Scalar> inArgs = model->createInArgs();
252 const MEB::OutArgs<Scalar> outArgs = model->createOutArgs();
253 const bool supports = inArgs.supports(MEB::IN_ARG_x) and
254 inArgs.supports(MEB::IN_ARG_x_dot) and
255 inArgs.supports(MEB::IN_ARG_x_dot_dot) and
256 inArgs.supports(MEB::IN_ARG_alpha) and
257 inArgs.supports(MEB::IN_ARG_beta) and
258 inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) and
259 outArgs.supports(MEB::OUT_ARG_f) and
260 outArgs.supports(MEB::OUT_ARG_W);
262 TEUCHOS_TEST_FOR_EXCEPTION( supports ==
false, std::logic_error,
263 model->description() <<
" can not support an implicit ODE with\n"
265 << inArgs.supports(MEB::IN_ARG_x) <<
"\n"
266 <<
" IN_ARG_x_dot = "
267 << inArgs.supports(MEB::IN_ARG_x_dot) <<
"\n"
268 <<
" IN_ARG_x_dot_dot = "
269 << inArgs.supports(MEB::IN_ARG_x_dot_dot) <<
"\n"
270 <<
" IN_ARG_alpha = "
271 << inArgs.supports(MEB::IN_ARG_alpha) <<
"\n"
273 << inArgs.supports(MEB::IN_ARG_beta) <<
"\n"
274 <<
" IN_ARG_W_x_dot_dot_coeff = "
275 << inArgs.supports(MEB::IN_ARG_W_x_dot_dot_coeff) <<
"\n"
277 << outArgs.supports(MEB::OUT_ARG_f) <<
"\n"
279 << outArgs.supports(MEB::OUT_ARG_W) <<
"\n"
280 <<
"Implicit Second Order ODE requires:\n"
281 <<
" IN_ARG_x = true\n"
282 <<
" IN_ARG_x_dot = true\n"
283 <<
" IN_ARG_x_dot_dot = true\n"
284 <<
" IN_ARG_alpha = true\n"
285 <<
" IN_ARG_beta = true\n"
286 <<
" IN_ARG_W_x_dot_dot_coeff = true\n"
287 <<
" OUT_ARG_f = true\n"
288 <<
" OUT_ARG_W = true\n");
296 using Teuchos::ParameterList;
299 RCP<ParameterList> noxPL = Teuchos::parameterList();
302 RCP<ParameterList> directionPL = Teuchos::parameterList();
303 directionPL->set<std::string>(
"Method",
"Newton");
304 RCP<ParameterList> newtonPL = Teuchos::parameterList();
305 newtonPL->set<std::string>(
"Forcing Term Method",
"Constant");
306 newtonPL->set<
bool> (
"Rescue Bad Newton Solve", 1);
307 directionPL->set(
"Newton", *newtonPL);
308 noxPL->set(
"Direction", *directionPL);
311 RCP<ParameterList> lineSearchPL = Teuchos::parameterList();
312 lineSearchPL->set<std::string>(
"Method",
"Full Step");
313 RCP<ParameterList> fullStepPL = Teuchos::parameterList();
314 fullStepPL->set<
double>(
"Full Step", 1);
315 lineSearchPL->set(
"Full Step", *fullStepPL);
316 noxPL->set(
"Line Search", *lineSearchPL);
318 noxPL->set<std::string>(
"Nonlinear Solver",
"Line Search Based");
321 RCP<ParameterList> printingPL = Teuchos::parameterList();
322 printingPL->set<
int>(
"Output Precision", 3);
323 printingPL->set<
int>(
"Output Processor", 0);
324 RCP<ParameterList> outputPL = Teuchos::parameterList();
325 outputPL->set<
bool>(
"Error", 1);
326 outputPL->set<
bool>(
"Warning", 1);
327 outputPL->set<
bool>(
"Outer Iteration", 0);
328 outputPL->set<
bool>(
"Parameters", 0);
329 outputPL->set<
bool>(
"Details", 0);
330 outputPL->set<
bool>(
"Linear Solver Details", 1);
331 outputPL->set<
bool>(
"Stepper Iteration", 1);
332 outputPL->set<
bool>(
"Stepper Details", 1);
333 outputPL->set<
bool>(
"Stepper Parameters", 1);
334 printingPL->set(
"Output Information", *outputPL);
335 noxPL->set(
"Printing", *printingPL);
338 RCP<ParameterList> solverOptionsPL = Teuchos::parameterList();
339 solverOptionsPL->set<std::string>(
"Status Test Check Type",
"Minimal");
340 noxPL->set(
"Solver Options", *solverOptionsPL);
343 RCP<ParameterList> statusTestsPL = Teuchos::parameterList();
344 statusTestsPL->set<std::string>(
"Test Type",
"Combo");
345 statusTestsPL->set<std::string>(
"Combo Type",
"OR");
346 statusTestsPL->set<
int>(
"Number of Tests", 2);
347 RCP<ParameterList> test0PL = Teuchos::parameterList();
348 test0PL->set<std::string>(
"Test Type",
"NormF");
349 test0PL->set<
double>(
"Tolerance", 1e-08);
350 statusTestsPL->set(
"Test 0", *test0PL);
351 RCP<ParameterList> test1PL = Teuchos::parameterList();
352 test1PL->set<std::string>(
"Test Type",
"MaxIters");
353 test1PL->set<
int>(
"Maximum Iterations", 10);
354 statusTestsPL->set(
"Test 1", *test1PL);
355 noxPL->set(
"Status Tests", *statusTestsPL);
358 RCP<ParameterList> solverPL = Teuchos::parameterList();
359 solverPL->set(
"NOX", *noxPL);
367 #endif // Tempus_Stepper_hpp