77int main(
int argc,
char *argv[])
83 Teuchos::RCP<const Thyra::ModelEvaluator<double> >
88 model->getNominalValues().get_x()->clone_v());
89 solState->setIndex (0);
90 solState->setTime (0.0);
91 solState->setTimeStep(0.0);
95 auto solHistory = Tempus::createSolutionHistoryState<double>(solState);
99 stepper->setModel(model);
100 stepper->initialize();
101 stepper->setInitialConditions(solHistory);
104 double finalTime = 2.0;
105 int nTimeSteps = 2000;
106 const double constDT = finalTime/nTimeSteps;
110 solHistory->getCurrentState()->getTime() < finalTime &&
111 solHistory->getCurrentState()->getIndex() < nTimeSteps) {
114 solHistory->initWorkingState();
115 auto workingState = solHistory->getWorkingState();
118 int index = workingState->getIndex();
120 double time = index*dt;
121 workingState->setTime(time);
122 workingState->setTimeStep(dt);
125 stepper->takeStep(solHistory);
128 solHistory->promoteWorkingState();
131 if (solHistory->getCurrentState()->getIndex() % 100 == 0) {
132 auto currentState = solHistory->getCurrentState();
133 cout << currentState->getIndex() <<
" " << currentState->getTime()
134 <<
" " << Thyra::get_ele(*(currentState->getX()), 0)
135 <<
" " << Thyra::get_ele(*(currentState->getX()), 1) << endl;
140 auto finalState = solHistory->getCurrentState();
141 RCP<Thyra::VectorBase<double> > x_n = finalState->getX();
142 RCP<Thyra::VectorBase<double> > x_regress = x_n->clone_v();
144 Thyra::DetachedVectorView<double> x_regress_view(*x_regress);
145 x_regress_view[0] = -1.59496108218721311;
146 x_regress_view[1] = 0.96359412806611255;
149 RCP<Thyra::VectorBase<double> > x_error = x_n->clone_v();
150 Thyra::V_VmV(x_error.ptr(), *x_n, *x_regress);
151 double x_L2norm_error = Thyra::norm_2(*x_error );
152 double x_L2norm_regress = Thyra::norm_2(*x_regress);
154 cout <<
"Relative L2 Norm of the error (regression) = "
155 << x_L2norm_error/x_L2norm_regress << endl;
156 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
158 cout <<
"FAILED regression constraint!" << endl;
162 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
165 cout <<
"\nEnd Result: Test Passed!" << std::endl;
167 return ( success ? EXIT_SUCCESS : EXIT_FAILURE );
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.