Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_UnitTest_NewmarkExplicitAForm.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 "../TestModels/HarmonicOscillatorModel.hpp"
22 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
23 
24 #include <fstream>
25 #include <vector>
26 
27 namespace Tempus_Unit_Test {
28 
29 using Teuchos::RCP;
30 using Teuchos::rcp;
31 using Teuchos::rcp_const_cast;
32 using Teuchos::rcp_dynamic_cast;
33 using Teuchos::ParameterList;
34 using Teuchos::sublist;
35 using Teuchos::getParametersFromXmlFile;
36 
38 
39 
40 // ************************************************************
41 // ************************************************************
42 TEUCHOS_UNIT_TEST(NewmarkExplicitAForm, Default_Construction)
43 {
44  auto model = rcp(new Tempus_Test::HarmonicOscillatorModel<double>());
45 
46  // Default construction.
47  auto stepper = rcp(new Tempus::StepperNewmarkExplicitAForm<double>());
48  stepper->setModel(model);
49  stepper->initialize();
50  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
51 
52 
53  // Default values for construction.
54  bool useFSAL = stepper->getUseFSALDefault();
55  std::string ICConsistency = stepper->getICConsistencyDefault();
56  bool ICConsistencyCheck = stepper->getICConsistencyCheckDefault();
57  double gamma = 0.5;
58 
59 
60  // Test the set functions.
61  stepper->setUseFSAL(useFSAL); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
62  stepper->setICConsistency(ICConsistency); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
63  stepper->setICConsistencyCheck(ICConsistencyCheck); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
64 
65  stepper->setGamma(gamma); stepper->initialize(); TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
66 
67 
68  // Full argument list construction.
70  model, Teuchos::null, useFSAL, ICConsistency, ICConsistencyCheck, gamma));
71  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
72 
73  // Test stepper properties.
74  TEUCHOS_ASSERT(stepper->getOrder() == 2);
75 }
76 
77 
78 // ************************************************************
79 // ************************************************************
80 TEUCHOS_UNIT_TEST(NewmarkExplicitAForm, StepperFactory_Construction)
81 {
82  auto model = rcp(new Tempus_Test::HarmonicOscillatorModel<double>());
83  testFactoryConstruction("Newmark Explicit a-Form", model);
84 }
85 
86 
87 } // namespace Tempus_Test
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
Consider the ODE: where is a constant, is a constant damping parameter, is a constant forcing par...
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)