Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Tempus_UnitTest_ERK_General.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
10
11
12namespace Tempus_Unit_Test {
13
14using Teuchos::RCP;
15using Teuchos::rcp;
16using Teuchos::rcp_const_cast;
17using Teuchos::rcp_dynamic_cast;
18
19
20// ************************************************************
21// ************************************************************
22TEUCHOS_UNIT_TEST(ERK_General, Default_Construction)
23{
24 auto model = rcp(new Tempus_Test::SinCosModel<double>());
25
26 // Default construction.
27 auto stepper = rcp(new Tempus::StepperERK_General<double>());
28 stepper->setModel(model);
29 stepper->initialize();
30 TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
31
32 // Default values for construction.
33 auto modifier = rcp(new Tempus::StepperRKModifierDefault<double>());
34 auto modifierX = rcp(new Tempus::StepperRKModifierXDefault<double>());
35 auto observer = rcp(new Tempus::StepperRKObserverDefault<double>());
36 bool useFSAL = stepper->getUseFSAL();
37 std::string ICConsistency = stepper->getICConsistency();
38 bool ICConsistencyCheck = stepper->getICConsistencyCheck();
39 bool useEmbedded = stepper->getUseEmbedded();
40
41 int NumStages = 4;
42 Teuchos::SerialDenseMatrix<int,double> A(NumStages,NumStages);
43 Teuchos::SerialDenseVector<int,double> b(NumStages);
44 Teuchos::SerialDenseVector<int,double> c(NumStages);
45 Teuchos::SerialDenseVector<int,double> bstar(0);
46
47 // Fill A:
48 A(0,0) = 0.0; A(0,1) = 0.0; A(0,2) = 0.0; A(0,3) = 0.0;
49 A(1,0) = 0.5; A(1,1) = 0.0; A(1,2) = 0.0; A(1,3) = 0.0;
50 A(2,0) = 0.0; A(2,1) = 0.5; A(2,2) = 0.0; A(2,3) = 0.0;
51 A(3,0) = 0.0; A(3,1) = 0.0; A(3,2) = 1.0; A(3,3) = 0.0;
52
53 // Fill b:
54 b(0) = 1.0/6.0; b(1) = 1.0/3.0; b(2) = 1.0/3.0; b(3) = 1.0/6.0;
55
56 // fill c:
57 c(0) = 0.0; c(1) = 0.5; c(2) = 0.5; c(3) = 1.0;
58
59 int order = 4;
60
61
62 // Test the set functions.
63 stepper->setAppAction(modifier); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
64 stepper->setAppAction(modifierX); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
65 stepper->setAppAction(observer); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
66 stepper->setUseFSAL(useFSAL); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
67 stepper->setICConsistency(ICConsistency); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
68 stepper->setICConsistencyCheck(ICConsistencyCheck); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
69 stepper->setUseEmbedded(useEmbedded); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
70
71 stepper->setTableau(A, b, c, order, order, order); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
72
73
74 // Full argument list construction.
75 stepper = rcp(new Tempus::StepperERK_General<double>(
76 model, useFSAL, ICConsistency, ICConsistencyCheck, useEmbedded,
77 A, b, c, order, order, order, bstar, modifier));
78 TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
79
80 // Test stepper properties.
81 TEUCHOS_ASSERT(stepper->getOrder() == 4);
82}
83
84
85// ************************************************************
86// ************************************************************
87TEUCHOS_UNIT_TEST(ERK_General, StepperFactory_Construction)
88{
89 auto model = rcp(new Tempus_Test::SinCosModel<double>());
90 testFactoryConstruction("General ERK", model);
91}
92
93
94// ************************************************************
95// ************************************************************
96TEUCHOS_UNIT_TEST(ERK_General, AppAction)
97{
98 auto stepper = rcp(new Tempus::StepperERK_General<double>());
99 auto model = rcp(new Tempus_Test::SinCosModel<double>());
100 testRKAppAction(stepper, model, out, success);
101}
102
103
104} // namespace Tempus_Test
General Explicit Runge-Kutta Butcher Tableau.
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation.
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.
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.