92 Teuchos::RCP<const Thyra::ModelEvaluator<double> >
97 model->getNominalValues().get_x()->clone_v());
98 solState->setIndex (0);
99 solState->setTime (0.0);
100 solState->setTimeStep(0.0);
104 auto solHistory = Tempus::createSolutionHistoryState<double>(solState);
108 stepper->setModel(model);
109 stepper->initialize();
110 stepper->setInitialConditions(solHistory);
113 double finalTime = 2.0;
114 int nTimeSteps = 2000;
115 const double constDT = finalTime/nTimeSteps;
119 cout << std::setw(8) <<
"index"
120 << std::setw(10) <<
"time"
121 << std::setw(12) <<
"x_0"
122 << std::setw(12) <<
"x_1" << endl;
124 auto currentState = solHistory->getCurrentState();
125 cout << std::setw(8) << currentState->getIndex()
126 << std::setw(10) << std::setprecision(3) << currentState->getTime()
127 << std::setw(12) << std::setprecision(4) << Thyra::get_ele(*(currentState->getX()), 0)
128 << std::setw(12) << std::setprecision(4) << Thyra::get_ele(*(currentState->getX()), 1)
133 solHistory->getCurrentTime() < finalTime &&
134 solHistory->getCurrentIndex() < nTimeSteps ) {
137 solHistory->initWorkingState();
138 auto workingState = solHistory->getWorkingState();
141 int index = workingState->getIndex();
143 double time = index*dt;
144 workingState->setTime(time);
145 workingState->setTimeStep(dt);
148 stepper->takeStep(solHistory);
151 solHistory->promoteWorkingState();
154 if (solHistory->getCurrentState()->getIndex() % 100 == 0) {
155 currentState = solHistory->getCurrentState();
156 cout << std::setw(8) << currentState->getIndex()
157 << std::setw(10) << std::setprecision(3) << currentState->getTime()
158 << std::setw(12) << std::setprecision(4) << Thyra::get_ele(*(currentState->getX()), 0)
159 << std::setw(12) << std::setprecision(4) << Thyra::get_ele(*(currentState->getX()), 1)
165 auto finalState = solHistory->getCurrentState();
169 if (passed && regressionPassed) success =
true;
171 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
174 cout <<
"\nEnd Result: Test Passed!" << std::endl;
176 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
bool tutorialRegressionTest(const Teuchos::RCP< Thyra::VectorBase< double > > &x_n, std::ostream &out=std::cout, const double relTol=Teuchos::as< double >(1.0e-8))
Regression check for the Tempus tutorial van der Pol examples.
Teuchos::RCP< SolutionState< Scalar > > createSolutionStateX(const Teuchos::RCP< Thyra::VectorBase< Scalar > > &x, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdot=Teuchos::null, const Teuchos::RCP< Thyra::VectorBase< Scalar > > &xdotdot=Teuchos::null)
Nonmember constructor from non-const solution vectors, x.