73int main(
int argc,
char *argv[])
79 Teuchos::RCP<const Thyra::ModelEvaluator<double> >
84 model->getNominalValues().get_x()->clone_v());
85 solState->setIndex (0);
86 solState->setTime (0.0);
87 solState->setTimeStep(0.0);
89 RCP<Thyra::VectorBase<double> > xDot_n =
90 model->getNominalValues().get_x_dot()->clone_v();
94 double finalTime = 2.0;
95 int nTimeSteps = 2000;
96 const double constDT = finalTime/nTimeSteps;
100 solState->getTime() < finalTime &&
101 solState->getIndex() < nTimeSteps) {
104 RCP<Thyra::VectorBase<double> > x_n = solState->getX();
105 RCP<Thyra::VectorBase<double> > x_np1 = solState->getX()->clone_v();
109 int index = solState->getIndex()+1;
111 double time = index*dt;
115 auto inArgs = model->createInArgs();
116 auto outArgs = model->createOutArgs();
119 inArgs.set_x_dot(Teuchos::null);
120 outArgs.set_f(xDot_n);
123 model->evalModel(inArgs, outArgs);
126 Thyra::V_VpStV(x_np1.ptr(), *x_n, dt, *xDot_n);
129 if ( std::isnan(Thyra::norm(*x_np1)) ) {
133 Thyra::V_V(x_n.ptr(), *x_np1);
134 solState->setIndex (index);
135 solState->setTime (time);
136 solState->setTimeStep(constDT);
141 if ( solState->getIndex()%100 == 0 )
142 cout << solState->getIndex() <<
" " << time
143 <<
" " << get_ele(*(x_n), 0)
144 <<
" " << get_ele(*(x_n), 1) << endl;
148 RCP<Thyra::VectorBase<double> > x_n = solState->getX();
149 RCP<Thyra::VectorBase<double> > x_regress = x_n->clone_v();
151 Thyra::DetachedVectorView<double> x_regress_view(*x_regress);
152 x_regress_view[0] = -1.59496108218721311;
153 x_regress_view[1] = 0.96359412806611255;
156 RCP<Thyra::VectorBase<double> > x_error = x_n->clone_v();
157 Thyra::V_VmV(x_error.ptr(), *x_n, *x_regress);
158 double x_L2norm_error = Thyra::norm_2(*x_error );
159 double x_L2norm_regress = Thyra::norm_2(*x_regress);
161 cout <<
"Relative L2 Norm of the error (regression) = "
162 << x_L2norm_error/x_L2norm_regress << endl;
163 if ( x_L2norm_error > 1.0e-08*x_L2norm_regress) {
165 cout <<
"FAILED regression constraint!" << endl;
169 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success);
172 cout <<
"\nEnd Result: Test Passed!" << std::endl;
174 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.