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;
43 getParametersFromXmlFile(
"Tempus_BackwardEuler_SteadyQuadratic.xml");
47 scm_pl->
set(
"Use DfDp as Tangent", use_dfdp_as_tangent);
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);
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");
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();
83 TEST_FLOATING_EQUALITY(x, x_exact, 1.0e-6);
84 TEST_FLOATING_EQUALITY(dxdb, dxdb_exact, 1.0e-6);
103 getParametersFromXmlFile(
"Tempus_BackwardEuler_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)
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
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.
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")