55 #include "Teuchos_LAPACK.hpp" 83 void update(std::vector<Real> &u,
const std::vector<Real> &s,
const Real alpha=1.0)
const {
84 for (
unsigned i=0; i<u.size(); i++) {
89 void axpy(std::vector<Real> &out,
const Real a,
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
90 for (
unsigned i=0; i < x.size(); i++) {
91 out[i] = a*x[i] + y[i];
95 void scale(std::vector<Real> &u,
const Real alpha=0.0)
const {
96 for (
unsigned i=0; i<u.size(); i++) {
101 void linear_solve(std::vector<Real> &u, std::vector<Real> &dl, std::vector<Real> &d, std::vector<Real> &du,
102 const std::vector<Real> &r,
const bool transpose =
false)
const {
103 if ( r.size() == 1 ) {
104 u.resize(1,r[0]/d[0]);
106 else if ( r.size() == 2 ) {
108 Real det = d[0]*d[1] - dl[0]*du[0];
109 u[0] = (d[1]*r[0] - du[0]*r[1])/det;
110 u[1] = (d[0]*r[1] - dl[0]*r[0])/det;
113 u.assign(r.begin(),r.end());
115 Teuchos::LAPACK<int,Real> lp;
116 std::vector<Real> du2(r.size()-2,0.0);
117 std::vector<int> ipiv(r.size(),0);
122 lp.GTTRF(dim,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&info);
127 lp.GTTRS(trans,dim,nhrs,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&u[0],ldb,&info);
133 Real u0 = 1.0, Real u1 = 0.0, Real f = 0.0,
134 Real cH1 = 1.0, Real cL2 = 1.0)
135 : nx_(nx), dx_(1.0/((Real)nx+1.0)),
136 nu_(nu), nl_(nl), u0_(u0), u1_(u1), f_(f),
137 cH1_(cH1), cL2_(cL2) {}
151 Real
compute_L2_dot(
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
153 Real c = (((int)x.size()==
nx_) ? 4.0 : 2.0);
154 for (
unsigned i=0; i<x.size(); i++) {
156 ip += dx_/6.0*(c*x[i] + x[i+1])*y[i];
158 else if ( i == x.size()-1 ) {
159 ip += dx_/6.0*(x[i-1] + c*x[i])*y[i];
162 ip += dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
174 void apply_mass(std::vector<Real> &Mu,
const std::vector<Real> &u )
const {
175 Mu.resize(u.size(),0.0);
176 Real c = (((int)u.size()==
nx_) ? 4.0 : 2.0);
177 for (
unsigned i=0; i<u.size(); i++) {
179 Mu[i] = dx_/6.0*(c*u[i] + u[i+1]);
181 else if ( i == u.size()-1 ) {
182 Mu[i] = dx_/6.0*(u[i-1] + c*u[i]);
185 Mu[i] = dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1]);
192 unsigned nx = u.size();
194 std::vector<Real> dl(nx-1,dx_/6.0);
195 std::vector<Real> d(nx,2.0*dx_/3.0);
196 std::vector<Real> du(nx-1,dx_/6.0);
197 if ( (
int)nx != nx_ ) {
206 std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
207 for (
int i = 0; i <
nx_; i++) {
208 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
212 axpy(diff,-1.0,iMMu,u);
215 outStream <<
"Test Inverse State Mass Matrix\n";
216 outStream <<
" ||u - inv(M)Mu|| = " << error <<
"\n";
217 outStream <<
" ||u|| = " << normu <<
"\n";
218 outStream <<
" Relative Error = " << error/normu <<
"\n";
221 u.resize(nx_+2,0.0); Mu.resize(nx_+2,0.0); iMMu.resize(nx_+2,0.0); diff.resize(nx_+2,0.0);
222 for (
int i = 0; i < nx_+2; i++) {
223 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
227 axpy(diff,-1.0,iMMu,u);
230 outStream <<
"Test Inverse Control Mass Matrix\n";
231 outStream <<
" ||z - inv(M)Mz|| = " << error <<
"\n";
232 outStream <<
" ||z|| = " << normu <<
"\n";
233 outStream <<
" Relative Error = " << error/normu <<
"\n";
241 Real
compute_H1_dot(
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
243 for (
int i=0; i<
nx_; i++) {
245 ip += cL2_*dx_/6.0*(4.0*x[i] + x[i+1])*y[i];
246 ip += cH1_*(2.0*x[i] - x[i+1])/dx_*y[i];
248 else if ( i == nx_-1 ) {
249 ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i])*y[i];
250 ip += cH1_*(2.0*x[i] - x[i-1])/dx_*y[i];
253 ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
254 ip += cH1_*(2.0*x[i] - x[i-1] - x[i+1])/dx_*y[i];
266 void apply_H1(std::vector<Real> &Mu,
const std::vector<Real> &u )
const {
268 for (
int i=0; i<
nx_; i++) {
270 Mu[i] = cL2_*dx_/6.0*(4.0*u[i] + u[i+1])
271 + cH1_*(2.0*u[i] - u[i+1])/
dx_;
273 else if ( i == nx_-1 ) {
274 Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i])
275 + cH1_*(2.0*u[i] - u[i-1])/
dx_;
278 Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1])
279 + cH1_*(2.0*u[i] - u[i-1] - u[i+1])/
dx_;
287 std::vector<Real> dl(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
288 std::vector<Real> d(nx_,2.0*(cL2_*dx_/3.0 + cH1_/dx_));
289 std::vector<Real> du(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
294 std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
295 for (
int i = 0; i <
nx_; i++) {
296 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
300 axpy(diff,-1.0,iMMu,u);
303 outStream <<
"Test Inverse State H1 Matrix\n";
304 outStream <<
" ||u - inv(M)Mu|| = " << error <<
"\n";
305 outStream <<
" ||u|| = " << normu <<
"\n";
306 outStream <<
" Relative Error = " << error/normu <<
"\n";
315 const std::vector<Real> &z)
const {
318 for (
int i=0; i<
nx_; i++) {
321 r[i] = nu_/dx_*(2.0*u[i]-u[i+1]);
324 r[i] = nu_/dx_*(2.0*u[i]-u[i-1]);
327 r[i] = nu_/dx_*(2.0*u[i]-u[i-1]-u[i+1]);
331 r[i] += nl_*u[i+1]*(u[i]+u[i+1])/6.0;
334 r[i] -= nl_*u[i-1]*(u[i-1]+u[i])/6.0;
337 r[i] -= dx_/6.0*(z[i]+4.0*z[i+1]+z[i+2]);
342 r[0] -= nl_*(u0_*u[ 0]/6.0 + u0_*u0_/6.0) + nu_*u0_/
dx_;
343 r[nx_-1] += nl_*(u1_*u[nx_-1]/6.0 + u1_*u1_/6.0) - nu_*u1_/
dx_;
347 void solve(std::vector<Real> &u,
const std::vector<Real> &z)
const {
349 std::vector<Real> r(u.size(),0.0);
356 std::vector<Real> d(nx_,0.0);
357 std::vector<Real> dl(nx_-1,0.0);
358 std::vector<Real> du(nx_-1,0.0);
360 Real alpha = 1.0, tmp = 0.0;
361 std::vector<Real> s(nx_,0.0);
362 std::vector<Real> utmp(nx_,0.0);
363 for (
int i=0; i<maxit; i++) {
372 utmp.assign(u.begin(),u.end());
376 while ( rnorm > (1.0-1.e-4*alpha)*tmp && alpha > std::sqrt(
ROL::ROL_EPSILON) ) {
378 utmp.assign(u.begin(),u.end());
384 u.assign(utmp.begin(),utmp.end());
385 if ( rnorm < rtol ) {
396 std::vector<Real> &d,
397 std::vector<Real> &du,
398 const std::vector<Real> &u)
const {
401 d.resize(nx_,nu_*2.0/dx_);
403 dl.resize(nx_-1,-nu_/dx_);
405 du.resize(nx_-1,-nu_/dx_);
407 for (
int i=0; i<
nx_; i++) {
409 dl[i] += nl_*(-2.0*u[i]-u[i+1])/6.0;
410 d[i] += nl_*u[i+1]/6.0;
413 d[i] -= nl_*u[i-1]/6.0;
414 du[i-1] += nl_*(u[i-1]+2.0*u[i])/6.0;
418 d[ 0] -= nl_*u0_/6.0;
419 d[nx_-1] += nl_*u1_/6.0;
424 const std::vector<Real> &v,
425 const std::vector<Real> &u,
426 const std::vector<Real> &z)
const {
428 for (
int i = 0; i <
nx_; i++) {
429 jv[i] = nu_/dx_*2.0*v[i];
431 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]);
434 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]);
437 jv[ 0] -= nl_*u0_/6.0*v[0];
438 jv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
443 const std::vector<Real> &v,
444 const std::vector<Real> &u,
445 const std::vector<Real> &z)
const {
447 std::vector<Real> d(nx_,0.0);
448 std::vector<Real> dl(nx_-1,0.0);
449 std::vector<Real> du(nx_-1,0.0);
457 const std::vector<Real> &v,
458 const std::vector<Real> &u,
459 const std::vector<Real> &z)
const {
461 for (
int i = 0; i <
nx_; i++) {
462 ajv[i] = nu_/dx_*2.0*v[i];
464 ajv[i] += -nu_/dx_*v[i-1]-nl_*(u[i-1]/6.0*v[i]
465 -(u[i-1]+2.0*u[i])/6.0*v[i-1]);
468 ajv[i] += -nu_/dx_*v[i+1]+nl_*(u[i+1]/6.0*v[i]
469 -(u[i+1]+2.0*u[i])/6.0*v[i+1]);
472 ajv[ 0] -= nl_*u0_/6.0*v[0];
473 ajv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
478 const std::vector<Real> &v,
479 const std::vector<Real> &u,
480 const std::vector<Real> &z)
const {
482 std::vector<Real> d(nx_,0.0);
483 std::vector<Real> du(nx_-1,0.0);
484 std::vector<Real> dl(nx_-1,0.0);
495 const std::vector<Real> &v,
496 const std::vector<Real> &u,
497 const std::vector<Real> &z)
const {
498 for (
int i=0; i<
nx_; i++) {
500 jv[i] = -dx_/6.0*(v[i]+4.0*v[i+1]+v[i+2]);
506 const std::vector<Real> &v,
507 const std::vector<Real> &u,
508 const std::vector<Real> &z)
const {
509 for (
int i=0; i<nx_+2; i++) {
511 jv[i] = -dx_/6.0*v[i];
514 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i]);
516 else if ( i == nx_ ) {
517 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i-2]);
519 else if ( i == nx_+1 ) {
520 jv[i] = -dx_/6.0*v[i-2];
523 jv[i] = -dx_/6.0*(v[i-2]+4.0*v[i-1]+v[i]);
532 const std::vector<Real> &w,
533 const std::vector<Real> &v,
534 const std::vector<Real> &u,
535 const std::vector<Real> &z)
const {
536 for (
int i=0; i<
nx_; i++) {
540 ahwv[i] += (w[i]*v[i+1] - w[i+1]*(2.0*v[i]+v[i+1]))/6.0;
543 ahwv[i] += (w[i-1]*(v[i-1]+2.0*v[i]) - w[i]*v[i-1])/6.0;
549 const std::vector<Real> &w,
550 const std::vector<Real> &v,
551 const std::vector<Real> &u,
552 const std::vector<Real> &z) {
553 ahwv.assign(u.size(),0.0);
556 const std::vector<Real> &w,
557 const std::vector<Real> &v,
558 const std::vector<Real> &u,
559 const std::vector<Real> &z) {
560 ahwv.assign(z.size(),0.0);
563 const std::vector<Real> &w,
564 const std::vector<Real> &v,
565 const std::vector<Real> &u,
566 const std::vector<Real> &z) {
567 ahwv.assign(z.size(),0.0);
574 Teuchos::RCP<std::vector<Real> >
vec_;
575 Teuchos::RCP<BurgersFEM<Real> >
fem_;
582 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
586 const std::vector<Real>& xval = *ex.
getVector();
587 std::copy(xval.begin(),xval.end(),vec_->begin());
592 const std::vector<Real>& xval = *ex.
getVector();
593 unsigned dimension = vec_->size();
594 for (
unsigned i=0; i<dimension; i++) {
595 (*vec_)[i] += xval[i];
600 unsigned dimension = vec_->size();
601 for (
unsigned i=0; i<dimension; i++) {
608 const std::vector<Real>& xval = *ex.
getVector();
609 return fem_->compute_L2_dot(xval,*vec_);
614 val = std::sqrt( dot(*
this) );
618 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
619 return Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
622 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
630 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
631 Teuchos::RCP<L2VectorPrimal> e
632 = Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
633 (*e->getVector())[i] = 1.0;
643 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
645 fem_->apply_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
654 Teuchos::RCP<std::vector<Real> >
vec_;
655 Teuchos::RCP<BurgersFEM<Real> >
fem_;
662 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
666 const std::vector<Real>& xval = *ex.
getVector();
667 std::copy(xval.begin(),xval.end(),vec_->begin());
672 const std::vector<Real>& xval = *ex.
getVector();
673 unsigned dimension = vec_->size();
674 for (
unsigned i=0; i<dimension; i++) {
675 (*vec_)[i] += xval[i];
680 unsigned dimension = vec_->size();
681 for (
unsigned i=0; i<dimension; i++) {
688 const std::vector<Real>& xval = *ex.
getVector();
689 unsigned dimension = vec_->size();
690 std::vector<Real> Mx(dimension,0.0);
691 fem_->apply_inverse_mass(Mx,xval);
693 for (
unsigned i = 0; i < dimension; i++) {
694 val += Mx[i]*(*vec_)[i];
701 val = std::sqrt( dot(*
this) );
705 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
706 return Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
709 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
717 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
718 Teuchos::RCP<L2VectorDual> e
719 = Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
720 (*e->getVector())[i] = 1.0;
730 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
732 fem_->apply_inverse_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
741 Teuchos::RCP<std::vector<Real> >
vec_;
742 Teuchos::RCP<BurgersFEM<Real> >
fem_;
749 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
753 const std::vector<Real>& xval = *ex.
getVector();
754 std::copy(xval.begin(),xval.end(),vec_->begin());
759 const std::vector<Real>& xval = *ex.
getVector();
760 unsigned dimension = vec_->size();
761 for (
unsigned i=0; i<dimension; i++) {
762 (*vec_)[i] += xval[i];
767 unsigned dimension = vec_->size();
768 for (
unsigned i=0; i<dimension; i++) {
775 const std::vector<Real>& xval = *ex.
getVector();
776 return fem_->compute_H1_dot(xval,*vec_);
781 val = std::sqrt( dot(*
this) );
785 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
786 return Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
789 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
797 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
798 Teuchos::RCP<H1VectorPrimal> e
799 = Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
800 (*e->getVector())[i] = 1.0;
810 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
812 fem_->apply_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
821 Teuchos::RCP<std::vector<Real> >
vec_;
822 Teuchos::RCP<BurgersFEM<Real> >
fem_;
829 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
833 const std::vector<Real>& xval = *ex.
getVector();
834 std::copy(xval.begin(),xval.end(),vec_->begin());
839 const std::vector<Real>& xval = *ex.
getVector();
840 unsigned dimension = vec_->size();
841 for (
unsigned i=0; i<dimension; i++) {
842 (*vec_)[i] += xval[i];
847 unsigned dimension = vec_->size();
848 for (
unsigned i=0; i<dimension; i++) {
855 const std::vector<Real>& xval = *ex.
getVector();
856 unsigned dimension = vec_->size();
857 std::vector<Real> Mx(dimension,0.0);
858 fem_->apply_inverse_H1(Mx,xval);
860 for (
unsigned i = 0; i < dimension; i++) {
861 val += Mx[i]*(*vec_)[i];
868 val = std::sqrt( dot(*
this) );
872 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
873 return Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
876 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
884 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
885 Teuchos::RCP<H1VectorDual> e
886 = Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
887 (*e->getVector())[i] = 1.0;
897 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
899 fem_->apply_inverse_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
918 Teuchos::RCP<BurgersFEM<Real> >
fem_;
923 : fem_(fem), useHessian_(useHessian) {}
927 Teuchos::RCP<std::vector<Real> > cp =
928 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(c)).getVector());
929 Teuchos::RCP<const std::vector<Real> > up =
930 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
931 Teuchos::RCP<const std::vector<Real> > zp =
932 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
933 fem_->compute_residual(*cp,*up,*zp);
939 Teuchos::RCP<std::vector<Real> > up =
940 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalStateVector>(u)).getVector());
941 up->assign(up->size(),z.
norm()/up->size());
942 Teuchos::RCP<const std::vector<Real> > zp =
943 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
944 fem_->solve(*up,*zp);
949 Teuchos::RCP<std::vector<Real> > jvp =
950 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(jv)).getVector());
951 Teuchos::RCP<const std::vector<Real> > vp =
952 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
953 Teuchos::RCP<const std::vector<Real> > up =
954 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
955 Teuchos::RCP<const std::vector<Real> > zp =
956 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
957 fem_->apply_pde_jacobian(*jvp,*vp,*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<PrimalControlVector>(
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();
970 fem_->apply_control_jacobian(*jvp,*vp,*up,*zp);
975 Teuchos::RCP<std::vector<Real> > ijvp =
976 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalStateVector>(ijv)).getVector());
977 Teuchos::RCP<const std::vector<Real> > vp =
978 (Teuchos::dyn_cast<PrimalConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
979 Teuchos::RCP<const std::vector<Real> > up =
980 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
981 Teuchos::RCP<const std::vector<Real> > zp =
982 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
983 fem_->apply_inverse_pde_jacobian(*ijvp,*vp,*up,*zp);
988 Teuchos::RCP<std::vector<Real> > jvp =
989 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ajv)).getVector());
990 Teuchos::RCP<const std::vector<Real> > vp =
991 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
992 Teuchos::RCP<const std::vector<Real> > up =
993 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
994 Teuchos::RCP<const std::vector<Real> > zp =
995 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
996 fem_->apply_adjoint_pde_jacobian(*jvp,*vp,*up,*zp);
1001 Teuchos::RCP<std::vector<Real> > jvp =
1002 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(jv)).getVector());
1003 Teuchos::RCP<const std::vector<Real> > vp =
1004 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1005 Teuchos::RCP<const std::vector<Real> > up =
1006 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1007 Teuchos::RCP<const std::vector<Real> > zp =
1008 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1009 fem_->apply_adjoint_control_jacobian(*jvp,*vp,*up,*zp);
1014 Teuchos::RCP<std::vector<Real> > iajvp =
1015 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualConstraintVector>(iajv)).getVector());
1016 Teuchos::RCP<const std::vector<Real> > vp =
1017 (Teuchos::dyn_cast<DualStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1018 Teuchos::RCP<const std::vector<Real> > up =
1019 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1020 Teuchos::RCP<const std::vector<Real> > zp =
1021 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1022 fem_->apply_inverse_adjoint_pde_jacobian(*iajvp,*vp,*up,*zp);
1027 if ( useHessian_ ) {
1028 Teuchos::RCP<std::vector<Real> > ahwvp =
1029 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1030 Teuchos::RCP<const std::vector<Real> > wp =
1031 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1032 Teuchos::RCP<const std::vector<Real> > vp =
1033 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1034 Teuchos::RCP<const std::vector<Real> > up =
1035 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1036 Teuchos::RCP<const std::vector<Real> > zp =
1037 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1038 fem_->apply_adjoint_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1047 if ( useHessian_ ) {
1048 Teuchos::RCP<std::vector<Real> > ahwvp =
1049 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1050 Teuchos::RCP<const std::vector<Real> > wp =
1051 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1052 Teuchos::RCP<const std::vector<Real> > vp =
1053 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1054 Teuchos::RCP<const std::vector<Real> > up =
1055 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1056 Teuchos::RCP<const std::vector<Real> > zp =
1057 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1058 fem_->apply_adjoint_control_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1066 if ( useHessian_ ) {
1067 Teuchos::RCP<std::vector<Real> > ahwvp =
1068 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1069 Teuchos::RCP<const std::vector<Real> > wp =
1070 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1071 Teuchos::RCP<const std::vector<Real> > vp =
1072 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1073 Teuchos::RCP<const std::vector<Real> > up =
1074 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1075 Teuchos::RCP<const std::vector<Real> > zp =
1076 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1077 fem_->apply_adjoint_pde_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1085 if ( useHessian_ ) {
1086 Teuchos::RCP<std::vector<Real> > ahwvp =
1087 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1088 Teuchos::RCP<const std::vector<Real> > wp =
1089 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1090 Teuchos::RCP<const std::vector<Real> > vp =
1091 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1092 Teuchos::RCP<const std::vector<Real> > up =
1093 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1094 Teuchos::RCP<const std::vector<Real> > zp =
1095 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1096 fem_->apply_adjoint_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1104 template<
class Real>
1115 Teuchos::RCP<BurgersFEM<Real> >
fem_;
1116 Teuchos::RCP<ROL::Vector<Real> >
ud_;
1122 Real alpha = 1.e-4) : alpha_(alpha), fem_(fem), ud_(ud) {
1123 diff_ = ud_->clone();
1127 Teuchos::RCP<const std::vector<Real> > up =
1128 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1129 Teuchos::RCP<const std::vector<Real> > zp =
1130 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1131 Teuchos::RCP<const std::vector<Real> > udp =
1134 std::vector<Real> diff(udp->size(),0.0);
1135 for (
unsigned i = 0; i < udp->size(); i++) {
1136 diff[i] = (*up)[i] - (*udp)[i];
1138 return 0.5*(fem_->compute_L2_dot(diff,diff) + alpha_*fem_->compute_L2_dot(*zp,*zp));
1142 Teuchos::RCP<std::vector<Real> > gp =
1143 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(g)).getVector());
1144 Teuchos::RCP<const std::vector<Real> > up =
1145 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1146 Teuchos::RCP<const std::vector<Real> > udp =
1149 std::vector<Real> diff(udp->size(),0.0);
1150 for (
unsigned i = 0; i < udp->size(); i++) {
1151 diff[i] = (*up)[i] - (*udp)[i];
1153 fem_->apply_mass(*gp,diff);
1157 Teuchos::RCP<std::vector<Real> > gp =
1158 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(g)).getVector());
1159 Teuchos::RCP<const std::vector<Real> > zp =
1160 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1162 fem_->apply_mass(*gp,*zp);
1163 for (
unsigned i = 0; i < zp->size(); i++) {
1170 Teuchos::RCP<std::vector<Real> > hvp =
1171 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(hv)).getVector());
1172 Teuchos::RCP<const std::vector<Real> > vp =
1173 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1175 fem_->apply_mass(*hvp,*vp);
1190 Teuchos::RCP<std::vector<Real> > hvp =
1191 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(hv)).getVector());
1192 Teuchos::RCP<const std::vector<Real> > vp =
1193 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1195 fem_->apply_mass(*hvp,*vp);
1196 for (
unsigned i = 0; i < vp->size(); i++) {
1197 (*hvp)[i] *= alpha_;
1202 template<
class Real>
1210 Teuchos::RCP<BurgersFEM<Real> >
fem_;
1215 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1218 catch (std::exception &e) {
1219 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1230 catch (std::exception &e) {
1236 void axpy(std::vector<Real> &out,
const Real a,
1237 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1238 out.resize(dim_,0.0);
1239 for (
unsigned i = 0; i < dim_; i++) {
1240 out[i] = a*x[i] + y[i];
1245 for (
int i = 0; i < dim_; i++ ) {
1246 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1253 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1254 dim_ = x_lo_.size();
1255 for (
int i = 0; i < dim_; i++ ) {
1257 min_diff_ = x_up_[i] - x_lo_[i];
1260 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1267 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1270 for (
int i = 0; i < dim_; i++ ) {
1271 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1274 if ( cnt == 0 ) { val =
false; }
1279 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1284 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1285 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1286 Real epsn = std::min(scale_*eps,min_diff_);
1287 for (
int i = 0; i < dim_; i++ ) {
1288 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1295 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1296 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1297 Real epsn = std::min(scale_*eps,min_diff_);
1298 for (
int i = 0; i < dim_; i++ ) {
1299 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1306 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1307 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1308 Real epsn = std::min(scale_*eps,min_diff_);
1309 for (
int i = 0; i < dim_; i++ ) {
1310 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1311 ((*ex)[i] >= x_up_[i]-epsn) ) {
1318 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1319 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1320 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1321 Real epsn = std::min(scale_*eps,min_diff_);
1322 for (
int i = 0; i < dim_; i++ ) {
1323 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1330 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1331 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1332 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1333 Real epsn = std::min(scale_*eps,min_diff_);
1334 for (
int i = 0; i < dim_; i++ ) {
1335 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1342 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1343 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1344 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1345 Real epsn = std::min(scale_*eps,min_diff_);
1346 for (
int i = 0; i < dim_; i++ ) {
1347 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1348 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1355 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1356 us->assign(x_up_.begin(),x_up_.end());
1362 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1363 ls->assign(x_lo_.begin(),x_lo_.end());
1369 template<
class Real>
1377 Teuchos::RCP<BurgersFEM<Real> >
fem_;
1382 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1385 catch (std::exception &e) {
1386 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1397 catch (std::exception &e) {
1403 void axpy(std::vector<Real> &out,
const Real a,
1404 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1405 out.resize(dim_,0.0);
1406 for (
unsigned i = 0; i < dim_; i++) {
1407 out[i] = a*x[i] + y[i];
1412 for (
int i = 0; i < dim_; i++ ) {
1413 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1420 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1421 dim_ = x_lo_.size();
1422 for (
int i = 0; i < dim_; i++ ) {
1424 min_diff_ = x_up_[i] - x_lo_[i];
1427 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1434 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1437 for (
int i = 0; i < dim_; i++ ) {
1438 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1441 if ( cnt == 0 ) { val =
false; }
1446 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1451 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1452 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1453 Real epsn = std::min(scale_*eps,min_diff_);
1454 for (
int i = 0; i < dim_; i++ ) {
1455 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1462 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1463 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1464 Real epsn = std::min(scale_*eps,min_diff_);
1465 for (
int i = 0; i < dim_; i++ ) {
1466 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1473 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1474 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1475 Real epsn = std::min(scale_*eps,min_diff_);
1476 for (
int i = 0; i < dim_; i++ ) {
1477 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1478 ((*ex)[i] >= x_up_[i]-epsn) ) {
1485 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1486 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1487 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1488 Real epsn = std::min(scale_*eps,min_diff_);
1489 for (
int i = 0; i < dim_; i++ ) {
1490 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1497 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1498 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1499 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1500 Real epsn = std::min(scale_*eps,min_diff_);
1501 for (
int i = 0; i < dim_; i++ ) {
1502 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1509 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1510 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1511 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1512 Real epsn = std::min(scale_*eps,min_diff_);
1513 for (
int i = 0; i < dim_; i++ ) {
1514 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1515 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1522 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1523 us->assign(x_up_.begin(),x_up_.end());
1529 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1530 ls->assign(x_lo_.begin(),x_lo_.end());
Provides the interface to evaluate simulation-based objective functions.
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
std::vector< Real > x_up_
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.
Teuchos::RCP< std::vector< Real > > vec_
Teuchos::RCP< ROL::Vector< Real > > ud_
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)
std::vector< Real > x_up_
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 ...
Teuchos::RCP< BurgersFEM< Real > > fem_
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.
Teuchos::RCP< H1VectorPrimal< Real > > dual_vec_
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
Teuchos::RCP< std::vector< Real > > vec_
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()
Teuchos::RCP< BurgersFEM< Real > > fem_
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.
Teuchos::RCP< H1VectorDual< Real > > dual_vec_
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 .
Defines the equality constraint operator interface for simulation-based optimization.
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)
Teuchos::RCP< ROL::Vector< Real > > diff_
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.
Teuchos::RCP< BurgersFEM< Real > > fem_
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
std::vector< Real > x_lo_
Teuchos::RCP< L2VectorPrimal< Real > > dual_vec_
Teuchos::RCP< BurgersFEM< Real > > fem_
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
Teuchos::RCP< BurgersFEM< Real > > fem_
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 .
Teuchos::RCP< BurgersFEM< Real > > fem_
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.
Teuchos::RCP< std::vector< Real > > vec_
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 .
Provides the interface to apply upper and lower bound constraints.
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 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 .
Teuchos::RCP< BurgersFEM< Real > > fem_
L2VectorPrimal< Real > PrimalControlVector
Teuchos::RCP< L2VectorDual< Real > > dual_vec_
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)
std::vector< Real > x_lo_
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
EqualityConstraint_BurgersControl(Teuchos::RCP< BurgersFEM< Real > > &fem, bool useHessian=true)
Teuchos::RCP< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Teuchos::RCP< std::vector< Real > > vec_
BurgersFEM(int nx=128, Real nu=1.e-2, Real nl=1.0, Real u0=1.0, Real u1=0.0, Real f=0.0, Real cH1=1.0, Real cL2=1.0)
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 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)
Teuchos::RCP< BurgersFEM< Real > > fem_
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)
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)
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.