Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_UnitTest_Utils.hpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_UnitTest_Utils_hpp
11 #define Tempus_UnitTest_Utils_hpp
12 
13 #include "Tempus_config.hpp"
14 
17 
18 #include "Thyra_VectorStdOps.hpp"
19 #include "NOX_Thyra.H"
20 
22 #include "Tempus_StepperFactory.hpp"
23 #include "Tempus_SolutionHistory.hpp"
24 #include "Tempus_IntegratorBasic.hpp"
25 
26 #include "../TestModels/SinCosModel.hpp"
27 
28 namespace Tempus_Unit_Test {
29 
31 using Teuchos::RCP;
32 using Teuchos::rcp;
33 using Teuchos::rcp_const_cast;
34 using Teuchos::rcp_dynamic_cast;
35 
36 using Thyra::get_ele;
37 
39 
43  std::string stepperType,
44  const Teuchos::RCP<const Thyra::ModelEvaluator<double> >& model)
45 {
47 
48  // Test using stepperType
49  // Passing in model.
50  auto stepper = sf->createStepper(stepperType, model);
51  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
52  // With setting model.
53  stepper = sf->createStepper(stepperType);
54  stepper->setModel(model);
55  stepper->initialize();
56  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
57 
58  // Test using ParameterList.
59  // Passing in model.
60  auto stepperPL = rcp_const_cast<ParameterList>(stepper->getValidParameters());
61  stepper = sf->createStepper(stepperPL, model);
62  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
63  // With setting model.
64  stepper = sf->createStepper(stepperPL);
65  stepper->setModel(model);
66  stepper->initialize();
67  TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
68 }
69 
70 } // namespace Tempus_Unit_Test
71 #endif // Tempus_UnitTest_Utils_hpp
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)