56 #include "Teuchos_LAPACK.hpp" 84 void update(std::vector<Real> &u,
const std::vector<Real> &s,
const Real alpha=1.0)
const {
85 for (
unsigned i=0; i<u.size(); i++) {
90 void axpy(std::vector<Real> &out,
const Real a,
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
91 for (
unsigned i=0; i < x.size(); i++) {
92 out[i] = a*x[i] + y[i];
96 void scale(std::vector<Real> &u,
const Real alpha=0.0)
const {
97 for (
unsigned i=0; i<u.size(); i++) {
102 void linear_solve(std::vector<Real> &u, std::vector<Real> &dl, std::vector<Real> &d, std::vector<Real> &du,
103 const std::vector<Real> &r,
const bool transpose =
false)
const {
104 if ( r.size() == 1 ) {
105 u.resize(1,r[0]/d[0]);
107 else if ( r.size() == 2 ) {
109 Real det = d[0]*d[1] - dl[0]*du[0];
110 u[0] = (d[1]*r[0] - du[0]*r[1])/det;
111 u[1] = (d[0]*r[1] - dl[0]*r[0])/det;
114 u.assign(r.begin(),r.end());
116 Teuchos::LAPACK<int,Real> lp;
117 std::vector<Real> du2(r.size()-2,0.0);
118 std::vector<int> ipiv(r.size(),0);
123 lp.GTTRF(dim,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&info);
128 lp.GTTRS(trans,dim,nhrs,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&u[0],ldb,&info);
133 BurgersFEM(
int nx = 128, Real nl = 1.0, Real cH1 = 1.0, Real cL2 = 1.0)
134 : nx_(nx), dx_(1.0/((Real)nx+1.0)), nl_(nl), cH1_(cH1), cL2_(cL2) {}
137 nu_ = std::pow(10.0,nu-2.0);
155 Real
compute_L2_dot(
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
157 Real c = (((int)x.size()==
nx_) ? 4.0 : 2.0);
158 for (
unsigned i=0; i<x.size(); i++) {
160 ip += dx_/6.0*(c*x[i] + x[i+1])*y[i];
162 else if ( i == x.size()-1 ) {
163 ip += dx_/6.0*(x[i-1] + c*x[i])*y[i];
166 ip += dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
178 void apply_mass(std::vector<Real> &Mu,
const std::vector<Real> &u )
const {
179 Mu.resize(u.size(),0.0);
180 Real c = (((int)u.size()==
nx_) ? 4.0 : 2.0);
181 for (
unsigned i=0; i<u.size(); i++) {
183 Mu[i] = dx_/6.0*(c*u[i] + u[i+1]);
185 else if ( i == u.size()-1 ) {
186 Mu[i] = dx_/6.0*(u[i-1] + c*u[i]);
189 Mu[i] = dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1]);
196 unsigned nx = u.size();
198 std::vector<Real> dl(nx-1,dx_/6.0);
199 std::vector<Real> d(nx,2.0*dx_/3.0);
200 std::vector<Real> du(nx-1,dx_/6.0);
201 if ( (
int)nx != nx_ ) {
210 std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
211 for (
int i = 0; i <
nx_; i++) {
212 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
216 axpy(diff,-1.0,iMMu,u);
219 outStream <<
"Test Inverse State Mass Matrix\n";
220 outStream <<
" ||u - inv(M)Mu|| = " << error <<
"\n";
221 outStream <<
" ||u|| = " << normu <<
"\n";
222 outStream <<
" Relative Error = " << error/normu <<
"\n";
225 u.resize(nx_+2,0.0); Mu.resize(nx_+2,0.0); iMMu.resize(nx_+2,0.0); diff.resize(nx_+2,0.0);
226 for (
int i = 0; i < nx_+2; i++) {
227 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
231 axpy(diff,-1.0,iMMu,u);
234 outStream <<
"Test Inverse Control Mass Matrix\n";
235 outStream <<
" ||z - inv(M)Mz|| = " << error <<
"\n";
236 outStream <<
" ||z|| = " << normu <<
"\n";
237 outStream <<
" Relative Error = " << error/normu <<
"\n";
245 Real
compute_H1_dot(
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
247 for (
int i=0; i<
nx_; i++) {
249 ip += cL2_*dx_/6.0*(4.0*x[i] + x[i+1])*y[i];
250 ip += cH1_*(2.0*x[i] - x[i+1])/dx_*y[i];
252 else if ( i == nx_-1 ) {
253 ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i])*y[i];
254 ip += cH1_*(2.0*x[i] - x[i-1])/dx_*y[i];
257 ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
258 ip += cH1_*(2.0*x[i] - x[i-1] - x[i+1])/dx_*y[i];
270 void apply_H1(std::vector<Real> &Mu,
const std::vector<Real> &u )
const {
272 for (
int i=0; i<
nx_; i++) {
274 Mu[i] = cL2_*dx_/6.0*(4.0*u[i] + u[i+1])
275 + cH1_*(2.0*u[i] - u[i+1])/
dx_;
277 else if ( i == nx_-1 ) {
278 Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i])
279 + cH1_*(2.0*u[i] - u[i-1])/
dx_;
282 Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1])
283 + cH1_*(2.0*u[i] - u[i-1] - u[i+1])/
dx_;
291 std::vector<Real> dl(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
292 std::vector<Real> d(nx_,2.0*(cL2_*dx_/3.0 + cH1_/dx_));
293 std::vector<Real> du(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
298 std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
299 for (
int i = 0; i <
nx_; i++) {
300 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
304 axpy(diff,-1.0,iMMu,u);
307 outStream <<
"Test Inverse State H1 Matrix\n";
308 outStream <<
" ||u - inv(M)Mu|| = " << error <<
"\n";
309 outStream <<
" ||u|| = " << normu <<
"\n";
310 outStream <<
" Relative Error = " << error/normu <<
"\n";
319 const std::vector<Real> &z)
const {
322 for (
int i=0; i<
nx_; i++) {
325 r[i] = nu_/dx_*(2.0*u[i]-u[i+1]);
328 r[i] = nu_/dx_*(2.0*u[i]-u[i-1]);
331 r[i] = nu_/dx_*(2.0*u[i]-u[i-1]-u[i+1]);
335 r[i] += nl_*u[i+1]*(u[i]+u[i+1])/6.0;
338 r[i] -= nl_*u[i-1]*(u[i-1]+u[i])/6.0;
341 r[i] -= dx_/6.0*(z[i]+4.0*z[i+1]+z[i+2]);
346 r[0] -= nl_*(u0_*u[ 0]/6.0 + u0_*u0_/6.0) + nu_*u0_/
dx_;
347 r[nx_-1] += nl_*(u1_*u[nx_-1]/6.0 + u1_*u1_/6.0) - nu_*u1_/
dx_;
351 void solve(std::vector<Real> &u,
const std::vector<Real> &z)
const {
354 std::vector<Real> r(u.size(),0.0);
361 std::vector<Real> d(nx_,0.0);
362 std::vector<Real> dl(nx_-1,0.0);
363 std::vector<Real> du(nx_-1,0.0);
365 Real alpha = 1.0, tmp = 0.0;
366 std::vector<Real> s(nx_,0.0);
367 std::vector<Real> utmp(nx_,0.0);
368 for (
int i=0; i<maxit; i++) {
377 utmp.assign(u.begin(),u.end());
381 while ( rnorm > (1.0-1.e-4*alpha)*tmp && alpha > std::sqrt(
ROL::ROL_EPSILON) ) {
383 utmp.assign(u.begin(),u.end());
389 u.assign(utmp.begin(),utmp.end());
390 if ( rnorm < rtol ) {
401 std::vector<Real> &d,
402 std::vector<Real> &du,
403 const std::vector<Real> &u)
const {
406 d.resize(nx_,nu_*2.0/dx_);
408 dl.resize(nx_-1,-nu_/dx_);
410 du.resize(nx_-1,-nu_/dx_);
412 for (
int i=0; i<
nx_; i++) {
414 dl[i] += nl_*(-2.0*u[i]-u[i+1])/6.0;
415 d[i] += nl_*u[i+1]/6.0;
418 d[i] -= nl_*u[i-1]/6.0;
419 du[i-1] += nl_*(u[i-1]+2.0*u[i])/6.0;
423 d[ 0] -= nl_*u0_/6.0;
424 d[nx_-1] += nl_*u1_/6.0;
429 const std::vector<Real> &v,
430 const std::vector<Real> &u,
431 const std::vector<Real> &z)
const {
433 for (
int i = 0; i <
nx_; i++) {
434 jv[i] = nu_/dx_*2.0*v[i];
436 jv[i] += -nu_/dx_*v[i-1]-nl_*(u[i-1]/6.0*v[i]+(u[i]+2.0*u[i-1])/6.0*v[i-1]);
439 jv[i] += -nu_/dx_*v[i+1]+nl_*(u[i+1]/6.0*v[i]+(u[i]+2.0*u[i+1])/6.0*v[i+1]);
442 jv[ 0] -= nl_*u0_/6.0*v[0];
443 jv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
448 const std::vector<Real> &v,
449 const std::vector<Real> &u,
450 const std::vector<Real> &z)
const {
452 std::vector<Real> d(nx_,0.0);
453 std::vector<Real> dl(nx_-1,0.0);
454 std::vector<Real> du(nx_-1,0.0);
462 const std::vector<Real> &v,
463 const std::vector<Real> &u,
464 const std::vector<Real> &z)
const {
466 for (
int i = 0; i <
nx_; i++) {
467 ajv[i] = nu_/dx_*2.0*v[i];
469 ajv[i] += -nu_/dx_*v[i-1]-nl_*(u[i-1]/6.0*v[i]
470 -(u[i-1]+2.0*u[i])/6.0*v[i-1]);
473 ajv[i] += -nu_/dx_*v[i+1]+nl_*(u[i+1]/6.0*v[i]
474 -(u[i+1]+2.0*u[i])/6.0*v[i+1]);
477 ajv[ 0] -= nl_*u0_/6.0*v[0];
478 ajv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
483 const std::vector<Real> &v,
484 const std::vector<Real> &u,
485 const std::vector<Real> &z)
const {
487 std::vector<Real> d(nx_,0.0);
488 std::vector<Real> du(nx_-1,0.0);
489 std::vector<Real> dl(nx_-1,0.0);
500 const std::vector<Real> &v,
501 const std::vector<Real> &u,
502 const std::vector<Real> &z)
const {
503 for (
int i=0; i<
nx_; i++) {
505 jv[i] = -dx_/6.0*(v[i]+4.0*v[i+1]+v[i+2]);
511 const std::vector<Real> &v,
512 const std::vector<Real> &u,
513 const std::vector<Real> &z)
const {
514 for (
int i=0; i<nx_+2; i++) {
516 jv[i] = -dx_/6.0*v[i];
519 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i]);
521 else if ( i == nx_ ) {
522 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i-2]);
524 else if ( i == nx_+1 ) {
525 jv[i] = -dx_/6.0*v[i-2];
528 jv[i] = -dx_/6.0*(v[i-2]+4.0*v[i-1]+v[i]);
537 const std::vector<Real> &w,
538 const std::vector<Real> &v,
539 const std::vector<Real> &u,
540 const std::vector<Real> &z)
const {
541 for (
int i=0; i<
nx_; i++) {
545 ahwv[i] += (w[i]*v[i+1] - w[i+1]*(2.0*v[i]+v[i+1]))/6.0;
548 ahwv[i] += (w[i-1]*(v[i-1]+2.0*v[i]) - w[i]*v[i-1])/6.0;
554 const std::vector<Real> &w,
555 const std::vector<Real> &v,
556 const std::vector<Real> &u,
557 const std::vector<Real> &z) {
558 ahwv.assign(u.size(),0.0);
561 const std::vector<Real> &w,
562 const std::vector<Real> &v,
563 const std::vector<Real> &u,
564 const std::vector<Real> &z) {
565 ahwv.assign(z.size(),0.0);
568 const std::vector<Real> &w,
569 const std::vector<Real> &v,
570 const std::vector<Real> &u,
571 const std::vector<Real> &z) {
572 ahwv.assign(z.size(),0.0);
579 Teuchos::RCP<std::vector<Real> > vec_;
580 Teuchos::RCP<BurgersFEM<Real> > fem_;
582 mutable Teuchos::RCP<L2VectorDual<Real> > dual_vec_;
587 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
591 const std::vector<Real>& xval = *ex.
getVector();
592 std::copy(xval.begin(),xval.end(),vec_->begin());
597 const std::vector<Real>& xval = *ex.
getVector();
598 unsigned dimension = vec_->size();
599 for (
unsigned i=0; i<dimension; i++) {
600 (*vec_)[i] += xval[i];
605 unsigned dimension = vec_->size();
606 for (
unsigned i=0; i<dimension; i++) {
613 const std::vector<Real>& xval = *ex.
getVector();
614 return fem_->compute_L2_dot(xval,*vec_);
619 val = std::sqrt( dot(*
this) );
623 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
624 return Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
627 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
635 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
636 Teuchos::RCP<L2VectorPrimal> e
637 = Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
638 (*e->getVector())[i] = 1.0;
648 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
650 fem_->apply_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
659 Teuchos::RCP<std::vector<Real> > vec_;
660 Teuchos::RCP<BurgersFEM<Real> > fem_;
662 mutable Teuchos::RCP<L2VectorPrimal<Real> > dual_vec_;
667 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
671 const std::vector<Real>& xval = *ex.
getVector();
672 std::copy(xval.begin(),xval.end(),vec_->begin());
677 const std::vector<Real>& xval = *ex.
getVector();
678 unsigned dimension = vec_->size();
679 for (
unsigned i=0; i<dimension; i++) {
680 (*vec_)[i] += xval[i];
685 unsigned dimension = vec_->size();
686 for (
unsigned i=0; i<dimension; i++) {
693 const std::vector<Real>& xval = *ex.
getVector();
694 unsigned dimension = vec_->size();
695 std::vector<Real> Mx(dimension,0.0);
696 fem_->apply_inverse_mass(Mx,xval);
698 for (
unsigned i = 0; i < dimension; i++) {
699 val += Mx[i]*(*vec_)[i];
706 val = std::sqrt( dot(*
this) );
710 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
711 return Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
714 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
722 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
723 Teuchos::RCP<L2VectorDual> e
724 = Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
725 (*e->getVector())[i] = 1.0;
735 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
737 fem_->apply_inverse_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
746 Teuchos::RCP<std::vector<Real> > vec_;
747 Teuchos::RCP<BurgersFEM<Real> > fem_;
749 mutable Teuchos::RCP<H1VectorDual<Real> > dual_vec_;
754 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
758 const std::vector<Real>& xval = *ex.
getVector();
759 std::copy(xval.begin(),xval.end(),vec_->begin());
764 const std::vector<Real>& xval = *ex.
getVector();
765 unsigned dimension = vec_->size();
766 for (
unsigned i=0; i<dimension; i++) {
767 (*vec_)[i] += xval[i];
772 unsigned dimension = vec_->size();
773 for (
unsigned i=0; i<dimension; i++) {
780 const std::vector<Real>& xval = *ex.
getVector();
781 return fem_->compute_H1_dot(xval,*vec_);
786 val = std::sqrt( dot(*
this) );
790 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
791 return Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
794 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
802 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
803 Teuchos::RCP<H1VectorPrimal> e
804 = Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
805 (*e->getVector())[i] = 1.0;
815 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
817 fem_->apply_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
826 Teuchos::RCP<std::vector<Real> > vec_;
827 Teuchos::RCP<BurgersFEM<Real> > fem_;
829 mutable Teuchos::RCP<H1VectorPrimal<Real> > dual_vec_;
834 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
838 const std::vector<Real>& xval = *ex.
getVector();
839 std::copy(xval.begin(),xval.end(),vec_->begin());
844 const std::vector<Real>& xval = *ex.
getVector();
845 unsigned dimension = vec_->size();
846 for (
unsigned i=0; i<dimension; i++) {
847 (*vec_)[i] += xval[i];
852 unsigned dimension = vec_->size();
853 for (
unsigned i=0; i<dimension; i++) {
860 const std::vector<Real>& xval = *ex.
getVector();
861 unsigned dimension = vec_->size();
862 std::vector<Real> Mx(dimension,0.0);
863 fem_->apply_inverse_H1(Mx,xval);
865 for (
unsigned i = 0; i < dimension; i++) {
866 val += Mx[i]*(*vec_)[i];
873 val = std::sqrt( dot(*
this) );
877 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
878 return Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
881 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
889 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
890 Teuchos::RCP<H1VectorDual> e
891 = Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
892 (*e->getVector())[i] = 1.0;
902 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
904 fem_->apply_inverse_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
923 Teuchos::RCP<BurgersFEM<Real> > fem_;
928 : fem_(fem), useHessian_(useHessian) {}
932 Teuchos::RCP<std::vector<Real> > cp =
933 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(c)).getVector());
934 Teuchos::RCP<const std::vector<Real> > up =
935 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
936 Teuchos::RCP<const std::vector<Real> > zp =
937 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
939 const std::vector<Real> param
941 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
943 fem_->compute_residual(*cp,*up,*zp);
947 Teuchos::RCP<std::vector<Real> > up =
948 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalStateVector>(u)).getVector());
949 up->assign(up->size(),z.
norm()/up->size());
950 Teuchos::RCP<const std::vector<Real> > zp =
951 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
953 const std::vector<Real> param
955 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
957 fem_->solve(*up,*zp);
962 Teuchos::RCP<std::vector<Real> > jvp =
963 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(jv)).getVector());
964 Teuchos::RCP<const std::vector<Real> > vp =
965 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
966 Teuchos::RCP<const std::vector<Real> > up =
967 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
968 Teuchos::RCP<const std::vector<Real> > zp =
969 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
971 const std::vector<Real> param
973 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
975 fem_->apply_pde_jacobian(*jvp,*vp,*up,*zp);
980 Teuchos::RCP<std::vector<Real> > jvp =
981 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(jv)).getVector());
982 Teuchos::RCP<const std::vector<Real> > vp =
983 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
984 Teuchos::RCP<const std::vector<Real> > up =
985 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
986 Teuchos::RCP<const std::vector<Real> > zp =
987 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
989 const std::vector<Real> param
991 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
993 fem_->apply_control_jacobian(*jvp,*vp,*up,*zp);
998 Teuchos::RCP<std::vector<Real> > ijvp =
999 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalStateVector>(ijv)).getVector());
1000 Teuchos::RCP<const std::vector<Real> > vp =
1001 (Teuchos::dyn_cast<PrimalConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1002 Teuchos::RCP<const std::vector<Real> > up =
1003 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1004 Teuchos::RCP<const std::vector<Real> > zp =
1005 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1007 const std::vector<Real> param
1009 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1011 fem_->apply_inverse_pde_jacobian(*ijvp,*vp,*up,*zp);
1016 Teuchos::RCP<std::vector<Real> > jvp =
1017 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ajv)).getVector());
1018 Teuchos::RCP<const std::vector<Real> > vp =
1019 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1020 Teuchos::RCP<const std::vector<Real> > up =
1021 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1022 Teuchos::RCP<const std::vector<Real> > zp =
1023 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1025 const std::vector<Real> param
1027 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1029 fem_->apply_adjoint_pde_jacobian(*jvp,*vp,*up,*zp);
1034 Teuchos::RCP<std::vector<Real> > jvp =
1035 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(jv)).getVector());
1036 Teuchos::RCP<const std::vector<Real> > vp =
1037 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1038 Teuchos::RCP<const std::vector<Real> > up =
1039 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1040 Teuchos::RCP<const std::vector<Real> > zp =
1041 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1043 const std::vector<Real> param
1045 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1047 fem_->apply_adjoint_control_jacobian(*jvp,*vp,*up,*zp);
1052 Teuchos::RCP<std::vector<Real> > iajvp =
1053 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualConstraintVector>(iajv)).getVector());
1054 Teuchos::RCP<const std::vector<Real> > vp =
1055 (Teuchos::dyn_cast<DualStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1056 Teuchos::RCP<const std::vector<Real> > up =
1057 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1058 Teuchos::RCP<const std::vector<Real> > zp =
1059 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1061 const std::vector<Real> param
1063 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1065 fem_->apply_inverse_adjoint_pde_jacobian(*iajvp,*vp,*up,*zp);
1070 if ( useHessian_ ) {
1071 Teuchos::RCP<std::vector<Real> > ahwvp =
1072 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1073 Teuchos::RCP<const std::vector<Real> > wp =
1074 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1075 Teuchos::RCP<const std::vector<Real> > vp =
1076 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1077 Teuchos::RCP<const std::vector<Real> > up =
1078 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1079 Teuchos::RCP<const std::vector<Real> > zp =
1080 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1082 const std::vector<Real> param
1084 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1086 fem_->apply_adjoint_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1095 if ( useHessian_ ) {
1096 Teuchos::RCP<std::vector<Real> > ahwvp =
1097 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1098 Teuchos::RCP<const std::vector<Real> > wp =
1099 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1100 Teuchos::RCP<const std::vector<Real> > vp =
1101 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1102 Teuchos::RCP<const std::vector<Real> > up =
1103 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1104 Teuchos::RCP<const std::vector<Real> > zp =
1105 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1107 const std::vector<Real> param
1109 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1111 fem_->apply_adjoint_control_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1119 if ( useHessian_ ) {
1120 Teuchos::RCP<std::vector<Real> > ahwvp =
1121 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1122 Teuchos::RCP<const std::vector<Real> > wp =
1123 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1124 Teuchos::RCP<const std::vector<Real> > vp =
1125 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1126 Teuchos::RCP<const std::vector<Real> > up =
1127 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1128 Teuchos::RCP<const std::vector<Real> > zp =
1129 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1131 const std::vector<Real> param
1133 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1135 fem_->apply_adjoint_pde_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1143 if ( useHessian_ ) {
1144 Teuchos::RCP<std::vector<Real> > ahwvp =
1145 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1146 Teuchos::RCP<const std::vector<Real> > wp =
1147 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1148 Teuchos::RCP<const std::vector<Real> > vp =
1149 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1150 Teuchos::RCP<const std::vector<Real> > up =
1151 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1152 Teuchos::RCP<const std::vector<Real> > zp =
1153 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1155 const std::vector<Real> param
1157 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1159 fem_->apply_adjoint_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1167 template<
class Real>
1178 Teuchos::RCP<BurgersFEM<Real> > fem_;
1179 Teuchos::RCP<ROL::Vector<Real> > ud_;
1180 Teuchos::RCP<ROL::Vector<Real> > diff_;
1185 Real alpha = 1.e-4) : alpha_(alpha), fem_(fem), ud_(ud) {
1186 diff_ = ud_->clone();
1190 Teuchos::RCP<const std::vector<Real> > up =
1191 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1192 Teuchos::RCP<const std::vector<Real> > zp =
1193 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1194 Teuchos::RCP<const std::vector<Real> > udp =
1197 std::vector<Real> diff(udp->size(),0.0);
1198 for (
unsigned i = 0; i < udp->size(); i++) {
1199 diff[i] = (*up)[i] - (*udp)[i];
1201 return 0.5*(fem_->compute_L2_dot(diff,diff) + alpha_*fem_->compute_L2_dot(*zp,*zp));
1205 Teuchos::RCP<std::vector<Real> > gp =
1206 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(g)).getVector());
1207 Teuchos::RCP<const std::vector<Real> > up =
1208 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1209 Teuchos::RCP<const std::vector<Real> > udp =
1212 std::vector<Real> diff(udp->size(),0.0);
1213 for (
unsigned i = 0; i < udp->size(); i++) {
1214 diff[i] = (*up)[i] - (*udp)[i];
1216 fem_->apply_mass(*gp,diff);
1220 Teuchos::RCP<std::vector<Real> > gp =
1221 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(g)).getVector());
1222 Teuchos::RCP<const std::vector<Real> > zp =
1223 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1225 fem_->apply_mass(*gp,*zp);
1226 for (
unsigned i = 0; i < zp->size(); i++) {
1233 Teuchos::RCP<std::vector<Real> > hvp =
1234 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(hv)).getVector());
1235 Teuchos::RCP<const std::vector<Real> > vp =
1236 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1238 fem_->apply_mass(*hvp,*vp);
1253 Teuchos::RCP<std::vector<Real> > hvp =
1254 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(hv)).getVector());
1255 Teuchos::RCP<const std::vector<Real> > vp =
1256 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1258 fem_->apply_mass(*hvp,*vp);
1259 for (
unsigned i = 0; i < vp->size(); i++) {
1260 (*hvp)[i] *= alpha_;
1265 template<
class Real>
1269 std::vector<Real> x_lo_;
1270 std::vector<Real> x_up_;
1273 Teuchos::RCP<BurgersFEM<Real> > fem_;
1278 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1281 catch (std::exception &e) {
1282 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1293 catch (std::exception &e) {
1299 void axpy(std::vector<Real> &out,
const Real a,
1300 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1301 out.resize(dim_,0.0);
1302 for (
unsigned i = 0; i < dim_; i++) {
1303 out[i] = a*x[i] + y[i];
1308 for (
int i = 0; i < dim_; i++ ) {
1309 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1316 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1317 dim_ = x_lo_.size();
1318 for (
int i = 0; i < dim_; i++ ) {
1320 min_diff_ = x_up_[i] - x_lo_[i];
1323 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1330 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1333 for (
int i = 0; i < dim_; i++ ) {
1334 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1337 if ( cnt == 0 ) { val =
false; }
1342 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1347 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1348 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1349 Real epsn = std::min(scale_*eps,min_diff_);
1350 for (
int i = 0; i < dim_; i++ ) {
1351 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1358 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1359 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1360 Real epsn = std::min(scale_*eps,min_diff_);
1361 for (
int i = 0; i < dim_; i++ ) {
1362 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1369 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1370 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1371 Real epsn = std::min(scale_*eps,min_diff_);
1372 for (
int i = 0; i < dim_; i++ ) {
1373 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1374 ((*ex)[i] >= x_up_[i]-epsn) ) {
1381 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1382 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1383 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1384 Real epsn = std::min(scale_*eps,min_diff_);
1385 for (
int i = 0; i < dim_; i++ ) {
1386 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1393 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1394 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1395 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1396 Real epsn = std::min(scale_*eps,min_diff_);
1397 for (
int i = 0; i < dim_; i++ ) {
1398 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1405 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1406 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1407 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1408 Real epsn = std::min(scale_*eps,min_diff_);
1409 for (
int i = 0; i < dim_; i++ ) {
1410 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1411 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1418 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1419 us->assign(x_up_.begin(),x_up_.end());
1425 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1426 ls->assign(x_lo_.begin(),x_lo_.end());
1432 template<
class Real>
1436 std::vector<Real> x_lo_;
1437 std::vector<Real> x_up_;
1440 Teuchos::RCP<BurgersFEM<Real> > fem_;
1445 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1448 catch (std::exception &e) {
1449 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1460 catch (std::exception &e) {
1466 void axpy(std::vector<Real> &out,
const Real a,
1467 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1468 out.resize(dim_,0.0);
1469 for (
unsigned i = 0; i < dim_; i++) {
1470 out[i] = a*x[i] + y[i];
1475 for (
int i = 0; i < dim_; i++ ) {
1476 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1483 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1484 dim_ = x_lo_.size();
1485 for (
int i = 0; i < dim_; i++ ) {
1487 min_diff_ = x_up_[i] - x_lo_[i];
1490 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1497 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1500 for (
int i = 0; i < dim_; i++ ) {
1501 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1504 if ( cnt == 0 ) { val =
false; }
1509 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1514 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1515 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1516 Real epsn = std::min(scale_*eps,min_diff_);
1517 for (
int i = 0; i < dim_; i++ ) {
1518 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1525 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1526 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1527 Real epsn = std::min(scale_*eps,min_diff_);
1528 for (
int i = 0; i < dim_; i++ ) {
1529 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1536 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1537 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1538 Real epsn = std::min(scale_*eps,min_diff_);
1539 for (
int i = 0; i < dim_; i++ ) {
1540 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1541 ((*ex)[i] >= x_up_[i]-epsn) ) {
1548 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1549 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1550 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1551 Real epsn = std::min(scale_*eps,min_diff_);
1552 for (
int i = 0; i < dim_; i++ ) {
1553 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1560 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1561 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1562 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1563 Real epsn = std::min(scale_*eps,min_diff_);
1564 for (
int i = 0; i < dim_; i++ ) {
1565 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1572 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1573 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1574 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1575 Real epsn = std::min(scale_*eps,min_diff_);
1576 for (
int i = 0; i < dim_; i++ ) {
1577 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1578 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1585 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1586 us->assign(x_up_.begin(),x_up_.end());
1592 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1593 ls->assign(x_lo_.begin(),x_lo_.end());
1599 template<
class Real,
class Ordinal>
1605 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1608 catch (std::exception &e) {
1609 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1616 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1618 Teuchos::RCP<std::vector<Real> > input_ptr;
1619 cast_vector(input_ptr,input);
1620 int dim_i = input_ptr->size();
1621 Teuchos::RCP<std::vector<Real> > output_ptr;
1622 cast_vector(output_ptr,output);
1623 int dim_o = output_ptr->size();
1624 if ( dim_i != dim_o ) {
1625 std::cout <<
"L2VectorBatchManager: DIMENSION MISMATCH ON RANK " 1634 template<
class Real,
class Ordinal>
1640 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1643 catch (std::exception &e) {
1644 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1651 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1653 Teuchos::RCP<std::vector<Real> > input_ptr;
1654 cast_vector(input_ptr,input);
1655 int dim_i = input_ptr->size();
1656 Teuchos::RCP<std::vector<Real> > output_ptr;
1657 cast_vector(output_ptr,output);
1658 int dim_o = output_ptr->size();
1659 if ( dim_i != dim_o ) {
1660 std::cout <<
"H1VectorBatchManager: DIMENSION MISMATCH ON RANK " 1669 template<
class Real>
1670 Real
random(
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) {
1672 if ( Teuchos::rank<int>(*comm)==0 ) {
1673 val = (Real)rand()/(Real)RAND_MAX;
1675 Teuchos::broadcast<int,Real>(*comm,0,1,&val);
BurgersFEM(int nx=128, Real nl=1.0, Real cH1=1.0, Real cL2=1.0)
L2VectorBatchManager(const Teuchos::RCP< const Teuchos::Comm< Ordinal > > &comm)
void pruneUpperActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the upper -active set.
void cast_vector(Teuchos::RCP< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
L2VectorPrimal< Real > PrimalControlVector
Real compute_H1_dot(const std::vector< Real > &x, const std::vector< Real > &y) const
void applyAdjointHessian_21(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
Real norm() const
Returns where .
void cast_const_vector(Teuchos::RCP< const std::vector< Real > > &xvec, const ROL::Vector< Real > &x) const
void apply_mass(std::vector< Real > &Mu, const std::vector< Real > &u) const
Teuchos::RCP< const std::vector< Real > > getVector() const
bool isFeasible(const ROL::Vector< Real > &x)
Check if the vector, v, is feasible.
void axpy(std::vector< Real > &out, const Real a, const std::vector< Real > &x, const std::vector< Real > &y) const
Teuchos::RCP< std::vector< Real > > getVector()
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
Real dot(const ROL::Vector< Real > &x) const
Compute where .
void apply_adjoint_pde_control_hessian(std::vector< Real > &ahwv, const std::vector< Real > &w, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z)
Teuchos::RCP< const std::vector< Real > > getVector() const
int dimension() const
Return dimension of the vector space.
void plus(const ROL::Vector< Real > &x)
Compute , where .
Objective_BurgersControl(const Teuchos::RCP< BurgersFEM< Real > > &fem, const Teuchos::RCP< ROL::Vector< Real > > &ud, Real alpha=1.e-4)
void applyAdjointHessian_22(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
void applyInverseJacobian_1(ROL::Vector< Real > &ijv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the inverse partial constraint Jacobian at , , to the vector .
void apply_adjoint_pde_hessian(std::vector< Real > &ahwv, const std::vector< Real > &w, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
L2VectorDual(const Teuchos::RCP< std::vector< Real > > &vec, const Teuchos::RCP< BurgersFEM< Real > > &fem)
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
Real norm() const
Returns where .
void pruneActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the -binding set.
Contains definitions of custom data types in ROL.
Real dot(const ROL::Vector< Real > &x) const
Compute where .
void plus(const ROL::Vector< Real > &x)
Compute , where .
void pruneLowerActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the lower -active set.
Teuchos::RCP< const std::vector< Real > > getVector() const
Real compute_H1_norm(const std::vector< Real > &r) const
void solve(std::vector< Real > &u, const std::vector< Real > &z) const
Real norm() const
Returns where .
void pruneUpperActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the upper -binding set.
Teuchos::RCP< std::vector< Real > > getVector()
void project(ROL::Vector< Real > &x)
Project optimization variables onto the bounds.
Teuchos::RCP< std::vector< Real > > getVector()
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Real random(const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
void applyAdjointHessian_11(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
H1VectorDual< Real > DualStateVector
void scale(const Real alpha)
Compute where .
L2VectorDual< Real > DualControlVector
Real dot(const ROL::Vector< Real > &x) const
Compute where .
void hessVec_22(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Real value(const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Compute value.
void pruneActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the -active set.
void plus(const ROL::Vector< Real > &x)
Compute , where .
void gradient_1(ROL::Vector< Real > &g, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Compute gradient with respect to first component.
Real mesh_spacing(void) const
void applyInverseAdjointJacobian_1(ROL::Vector< Real > &iajv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the inverse of the adjoint of the partial constraint Jacobian at , , to the vector ...
bool isFeasible(const ROL::Vector< Real > &x)
Check if the vector, v, is feasible.
int dimension() const
Return dimension of the vector space.
void test_inverse_mass(std::ostream &outStream=std::cout)
void apply_pde_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
H1BoundConstraint(std::vector< Real > &l, std::vector< Real > &u, const Teuchos::RCP< BurgersFEM< Real > > &fem, Real scale=1.0)
void applyAdjointJacobian_1(ROL::Vector< Real > &ajv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Jacobian at , , to the vector . This is the primary inter...
void pruneActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the -active set.
void applyAdjointJacobian_2(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the primary interface...
void pruneLowerActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the lower -binding set.
void applyJacobian_1(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the partial constraint Jacobian at , , to the vector .
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
void scale(const Real alpha)
Compute where .
void compute_pde_jacobian(std::vector< Real > &dl, std::vector< Real > &d, std::vector< Real > &du, const std::vector< Real > &u) const
H1VectorPrimal< Real > PrimalStateVector
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
Real compute_L2_dot(const std::vector< Real > &x, const std::vector< Real > &y) const
void pruneLowerActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the lower -active set.
void hessVec_21(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
void linear_solve(std::vector< Real > &u, std::vector< Real > &dl, std::vector< Real > &d, std::vector< Real > &du, const std::vector< Real > &r, const bool transpose=false) const
void cast_vector(Teuchos::RCP< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
void apply_inverse_mass(std::vector< Real > &Mu, const std::vector< Real > &u) const
void axpy(std::vector< Real > &out, const Real a, const std::vector< Real > &x, const std::vector< Real > &y) const
void hessVec_12(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
void setVectorToUpperBound(ROL::Vector< Real > &u)
Set the input vector to the upper bound.
H1VectorDual< Real > PrimalConstraintVector
void update(std::vector< Real > &u, const std::vector< Real > &s, const Real alpha=1.0) const
void pruneLowerActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the lower -binding set.
void scale(const Real alpha)
Compute where .
void projection(std::vector< Real > &x)
void gradient_2(ROL::Vector< Real > &g, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Compute gradient with respect to second component.
void cast_vector(Teuchos::RCP< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
H1VectorPrimal< Real > DualConstraintVector
void setVectorToLowerBound(ROL::Vector< Real > &l)
Set the input vector to the lower bound.
void apply_adjoint_control_hessian(std::vector< Real > &ahwv, const std::vector< Real > &w, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z)
void solve(ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Given , solve for .
const std::vector< Real > getParameter(void) const
Provides the interface to apply upper and lower bound constraints.
void sumAll(Real *input, Real *output, int dim)
void compute_residual(std::vector< Real > &r, const std::vector< Real > &u, const std::vector< Real > &z) const
void projection(std::vector< Real > &x)
void cast_const_vector(Teuchos::RCP< const std::vector< Real > > &xvec, const ROL::Vector< Real > &x) const
void applyJacobian_2(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the partial constraint Jacobian at , , to the vector .
H1VectorDual< Real > DualStateVector
void set_problem_data(const Real nu, const Real f, const Real u0, const Real u1)
void hessVec_11(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply Hessian approximation to vector.
void apply_control_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
void test_inverse_H1(std::ostream &outStream=std::cout)
void value(ROL::Vector< Real > &c, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Evaluate the constraint operator at .
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
H1VectorDual(const Teuchos::RCP< std::vector< Real > > &vec, const Teuchos::RCP< BurgersFEM< Real > > &fem)
void apply_adjoint_control_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
Real dot(const ROL::Vector< Real > &x) const
Compute where .
L2VectorPrimal< Real > PrimalControlVector
void pruneUpperActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the upper -binding set.
void pruneActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the -binding set.
H1VectorPrimal< Real > PrimalStateVector
L2VectorPrimal(const Teuchos::RCP< std::vector< Real > > &vec, const Teuchos::RCP< BurgersFEM< Real > > &fem)
void apply_inverse_pde_jacobian(std::vector< Real > &ijv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
void axpy(std::vector< Real > &out, const Real a, const std::vector< Real > &x, const std::vector< Real > &y) const
void cast_vector(Teuchos::RCP< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
EqualityConstraint_BurgersControl(Teuchos::RCP< BurgersFEM< Real > > &fem, bool useHessian=true)
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
void apply_H1(std::vector< Real > &Mu, const std::vector< Real > &u) const
void plus(const ROL::Vector< Real > &x)
Compute , where .
virtual void set(const Vector &x)
Set where .
void sumAll(ROL::Vector< Real > &input, ROL::Vector< Real > &output)
void apply_inverse_H1(std::vector< Real > &Mu, const std::vector< Real > &u) const
void project(ROL::Vector< Real > &x)
Project optimization variables onto the bounds.
virtual Real norm() const =0
Returns where .
void apply_adjoint_pde_jacobian(std::vector< Real > &ajv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
void apply_inverse_adjoint_pde_jacobian(std::vector< Real > &iajv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
void apply_adjoint_control_pde_hessian(std::vector< Real > &ahwv, const std::vector< Real > &w, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z)
int dimension() const
Return dimension of the vector space.
L2VectorDual< Real > DualControlVector
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Teuchos::RCP< ROL::Vector< Real > > basis(const int i) const
Return i-th basis vector.
H1VectorPrimal(const Teuchos::RCP< std::vector< Real > > &vec, const Teuchos::RCP< BurgersFEM< Real > > &fem)
void sumAll(ROL::Vector< Real > &input, ROL::Vector< Real > &output)
Real norm() const
Returns where .
void scale(std::vector< Real > &u, const Real alpha=0.0) const
Teuchos::RCP< std::vector< Real > > getVector()
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
void applyAdjointHessian_12(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Hessian at , , to vector in direction ...
L2BoundConstraint(std::vector< Real > &l, std::vector< Real > &u, const Teuchos::RCP< BurgersFEM< Real > > &fem, Real scale=1.0)
H1VectorBatchManager(const Teuchos::RCP< const Teuchos::Comm< Ordinal > > &comm)
void pruneUpperActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the upper -active set.
Teuchos::RCP< const std::vector< Real > > getVector() const
void setVectorToLowerBound(ROL::Vector< Real > &l)
Set the input vector to the lower bound.
void scale(const Real alpha)
Compute where .
int dimension() const
Return dimension of the vector space.
static const double ROL_EPSILON
Platform-dependent machine epsilon.
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Real compute_L2_norm(const std::vector< Real > &r) const
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
void setVectorToUpperBound(ROL::Vector< Real > &u)
Set the input vector to the upper bound.