13 #include "Tempus_config.hpp"
14 #include "Tempus_IntegratorPseudoTransientForwardSensitivity.hpp"
15 #include "Tempus_IntegratorPseudoTransientAdjointSensitivity.hpp"
17 #include "Thyra_VectorStdOps.hpp"
18 #include "Thyra_MultiVectorStdOps.hpp"
20 #include "../TestModels/SteadyQuadraticModel.hpp"
22 #include "Thyra_DefaultMultiVectorProductVector.hpp"
23 #include "Thyra_DefaultProductVector.hpp"
28 namespace Tempus_Test {
32 using Teuchos::sublist;
33 using Teuchos::getParametersFromXmlFile;
42 getParametersFromXmlFile(
"Tempus_BackwardEuler_SteadyQuadratic.xml");
46 scm_pl->
set(
"Use DfDp as Tangent", use_dfdp_as_tangent);
53 sens_pl.
set(
"Use DfDp as Tangent", use_dfdp_as_tangent);
54 sens_pl.
set(
"Reuse State Linear Solver",
true);
55 sens_pl.
set(
"Force W Update",
true);
60 Tempus::integratorPseudoTransientForwardSensitivity<double>(pl, model);
63 bool integratorStatus = integrator->advanceTime();
67 double time = integrator->getTime();
68 double timeFinal =pl->sublist(
"Default Integrator")
69 .sublist(
"Time Step Control").
get<
double>(
"Final Time");
75 const double x = Thyra::get_ele(*x_vec, 0);
76 const double dxdb = Thyra::get_ele(*(DxDp_vec->col(0)), 0);
77 const double x_exact = model->getSteadyStateSolution();
78 const double dxdb_exact = model->getSteadyStateSolutionSensitivity();
80 TEST_FLOATING_EQUALITY( x, x_exact, 1.0e-6 );
81 TEST_FLOATING_EQUALITY( dxdb, dxdb_exact, 1.0e-6 );
100 getParametersFromXmlFile(
"Tempus_BackwardEuler_SteadyQuadratic.xml");
113 Tempus::integratorPseudoTransientAdjointSensitivity<double>(pl, model);
116 bool integratorStatus = integrator->advanceTime();
120 double time = integrator->getTime();
121 double timeFinal =pl->sublist(
"Default Integrator")
122 .sublist(
"Time Step Control").
get<
double>(
"Final Time");
128 const double x = Thyra::get_ele(*x_vec, 0);
129 const double dxdb = Thyra::get_ele(*(DxDp_vec->col(0)), 0);
130 const double x_exact = model->getSteadyStateSolution();
131 const double dxdb_exact = model->getSteadyStateSolutionSensitivity();
133 TEST_FLOATING_EQUALITY( x, x_exact, 1.0e-6 );
134 TEST_FLOATING_EQUALITY( dxdb, dxdb_exact, 1.0e-6 );
void test_pseudotransient_fsa(const bool use_dfdp_as_tangent, Teuchos::FancyOStream &out, bool &success)
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
TEUCHOS_UNIT_TEST(BackwardEuler, SinCos_ASA)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Simple quadratic equation with a stable steady-state. This is a simple differential equation which h...
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")