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);
159 Real
compute_L2_dot(
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
161 Real c = (((int)x.size()==
nx_) ? 4.0 : 2.0);
162 for (
unsigned i=0; i<x.size(); i++) {
164 ip += dx_/6.0*(c*x[i] + x[i+1])*y[i];
166 else if ( i == x.size()-1 ) {
167 ip += dx_/6.0*(x[i-1] + c*x[i])*y[i];
170 ip += dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
182 void apply_mass(std::vector<Real> &Mu,
const std::vector<Real> &u )
const {
183 Mu.resize(u.size(),0.0);
184 Real c = (((int)u.size()==
nx_) ? 4.0 : 2.0);
185 for (
unsigned i=0; i<u.size(); i++) {
187 Mu[i] = dx_/6.0*(c*u[i] + u[i+1]);
189 else if ( i == u.size()-1 ) {
190 Mu[i] = dx_/6.0*(u[i-1] + c*u[i]);
193 Mu[i] = dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1]);
200 unsigned nx = u.size();
202 std::vector<Real> dl(nx-1,dx_/6.0);
203 std::vector<Real> d(nx,2.0*dx_/3.0);
204 std::vector<Real> du(nx-1,dx_/6.0);
205 if ( (
int)nx != nx_ ) {
214 std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
215 for (
int i = 0; i <
nx_; i++) {
216 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
220 axpy(diff,-1.0,iMMu,u);
223 outStream <<
"Test Inverse State Mass Matrix\n";
224 outStream <<
" ||u - inv(M)Mu|| = " << error <<
"\n";
225 outStream <<
" ||u|| = " << normu <<
"\n";
226 outStream <<
" Relative Error = " << error/normu <<
"\n";
229 u.resize(nx_+2,0.0); Mu.resize(nx_+2,0.0); iMMu.resize(nx_+2,0.0); diff.resize(nx_+2,0.0);
230 for (
int i = 0; i < nx_+2; i++) {
231 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
235 axpy(diff,-1.0,iMMu,u);
238 outStream <<
"Test Inverse Control Mass Matrix\n";
239 outStream <<
" ||z - inv(M)Mz|| = " << error <<
"\n";
240 outStream <<
" ||z|| = " << normu <<
"\n";
241 outStream <<
" Relative Error = " << error/normu <<
"\n";
249 Real
compute_H1_dot(
const std::vector<Real> &x,
const std::vector<Real> &y)
const {
251 for (
int i=0; i<
nx_; i++) {
253 ip += cL2_*dx_/6.0*(4.0*x[i] + x[i+1])*y[i];
254 ip += cH1_*(2.0*x[i] - x[i+1])/dx_*y[i];
256 else if ( i == nx_-1 ) {
257 ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i])*y[i];
258 ip += cH1_*(2.0*x[i] - x[i-1])/dx_*y[i];
261 ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
262 ip += cH1_*(2.0*x[i] - x[i-1] - x[i+1])/dx_*y[i];
274 void apply_H1(std::vector<Real> &Mu,
const std::vector<Real> &u )
const {
276 for (
int i=0; i<
nx_; i++) {
278 Mu[i] = cL2_*dx_/6.0*(4.0*u[i] + u[i+1])
279 + cH1_*(2.0*u[i] - u[i+1])/
dx_;
281 else if ( i == nx_-1 ) {
282 Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i])
283 + cH1_*(2.0*u[i] - u[i-1])/
dx_;
286 Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1])
287 + cH1_*(2.0*u[i] - u[i-1] - u[i+1])/
dx_;
295 std::vector<Real> dl(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
296 std::vector<Real> d(nx_,2.0*(cL2_*dx_/3.0 + cH1_/dx_));
297 std::vector<Real> du(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
302 std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
303 for (
int i = 0; i <
nx_; i++) {
304 u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
308 axpy(diff,-1.0,iMMu,u);
311 outStream <<
"Test Inverse State H1 Matrix\n";
312 outStream <<
" ||u - inv(M)Mu|| = " << error <<
"\n";
313 outStream <<
" ||u|| = " << normu <<
"\n";
314 outStream <<
" Relative Error = " << error/normu <<
"\n";
323 const std::vector<Real> &z)
const {
326 for (
int i=0; i<
nx_; i++) {
329 r[i] = nu_/dx_*(2.0*u[i]-u[i+1]);
332 r[i] = nu_/dx_*(2.0*u[i]-u[i-1]);
335 r[i] = nu_/dx_*(2.0*u[i]-u[i-1]-u[i+1]);
339 r[i] += nl_*u[i+1]*(u[i]+u[i+1])/6.0;
342 r[i] -= nl_*u[i-1]*(u[i-1]+u[i])/6.0;
345 r[i] -= dx_/6.0*(z[i]+4.0*z[i+1]+z[i+2]);
350 r[0] -= nl_*(u0_*u[ 0]/6.0 + u0_*u0_/6.0) + nu_*u0_/
dx_;
351 r[nx_-1] += nl_*(u1_*u[nx_-1]/6.0 + u1_*u1_/6.0) - nu_*u1_/
dx_;
355 void solve(std::vector<Real> &u,
const std::vector<Real> &z)
const {
358 std::vector<Real> r(u.size(),0.0);
365 std::vector<Real> d(nx_,0.0);
366 std::vector<Real> dl(nx_-1,0.0);
367 std::vector<Real> du(nx_-1,0.0);
369 Real alpha = 1.0, tmp = 0.0;
370 std::vector<Real> s(nx_,0.0);
371 std::vector<Real> utmp(nx_,0.0);
372 for (
int i=0; i<maxit; i++) {
381 utmp.assign(u.begin(),u.end());
385 while ( rnorm > (1.0-1.e-4*alpha)*tmp && alpha > std::sqrt(
ROL::ROL_EPSILON) ) {
387 utmp.assign(u.begin(),u.end());
393 u.assign(utmp.begin(),utmp.end());
394 if ( rnorm < rtol ) {
405 std::vector<Real> &d,
406 std::vector<Real> &du,
407 const std::vector<Real> &u)
const {
410 d.resize(nx_,nu_*2.0/dx_);
412 dl.resize(nx_-1,-nu_/dx_);
414 du.resize(nx_-1,-nu_/dx_);
416 for (
int i=0; i<
nx_; i++) {
418 dl[i] += nl_*(-2.0*u[i]-u[i+1])/6.0;
419 d[i] += nl_*u[i+1]/6.0;
422 d[i] -= nl_*u[i-1]/6.0;
423 du[i-1] += nl_*(u[i-1]+2.0*u[i])/6.0;
427 d[ 0] -= nl_*u0_/6.0;
428 d[nx_-1] += nl_*u1_/6.0;
433 const std::vector<Real> &v,
434 const std::vector<Real> &u,
435 const std::vector<Real> &z)
const {
437 for (
int i = 0; i <
nx_; i++) {
438 jv[i] = nu_/dx_*2.0*v[i];
440 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]);
443 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]);
446 jv[ 0] -= nl_*u0_/6.0*v[0];
447 jv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
452 const std::vector<Real> &v,
453 const std::vector<Real> &u,
454 const std::vector<Real> &z)
const {
456 std::vector<Real> d(nx_,0.0);
457 std::vector<Real> dl(nx_-1,0.0);
458 std::vector<Real> du(nx_-1,0.0);
466 const std::vector<Real> &v,
467 const std::vector<Real> &u,
468 const std::vector<Real> &z)
const {
470 for (
int i = 0; i <
nx_; i++) {
471 ajv[i] = nu_/dx_*2.0*v[i];
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[i] += -nu_/dx_*v[i+1]+nl_*(u[i+1]/6.0*v[i]
478 -(u[i+1]+2.0*u[i])/6.0*v[i+1]);
481 ajv[ 0] -= nl_*u0_/6.0*v[0];
482 ajv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
487 const std::vector<Real> &v,
488 const std::vector<Real> &u,
489 const std::vector<Real> &z)
const {
491 std::vector<Real> d(nx_,0.0);
492 std::vector<Real> du(nx_-1,0.0);
493 std::vector<Real> dl(nx_-1,0.0);
504 const std::vector<Real> &v,
505 const std::vector<Real> &u,
506 const std::vector<Real> &z)
const {
507 for (
int i=0; i<
nx_; i++) {
509 jv[i] = -dx_/6.0*(v[i]+4.0*v[i+1]+v[i+2]);
515 const std::vector<Real> &v,
516 const std::vector<Real> &u,
517 const std::vector<Real> &z)
const {
518 for (
int i=0; i<nx_+2; i++) {
520 jv[i] = -dx_/6.0*v[i];
523 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i]);
525 else if ( i == nx_ ) {
526 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i-2]);
528 else if ( i == nx_+1 ) {
529 jv[i] = -dx_/6.0*v[i-2];
532 jv[i] = -dx_/6.0*(v[i-2]+4.0*v[i-1]+v[i]);
541 const std::vector<Real> &w,
542 const std::vector<Real> &v,
543 const std::vector<Real> &u,
544 const std::vector<Real> &z)
const {
545 for (
int i=0; i<
nx_; i++) {
549 ahwv[i] += (w[i]*v[i+1] - w[i+1]*(2.0*v[i]+v[i+1]))/6.0;
552 ahwv[i] += (w[i-1]*(v[i-1]+2.0*v[i]) - w[i]*v[i-1])/6.0;
558 const std::vector<Real> &w,
559 const std::vector<Real> &v,
560 const std::vector<Real> &u,
561 const std::vector<Real> &z) {
562 ahwv.assign(u.size(),0.0);
565 const std::vector<Real> &w,
566 const std::vector<Real> &v,
567 const std::vector<Real> &u,
568 const std::vector<Real> &z) {
569 ahwv.assign(z.size(),0.0);
572 const std::vector<Real> &w,
573 const std::vector<Real> &v,
574 const std::vector<Real> &u,
575 const std::vector<Real> &z) {
576 ahwv.assign(z.size(),0.0);
583 Teuchos::RCP<std::vector<Real> > vec_;
584 Teuchos::RCP<BurgersFEM<Real> > fem_;
586 mutable Teuchos::RCP<L2VectorDual<Real> > dual_vec_;
591 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
595 const std::vector<Real>& xval = *ex.
getVector();
596 std::copy(xval.begin(),xval.end(),vec_->begin());
601 const std::vector<Real>& xval = *ex.
getVector();
602 unsigned dimension = vec_->size();
603 for (
unsigned i=0; i<dimension; i++) {
604 (*vec_)[i] += xval[i];
609 unsigned dimension = vec_->size();
610 for (
unsigned i=0; i<dimension; i++) {
617 const std::vector<Real>& xval = *ex.
getVector();
618 return fem_->compute_L2_dot(xval,*vec_);
623 val = std::sqrt( dot(*
this) );
627 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
628 return Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
631 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
639 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
640 Teuchos::RCP<L2VectorPrimal> e
641 = Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
642 (*e->getVector())[i] = 1.0;
652 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
654 fem_->apply_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
663 Teuchos::RCP<std::vector<Real> > vec_;
664 Teuchos::RCP<BurgersFEM<Real> > fem_;
666 mutable Teuchos::RCP<L2VectorPrimal<Real> > dual_vec_;
671 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
675 const std::vector<Real>& xval = *ex.
getVector();
676 std::copy(xval.begin(),xval.end(),vec_->begin());
681 const std::vector<Real>& xval = *ex.
getVector();
682 unsigned dimension = vec_->size();
683 for (
unsigned i=0; i<dimension; i++) {
684 (*vec_)[i] += xval[i];
689 unsigned dimension = vec_->size();
690 for (
unsigned i=0; i<dimension; i++) {
697 const std::vector<Real>& xval = *ex.
getVector();
698 unsigned dimension = vec_->size();
699 std::vector<Real> Mx(dimension,0.0);
700 fem_->apply_inverse_mass(Mx,xval);
702 for (
unsigned i = 0; i < dimension; i++) {
703 val += Mx[i]*(*vec_)[i];
710 val = std::sqrt( dot(*
this) );
714 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
715 return Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
718 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
726 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
727 Teuchos::RCP<L2VectorDual> e
728 = Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
729 (*e->getVector())[i] = 1.0;
739 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
741 fem_->apply_inverse_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
750 Teuchos::RCP<std::vector<Real> > vec_;
751 Teuchos::RCP<BurgersFEM<Real> > fem_;
753 mutable Teuchos::RCP<H1VectorDual<Real> > dual_vec_;
758 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
762 const std::vector<Real>& xval = *ex.
getVector();
763 std::copy(xval.begin(),xval.end(),vec_->begin());
768 const std::vector<Real>& xval = *ex.
getVector();
769 unsigned dimension = vec_->size();
770 for (
unsigned i=0; i<dimension; i++) {
771 (*vec_)[i] += xval[i];
776 unsigned dimension = vec_->size();
777 for (
unsigned i=0; i<dimension; i++) {
784 const std::vector<Real>& xval = *ex.
getVector();
785 return fem_->compute_H1_dot(xval,*vec_);
790 val = std::sqrt( dot(*
this) );
794 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
795 return Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
798 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
806 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
807 Teuchos::RCP<H1VectorPrimal> e
808 = Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
809 (*e->getVector())[i] = 1.0;
819 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
821 fem_->apply_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
830 Teuchos::RCP<std::vector<Real> > vec_;
831 Teuchos::RCP<BurgersFEM<Real> > fem_;
833 mutable Teuchos::RCP<H1VectorPrimal<Real> > dual_vec_;
838 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
842 const std::vector<Real>& xval = *ex.
getVector();
843 std::copy(xval.begin(),xval.end(),vec_->begin());
848 const std::vector<Real>& xval = *ex.
getVector();
849 unsigned dimension = vec_->size();
850 for (
unsigned i=0; i<dimension; i++) {
851 (*vec_)[i] += xval[i];
856 unsigned dimension = vec_->size();
857 for (
unsigned i=0; i<dimension; i++) {
864 const std::vector<Real>& xval = *ex.
getVector();
865 unsigned dimension = vec_->size();
866 std::vector<Real> Mx(dimension,0.0);
867 fem_->apply_inverse_H1(Mx,xval);
869 for (
unsigned i = 0; i < dimension; i++) {
870 val += Mx[i]*(*vec_)[i];
877 val = std::sqrt( dot(*
this) );
881 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
882 return Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
885 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
893 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
894 Teuchos::RCP<H1VectorDual> e
895 = Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
896 (*e->getVector())[i] = 1.0;
906 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
908 fem_->apply_inverse_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
927 typedef typename std::vector<Real>::size_type
uint;
929 Teuchos::RCP<BurgersFEM<Real> > fem_;
934 : fem_(fem), useHessian_(useHessian) {}
938 Teuchos::RCP<std::vector<Real> > cp =
939 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(c)).getVector());
940 Teuchos::RCP<const std::vector<Real> > up =
941 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
942 Teuchos::RCP<const std::vector<Real> > zp =
943 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
945 const std::vector<Real> param
947 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
949 fem_->compute_residual(*cp,*up,*zp);
953 Teuchos::RCP<std::vector<Real> > up =
954 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalStateVector>(u)).getVector());
955 up->assign(up->size(),z.
norm()/up->size());
956 Teuchos::RCP<const std::vector<Real> > zp =
957 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
959 const std::vector<Real> param
961 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
963 fem_->solve(*up,*zp);
968 Teuchos::RCP<std::vector<Real> > jvp =
969 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(jv)).getVector());
970 Teuchos::RCP<const std::vector<Real> > vp =
971 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
972 Teuchos::RCP<const std::vector<Real> > up =
973 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
974 Teuchos::RCP<const std::vector<Real> > zp =
975 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
977 const std::vector<Real> param
979 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
981 fem_->apply_pde_jacobian(*jvp,*vp,*up,*zp);
986 Teuchos::RCP<std::vector<Real> > jvp =
987 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(jv)).getVector());
988 Teuchos::RCP<const std::vector<Real> > vp =
989 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
990 Teuchos::RCP<const std::vector<Real> > up =
991 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
992 Teuchos::RCP<const std::vector<Real> > zp =
993 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
995 const std::vector<Real> param
997 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
999 fem_->apply_control_jacobian(*jvp,*vp,*up,*zp);
1004 Teuchos::RCP<std::vector<Real> > ijvp =
1005 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalStateVector>(ijv)).getVector());
1006 Teuchos::RCP<const std::vector<Real> > vp =
1007 (Teuchos::dyn_cast<PrimalConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1008 Teuchos::RCP<const std::vector<Real> > up =
1009 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1010 Teuchos::RCP<const std::vector<Real> > zp =
1011 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1013 const std::vector<Real> param
1015 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1017 fem_->apply_inverse_pde_jacobian(*ijvp,*vp,*up,*zp);
1022 Teuchos::RCP<std::vector<Real> > jvp =
1023 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ajv)).getVector());
1024 Teuchos::RCP<const std::vector<Real> > vp =
1025 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1026 Teuchos::RCP<const std::vector<Real> > up =
1027 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1028 Teuchos::RCP<const std::vector<Real> > zp =
1029 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1031 const std::vector<Real> param
1033 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1035 fem_->apply_adjoint_pde_jacobian(*jvp,*vp,*up,*zp);
1040 Teuchos::RCP<std::vector<Real> > jvp =
1041 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(jv)).getVector());
1042 Teuchos::RCP<const std::vector<Real> > vp =
1043 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1044 Teuchos::RCP<const std::vector<Real> > up =
1045 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1046 Teuchos::RCP<const std::vector<Real> > zp =
1047 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1049 const std::vector<Real> param
1051 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1053 fem_->apply_adjoint_control_jacobian(*jvp,*vp,*up,*zp);
1058 Teuchos::RCP<std::vector<Real> > iajvp =
1059 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualConstraintVector>(iajv)).getVector());
1060 Teuchos::RCP<const std::vector<Real> > vp =
1061 (Teuchos::dyn_cast<DualStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1062 Teuchos::RCP<const std::vector<Real> > up =
1063 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1064 Teuchos::RCP<const std::vector<Real> > zp =
1065 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1067 const std::vector<Real> param
1069 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1071 fem_->apply_inverse_adjoint_pde_jacobian(*iajvp,*vp,*up,*zp);
1076 if ( useHessian_ ) {
1077 Teuchos::RCP<std::vector<Real> > ahwvp =
1078 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1079 Teuchos::RCP<const std::vector<Real> > wp =
1080 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1081 Teuchos::RCP<const std::vector<Real> > vp =
1082 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1083 Teuchos::RCP<const std::vector<Real> > up =
1084 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1085 Teuchos::RCP<const std::vector<Real> > zp =
1086 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1088 const std::vector<Real> param
1090 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1092 fem_->apply_adjoint_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1101 if ( useHessian_ ) {
1102 Teuchos::RCP<std::vector<Real> > ahwvp =
1103 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1104 Teuchos::RCP<const std::vector<Real> > wp =
1105 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1106 Teuchos::RCP<const std::vector<Real> > vp =
1107 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1108 Teuchos::RCP<const std::vector<Real> > up =
1109 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1110 Teuchos::RCP<const std::vector<Real> > zp =
1111 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1113 const std::vector<Real> param
1115 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1117 fem_->apply_adjoint_control_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1125 if ( useHessian_ ) {
1126 Teuchos::RCP<std::vector<Real> > ahwvp =
1127 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1128 Teuchos::RCP<const std::vector<Real> > wp =
1129 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1130 Teuchos::RCP<const std::vector<Real> > vp =
1131 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1132 Teuchos::RCP<const std::vector<Real> > up =
1133 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1134 Teuchos::RCP<const std::vector<Real> > zp =
1135 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1137 const std::vector<Real> param
1139 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1141 fem_->apply_adjoint_pde_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1149 if ( useHessian_ ) {
1150 Teuchos::RCP<std::vector<Real> > ahwvp =
1151 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1152 Teuchos::RCP<const std::vector<Real> > wp =
1153 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1154 Teuchos::RCP<const std::vector<Real> > vp =
1155 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1156 Teuchos::RCP<const std::vector<Real> > up =
1157 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1158 Teuchos::RCP<const std::vector<Real> > zp =
1159 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1161 const std::vector<Real> param
1163 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1165 fem_->apply_adjoint_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1173 template<
class Real>
1183 Teuchos::RCP<BurgersFEM<Real> > fem_;
1190 Real x = 0.0) : fem_(fem), x_(x) {
1191 for (
int i = 1; i < fem_->num_dof()+1; i++) {
1192 if ( (Real)i*(fem_->mesh_spacing()) >= x_ ) {
1193 indices_.push_back(i-1);
1199 Teuchos::RCP<const std::vector<Real> > up =
1200 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1209 Real val = 0.5*((((Real)indices_[0]+1.)*(fem_->mesh_spacing())-x_)
1210 *(x_+(2.-((Real)indices_[0]+1.))*(fem_->mesh_spacing()))/(fem_->mesh_spacing())
1211 +(fem_->mesh_spacing())) * (*up)[indices_[0]];
1212 for (uint i = 1; i < indices_.size(); i++) {
1213 val += (fem_->mesh_spacing())*(*up)[indices_[i]];
1219 Teuchos::RCP<std::vector<Real> > gp =
1220 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(g)).getVector());
1221 Teuchos::RCP<const std::vector<Real> > up =
1222 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1233 (*gp)[indices_[0]] = -0.5*((((Real)indices_[0]+1.)*(fem_->mesh_spacing())-x_)
1234 *(x_+(2.-((Real)indices_[0]+1.))*(fem_->mesh_spacing()))/(fem_->mesh_spacing())
1235 +(fem_->mesh_spacing()));
1238 for (uint i = 1; i < indices_.size(); i++) {
1239 (*gp)[indices_[i]] = -(fem_->mesh_spacing());
1281 template<
class Real>
1285 std::vector<Real> x_lo_;
1286 std::vector<Real> x_up_;
1289 Teuchos::RCP<BurgersFEM<Real> > fem_;
1294 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1297 catch (std::exception &e) {
1298 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1309 catch (std::exception &e) {
1315 void axpy(std::vector<Real> &out,
const Real a,
1316 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1317 out.resize(dim_,0.0);
1318 for (
unsigned i = 0; i < dim_; i++) {
1319 out[i] = a*x[i] + y[i];
1324 for (
int i = 0; i < dim_; i++ ) {
1325 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1332 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1333 dim_ = x_lo_.size();
1334 for (
int i = 0; i < dim_; i++ ) {
1336 min_diff_ = x_up_[i] - x_lo_[i];
1339 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1346 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1349 for (
int i = 0; i < dim_; i++ ) {
1350 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1353 if ( cnt == 0 ) { val =
false; }
1358 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1363 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1364 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1365 Real epsn = std::min(scale_*eps,min_diff_);
1366 for (
int i = 0; i < dim_; i++ ) {
1367 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1374 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1375 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1376 Real epsn = std::min(scale_*eps,min_diff_);
1377 for (
int i = 0; i < dim_; i++ ) {
1378 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1385 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1386 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1387 Real epsn = std::min(scale_*eps,min_diff_);
1388 for (
int i = 0; i < dim_; i++ ) {
1389 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1390 ((*ex)[i] >= x_up_[i]-epsn) ) {
1397 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1398 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1399 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1400 Real epsn = std::min(scale_*eps,min_diff_);
1401 for (
int i = 0; i < dim_; i++ ) {
1402 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1409 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1410 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1411 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1412 Real epsn = std::min(scale_*eps,min_diff_);
1413 for (
int i = 0; i < dim_; i++ ) {
1414 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1421 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1422 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1423 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1424 Real epsn = std::min(scale_*eps,min_diff_);
1425 for (
int i = 0; i < dim_; i++ ) {
1426 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1427 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1434 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1435 us->assign(x_up_.begin(),x_up_.end());
1441 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1442 ls->assign(x_lo_.begin(),x_lo_.end());
1448 template<
class Real>
1452 std::vector<Real> x_lo_;
1453 std::vector<Real> x_up_;
1456 Teuchos::RCP<BurgersFEM<Real> > fem_;
1461 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1464 catch (std::exception &e) {
1465 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1476 catch (std::exception &e) {
1482 void axpy(std::vector<Real> &out,
const Real a,
1483 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1484 out.resize(dim_,0.0);
1485 for (
unsigned i = 0; i < dim_; i++) {
1486 out[i] = a*x[i] + y[i];
1491 for (
int i = 0; i < dim_; i++ ) {
1492 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1499 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1500 dim_ = x_lo_.size();
1501 for (
int i = 0; i < dim_; i++ ) {
1503 min_diff_ = x_up_[i] - x_lo_[i];
1506 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1513 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1516 for (
int i = 0; i < dim_; i++ ) {
1517 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1520 if ( cnt == 0 ) { val =
false; }
1525 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1530 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1531 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1532 Real epsn = std::min(scale_*eps,min_diff_);
1533 for (
int i = 0; i < dim_; i++ ) {
1534 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1541 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1542 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1543 Real epsn = std::min(scale_*eps,min_diff_);
1544 for (
int i = 0; i < dim_; i++ ) {
1545 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1552 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1553 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1554 Real epsn = std::min(scale_*eps,min_diff_);
1555 for (
int i = 0; i < dim_; i++ ) {
1556 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1557 ((*ex)[i] >= x_up_[i]-epsn) ) {
1564 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1565 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1566 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1567 Real epsn = std::min(scale_*eps,min_diff_);
1568 for (
int i = 0; i < dim_; i++ ) {
1569 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1576 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1577 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1578 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1579 Real epsn = std::min(scale_*eps,min_diff_);
1580 for (
int i = 0; i < dim_; i++ ) {
1581 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1588 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1589 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1590 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1591 Real epsn = std::min(scale_*eps,min_diff_);
1592 for (
int i = 0; i < dim_; i++ ) {
1593 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1594 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1601 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1602 us->assign(x_up_.begin(),x_up_.end());
1608 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1609 ls->assign(x_lo_.begin(),x_lo_.end());
1615 template<
class Real,
class Ordinal>
1621 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1624 catch (std::exception &e) {
1625 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1632 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1634 Teuchos::RCP<std::vector<Real> > input_ptr;
1635 cast_vector(input_ptr,input);
1636 int dim_i = input_ptr->size();
1637 Teuchos::RCP<std::vector<Real> > output_ptr;
1638 cast_vector(output_ptr,output);
1639 int dim_o = output_ptr->size();
1640 if ( dim_i != dim_o ) {
1641 std::cout <<
"L2VectorBatchManager: DIMENSION MISMATCH ON RANK " 1650 template<
class Real,
class Ordinal>
1656 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1659 catch (std::exception &e) {
1660 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1667 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1669 Teuchos::RCP<std::vector<Real> > input_ptr;
1670 cast_vector(input_ptr,input);
1671 int dim_i = input_ptr->size();
1672 Teuchos::RCP<std::vector<Real> > output_ptr;
1673 cast_vector(output_ptr,output);
1674 int dim_o = output_ptr->size();
1675 if ( dim_i != dim_o ) {
1676 std::cout <<
"H1VectorBatchManager: DIMENSION MISMATCH ON RANK " 1685 template<
class Real>
1686 Real
random(
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) {
1688 if ( Teuchos::rank<int>(*comm)==0 ) {
1689 val = (Real)rand()/(Real)RAND_MAX;
1691 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.
Objective_BurgersControl(const Teuchos::RCP< BurgersFEM< Real > > &fem, Real x=0.0)
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.
Real get_viscosity(void) const
void plus(const ROL::Vector< Real > &x)
Compute , where .
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.
std::vector< Real >::size_type uint
Teuchos::RCP< std::vector< Real > > getVector()
Real random(const Teuchos::RCP< const Teuchos::Comm< int > > &comm)
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.
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.
std::vector< int > indices_
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.