14 #include "Tempus_config.hpp"
15 #include "Tempus_IntegratorPseudoTransientForwardSensitivity.hpp"
16 #include "Tempus_IntegratorPseudoTransientAdjointSensitivity.hpp"
18 #include "Thyra_VectorStdOps.hpp"
19 #include "Thyra_MultiVectorStdOps.hpp"
21 #include "../TestModels/SteadyQuadraticModel.hpp"
23 #include "Thyra_DefaultMultiVectorProductVector.hpp"
24 #include "Thyra_DefaultProductVector.hpp"
29 namespace Tempus_Test {
31 using Teuchos::getParametersFromXmlFile;
34 using Teuchos::sublist;
42 RCP<ParameterList> pList =
43 getParametersFromXmlFile(
"Tempus_DIRK_SteadyQuadratic.xml");
46 RCP<ParameterList> scm_pl = sublist(pList,
"SteadyQuadraticModel",
true);
47 scm_pl->set(
"Use DfDp as Tangent", use_dfdp_as_tangent);
48 RCP<SteadyQuadraticModel<double> > model =
52 RCP<ParameterList> pl = sublist(pList,
"Tempus",
true);
53 ParameterList &sens_pl = pl->sublist(
"Sensitivities");
54 sens_pl.set(
"Use DfDp as Tangent", use_dfdp_as_tangent);
55 sens_pl.set(
"Reuse State Linear Solver",
true);
56 sens_pl.set(
"Force W Update",
true);
60 RCP<Tempus::IntegratorPseudoTransientForwardSensitivity<double> > integrator =
61 Tempus::createIntegratorPseudoTransientForwardSensitivity<double>(pl,
65 bool integratorStatus = integrator->advanceTime();
69 double time = integrator->getTime();
70 double timeFinal = pl->sublist(
"Default Integrator")
71 .sublist(
"Time Step Control")
72 .get<
double>(
"Final Time");
76 RCP<const Thyra::VectorBase<double> > x_vec = integrator->getX();
77 RCP<const Thyra::MultiVectorBase<double> > DxDp_vec = integrator->getDxDp();
78 const double x = Thyra::get_ele(*x_vec, 0);
79 const double dxdb = Thyra::get_ele(*(DxDp_vec->col(0)), 0);
80 const double x_exact = model->getSteadyStateSolution();
81 const double dxdb_exact = model->getSteadyStateSolutionSensitivity();
103 getParametersFromXmlFile(
"Tempus_DIRK_SteadyQuadratic.xml");
116 Tempus::integratorPseudoTransientAdjointSensitivity<double>(pl, model);
119 bool integratorStatus = integrator->advanceTime();
123 double time = integrator->getTime();
124 double timeFinal = pl->sublist(
"Default Integrator")
125 .sublist(
"Time Step Control")
126 .
get<
double>(
"Final Time");
132 const double x = Thyra::get_ele(*x_vec, 0);
133 const double dxdb = Thyra::get_ele(*(DxDp_vec->col(0)), 0);
134 const double x_exact = model->getSteadyStateSolution();
135 const double dxdb_exact = model->getSteadyStateSolutionSensitivity();
137 TEST_FLOATING_EQUALITY(x, x_exact, 1.0e-6);
138 TEST_FLOATING_EQUALITY(dxdb, dxdb_exact, 1.0e-6);
void test_pseudotransient_fsa(const bool use_dfdp_as_tangent, Teuchos::FancyOStream &out, bool &success)
#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.