Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
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
15#include "Teuchos_UnitTestHarness.hpp"
16#include "Teuchos_XMLParameterListHelpers.hpp"
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
28namespace Tempus_Unit_Test {
29
30using Teuchos::ParameterList;
31using Teuchos::RCP;
32using Teuchos::rcp;
33using Teuchos::rcp_const_cast;
34using Teuchos::rcp_dynamic_cast;
35
36using Thyra::get_ele;
37
39
43 std::string stepperType,
44 const Teuchos::RCP<const Thyra::ModelEvaluator<double> >& model)
45{
46 RCP<StepperFactory<double> > sf = Teuchos::rcp(new StepperFactory<double>());
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.