Tempus
Version of the Day
Time Integration
Toggle main menu visibility
Loading...
Searching...
No Matches
unit_test
Tempus_UnitTest_ERK_ForwardEuler.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
9
#include "
Tempus_UnitTest_RK_Utils.hpp
"
10
11
#include "../TestModels/DahlquistTestModel.hpp"
12
13
14
namespace
Tempus_Unit_Test
{
15
16
using
Teuchos::RCP;
17
using
Teuchos::rcp;
18
using
Teuchos::rcp_const_cast;
19
using
Teuchos::rcp_dynamic_cast;
20
21
22
// ************************************************************
23
// ************************************************************
24
TEUCHOS_UNIT_TEST
(ERK_ForwardEuler, Default_Construction)
25
{
26
auto
stepper = rcp(
new
Tempus::StepperERK_ForwardEuler<double>
());
27
testExplicitRKAccessorsFullConstruction
(stepper);
28
29
// Test stepper properties.
30
TEUCHOS_ASSERT(stepper->getOrder() == 1);
31
const
auto
rk_fe = stepper->getTableau();
32
33
TEUCHOS_ASSERT( rk_fe->isTVD() );
34
TEUCHOS_ASSERT( rk_fe->getTVDCoeff() == 1 );
35
}
36
37
38
// ************************************************************
39
// ************************************************************
40
TEUCHOS_UNIT_TEST
(ERK_ForwardEuler, StepperFactory_Construction)
41
{
42
auto
model = rcp(
new
Tempus_Test::SinCosModel<double>
());
43
testFactoryConstruction
(
"RK Forward Euler"
, model);
44
}
45
46
47
// ************************************************************
48
// ************************************************************
49
TEUCHOS_UNIT_TEST
(ERK_ForwardEuler, AppAction)
50
{
51
auto
stepper = rcp(
new
Tempus::StepperERK_ForwardEuler<double>
());
52
auto
model = rcp(
new
Tempus_Test::SinCosModel<double>
());
53
testRKAppAction
(stepper, model, out, success);
54
}
55
56
57
// ************************************************************
58
// ************************************************************
59
TEUCHOS_UNIT_TEST
(ERK_ForwardEuler, FSAL)
60
{
61
auto
stepper = rcp(
new
Tempus::StepperERK_ForwardEuler<double>
());
62
Teuchos::RCP<const Thyra::ModelEvaluator<double> >
63
model = rcp(
new
Tempus_Test::DahlquistTestModel<double>
(-1.0,
true
));
64
65
stepper->setModel(model);
66
stepper->setICConsistency(
"Consistent"
);
67
stepper->setUseFSAL(
true
);
68
stepper->initialize();
69
70
// Create a SolutionHistory.
71
auto
solutionHistory =
Tempus::createSolutionHistoryME
(model);
72
73
// Take one time step.
74
stepper->setInitialConditions(solutionHistory);
75
solutionHistory->initWorkingState();
76
double
dt = 1.0;
77
solutionHistory->getWorkingState()->setTimeStep(dt);
78
solutionHistory->getWorkingState()->setTime(dt);
79
stepper->takeStep(solutionHistory);
80
81
// Test solution.
82
const
double
relTol = 1.0e-14;
83
84
// ICs
85
auto
currentState = solutionHistory->getCurrentState();
86
const
double
x_0 = get_ele(*(currentState->getX()), 0);
87
const
double
xDot_0 = get_ele(*(currentState->getXDot()), 0);
88
TEST_FLOATING_EQUALITY(x_0, 1.0, relTol);
89
TEST_FLOATING_EQUALITY(xDot_0, -1.0, relTol);
90
TEST_ASSERT(std::abs(currentState->getTime()) < relTol);
91
92
// After one step.
93
auto
workingState = solutionHistory->getWorkingState();
94
const
double
x_1 = get_ele(*(workingState->getX()), 0);
95
const
double
xDot_1 = get_ele(*(workingState->getXDot()), 0);
96
//out << "xDot_1 = " << xDot_1 << std::endl;
97
TEST_ASSERT(std::abs(x_1 ) < relTol);
98
TEST_ASSERT(std::abs(xDot_1) < relTol);
99
TEST_FLOATING_EQUALITY(workingState->getTime(), 1.0, relTol);
100
101
}
102
103
104
}
// namespace Tempus_Unit_Test
Tempus_UnitTest_RK_Utils.hpp
Tempus::StepperERK_ForwardEuler
Forward Euler Runge-Kutta Butcher Tableau.
Definition
Tempus_StepperRKButcherTableau.hpp:45
Tempus_Test::DahlquistTestModel
The classic Dahlquist Test Problem.
Definition
DahlquistTestModel_decl.hpp:37
Tempus_Test::SinCosModel
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation.
Definition
SinCosModel_decl.hpp:94
Tempus_Unit_Test
Definition
Tempus_UnitTest_BackwardEuler.cpp:22
Tempus_Unit_Test::testExplicitRKAccessorsFullConstruction
void testExplicitRKAccessorsFullConstruction(const RCP< Tempus::StepperExplicitRK< double > > &stepper)
Unit test utility for ExplicitRK Stepper construction and accessors.
Definition
Tempus_UnitTest_RK_Utils.hpp:41
Tempus_Unit_Test::testRKAppAction
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.
Definition
Tempus_UnitTest_RK_Utils.hpp:552
Tempus_Unit_Test::TEUCHOS_UNIT_TEST
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
Definition
Tempus_UnitTest_BackwardEuler.cpp:34
Tempus_Unit_Test::testFactoryConstruction
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
Definition
Tempus_UnitTest_Utils.hpp:42
Tempus::createSolutionHistoryME
Teuchos::RCP< SolutionHistory< Scalar > > createSolutionHistoryME(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Nonmember contructor from a Thyra ModelEvaluator.
Definition
Tempus_SolutionHistory_impl.hpp:740
Generated by
1.17.0