Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_UnitTest_Trapezoidal.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 "Teuchos_UnitTestHarness.hpp"
10 #include "Teuchos_XMLParameterListHelpers.hpp"
11 #include "Teuchos_TimeMonitor.hpp"
12 #include "Teuchos_DefaultComm.hpp"
13 
14 #include "Thyra_VectorStdOps.hpp"
15 
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;
32 using Teuchos::ParameterList;
33 using Teuchos::sublist;
34 using Teuchos::getParametersFromXmlFile;
35 
37 
38 
39 // ************************************************************
40 // ************************************************************
41 TEUCHOS_UNIT_TEST(Trapezoidal, Default_Construction)
42 {
43  auto model = rcp(new Tempus_Test::SinCosModel<double>());
44 
45  // Default construction.
46  auto stepper = rcp(new Tempus::StepperTrapezoidal<double>());
47  stepper->setModel(model);
48  stepper->initialize();
49  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
50 
51 
52  // Default values for construction.
53  auto obs = rcp(new Tempus::StepperTrapezoidalObserver<double>());
54  auto solver = rcp(new Thyra::NOXNonlinearSolver());
55  solver->setParameterList(Tempus::defaultSolverParameters());
56 
57  bool useFSAL = stepper->getUseFSALDefault();
58  std::string ICConsistency = stepper->getICConsistencyDefault();
59  bool ICConsistencyCheck = stepper->getICConsistencyCheckDefault();
60  bool zeroInitialGuess = stepper->getZeroInitialGuess();
61 
62  // Test the set functions.
63  stepper->setObserver(obs); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
64  stepper->setSolver(solver); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
65  stepper->setUseFSAL(useFSAL); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
66  stepper->setICConsistency(ICConsistency); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
67  stepper->setICConsistencyCheck(ICConsistencyCheck); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
68  stepper->setZeroInitialGuess(zeroInitialGuess); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
69 
70 
71  // Full argument list construction.
72  stepper = rcp(new Tempus::StepperTrapezoidal<double>(
73  model, obs, solver, useFSAL,
74  ICConsistency, ICConsistencyCheck, zeroInitialGuess));
75  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
76 
77  // Test stepper properties.
78  TEUCHOS_ASSERT(stepper->getOrder() == 2);
79 }
80 
81 
82 // ************************************************************
83 // ************************************************************
84 TEUCHOS_UNIT_TEST(Trapezoidal, StepperFactory_Construction)
85 {
86  auto model = rcp(new Tempus_Test::SinCosModel<double>());
87  testFactoryConstruction("Trapezoidal Method", model);
88 }
89 
90 
91 } // namespace Tempus_Test
Trapezoidal method time stepper.
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
Sine-Cosine model problem from Rythmos. This is a canonical Sine-Cosine differential equation with a...
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters()
Returns the default solver ParameterList for implicit Steppers.
StepperTrapezoidalObserver class for StepperTrapezoidal.
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)