Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_UnitTest_DIRK_BackwardEuler.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
11 #include "Teuchos_TimeMonitor.hpp"
12 #include "Teuchos_DefaultComm.hpp"
13 
14 #include "Thyra_VectorStdOps.hpp"
15 #include "Tempus_IntegratorBasic.hpp"
16 
18 
19 #include "../TestModels/SinCosModel.hpp"
20 #include "../TestModels/VanDerPolModel.hpp"
21 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
22 
23 #include <fstream>
24 #include <vector>
25 
26 namespace Tempus_Unit_Test {
27 
28 using Teuchos::RCP;
29 using Teuchos::rcp;
30 using Teuchos::rcp_const_cast;
31 using Teuchos::rcp_dynamic_cast;
33 using Teuchos::sublist;
34 using Teuchos::getParametersFromXmlFile;
35 
36 
37 // ************************************************************
38 // ************************************************************
39 TEUCHOS_UNIT_TEST(DIRK_BackwardEuler, Default_Construction)
40 {
41  auto stepper = rcp(new Tempus::StepperDIRK_BackwardEuler<double>());
43 
44  // Test stepper properties.
45  TEUCHOS_ASSERT(stepper->getOrder() == 1);
46 }
47 
48 
49 // ************************************************************
50 // ************************************************************
51 TEUCHOS_UNIT_TEST(DIRK_BackwardEuler, StepperFactory_Construction)
52 {
53  auto model = rcp(new Tempus_Test::SinCosModel<double>());
54  testFactoryConstruction("RK Backward Euler", model);
55 }
56 
57 
58 // ************************************************************
59 //* Test: construct the integrator from PL and make sure that
60 //* the solver PL is the same as the provided solver PL
61 //* and not the default solver PL
62 // ************************************************************
63 
64 TEUCHOS_UNIT_TEST(DIRK_BackwardEuler, App_PL)
65 {
66  auto model = rcp(new Tempus_Test::SinCosModel<double>());
67 
68  // read the params from xml file
69  auto pList = getParametersFromXmlFile("Tempus_DIRK_VanDerPol.xml");
70  auto pl = sublist(pList, "Tempus", true);
71  auto appSolverPL = pl->sublist("App Stepper").sublist("App Solver");
72 
73 
74  // setup the Integrator
75  auto integrator = Tempus::createIntegratorBasic<double>(pl, model);
76  auto stepperSolverPL = Teuchos::ParameterList();
77  stepperSolverPL.set("NOX", *(integrator->getStepper()->getSolver()->getParameterList()));
78 
79  // make sure the app Solver PL is being used
80  TEUCHOS_ASSERT( Teuchos::haveSameValues(appSolverPL, stepperSolverPL) );
81 
82 }
83 
84 
85 
86 // ************************************************************
87 // ************************************************************
88 TEUCHOS_UNIT_TEST(DIRK_BackwardEuler, AppAction)
89 {
90  auto stepper = rcp(new Tempus::StepperDIRK_BackwardEuler<double>());
91  auto model = rcp(new Tempus_Test::SinCosModel<double>());
92  testRKAppAction(stepper, model, out, success);
93 }
94 
95 
96 } // namespace Tempus_Test
void testRKAppAction(const Teuchos::RCP< Tempus::StepperRKBase< double > > &stepper, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model, Teuchos::FancyOStream &out, bool &success)
Unit test utility for Stepper RK AppAction.
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
Backward Euler Runge-Kutta Butcher Tableau.
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation with a...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
void testDIRKAccessorsFullConstruction(const RCP< Tempus::StepperDIRK< double > > &stepper)
Unit test utility for ExplicitRK Stepper construction and accessors.
#define TEUCHOS_ASSERT(assertion_test)