9 #ifndef Tempus_Stepper_impl_hpp
10 #define Tempus_Stepper_impl_hpp
17 Teuchos::RCP<Teuchos::ParameterList> pl, std::string stepperType)
19 pl->setName(
"Default Stepper - " + stepperType);
20 pl->set<std::string>(
"Stepper Type", stepperType);
22 pl->set<
bool>(
"Use FSAL",
false,
23 "The First-Step-As-Last (FSAL) principle is the situation where the\n"
24 "last function evaluation, f(x^{n-1},t^{n-1}) [a.k.a. xDot^{n-1}],\n"
25 "can be used for the first function evaluation, f(x^n,t^n)\n"
26 "[a.k.a. xDot^n]. For RK methods, this applies to the stages.\n"
28 "Often the FSAL priniciple can be used to save an evaluation.\n"
29 "However there are cases when it cannot be used, e.g., operator\n"
30 "splitting where other steppers/operators have modified the solution,\n"
31 "x^*, and thus require the function evaluation, f(x^*, t^{n-1}).\n"
33 "It should be noted that when the FSAL priniciple can be used\n"
34 "(can set useFSAL=true), setting useFSAL=false will give the\n"
35 "same solution but at additional expense. However, the reverse\n"
36 "is not true. When the FSAL priniciple can not be used\n"
37 "(need to set useFSAL=false), setting useFSAL=true will produce\n"
38 "incorrect solutions.\n"
40 "Default in general for explicit and implicit steppers is false,\n"
41 "but individual steppers can override this default.");
43 pl->set<std::string>(
"Initial Condition Consistency",
"None",
44 "This indicates which type of consistency should be applied to\n"
45 "the initial conditions (ICs):\n"
47 " 'None' - Do nothing to the ICs provided in the SolutionHistory.\n"
48 " 'Zero' - Set the derivative of the SolutionState to zero in the\n"
49 " SolutionHistory provided, e.g., xDot^0 = 0, or \n"
51 " 'App' - Use the application's ICs, e.g., getNominalValues().\n"
52 " 'Consistent' - Make the initial conditions for x and xDot\n"
53 " consistent with the governing equations, e.g.,\n"
54 " xDot = f(x,t), and f(x, xDot, t) = 0. For implicit\n"
55 " ODEs, this requires a solve of f(x, xDot, t) = 0 for\n"
56 " xDot, and another Jacobian and residual may be\n"
57 " needed, e.g., boundary conditions on xDot may need\n"
58 " to replace boundary conditions on x.\n"
60 "In general for explicit steppers, the default is 'Consistent',\n"
61 "because it is fairly cheap with just one residual evaluation.\n"
62 "In general for implicit steppers, the default is 'None', because\n"
63 "the application often knows its IC and can set it the initial\n"
64 "SolutionState. Also, as noted above, 'Consistent' may require\n"
65 "another Jacobian from the application. Individual steppers may\n"
66 "override these defaults.");
68 pl->set<
bool>(
"Initial Condition Consistency Check",
true,
69 "Check if the initial condition, x and xDot, is consistent with the\n"
70 "governing equations, xDot = f(x,t), or f(x, xDot, t) = 0.\n"
72 "In general for explicit and implicit steppers, the default is true,\n"
73 "because it is fairly cheap with just one residual evaluation.\n"
74 "Individual steppers may override this default.");
81 using Teuchos::ParameterList;
84 RCP<ParameterList> noxPL = Teuchos::parameterList();
87 RCP<ParameterList> directionPL = Teuchos::parameterList();
88 directionPL->set<std::string>(
"Method",
"Newton");
89 RCP<ParameterList> newtonPL = Teuchos::parameterList();
90 newtonPL->set<std::string>(
"Forcing Term Method",
"Constant");
91 newtonPL->set<
bool> (
"Rescue Bad Newton Solve", 1);
92 directionPL->set(
"Newton", *newtonPL);
93 noxPL->set(
"Direction", *directionPL);
96 RCP<ParameterList> lineSearchPL = Teuchos::parameterList();
97 lineSearchPL->set<std::string>(
"Method",
"Full Step");
98 RCP<ParameterList> fullStepPL = Teuchos::parameterList();
99 fullStepPL->set<
double>(
"Full Step", 1);
100 lineSearchPL->set(
"Full Step", *fullStepPL);
101 noxPL->set(
"Line Search", *lineSearchPL);
103 noxPL->set<std::string>(
"Nonlinear Solver",
"Line Search Based");
106 RCP<ParameterList> printingPL = Teuchos::parameterList();
107 printingPL->set<
int>(
"Output Precision", 3);
108 printingPL->set<
int>(
"Output Processor", 0);
109 RCP<ParameterList> outputPL = Teuchos::parameterList();
110 outputPL->set<
bool>(
"Error", 1);
111 outputPL->set<
bool>(
"Warning", 1);
112 outputPL->set<
bool>(
"Outer Iteration", 0);
113 outputPL->set<
bool>(
"Parameters", 0);
114 outputPL->set<
bool>(
"Details", 0);
115 outputPL->set<
bool>(
"Linear Solver Details", 1);
116 outputPL->set<
bool>(
"Stepper Iteration", 1);
117 outputPL->set<
bool>(
"Stepper Details", 1);
118 outputPL->set<
bool>(
"Stepper Parameters", 1);
119 printingPL->set(
"Output Information", *outputPL);
120 noxPL->set(
"Printing", *printingPL);
123 RCP<ParameterList> solverOptionsPL = Teuchos::parameterList();
124 solverOptionsPL->set<std::string>(
"Status Test Check Type",
"Minimal");
125 noxPL->set(
"Solver Options", *solverOptionsPL);
128 RCP<ParameterList> statusTestsPL = Teuchos::parameterList();
129 statusTestsPL->set<std::string>(
"Test Type",
"Combo");
130 statusTestsPL->set<std::string>(
"Combo Type",
"OR");
131 statusTestsPL->set<
int>(
"Number of Tests", 2);
132 RCP<ParameterList> test0PL = Teuchos::parameterList();
133 test0PL->set<std::string>(
"Test Type",
"NormF");
134 test0PL->set<
double>(
"Tolerance", 1e-08);
135 statusTestsPL->set(
"Test 0", *test0PL);
136 RCP<ParameterList> test1PL = Teuchos::parameterList();
137 test1PL->set<std::string>(
"Test Type",
"MaxIters");
138 test1PL->set<
int>(
"Maximum Iterations", 10);
139 statusTestsPL->set(
"Test 1", *test1PL);
140 noxPL->set(
"Status Tests", *statusTestsPL);
143 RCP<ParameterList> solverPL = Teuchos::parameterList();
144 solverPL->set(
"NOX", *noxPL);
150 template<
class Scalar>
153 Teuchos::RCP<Teuchos::FancyOStream> out = this->getOStream();
155 bool isValidSetup = this->isValidSetup(*out);
158 this->isInitialized_ =
true;
160 this->describe(*out, Teuchos::VERB_MEDIUM);
164 template<
class Scalar>
167 if ( !this->isInitialized() ) {
168 this->describe( *(this->getOStream()), Teuchos::VERB_MEDIUM);
169 TEUCHOS_TEST_FOR_EXCEPTION( !this->isInitialized(), std::logic_error,
170 "Error - " << this->description() <<
" is not initialized!");
176 template<
class Scalar>
177 Teuchos::RCP<Thyra::VectorBase<Scalar> >
180 if (state->getX() != Teuchos::null) stepperX_ = state->getX();
184 TEUCHOS_TEST_FOR_EXCEPTION( stepperX_ == Teuchos::null, std::logic_error,
185 "Error - stepperX_ has not been set in setInitialConditions() or\n"
186 " can not be set from the state!\n");
191 template<
class Scalar>
192 Teuchos::RCP<Thyra::VectorBase<Scalar> >
195 if (state->getXDot() != Teuchos::null) stepperXDot_ = state->getXDot();
199 TEUCHOS_TEST_FOR_EXCEPTION( stepperXDot_ == Teuchos::null, std::logic_error,
200 "Error - stepperXDot_ has not set in setInitialConditions() or\n"
201 " can not be set from the state!\n");
206 template<
class Scalar>
207 Teuchos::RCP<Thyra::VectorBase<Scalar> >
210 if (state->getXDotDot() != Teuchos::null) stepperXDotDot_=state->getXDotDot();
214 TEUCHOS_TEST_FOR_EXCEPTION( stepperXDotDot_==Teuchos::null, std::logic_error,
215 "Error - stepperXDotDot_ has not set in setInitialConditions() or\n"
216 " can not be set from the state!\n");
218 return stepperXDotDot_;
222 template<
class Scalar>
224 const Teuchos::EVerbosityLevel verbLevel)
const
226 out <<
"--- Stepper ---\n"
228 <<
" stepperType_ = " << stepperType_ << std::endl
230 <<
" ICConsistency_ = " << ICConsistency_ << std::endl
231 <<
" ICConsistencyCheck_ = " <<
Teuchos::toString(ICConsistencyCheck_) << std::endl
232 <<
" stepperX_ = " << stepperX_ << std::endl
233 <<
" stepperXDot_ = " << stepperXDot_ << std::endl
234 <<
" stepperXDotDot_ = " << stepperXDotDot_ << std::endl;
238 template<
class Scalar>
240 Teuchos::FancyOStream & out)
const
242 bool isValidSetup =
true;
244 if ( !(ICConsistency_ ==
"None" || ICConsistency_ ==
"Zero" ||
245 ICConsistency_ ==
"App" || ICConsistency_ ==
"Consistent") ) {
246 isValidSetup =
false;
247 out <<
"The IC consistency does not have a valid value!\n"
248 <<
"('None', 'Zero', 'App' or 'Consistent')\n"
249 <<
" ICConsistency = " << ICConsistency_ <<
"\n";
257 #endif // Tempus_Stepper_impl_hpp
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
const std::string toString(const Status status)
Convert Status to string.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperX(Teuchos::RCP< SolutionState< Scalar > > state)
Get x from SolutionState or Stepper storage.
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters()
Returns the default solver ParameterList for implicit Steppers.
virtual void initialize()
Initialize after construction and changing input parameters.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDotDot(Teuchos::RCP< SolutionState< Scalar > > state)
Get xDotDot from SolutionState or Stepper storage.
virtual void checkInitialized()
Check initialization, and error out on failure.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
void getValidParametersBasic(Teuchos::RCP< Teuchos::ParameterList > pl, std::string stepperType)
Provide basic parameters to Steppers.
virtual Teuchos::RCP< Thyra::VectorBase< Scalar > > getStepperXDot(Teuchos::RCP< SolutionState< Scalar > > state)
Get xDot from SolutionState or Stepper storage.
Solution state for integrators and steppers. SolutionState contains the metadata for solutions and th...