54 #include "ROL_TeuchosBatchManager.hpp" 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_;
355 std::vector<Real> &d,
356 std::vector<Real> &du,
357 const std::vector<Real> &u)
const {
360 d.resize(nx_,nu_*2.0/dx_);
362 dl.resize(nx_-1,-nu_/dx_);
364 du.resize(nx_-1,-nu_/dx_);
366 for (
int i=0; i<
nx_; i++) {
368 dl[i] += nl_*(-2.0*u[i]-u[i+1])/6.0;
369 d[i] += nl_*u[i+1]/6.0;
372 d[i] -= nl_*u[i-1]/6.0;
373 du[i-1] += nl_*(u[i-1]+2.0*u[i])/6.0;
377 d[ 0] -= nl_*u0_/6.0;
378 d[nx_-1] += nl_*u1_/6.0;
383 const std::vector<Real> &v,
384 const std::vector<Real> &u,
385 const std::vector<Real> &z)
const {
387 for (
int i = 0; i <
nx_; i++) {
388 jv[i] = nu_/dx_*2.0*v[i];
390 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]);
393 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]);
396 jv[ 0] -= nl_*u0_/6.0*v[0];
397 jv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
402 const std::vector<Real> &v,
403 const std::vector<Real> &u,
404 const std::vector<Real> &z)
const {
406 std::vector<Real> d(nx_,0.0);
407 std::vector<Real> dl(nx_-1,0.0);
408 std::vector<Real> du(nx_-1,0.0);
416 const std::vector<Real> &v,
417 const std::vector<Real> &u,
418 const std::vector<Real> &z)
const {
420 for (
int i = 0; i <
nx_; i++) {
421 ajv[i] = nu_/dx_*2.0*v[i];
423 ajv[i] += -nu_/dx_*v[i-1]-nl_*(u[i-1]/6.0*v[i]
424 -(u[i-1]+2.0*u[i])/6.0*v[i-1]);
427 ajv[i] += -nu_/dx_*v[i+1]+nl_*(u[i+1]/6.0*v[i]
428 -(u[i+1]+2.0*u[i])/6.0*v[i+1]);
431 ajv[ 0] -= nl_*u0_/6.0*v[0];
432 ajv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
437 const std::vector<Real> &v,
438 const std::vector<Real> &u,
439 const std::vector<Real> &z)
const {
441 std::vector<Real> d(nx_,0.0);
442 std::vector<Real> du(nx_-1,0.0);
443 std::vector<Real> dl(nx_-1,0.0);
454 const std::vector<Real> &v,
455 const std::vector<Real> &u,
456 const std::vector<Real> &z)
const {
457 for (
int i=0; i<
nx_; i++) {
459 jv[i] = -dx_/6.0*(v[i]+4.0*v[i+1]+v[i+2]);
465 const std::vector<Real> &v,
466 const std::vector<Real> &u,
467 const std::vector<Real> &z)
const {
468 for (
int i=0; i<nx_+2; i++) {
470 jv[i] = -dx_/6.0*v[i];
473 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i]);
475 else if ( i == nx_ ) {
476 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i-2]);
478 else if ( i == nx_+1 ) {
479 jv[i] = -dx_/6.0*v[i-2];
482 jv[i] = -dx_/6.0*(v[i-2]+4.0*v[i-1]+v[i]);
491 const std::vector<Real> &w,
492 const std::vector<Real> &v,
493 const std::vector<Real> &u,
494 const std::vector<Real> &z)
const {
495 for (
int i=0; i<
nx_; i++) {
499 ahwv[i] += (w[i]*v[i+1] - w[i+1]*(2.0*v[i]+v[i+1]))/6.0;
502 ahwv[i] += (w[i-1]*(v[i-1]+2.0*v[i]) - w[i]*v[i-1])/6.0;
508 const std::vector<Real> &w,
509 const std::vector<Real> &v,
510 const std::vector<Real> &u,
511 const std::vector<Real> &z) {
512 ahwv.assign(u.size(),0.0);
515 const std::vector<Real> &w,
516 const std::vector<Real> &v,
517 const std::vector<Real> &u,
518 const std::vector<Real> &z) {
519 ahwv.assign(z.size(),0.0);
522 const std::vector<Real> &w,
523 const std::vector<Real> &v,
524 const std::vector<Real> &u,
525 const std::vector<Real> &z) {
526 ahwv.assign(z.size(),0.0);
533 ROL::Ptr<BurgersFEM<Real> > fem_;
534 mutable ROL::Ptr<L2VectorDual<Real> > dual_vec_;
540 :
ROL::StdVector<Real>(vec),
541 fem_(fem), dual_vec_(
ROL::nullPtr), isDualInitialized_(false) {}
545 const std::vector<Real>& xval = *ex.
getVector();
547 return fem_->compute_L2_dot(xval,yval);
550 ROL::Ptr<ROL::Vector<Real> >
clone()
const {
551 return ROL::makePtr<L2VectorPrimal>(
556 if ( !isDualInitialized_) {
557 dual_vec_ = ROL::makePtr<L2VectorDual<Real>>(
559 isDualInitialized_ =
true;
570 ROL::Ptr<BurgersFEM<Real> > fem_;
577 :
ROL::StdVector<Real>(vec),
578 fem_(fem), prim_vec_(
ROL::nullPtr), isPrimalInitialized_(false) {}
582 const std::vector<Real>& xval = *ex.
getVector();
584 unsigned dimension = yval.size();
585 std::vector<Real> Mx(dimension,0.0);
586 fem_->apply_inverse_mass(Mx,xval);
588 for (
unsigned i = 0; i < dimension; i++) {
589 val += Mx[i]*yval[i];
594 ROL::Ptr<ROL::Vector<Real> >
clone()
const {
595 return ROL::makePtr<L2VectorDual>(
600 if (!isPrimalInitialized_) {
601 prim_vec_ = ROL::makePtr<L2VectorPrimal<Real>>(
603 isPrimalInitialized_ =
true;
614 ROL::Ptr<BurgersFEM<Real> > fem_;
615 mutable ROL::Ptr<H1VectorDual<Real> > dual_vec_;
621 :
ROL::StdVector<Real>(vec),
622 fem_(fem), dual_vec_(
ROL::nullPtr), isDualInitialized_(false) {}
626 const std::vector<Real>& xval = *ex.
getVector();
628 return fem_->compute_H1_dot(xval,yval);
631 ROL::Ptr<ROL::Vector<Real> >
clone()
const {
632 return ROL::makePtr<H1VectorPrimal>(
637 if ( !isDualInitialized_) {
638 dual_vec_ = ROL::makePtr<H1VectorDual<Real>>(
640 isDualInitialized_ =
true;
651 ROL::Ptr<BurgersFEM<Real> > fem_;
658 :
ROL::StdVector<Real>(vec),
659 fem_(fem), prim_vec_(
ROL::nullPtr), isPrimalInitialized_(false) {}
663 const std::vector<Real>& xval = *ex.
getVector();
665 unsigned dimension = yval.size();
666 std::vector<Real> Mx(dimension,0.0);
667 fem_->apply_inverse_H1(Mx,xval);
669 for (
unsigned i = 0; i < dimension; i++) {
670 val += Mx[i]*yval[i];
675 ROL::Ptr<ROL::Vector<Real> >
clone()
const {
676 return ROL::makePtr<H1VectorDual>(
681 if (!isPrimalInitialized_) {
682 prim_vec_ = ROL::makePtr<H1VectorPrimal<Real>>(
684 isPrimalInitialized_ =
true;
705 ROL::Ptr<BurgersFEM<Real> > fem_;
710 : fem_(fem), useHessian_(useHessian) {}
714 ROL::Ptr<std::vector<Real> > cp =
715 dynamic_cast<PrimalConstraintVector&
>(c).getVector();
716 ROL::Ptr<const std::vector<Real> > up =
717 dynamic_cast<const PrimalStateVector&
>(u).getVector();
718 ROL::Ptr<const std::vector<Real> > zp =
719 dynamic_cast<const PrimalControlVector&
>(z).getVector();
721 const std::vector<Real> param
723 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
725 fem_->compute_residual(*cp,*up,*zp);
730 ROL::Ptr<std::vector<Real> > jvp =
731 dynamic_cast<PrimalConstraintVector&
>(jv).getVector();
732 ROL::Ptr<const std::vector<Real> > vp =
733 dynamic_cast<const PrimalStateVector&
>(v).getVector();
734 ROL::Ptr<const std::vector<Real> > up =
735 dynamic_cast<const PrimalStateVector&
>(u).getVector();
736 ROL::Ptr<const std::vector<Real> > zp =
737 dynamic_cast<const PrimalControlVector&
>(z).getVector();
739 const std::vector<Real> param
741 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
743 fem_->apply_pde_jacobian(*jvp,*vp,*up,*zp);
748 ROL::Ptr<std::vector<Real> > jvp =
749 dynamic_cast<PrimalConstraintVector&
>(jv).getVector();
750 ROL::Ptr<const std::vector<Real> > vp =
751 dynamic_cast<const PrimalControlVector&
>(v).getVector();
752 ROL::Ptr<const std::vector<Real> > up =
753 dynamic_cast<const PrimalStateVector&
>(u).getVector();
754 ROL::Ptr<const std::vector<Real> > zp =
755 dynamic_cast<const PrimalControlVector&
>(z).getVector();
757 const std::vector<Real> param
759 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
761 fem_->apply_control_jacobian(*jvp,*vp,*up,*zp);
766 ROL::Ptr<std::vector<Real> > ijvp =
767 dynamic_cast<PrimalStateVector&
>(ijv).getVector();
768 ROL::Ptr<const std::vector<Real> > vp =
769 dynamic_cast<const PrimalConstraintVector&
>(v).getVector();
770 ROL::Ptr<const std::vector<Real> > up =
771 dynamic_cast<const PrimalStateVector&
>(u).getVector();
772 ROL::Ptr<const std::vector<Real> > zp =
773 dynamic_cast<const PrimalControlVector&
>(z).getVector();
775 const std::vector<Real> param
777 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
779 fem_->apply_inverse_pde_jacobian(*ijvp,*vp,*up,*zp);
784 ROL::Ptr<std::vector<Real> > jvp =
785 dynamic_cast<DualStateVector&
>(ajv).getVector();
786 ROL::Ptr<const std::vector<Real> > vp =
787 dynamic_cast<const DualConstraintVector&
>(v).getVector();
788 ROL::Ptr<const std::vector<Real> > up =
789 dynamic_cast<const PrimalStateVector&
>(u).getVector();
790 ROL::Ptr<const std::vector<Real> > zp =
791 dynamic_cast<const PrimalControlVector&
>(z).getVector();
793 const std::vector<Real> param
795 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
797 fem_->apply_adjoint_pde_jacobian(*jvp,*vp,*up,*zp);
802 ROL::Ptr<std::vector<Real> > jvp =
803 dynamic_cast<DualControlVector&
>(jv).getVector();
804 ROL::Ptr<const std::vector<Real> > vp =
805 dynamic_cast<const DualConstraintVector&
>(v).getVector();
806 ROL::Ptr<const std::vector<Real> > up =
807 dynamic_cast<const PrimalStateVector&
>(u).getVector();
808 ROL::Ptr<const std::vector<Real> > zp =
809 dynamic_cast<const PrimalControlVector&
>(z).getVector();
811 const std::vector<Real> param
813 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
815 fem_->apply_adjoint_control_jacobian(*jvp,*vp,*up,*zp);
820 ROL::Ptr<std::vector<Real> > iajvp =
821 dynamic_cast<DualConstraintVector&
>(iajv).getVector();
822 ROL::Ptr<const std::vector<Real> > vp =
823 dynamic_cast<const DualStateVector&
>(v).getVector();
824 ROL::Ptr<const std::vector<Real> > up =
825 dynamic_cast<const PrimalStateVector&
>(u).getVector();
826 ROL::Ptr<const std::vector<Real> > zp =
827 dynamic_cast<const PrimalControlVector&
>(z).getVector();
829 const std::vector<Real> param
831 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
833 fem_->apply_inverse_adjoint_pde_jacobian(*iajvp,*vp,*up,*zp);
839 ROL::Ptr<std::vector<Real> > ahwvp =
840 dynamic_cast<DualStateVector&
>(ahwv).getVector();
841 ROL::Ptr<const std::vector<Real> > wp =
842 dynamic_cast<const DualConstraintVector&
>(w).getVector();
843 ROL::Ptr<const std::vector<Real> > vp =
844 dynamic_cast<const PrimalStateVector&
>(v).getVector();
845 ROL::Ptr<const std::vector<Real> > up =
846 dynamic_cast<const PrimalStateVector&
>(u).getVector();
847 ROL::Ptr<const std::vector<Real> > zp =
848 dynamic_cast<const PrimalControlVector&
>(z).getVector();
850 const std::vector<Real> param
852 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
854 fem_->apply_adjoint_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
864 ROL::Ptr<std::vector<Real> > ahwvp =
865 dynamic_cast<DualControlVector&
>(ahwv).getVector();
866 ROL::Ptr<const std::vector<Real> > wp =
867 dynamic_cast<const DualConstraintVector&
>(w).getVector();
868 ROL::Ptr<const std::vector<Real> > vp =
869 dynamic_cast<const PrimalStateVector&
>(v).getVector();
870 ROL::Ptr<const std::vector<Real> > up =
871 dynamic_cast<const PrimalStateVector&
>(u).getVector();
872 ROL::Ptr<const std::vector<Real> > zp =
873 dynamic_cast<const PrimalControlVector&
>(z).getVector();
875 const std::vector<Real> param
877 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
879 fem_->apply_adjoint_control_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
888 ROL::Ptr<std::vector<Real> > ahwvp =
889 dynamic_cast<DualStateVector&
>(ahwv).getVector();
890 ROL::Ptr<const std::vector<Real> > wp =
891 dynamic_cast<const DualConstraintVector&
>(w).getVector();
892 ROL::Ptr<const std::vector<Real> > vp =
893 dynamic_cast<const PrimalControlVector&
>(v).getVector();
894 ROL::Ptr<const std::vector<Real> > up =
895 dynamic_cast<const PrimalStateVector&
>(u).getVector();
896 ROL::Ptr<const std::vector<Real> > zp =
897 dynamic_cast<const PrimalControlVector&
>(z).getVector();
899 const std::vector<Real> param
901 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
903 fem_->apply_adjoint_pde_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
912 ROL::Ptr<std::vector<Real> > ahwvp =
913 dynamic_cast<DualControlVector&
>(ahwv).getVector();
914 ROL::Ptr<const std::vector<Real> > wp =
915 dynamic_cast<const DualConstraintVector&
>(w).getVector();
916 ROL::Ptr<const std::vector<Real> > vp =
917 dynamic_cast<const PrimalControlVector&
>(v).getVector();
918 ROL::Ptr<const std::vector<Real> > up =
919 dynamic_cast<const PrimalStateVector&
>(u).getVector();
920 ROL::Ptr<const std::vector<Real> > zp =
921 dynamic_cast<const PrimalControlVector&
>(z).getVector();
923 const std::vector<Real> param
925 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
927 fem_->apply_adjoint_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
946 ROL::Ptr<BurgersFEM<Real> > fem_;
947 ROL::Ptr<ROL::Vector<Real> > ud_;
948 ROL::Ptr<ROL::Vector<Real> > diff_;
953 Real alpha = 1.e-4) : alpha_(alpha), fem_(fem), ud_(ud) {
954 diff_ = ud_->clone();
960 ROL::Ptr<const std::vector<Real> > up =
961 dynamic_cast<const PrimalStateVector&
>(u).getVector();
962 ROL::Ptr<const std::vector<Real> > zp =
963 dynamic_cast<const PrimalControlVector&
>(z).getVector();
964 ROL::Ptr<const std::vector<Real> > udp =
967 std::vector<Real> diff(udp->size(),0.0);
968 for (
unsigned i = 0; i < udp->size(); i++) {
969 diff[i] = (*up)[i] - (*udp)[i];
971 return 0.5*(fem_->compute_L2_dot(diff,diff) + alpha_*fem_->compute_L2_dot(*zp,*zp));
975 ROL::Ptr<std::vector<Real> > gp =
976 dynamic_cast<DualStateVector&
>(g).getVector();
977 ROL::Ptr<const std::vector<Real> > up =
978 dynamic_cast<const PrimalStateVector&
>(u).getVector();
979 ROL::Ptr<const std::vector<Real> > udp =
982 std::vector<Real> diff(udp->size(),0.0);
983 for (
unsigned i = 0; i < udp->size(); i++) {
984 diff[i] = (*up)[i] - (*udp)[i];
986 fem_->apply_mass(*gp,diff);
990 ROL::Ptr<std::vector<Real> > gp =
991 dynamic_cast<DualControlVector&
>(g).getVector();
992 ROL::Ptr<const std::vector<Real> > zp =
993 dynamic_cast<const PrimalControlVector&
>(z).getVector();
995 fem_->apply_mass(*gp,*zp);
996 for (
unsigned i = 0; i < zp->size(); i++) {
1003 ROL::Ptr<std::vector<Real> > hvp =
1004 dynamic_cast<DualStateVector&
>(hv).getVector();
1005 ROL::Ptr<const std::vector<Real> > vp =
1006 dynamic_cast<const PrimalStateVector&
>(v).getVector();
1008 fem_->apply_mass(*hvp,*vp);
1023 ROL::Ptr<std::vector<Real> > hvp =
1024 dynamic_cast<DualControlVector&
>(hv).getVector();
1025 ROL::Ptr<const std::vector<Real> > vp =
1026 dynamic_cast<const PrimalControlVector&
>(v).getVector();
1028 fem_->apply_mass(*hvp,*vp);
1029 for (
unsigned i = 0; i < vp->size(); i++) {
1030 (*hvp)[i] *= alpha_;
1035 template<
class Real>
1039 std::vector<Real> x_lo_;
1040 std::vector<Real> x_up_;
1043 ROL::Ptr<BurgersFEM<Real> > fem_;
1044 ROL::Ptr<ROL::Vector<Real> > l_;
1045 ROL::Ptr<ROL::Vector<Real> > u_;
1052 catch (std::exception &e) {
1062 catch (std::exception &e) {
1067 void axpy(std::vector<Real> &out,
const Real a,
1068 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1069 out.resize(dim_,0.0);
1070 for (
unsigned i = 0; i < dim_; i++) {
1071 out[i] = a*x[i] + y[i];
1076 for (
int i = 0; i < dim_; i++ ) {
1077 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1084 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1085 dim_ = x_lo_.size();
1086 for (
int i = 0; i < dim_; i++ ) {
1088 min_diff_ = x_up_[i] - x_lo_[i];
1091 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1095 l_ = ROL::makePtr<L2VectorPrimal<Real>>(
1096 ROL::makePtr<std::vector<Real>>(l), fem);
1097 u_ = ROL::makePtr<L2VectorPrimal<Real>>(
1098 ROL::makePtr<std::vector<Real>>(u), fem);
1102 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1105 for (
int i = 0; i < dim_; i++ ) {
1106 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1109 if ( cnt == 0 ) { val =
false; }
1114 ROL::Ptr<std::vector<Real> > ex; cast_vector(ex,x);
1119 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1120 ROL::Ptr<std::vector<Real> > ev; cast_vector(ev,v);
1121 Real epsn = std::min(scale_*eps,min_diff_);
1122 for (
int i = 0; i < dim_; i++ ) {
1123 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1130 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1131 ROL::Ptr<std::vector<Real> > ev; cast_vector(ev,v);
1132 Real epsn = std::min(scale_*eps,min_diff_);
1133 for (
int i = 0; i < dim_; i++ ) {
1134 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1141 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1142 ROL::Ptr<std::vector<Real> > ev; cast_vector(ev,v);
1143 Real epsn = std::min(scale_*eps,min_diff_);
1144 for (
int i = 0; i < dim_; i++ ) {
1145 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1146 ((*ex)[i] >= x_up_[i]-epsn) ) {
1153 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1154 ROL::Ptr<const std::vector<Real> > eg; cast_const_vector(eg,g);
1155 ROL::Ptr<std::vector<Real> > ev; cast_vector(ev,v);
1156 Real epsn = std::min(scale_*eps,min_diff_);
1157 for (
int i = 0; i < dim_; i++ ) {
1158 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1165 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1166 ROL::Ptr<const std::vector<Real> > eg; cast_const_vector(eg,g);
1167 ROL::Ptr<std::vector<Real> > ev; cast_vector(ev,v);
1168 Real epsn = std::min(scale_*eps,min_diff_);
1169 for (
int i = 0; i < dim_; i++ ) {
1170 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1177 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1178 ROL::Ptr<const std::vector<Real> > eg; cast_const_vector(eg,g);
1179 ROL::Ptr<std::vector<Real> > ev; cast_vector(ev,v);
1180 Real epsn = std::min(scale_*eps,min_diff_);
1181 for (
int i = 0; i < dim_; i++ ) {
1182 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1183 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1198 template<
class Real>
1202 std::vector<Real> x_lo_;
1203 std::vector<Real> x_up_;
1206 ROL::Ptr<BurgersFEM<Real> > fem_;
1207 ROL::Ptr<ROL::Vector<Real> > l_;
1208 ROL::Ptr<ROL::Vector<Real> > u_;
1213 xvec = ROL::constPtrCast<std::vector<Real> >(
1216 catch (std::exception &e) {
1217 xvec = ROL::constPtrCast<std::vector<Real> >(
1227 catch (std::exception &e) {
1232 void axpy(std::vector<Real> &out,
const Real a,
1233 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1234 out.resize(dim_,0.0);
1235 for (
unsigned i = 0; i < dim_; i++) {
1236 out[i] = a*x[i] + y[i];
1241 for (
int i = 0; i < dim_; i++ ) {
1242 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1249 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1250 dim_ = x_lo_.size();
1251 for (
int i = 0; i < dim_; i++ ) {
1253 min_diff_ = x_up_[i] - x_lo_[i];
1256 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1260 l_ = ROL::makePtr<H1VectorPrimal<Real>>(
1261 ROL::makePtr<std::vector<Real>>(l), fem);
1262 u_ = ROL::makePtr<H1VectorPrimal<Real>>(
1263 ROL::makePtr<std::vector<Real>>(u), fem);
1267 ROL::Ptr<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 ROL::Ptr<std::vector<Real> > ex; cast_vector(ex,x);
1284 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1285 ROL::Ptr<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 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1296 ROL::Ptr<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 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1307 ROL::Ptr<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 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1319 ROL::Ptr<const std::vector<Real> > eg; cast_const_vector(eg,g);
1320 ROL::Ptr<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 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1331 ROL::Ptr<const std::vector<Real> > eg; cast_const_vector(eg,g);
1332 ROL::Ptr<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 ROL::Ptr<const std::vector<Real> > ex; cast_const_vector(ex,x);
1343 ROL::Ptr<const std::vector<Real> > eg; cast_const_vector(eg,g);
1344 ROL::Ptr<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) ) {
1363 template<
class Real,
class Ordinal>
1371 catch (std::exception &e) {
1378 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1380 ROL::Ptr<std::vector<Real> > input_ptr;
1381 cast_vector(input_ptr,input);
1382 int dim_i = input_ptr->size();
1383 ROL::Ptr<std::vector<Real> > output_ptr;
1384 cast_vector(output_ptr,output);
1385 int dim_o = output_ptr->size();
1386 if ( dim_i != dim_o ) {
1387 std::cout <<
"L2VectorBatchManager: DIMENSION MISMATCH ON RANK " 1388 << ROL::TeuchosBatchManager<Real,Ordinal>::batchID() <<
"\n";
1391 ROL::TeuchosBatchManager<Real,Ordinal>::sumAll(&(*input_ptr)[0],&(*output_ptr)[0],dim_i);
1396 template<
class Real,
class Ordinal>
1404 catch (std::exception &e) {
1411 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1413 ROL::Ptr<std::vector<Real> > input_ptr;
1414 cast_vector(input_ptr,input);
1415 int dim_i = input_ptr->size();
1416 ROL::Ptr<std::vector<Real> > output_ptr;
1417 cast_vector(output_ptr,output);
1418 int dim_o = output_ptr->size();
1419 if ( dim_i != dim_o ) {
1420 std::cout <<
"H1VectorBatchManager: DIMENSION MISMATCH ON RANK " 1421 << ROL::TeuchosBatchManager<Real,Ordinal>::batchID() <<
"\n";
1424 ROL::TeuchosBatchManager<Real,Ordinal>::sumAll(&(*input_ptr)[0],&(*output_ptr)[0],dim_i);
1429 template<
class Real>
1430 Real
random(
const ROL::Ptr<
const Teuchos::Comm<int> > &comm) {
1432 if ( Teuchos::rank<int>(*comm)==0 ) {
1433 val = (Real)rand()/(Real)RAND_MAX;
1435 Teuchos::broadcast<int,Real>(*comm,0,1,&val);
H1VectorPrimal< Real > DualConstraintVector
BurgersFEM(int nx=128, Real nl=1.0, Real cH1=1.0, Real cL2=1.0)
L2VectorDual(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BurgersFEM< Real > > &fem)
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 apply_pde_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
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 axpy(std::vector< Real > &out, const Real a, const std::vector< Real > &x, const std::vector< Real > &y) const
bool isFeasible(const ROL::Vector< Real > &x)
Check if the vector, v, is feasible.
Real dot(const ROL::Vector< Real > &x) const
Compute where .
void compute_residual(std::vector< Real > &r, const std::vector< Real > &u, const std::vector< Real > &z) const
const ROL::Ptr< const ROL::Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
ROL::Ptr< const std::vector< Real > > getVector() const
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
ROL::Ptr< L2VectorPrimal< Real > > prim_vec_
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)
ROL::Ptr< H1VectorPrimal< Real > > prim_vec_
ROL::Ptr< const std::vector< Real > > getVector() const
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 optimization-space derivative of the adjoint of the constraint simulation-space Jacobian at...
void axpy(std::vector< Real > &out, const Real a, const std::vector< Real > &x, const std::vector< Real > &y) const
void apply_inverse_H1(std::vector< Real > &Mu, const std::vector< Real > &u) const
H1VectorPrimal(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BurgersFEM< Real > > &fem)
ROL::Ptr< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
void cast_vector(ROL::Ptr< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
void pruneActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &g, const ROL::Vector< Real > &x, Real eps)
Contains definitions of custom data types in ROL.
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 simulation-space derivative of the adjoint of the constraint simulation-space Jacobian at ...
L2VectorBatchManager(const ROL::Ptr< const Teuchos::Comm< Ordinal > > &comm)
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.
Real random(const ROL::Ptr< const Teuchos::Comm< int > > &comm)
L2BoundConstraint(std::vector< Real > &l, std::vector< Real > &u, const ROL::Ptr< BurgersFEM< Real > > &fem, Real scale=1.0)
Ptr< const std::vector< Element > > getVector() 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 ...
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.
H1VectorDual(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BurgersFEM< Real > > &fem)
void compute_pde_jacobian(std::vector< Real > &dl, std::vector< Real > &d, std::vector< Real > &du, const std::vector< Real > &u) const
void project(ROL::Vector< Real > &x)
Project optimization variables onto the bounds.
Real compute_H1_dot(const std::vector< Real > &x, const std::vector< Real > &y) const
void apply_control_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
virtual void zero()
Set to zero vector.
void scale(std::vector< Real > &u, const Real alpha=0.0) const
Defines the linear algebra or vector space interface.
H1VectorDual< Real > DualStateVector
H1VectorDual< Real > PrimalConstraintVector
ROL::Ptr< const std::vector< Real > > getVector() const
L2VectorPrimal(const ROL::Ptr< std::vector< Real > > &vec, const ROL::Ptr< BurgersFEM< Real > > &fem)
H1VectorPrimal< Real > PrimalStateVector
void hessVec_22(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
ROL::Ptr< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Constraint_BurgersControl(ROL::Ptr< BurgersFEM< Real > > &fem, bool useHessian=true)
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)
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 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.
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
bool isFeasible(const ROL::Vector< Real > &x)
Check if the vector, v, is feasible.
void test_inverse_mass(std::ostream &outStream=std::cout)
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
void apply_mass(std::vector< Real > &Mu, const std::vector< Real > &u) const
const ROL::Ptr< const ROL::Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
void apply_H1(std::vector< Real > &Mu, const std::vector< Real > &u) const
void pruneActive(ROL::Vector< Real > &v, const ROL::Vector< Real > &x, Real eps)
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 simulation-space derivative of the adjoint of the constraint optimization-space Jacobian at...
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 -binding set.
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Real compute_L2_dot(const std::vector< Real > &x, const std::vector< Real > &y) const
void cast_vector(ROL::Ptr< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
Real mesh_spacing(void) const
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
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
ROL::Ptr< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Real dot(const ROL::Vector< Real > &x) const
Compute where .
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
H1VectorDual< Real > DualStateVector
const ROL::Ptr< const ROL::Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
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 .
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.
Real dot(const ROL::Vector< Real > &x) const
Compute where .
void hessVec_21(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Real compute_H1_norm(const std::vector< Real > &r) const
L2VectorPrimal< Real > PrimalControlVector
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 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 -binding set.
void cast_const_vector(ROL::Ptr< const std::vector< Real > > &xvec, const ROL::Vector< Real > &x) const
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 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 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 .
Provides the interface to apply upper and lower bound constraints.
void projection(std::vector< Real > &x)
void axpy(std::vector< Real > &out, const Real a, const std::vector< Real > &x, const std::vector< Real > &y) const
H1VectorBatchManager(const ROL::Ptr< const Teuchos::Comm< Ordinal > > &comm)
const ROL::Vector< Real > & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
void apply_inverse_mass(std::vector< Real > &Mu, const std::vector< Real > &u) const
const std::vector< Real > getParameter(void) const
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 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 .
void test_inverse_H1(std::ostream &outStream=std::cout)
int dimension() const
Return dimension of the vector space.
ROL::Ptr< ROL::Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
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
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)
H1VectorPrimal< Real > PrimalStateVector
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
L2VectorDual< Real > DualControlVector
Real compute_L2_norm(const std::vector< Real > &r) const
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 optimization-space derivative of the adjoint of the constraint optimization-space Jacobian ...
void sumAll(ROL::Vector< Real > &input, ROL::Vector< Real > &output)
void project(ROL::Vector< Real > &x)
Project optimization variables onto the bounds.
const ROL::Ptr< const ROL::Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
void update(std::vector< Real > &u, const std::vector< Real > &s, const Real alpha=1.0) 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)
void cast_vector(ROL::Ptr< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
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...
Defines the constraint operator interface for simulation-based optimization.
L2VectorDual< Real > DualControlVector
bool isPrimalInitialized_
void value(ROL::Vector< Real > &c, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Evaluate the constraint operator at .
void sumAll(ROL::Vector< Real > &input, ROL::Vector< Real > &output)
bool isPrimalInitialized_
Real dot(const ROL::Vector< Real > &x) const
Compute where .
Objective_BurgersControl(const ROL::Ptr< BurgersFEM< Real > > &fem, const ROL::Ptr< ROL::Vector< Real > > &ud, Real alpha=1.e-4)
void cast_vector(ROL::Ptr< std::vector< Real > > &xvec, ROL::Vector< Real > &x) const
ROL::Ptr< const std::vector< Real > > getVector() const
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_const_vector(ROL::Ptr< const std::vector< Real > > &xvec, const ROL::Vector< Real > &x) const
H1BoundConstraint(std::vector< Real > &l, std::vector< Real > &u, const ROL::Ptr< BurgersFEM< Real > > &fem, Real scale=1.0)