Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Tempus_SubcyclingTest.cpp
Go to the documentation of this file.
1//@HEADER
2// *****************************************************************************
3// Tempus: Time Integration and Sensitivity Analysis Package
4//
5// Copyright 2017 NTESS and the Tempus contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8//@HEADER
9
10#include "Teuchos_UnitTestHarness.hpp"
11#include "Teuchos_XMLParameterListHelpers.hpp"
12#include "Teuchos_TimeMonitor.hpp"
13
14#include "Thyra_VectorStdOps.hpp"
15
16#include "Tempus_IntegratorBasic.hpp"
17#include "Tempus_IntegratorObserverSubcycling.hpp"
18
19#include "Tempus_StepperFactory.hpp"
20#include "Tempus_StepperForwardEuler.hpp"
21#include "Tempus_StepperBackwardEuler.hpp"
22#include "Tempus_StepperSubcycling.hpp"
23#include "Tempus_StepperOperatorSplit.hpp"
26
27#include "../TestModels/SinCosModel.hpp"
28#include "../TestModels/VanDerPol_IMEX_ExplicitModel.hpp"
29#include "../TestModels/VanDerPol_IMEX_ImplicitModel.hpp"
30#include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
31
32#include <fstream>
33#include <vector>
34
35namespace Tempus_Test {
36
37using Teuchos::getParametersFromXmlFile;
38using Teuchos::ParameterList;
39using Teuchos::RCP;
40using Teuchos::rcp;
41using Teuchos::rcp_const_cast;
42using Teuchos::rcp_dynamic_cast;
43using Teuchos::sublist;
44
48
49// ************************************************************
50// ************************************************************
51TEUCHOS_UNIT_TEST(Subcycling, ParameterList)
52{
53 // Read params from .xml file
54 RCP<ParameterList> pList =
55 getParametersFromXmlFile("Tempus_Subcycling_SinCos.xml");
56
57 // std::ofstream ftmp("PL.txt");
58 // pList->print(ftmp);
59 // ftmp.close();
60
61 // Setup the SinCosModel
62 RCP<ParameterList> scm_pl = sublist(pList, "SinCosModel", true);
63 auto model = rcp(new SinCosModel<double>(scm_pl));
64
65 RCP<ParameterList> tempusPL = sublist(pList, "Tempus", true);
66
67 // Test constructor IntegratorBasic(tempusPL, model)
68 {
69 RCP<Tempus::IntegratorBasic<double>> integrator =
70 Tempus::createIntegratorBasic<double>(tempusPL, model);
71
72 RCP<ParameterList> stepperPL = sublist(tempusPL, "Demo Stepper", true);
73 RCP<const ParameterList> defaultPL =
74 integrator->getStepper()->getValidParameters();
75
76 bool pass = haveSameValuesSorted(*stepperPL, *defaultPL, true);
77 if (!pass) {
78 out << std::endl;
79 out << "stepperPL -------------- \n"
80 << *stepperPL << std::endl;
81 out << "defaultPL -------------- \n"
82 << *defaultPL << std::endl;
83 }
84 TEST_ASSERT(pass)
85 }
86
87 // Test constructor IntegratorBasic(model, stepperType)
88 {
89 RCP<Tempus::IntegratorBasic<double>> integrator =
90 Tempus::createIntegratorBasic<double>(model,
91 std::string("Forward Euler"));
92
93 RCP<ParameterList> stepperPL = sublist(tempusPL, "Demo Stepper", true);
94 RCP<const ParameterList> defaultPL =
95 integrator->getStepper()->getValidParameters();
96
97 bool pass = haveSameValuesSorted(*stepperPL, *defaultPL, true);
98 if (!pass) {
99 out << std::endl;
100 out << "stepperPL -------------- \n"
101 << *stepperPL << std::endl;
102 out << "defaultPL -------------- \n"
103 << *defaultPL << std::endl;
104 }
105 TEST_ASSERT(pass)
106 }
107}
108
109// ************************************************************
110// ************************************************************
111TEUCHOS_UNIT_TEST(Subcycling, ConstructingFromDefaults)
112{
113 double dt = 0.4;
114
115 // Setup the SinCosModel ------------------------------------
116 auto model = rcp(new SinCosModel<double>());
117 auto modelME = rcp_dynamic_cast<const Thyra::ModelEvaluator<double>>(model);
118
119 // Setup Stepper for field solve ----------------------------
120 auto stepper = rcp(new Tempus::StepperSubcycling<double>());
121 auto stepperFE = Tempus::createStepperForwardEuler(modelME, Teuchos::null);
122 stepper->setSubcyclingStepper(stepperFE);
123
124 stepper->setSubcyclingMinTimeStep(0.1);
125 stepper->setSubcyclingInitTimeStep(0.1);
126 stepper->setSubcyclingMaxTimeStep(0.1);
127 stepper->setSubcyclingMaxFailures(10);
128 stepper->setSubcyclingMaxConsecFailures(5);
129 stepper->setSubcyclingScreenOutputIndexInterval(1);
130 stepper->setSubcyclingIntegratorObserver(
132 stepper->setSubcyclingPrintDtChanges(true);
133
134 // Set subcycling strategy.
135 auto subStrategy =
137 stepper->setSubcyclingTimeStepControlStrategy(subStrategy);
138
139 // Setup TimeStepControl ------------------------------------
140 auto timeStepControl = rcp(new Tempus::TimeStepControl<double>());
141 timeStepControl->setInitIndex(0);
142 timeStepControl->setFinalIndex(10);
143 timeStepControl->setInitTime(0.0);
144 timeStepControl->setFinalTime(1.0);
145 timeStepControl->setInitTimeStep(dt);
146
147 // Set TimeStepControl strategy.
148 auto strategy = rcp(new Tempus::TimeStepControlStrategyBasicVS<double>());
149 strategy->initialize();
150 timeStepControl->setTimeStepControlStrategy(strategy);
151
152 timeStepControl->initialize();
153
154 // Setup initial condition SolutionState --------------------
155 auto inArgsIC = stepper->getModel()->getNominalValues();
156 auto icSolution = rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x());
157 auto icState = Tempus::createSolutionStateX(icSolution);
158 icState->setTime(timeStepControl->getInitTime());
159 icState->setIndex(timeStepControl->getInitIndex());
160 icState->setTimeStep(0.0); // dt for ICs are indicated by zero.
161 icState->setSolutionStatus(Tempus::Status::PASSED); // ICs are passing.
162
163 // Setup SolutionHistory ------------------------------------
164 auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
165 solutionHistory->setName("Forward States");
166 solutionHistory->setStorageType(Tempus::STORAGE_TYPE_STATIC);
167 solutionHistory->setStorageLimit(2);
168 solutionHistory->addState(icState);
169
170 // Ensure ICs are consistent and stepper memory is set (e.g., xDot is set).
171 stepper->setInitialConditions(solutionHistory);
172 stepper->initialize();
173
174 // Setup Integrator -----------------------------------------
175 RCP<Tempus::IntegratorBasic<double>> integrator =
176 Tempus::createIntegratorBasic<double>();
177 integrator->setStepper(stepper);
178 integrator->setTimeStepControl(timeStepControl);
179 integrator->setSolutionHistory(solutionHistory);
180 integrator->setScreenOutputIndexInterval(1);
181 // integrator->setObserver(...);
182 integrator->initialize();
183
184 // Integrate to timeMax
185 bool integratorStatus = integrator->advanceTime();
186 TEST_ASSERT(integratorStatus)
187
188 // Test if at 'Final Time'
189 double time = integrator->getTime();
190 double timeFinal = 1.0;
191 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
192
193 // Time-integrated solution and the exact solution
194 RCP<Thyra::VectorBase<double>> x = integrator->getX();
195 RCP<const Thyra::VectorBase<double>> x_exact =
196 model->getExactSolution(time).get_x();
197
198 // Calculate the error
199 RCP<Thyra::VectorBase<double>> xdiff = x->clone_v();
200 Thyra::V_StVpStV(xdiff.ptr(), 1.0, *x_exact, -1.0, *(x));
201
202 // Check the order and intercept
203 out << " Stepper = " << stepper->description() << std::endl;
204 out << " =========================" << std::endl;
205 out << " Exact solution : " << get_ele(*(x_exact), 0) << " "
206 << get_ele(*(x_exact), 1) << std::endl;
207 out << " Computed solution: " << get_ele(*(x), 0) << " "
208 << get_ele(*(x), 1) << std::endl;
209 out << " Difference : " << get_ele(*(xdiff), 0) << " "
210 << get_ele(*(xdiff), 1) << std::endl;
211 out << " =========================" << std::endl;
212 TEST_FLOATING_EQUALITY(get_ele(*(x), 0), 0.882508, 1.0e-4);
213 TEST_FLOATING_EQUALITY(get_ele(*(x), 1), 0.570790, 1.0e-4);
214}
215
216// ************************************************************
217// ************************************************************
218TEUCHOS_UNIT_TEST(Subcycling, SinCosAdapt)
219{
220 RCP<Tempus::IntegratorBasic<double>> integrator;
221 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
222 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
223 std::vector<double> StepSize;
224
225 double dt = 0.05;
226
227 // Setup the SinCosModel
228 const int nTimeStepSizes = 2;
229 std::string output_file_string = "Tempus_Subcycling_SinCos";
230 std::string output_file_name = output_file_string + ".dat";
231 std::string err_out_file_name = output_file_string + "-Error.dat";
232 double time = 0.0;
233 for (int n = 0; n < nTimeStepSizes; n++) {
234 dt /= 2;
235
236 // Setup the SinCosModel ------------------------------------
237 auto model = rcp(new SinCosModel<double>());
238 auto modelME = rcp_dynamic_cast<const Thyra::ModelEvaluator<double>>(model);
239
240 // Setup Stepper for field solve ----------------------------
241 auto stepper = rcp(new Tempus::StepperSubcycling<double>());
242 auto stepperFE = Tempus::createStepperForwardEuler(modelME, Teuchos::null);
243 stepper->setSubcyclingStepper(stepperFE);
244
245 stepper->setSubcyclingMinTimeStep(dt / 10.0);
246 stepper->setSubcyclingInitTimeStep(dt / 10.0);
247 stepper->setSubcyclingMaxTimeStep(dt);
248 stepper->setSubcyclingMaxFailures(10);
249 stepper->setSubcyclingMaxConsecFailures(5);
250 stepper->setSubcyclingScreenOutputIndexInterval(1);
251 // stepper->setSubcyclingIntegratorObserver(
252 // Teuchos::rcp(new Tempus::IntegratorObserverSubcycling<double>()));
253 // stepper->setSubcyclingPrintDtChanges (true);
254
255 // Set variable strategy.
256 auto strategy = rcp(new Tempus::TimeStepControlStrategyBasicVS<double>());
257 strategy->setMinEta(0.02);
258 strategy->setMaxEta(0.04);
259 strategy->initialize();
260 stepper->setSubcyclingTimeStepControlStrategy(strategy);
261
262 // Setup TimeStepControl ------------------------------------
263 auto timeStepControl = rcp(new Tempus::TimeStepControl<double>());
264 timeStepControl->setInitIndex(0);
265 timeStepControl->setInitTime(0.0);
266 timeStepControl->setFinalTime(1.0);
267 timeStepControl->setMinTimeStep(dt);
268 timeStepControl->setInitTimeStep(dt);
269 timeStepControl->setMaxTimeStep(dt);
270 timeStepControl->initialize();
271
272 // Setup initial condition SolutionState --------------------
273 auto inArgsIC = stepper->getModel()->getNominalValues();
274 auto icSolution =
275 rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x());
276 auto icState = Tempus::createSolutionStateX(icSolution);
277 icState->setTime(timeStepControl->getInitTime());
278 icState->setIndex(timeStepControl->getInitIndex());
279 icState->setTimeStep(0.0); // dt for ICs are zero.
280 icState->setSolutionStatus(Tempus::Status::PASSED); // ICs are passing.
281
282 // Setup SolutionHistory ------------------------------------
283 auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
284 solutionHistory->setName("Forward States");
285 solutionHistory->setStorageType(Tempus::STORAGE_TYPE_STATIC);
286 solutionHistory->setStorageLimit(2);
287 solutionHistory->addState(icState);
288
289 // Ensure ICs are consistent and stepper memory is set (e.g., xDot is set).
290 stepper->setInitialConditions(solutionHistory);
291 stepper->initialize();
292
293 // Setup Integrator -----------------------------------------
294 integrator = Tempus::createIntegratorBasic<double>();
295 integrator->setStepper(stepper);
296 integrator->setTimeStepControl(timeStepControl);
297 integrator->setSolutionHistory(solutionHistory);
298 integrator->setScreenOutputIndexInterval(10);
299 // integrator->setObserver(...);
300 integrator->initialize();
301
302 // Integrate to timeMax
303 bool integratorStatus = integrator->advanceTime();
304 TEST_ASSERT(integratorStatus)
305
306 // Test if at 'Final Time'
307 time = integrator->getTime();
308 double timeFinal = 1.0;
309 TEST_FLOATING_EQUALITY(time, timeFinal, 1.0e-14);
310
311 // Time-integrated solution and the exact solution
312 RCP<Thyra::VectorBase<double>> x = integrator->getX();
313 RCP<const Thyra::VectorBase<double>> x_exact =
314 model->getExactSolution(time).get_x();
315
317 // if (n == 0) {
318 // std::ofstream ftmp(output_file_name);
319 // //Warning: the following assumes serial run
320 // FILE *gold_file = fopen("Tempus_Subcycling_SinCos_AdaptDt_gold.dat",
321 // "r"); RCP<const SolutionHistory<double> > solutionHistory =
322 // integrator->getSolutionHistory();
323 // RCP<const Thyra::VectorBase<double> > x_exact_plot;
324 // for (int i=0; i<solutionHistory->getNumStates(); i++) {
325 // char time_gold_char[100];
326 // fgets(time_gold_char, 100, gold_file);
327 // double time_gold;
328 // sscanf(time_gold_char, "%lf", &time_gold);
329 // RCP<const SolutionState<double> > solutionState =
330 // (*solutionHistory)[i]; double time_i = solutionState->getTime();
331 // //Throw error if time does not match time in gold file to specified
332 // tolerance TEST_FLOATING_EQUALITY( time_i, time_gold, 1.0e-5 );
333 // RCP<const Thyra::VectorBase<double> > x_plot = solutionState->getX();
334 // x_exact_plot = model->getExactSolution(time_i).get_x();
335 // ftmp << time_i << " "
336 // << get_ele(*(x_plot), 0) << " "
337 // << get_ele(*(x_plot), 1) << " "
338 // << get_ele(*(x_exact_plot), 0) << " "
339 // << get_ele(*(x_exact_plot), 1) << std::endl;
340 // }
341 // ftmp.close();
342 // }
343
344 // Store off the final solution and step size
345 StepSize.push_back(dt);
346 auto solution = Thyra::createMember(model->get_x_space());
347 Thyra::copy(*(integrator->getX()), solution.ptr());
348 solutions.push_back(solution);
349 if (n == nTimeStepSizes - 1) { // Add exact solution last in vector.
350 StepSize.push_back(0.0);
351 auto solutionExact = Thyra::createMember(model->get_x_space());
352 Thyra::copy(*(model->getExactSolution(time).get_x()),
353 solutionExact.ptr());
354 solutions.push_back(solutionExact);
355 }
356 }
357
358 // Check the order and intercept
359 if (nTimeStepSizes > 1) {
360 double xSlope = 0.0;
361 double xDotSlope = 0.0;
362 std::vector<double> xErrorNorm;
363 std::vector<double> xDotErrorNorm;
364 RCP<Tempus::Stepper<double>> stepper = integrator->getStepper();
365 // double order = stepper->getOrder();
366 writeOrderError("Tempus_BDF2_SinCos-Error.dat", stepper, StepSize,
367 solutions, xErrorNorm, xSlope, solutionsDot, xDotErrorNorm,
368 xDotSlope, out);
369
370 TEST_FLOATING_EQUALITY(xSlope, 1.00137, 0.01);
371 // TEST_FLOATING_EQUALITY( xDotSlope, 1.95089, 0.01 );
372 TEST_FLOATING_EQUALITY(xErrorNorm[0], 0.00387948, 1.0e-4);
373 // TEST_FLOATING_EQUALITY( xDotErrorNorm[0], 0.000197325, 1.0e-4 );
374 }
375
376 Teuchos::TimeMonitor::summarize();
377}
378
379// ************************************************************
380// ************************************************************
381TEUCHOS_UNIT_TEST(Subcycling, VanDerPolOperatorSplit)
382{
383 RCP<Tempus::IntegratorBasic<double>> integrator;
384 std::vector<RCP<Thyra::VectorBase<double>>> solutions;
385 std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
386 std::vector<double> StepSize;
387 std::vector<double> xErrorNorm;
388 std::vector<double> xDotErrorNorm;
389 const int nTimeStepSizes = 4; // 8 for Error plot
390 double dt = 0.1;
391 double time = 0.0;
392 for (int n = 0; n < nTimeStepSizes; n++) {
393 // Set the step size
394 dt /= 2;
395 if (n == nTimeStepSizes - 1) dt /= 10.0;
396
397 // Setup the explicit and implicit VanDerPol ModelEvaluators
398 auto tmpModel = rcp(new VanDerPol_IMEX_ExplicitModel<double>());
399 auto pl = Teuchos::rcp_const_cast<Teuchos::ParameterList>(
400 tmpModel->getValidParameters());
401 pl->set("Coeff epsilon", 0.1);
402 RCP<const Thyra::ModelEvaluator<double>> explicitModel =
404 RCP<const Thyra::ModelEvaluator<double>> implicitModel =
406
407 // Setup Steppers for field solve ---------------------------
408
409 // Explicit Subcycling Stepper
410 auto stepperSC = rcp(new Tempus::StepperSubcycling<double>());
411 auto stepperFE =
412 Tempus::createStepperForwardEuler(explicitModel, Teuchos::null);
413 stepperFE->setUseFSAL(false);
414 stepperFE->initialize();
415 stepperSC->setSubcyclingStepper(stepperFE);
416
417 stepperSC->setSubcyclingMinTimeStep(0.00001);
418 stepperSC->setSubcyclingInitTimeStep(dt / 10.0);
419 stepperSC->setSubcyclingMaxTimeStep(dt / 10.0);
420 stepperSC->setSubcyclingMaxFailures(10);
421 stepperSC->setSubcyclingMaxConsecFailures(5);
422 stepperSC->setSubcyclingScreenOutputIndexInterval(1);
423 // stepper->setSubcyclingIntegratorObserver(
424 // Teuchos::rcp(new Tempus::IntegratorObserverSubcycling<double>()));
425 // stepperSC->setSubcyclingPrintDtChanges (true);
426
427 auto strategySC = rcp(new Tempus::TimeStepControlStrategyBasicVS<double>());
428 strategySC->setMinEta(0.000001);
429 strategySC->setMaxEta(0.01);
430 strategySC->initialize();
431 stepperSC->setSubcyclingTimeStepControlStrategy(strategySC);
432
433 // Implicit Stepper
434 auto stepperBE =
435 Tempus::createStepperBackwardEuler(implicitModel, Teuchos::null);
436
437 // Operator-Split Stepper
438 auto stepper = rcp(new Tempus::StepperOperatorSplit<double>());
439 stepper->addStepper(stepperSC);
440 stepper->addStepper(stepperBE);
441
442 // Setup TimeStepControl ------------------------------------
443 auto timeStepControl = rcp(new Tempus::TimeStepControl<double>());
444 timeStepControl->setInitIndex(0);
445 timeStepControl->setInitTime(0.0);
446 // timeStepControl->setFinalIndex(2);
447 timeStepControl->setFinalTime(2.0);
448 timeStepControl->setMinTimeStep(0.000001);
449 timeStepControl->setInitTimeStep(dt);
450 timeStepControl->setMaxTimeStep(dt);
451
452 // timeStepControl->setInitTimeStep(dt/2.0);
453 // timeStepControl->setMaxTimeStep (dt);
454 // auto strategy = rcp(new
455 // Tempus::TimeStepControlStrategyBasicVS<double>());
456 // strategy->setMinEta(1.0e-6);
457 // strategy->setMaxEta(5.0);
458 // strategy->initialize();
459 // timeStepControl->getTimeStepControlStrategy()->clearObservers();
460 // timeStepControl->getTimeStepControlStrategy()->addStrategy(strategy);
461
462 timeStepControl->initialize();
463
464 // Setup initial condition SolutionState --------------------
465 auto inArgsIC = stepper->getModel()->getNominalValues();
466 auto icX = rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x());
467 auto icXDot =
468 rcp_const_cast<Thyra::VectorBase<double>>(inArgsIC.get_x_dot());
469 auto icState = Tempus::createSolutionStateX(icX, icXDot);
470 icState->setTime(timeStepControl->getInitTime());
471 icState->setIndex(timeStepControl->getInitIndex());
472 icState->setTimeStep(0.0); // dt for ICs are zero.
473 icState->setOrder(stepper->getOrder());
474 icState->setSolutionStatus(Tempus::Status::PASSED); // ICs are passing.
475
476 // Setup SolutionHistory ------------------------------------
477 auto solutionHistory = rcp(new Tempus::SolutionHistory<double>());
478 solutionHistory->setName("Forward States");
479 solutionHistory->setStorageType(Tempus::STORAGE_TYPE_UNLIMITED);
480 // solutionHistory->setStorageType(Tempus::STORAGE_TYPE_STATIC);
481 solutionHistory->setStorageLimit(3);
482 solutionHistory->addState(icState);
483
484 // Ensure ICs are consistent and stepper memory is set (e.g., xDot is set).
485 stepperSC->setInitialConditions(solutionHistory);
486 stepper->initialize();
487
488 // Setup Integrator -----------------------------------------
489 integrator = Tempus::createIntegratorBasic<double>();
490 integrator->setStepper(stepper);
491 integrator->setTimeStepControl(timeStepControl);
492 integrator->setSolutionHistory(solutionHistory);
493 integrator->setScreenOutputIndexInterval(10);
494 // integrator->setObserver(...);
495 integrator->initialize();
496
497 // Integrate to timeMax
498 bool integratorStatus = integrator->advanceTime();
499 TEST_ASSERT(integratorStatus)
500
501 // Test if at 'Final Time'
502 time = integrator->getTime();
503 double timeFinal = 2.0;
504 double tol = 100.0 * std::numeric_limits<double>::epsilon();
505 TEST_FLOATING_EQUALITY(time, timeFinal, tol);
506
507 // Store off the final solution and step size
508 StepSize.push_back(dt);
509 auto solution = Thyra::createMember(implicitModel->get_x_space());
510 Thyra::copy(*(integrator->getX()), solution.ptr());
511 solutions.push_back(solution);
512 auto solutionDot = Thyra::createMember(implicitModel->get_x_space());
513 Thyra::copy(*(integrator->getXDot()), solutionDot.ptr());
514 solutionsDot.push_back(solutionDot);
515
516 // Output finest temporal solution for plotting
517 // This only works for ONE MPI process
518 if ((n == 0) || (n == nTimeStepSizes - 1)) {
519 std::string fname = "Tempus_Subcycling_VanDerPol-Ref.dat";
520 if (n == 0) fname = "Tempus_Subcycling_VanDerPol.dat";
521 writeSolution(fname, integrator->getSolutionHistory());
522 // solutionHistory->printHistory("medium");
523 }
524 }
525
526 // Check the order and intercept
527 double xSlope = 0.0;
528 double xDotSlope = 0.0;
529 RCP<Tempus::Stepper<double>> stepper = integrator->getStepper();
530 // double order = stepper->getOrder();
531 writeOrderError("Tempus_Subcycling_VanDerPol-Error.dat", stepper, StepSize,
532 solutions, xErrorNorm, xSlope, solutionsDot, xDotErrorNorm,
533 xDotSlope, out);
534
535 TEST_FLOATING_EQUALITY(xSlope, 1.25708, 0.05);
536 TEST_FLOATING_EQUALITY(xDotSlope, 1.20230, 0.05);
537 TEST_FLOATING_EQUALITY(xErrorNorm[0], 0.37156, 1.0e-4);
538 TEST_FLOATING_EQUALITY(xDotErrorNorm[0], 3.11651, 1.0e-4);
539
540 Teuchos::TimeMonitor::summarize();
541}
542
543} // namespace Tempus_Test
IntegratorObserverSubcycling class for time integrators. This basic class has simple no-op functions,...
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
Solution state for integrators and steppers.
OperatorSplit stepper loops through the Stepper list.
StepControlStrategy class for TimeStepControl.
StepControlStrategy class for TimeStepControl.
TimeStepControl manages the time step size. There several mechanisms that effect the time step size a...
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation.
void writeSolution(const std::string filename, Teuchos::RCP< const Tempus::SolutionHistory< Scalar > > solutionHistory)
void writeOrderError(const std::string filename, Teuchos::RCP< Tempus::Stepper< Scalar > > stepper, std::vector< Scalar > &StepSize, std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > &solutions, std::vector< Scalar > &xErrorNorm, Scalar &xSlope, std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > &solutionsDot, std::vector< Scalar > &xDotErrorNorm, Scalar &xDotSlope, std::vector< Teuchos::RCP< Thyra::VectorBase< Scalar > > > &solutionsDotDot, std::vector< Scalar > &xDotDotErrorNorm, Scalar &xDotDotSlope, Teuchos::FancyOStream &out)
TEUCHOS_UNIT_TEST(BackwardEuler, SinCos_ASA)
@ STORAGE_TYPE_STATIC
Keep a fix number of states.
@ STORAGE_TYPE_UNLIMITED
Grow the history as needed.
Teuchos::RCP< StepperBackwardEuler< Scalar > > createStepperBackwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
Teuchos::RCP< SolutionState< Scalar > > createSolutionStateX(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdot=Teuchos::null, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdotdot=Teuchos::null)
Nonmember constructor from non-const solution vectors, x.
Teuchos::RCP< StepperForwardEuler< Scalar > > createStepperForwardEuler(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.