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_;
359 std::vector<Real> &d,
360 std::vector<Real> &du,
361 const std::vector<Real> &u)
const {
364 d.resize(nx_,nu_*2.0/dx_);
366 dl.resize(nx_-1,-nu_/dx_);
368 du.resize(nx_-1,-nu_/dx_);
370 for (
int i=0; i<
nx_; i++) {
372 dl[i] += nl_*(-2.0*u[i]-u[i+1])/6.0;
373 d[i] += nl_*u[i+1]/6.0;
376 d[i] -= nl_*u[i-1]/6.0;
377 du[i-1] += nl_*(u[i-1]+2.0*u[i])/6.0;
381 d[ 0] -= nl_*u0_/6.0;
382 d[nx_-1] += nl_*u1_/6.0;
387 const std::vector<Real> &v,
388 const std::vector<Real> &u,
389 const std::vector<Real> &z)
const {
391 for (
int i = 0; i <
nx_; i++) {
392 jv[i] = nu_/dx_*2.0*v[i];
394 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]);
397 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]);
400 jv[ 0] -= nl_*u0_/6.0*v[0];
401 jv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
406 const std::vector<Real> &v,
407 const std::vector<Real> &u,
408 const std::vector<Real> &z)
const {
410 std::vector<Real> d(nx_,0.0);
411 std::vector<Real> dl(nx_-1,0.0);
412 std::vector<Real> du(nx_-1,0.0);
420 const std::vector<Real> &v,
421 const std::vector<Real> &u,
422 const std::vector<Real> &z)
const {
424 for (
int i = 0; i <
nx_; i++) {
425 ajv[i] = nu_/dx_*2.0*v[i];
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[i] += -nu_/dx_*v[i+1]+nl_*(u[i+1]/6.0*v[i]
432 -(u[i+1]+2.0*u[i])/6.0*v[i+1]);
435 ajv[ 0] -= nl_*u0_/6.0*v[0];
436 ajv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
441 const std::vector<Real> &v,
442 const std::vector<Real> &u,
443 const std::vector<Real> &z)
const {
445 std::vector<Real> d(nx_,0.0);
446 std::vector<Real> du(nx_-1,0.0);
447 std::vector<Real> dl(nx_-1,0.0);
458 const std::vector<Real> &v,
459 const std::vector<Real> &u,
460 const std::vector<Real> &z)
const {
461 for (
int i=0; i<
nx_; i++) {
463 jv[i] = -dx_/6.0*(v[i]+4.0*v[i+1]+v[i+2]);
469 const std::vector<Real> &v,
470 const std::vector<Real> &u,
471 const std::vector<Real> &z)
const {
472 for (
int i=0; i<nx_+2; i++) {
474 jv[i] = -dx_/6.0*v[i];
477 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i]);
479 else if ( i == nx_ ) {
480 jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i-2]);
482 else if ( i == nx_+1 ) {
483 jv[i] = -dx_/6.0*v[i-2];
486 jv[i] = -dx_/6.0*(v[i-2]+4.0*v[i-1]+v[i]);
495 const std::vector<Real> &w,
496 const std::vector<Real> &v,
497 const std::vector<Real> &u,
498 const std::vector<Real> &z)
const {
499 for (
int i=0; i<
nx_; i++) {
503 ahwv[i] += (w[i]*v[i+1] - w[i+1]*(2.0*v[i]+v[i+1]))/6.0;
506 ahwv[i] += (w[i-1]*(v[i-1]+2.0*v[i]) - w[i]*v[i-1])/6.0;
512 const std::vector<Real> &w,
513 const std::vector<Real> &v,
514 const std::vector<Real> &u,
515 const std::vector<Real> &z) {
516 ahwv.assign(u.size(),0.0);
519 const std::vector<Real> &w,
520 const std::vector<Real> &v,
521 const std::vector<Real> &u,
522 const std::vector<Real> &z) {
523 ahwv.assign(z.size(),0.0);
526 const std::vector<Real> &w,
527 const std::vector<Real> &v,
528 const std::vector<Real> &u,
529 const std::vector<Real> &z) {
530 ahwv.assign(z.size(),0.0);
537 Teuchos::RCP<std::vector<Real> > vec_;
538 Teuchos::RCP<BurgersFEM<Real> > fem_;
540 mutable Teuchos::RCP<L2VectorDual<Real> > dual_vec_;
545 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
549 const std::vector<Real>& xval = *ex.
getVector();
550 std::copy(xval.begin(),xval.end(),vec_->begin());
555 const std::vector<Real>& xval = *ex.
getVector();
556 unsigned dimension = vec_->size();
557 for (
unsigned i=0; i<dimension; i++) {
558 (*vec_)[i] += xval[i];
563 unsigned dimension = vec_->size();
564 for (
unsigned i=0; i<dimension; i++) {
571 const std::vector<Real>& xval = *ex.
getVector();
572 return fem_->compute_L2_dot(xval,*vec_);
577 val = std::sqrt( dot(*
this) );
581 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
582 return Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
585 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
593 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
594 Teuchos::RCP<L2VectorPrimal> e
595 = Teuchos::rcp(
new L2VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
596 (*e->getVector())[i] = 1.0;
606 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
608 fem_->apply_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
617 Teuchos::RCP<std::vector<Real> > vec_;
618 Teuchos::RCP<BurgersFEM<Real> > fem_;
620 mutable Teuchos::RCP<L2VectorPrimal<Real> > dual_vec_;
625 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
629 const std::vector<Real>& xval = *ex.
getVector();
630 std::copy(xval.begin(),xval.end(),vec_->begin());
635 const std::vector<Real>& xval = *ex.
getVector();
636 unsigned dimension = vec_->size();
637 for (
unsigned i=0; i<dimension; i++) {
638 (*vec_)[i] += xval[i];
643 unsigned dimension = vec_->size();
644 for (
unsigned i=0; i<dimension; i++) {
651 const std::vector<Real>& xval = *ex.
getVector();
652 unsigned dimension = vec_->size();
653 std::vector<Real> Mx(dimension,0.0);
654 fem_->apply_inverse_mass(Mx,xval);
656 for (
unsigned i = 0; i < dimension; i++) {
657 val += Mx[i]*(*vec_)[i];
664 val = std::sqrt( dot(*
this) );
668 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
669 return Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
672 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
680 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
681 Teuchos::RCP<L2VectorDual> e
682 = Teuchos::rcp(
new L2VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
683 (*e->getVector())[i] = 1.0;
693 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
695 fem_->apply_inverse_mass(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
704 Teuchos::RCP<std::vector<Real> > vec_;
705 Teuchos::RCP<BurgersFEM<Real> > fem_;
707 mutable Teuchos::RCP<H1VectorDual<Real> > dual_vec_;
712 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
716 const std::vector<Real>& xval = *ex.
getVector();
717 std::copy(xval.begin(),xval.end(),vec_->begin());
722 const std::vector<Real>& xval = *ex.
getVector();
723 unsigned dimension = vec_->size();
724 for (
unsigned i=0; i<dimension; i++) {
725 (*vec_)[i] += xval[i];
730 unsigned dimension = vec_->size();
731 for (
unsigned i=0; i<dimension; i++) {
738 const std::vector<Real>& xval = *ex.
getVector();
739 return fem_->compute_H1_dot(xval,*vec_);
744 val = std::sqrt( dot(*
this) );
748 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
749 return Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
752 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
760 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
761 Teuchos::RCP<H1VectorPrimal> e
762 = Teuchos::rcp(
new H1VectorPrimal( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
763 (*e->getVector())[i] = 1.0;
773 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
775 fem_->apply_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
784 Teuchos::RCP<std::vector<Real> > vec_;
785 Teuchos::RCP<BurgersFEM<Real> > fem_;
787 mutable Teuchos::RCP<H1VectorPrimal<Real> > dual_vec_;
792 : vec_(vec), fem_(fem), dual_vec_(Teuchos::null) {}
796 const std::vector<Real>& xval = *ex.
getVector();
797 std::copy(xval.begin(),xval.end(),vec_->begin());
802 const std::vector<Real>& xval = *ex.
getVector();
803 unsigned dimension = vec_->size();
804 for (
unsigned i=0; i<dimension; i++) {
805 (*vec_)[i] += xval[i];
810 unsigned dimension = vec_->size();
811 for (
unsigned i=0; i<dimension; i++) {
818 const std::vector<Real>& xval = *ex.
getVector();
819 unsigned dimension = vec_->size();
820 std::vector<Real> Mx(dimension,0.0);
821 fem_->apply_inverse_H1(Mx,xval);
823 for (
unsigned i = 0; i < dimension; i++) {
824 val += Mx[i]*(*vec_)[i];
831 val = std::sqrt( dot(*
this) );
835 Teuchos::RCP<ROL::Vector<Real> >
clone()
const {
836 return Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
839 Teuchos::RCP<const std::vector<Real> >
getVector()
const {
847 Teuchos::RCP<ROL::Vector<Real> >
basis(
const int i )
const {
848 Teuchos::RCP<H1VectorDual> e
849 = Teuchos::rcp(
new H1VectorDual( Teuchos::rcp(
new std::vector<Real>(vec_->size(),0.0)),fem_));
850 (*e->getVector())[i] = 1.0;
860 Teuchos::rcp(
new std::vector<Real>(*vec_)),fem_));
862 fem_->apply_inverse_H1(*(Teuchos::rcp_const_cast<std::vector<Real> >(dual_vec_->getVector())),*vec_);
881 typedef typename std::vector<Real>::size_type
uint;
883 Teuchos::RCP<BurgersFEM<Real> > fem_;
888 : fem_(fem), useHessian_(useHessian) {}
892 Teuchos::RCP<std::vector<Real> > cp =
893 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(c)).getVector());
894 Teuchos::RCP<const std::vector<Real> > up =
895 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
896 Teuchos::RCP<const std::vector<Real> > zp =
897 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
899 const std::vector<Real> param
901 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
903 fem_->compute_residual(*cp,*up,*zp);
908 Teuchos::RCP<std::vector<Real> > jvp =
909 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(jv)).getVector());
910 Teuchos::RCP<const std::vector<Real> > vp =
911 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
912 Teuchos::RCP<const std::vector<Real> > up =
913 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
914 Teuchos::RCP<const std::vector<Real> > zp =
915 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
917 const std::vector<Real> param
919 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
921 fem_->apply_pde_jacobian(*jvp,*vp,*up,*zp);
926 Teuchos::RCP<std::vector<Real> > jvp =
927 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalConstraintVector>(jv)).getVector());
928 Teuchos::RCP<const std::vector<Real> > vp =
929 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
930 Teuchos::RCP<const std::vector<Real> > up =
931 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
932 Teuchos::RCP<const std::vector<Real> > zp =
933 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
935 const std::vector<Real> param
937 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
939 fem_->apply_control_jacobian(*jvp,*vp,*up,*zp);
944 Teuchos::RCP<std::vector<Real> > ijvp =
945 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<PrimalStateVector>(ijv)).getVector());
946 Teuchos::RCP<const std::vector<Real> > vp =
947 (Teuchos::dyn_cast<PrimalConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
948 Teuchos::RCP<const std::vector<Real> > up =
949 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
950 Teuchos::RCP<const std::vector<Real> > zp =
951 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
953 const std::vector<Real> param
955 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
957 fem_->apply_inverse_pde_jacobian(*ijvp,*vp,*up,*zp);
962 Teuchos::RCP<std::vector<Real> > jvp =
963 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ajv)).getVector());
964 Teuchos::RCP<const std::vector<Real> > vp =
965 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
966 Teuchos::RCP<const std::vector<Real> > up =
967 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
968 Teuchos::RCP<const std::vector<Real> > zp =
969 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
971 const std::vector<Real> param
973 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
975 fem_->apply_adjoint_pde_jacobian(*jvp,*vp,*up,*zp);
980 Teuchos::RCP<std::vector<Real> > jvp =
981 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(jv)).getVector());
982 Teuchos::RCP<const std::vector<Real> > vp =
983 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
984 Teuchos::RCP<const std::vector<Real> > up =
985 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
986 Teuchos::RCP<const std::vector<Real> > zp =
987 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
989 const std::vector<Real> param
991 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
993 fem_->apply_adjoint_control_jacobian(*jvp,*vp,*up,*zp);
998 Teuchos::RCP<std::vector<Real> > iajvp =
999 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualConstraintVector>(iajv)).getVector());
1000 Teuchos::RCP<const std::vector<Real> > vp =
1001 (Teuchos::dyn_cast<DualStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1002 Teuchos::RCP<const std::vector<Real> > up =
1003 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1004 Teuchos::RCP<const std::vector<Real> > zp =
1005 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1007 const std::vector<Real> param
1009 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1011 fem_->apply_inverse_adjoint_pde_jacobian(*iajvp,*vp,*up,*zp);
1016 if ( useHessian_ ) {
1017 Teuchos::RCP<std::vector<Real> > ahwvp =
1018 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1019 Teuchos::RCP<const std::vector<Real> > wp =
1020 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1021 Teuchos::RCP<const std::vector<Real> > vp =
1022 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1023 Teuchos::RCP<const std::vector<Real> > up =
1024 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1025 Teuchos::RCP<const std::vector<Real> > zp =
1026 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1028 const std::vector<Real> param
1030 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1032 fem_->apply_adjoint_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1041 if ( useHessian_ ) {
1042 Teuchos::RCP<std::vector<Real> > ahwvp =
1043 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1044 Teuchos::RCP<const std::vector<Real> > wp =
1045 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1046 Teuchos::RCP<const std::vector<Real> > vp =
1047 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1048 Teuchos::RCP<const std::vector<Real> > up =
1049 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1050 Teuchos::RCP<const std::vector<Real> > zp =
1051 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1053 const std::vector<Real> param
1055 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1057 fem_->apply_adjoint_control_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
1065 if ( useHessian_ ) {
1066 Teuchos::RCP<std::vector<Real> > ahwvp =
1067 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(ahwv)).getVector());
1068 Teuchos::RCP<const std::vector<Real> > wp =
1069 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1070 Teuchos::RCP<const std::vector<Real> > vp =
1071 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1072 Teuchos::RCP<const std::vector<Real> > up =
1073 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1074 Teuchos::RCP<const std::vector<Real> > zp =
1075 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1077 const std::vector<Real> param
1079 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1081 fem_->apply_adjoint_pde_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1089 if ( useHessian_ ) {
1090 Teuchos::RCP<std::vector<Real> > ahwvp =
1091 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualControlVector>(ahwv)).getVector());
1092 Teuchos::RCP<const std::vector<Real> > wp =
1093 (Teuchos::dyn_cast<DualConstraintVector>(
const_cast<ROL::Vector<Real> &
>(w))).getVector();
1094 Teuchos::RCP<const std::vector<Real> > vp =
1095 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(v))).getVector();
1096 Teuchos::RCP<const std::vector<Real> > up =
1097 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1098 Teuchos::RCP<const std::vector<Real> > zp =
1099 (Teuchos::dyn_cast<PrimalControlVector>(
const_cast<ROL::Vector<Real> &
>(z))).getVector();
1101 const std::vector<Real> param
1103 fem_->set_problem_data(param[0],param[1],param[2],param[3]);
1105 fem_->apply_adjoint_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
1113 template<
class Real>
1123 Teuchos::RCP<BurgersFEM<Real> > fem_;
1130 Real x = 0.0) : fem_(fem), x_(x) {
1131 for (
int i = 1; i < fem_->num_dof()+1; i++) {
1132 if ( (Real)i*(fem_->mesh_spacing()) >= x_ ) {
1133 indices_.push_back(i-1);
1139 Teuchos::RCP<const std::vector<Real> > up =
1140 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1149 Real val = 0.5*((((Real)indices_[0]+1.)*(fem_->mesh_spacing())-x_)
1150 *(x_+(2.-((Real)indices_[0]+1.))*(fem_->mesh_spacing()))/(fem_->mesh_spacing())
1151 +(fem_->mesh_spacing())) * (*up)[indices_[0]];
1152 for (uint i = 1; i < indices_.size(); i++) {
1153 val += (fem_->mesh_spacing())*(*up)[indices_[i]];
1159 Teuchos::RCP<std::vector<Real> > gp =
1160 Teuchos::rcp_const_cast<std::vector<Real> >((Teuchos::dyn_cast<DualStateVector>(g)).getVector());
1161 Teuchos::RCP<const std::vector<Real> > up =
1162 (Teuchos::dyn_cast<PrimalStateVector>(
const_cast<ROL::Vector<Real> &
>(u))).getVector();
1173 (*gp)[indices_[0]] = -0.5*((((Real)indices_[0]+1.)*(fem_->mesh_spacing())-x_)
1174 *(x_+(2.-((Real)indices_[0]+1.))*(fem_->mesh_spacing()))/(fem_->mesh_spacing())
1175 +(fem_->mesh_spacing()));
1178 for (uint i = 1; i < indices_.size(); i++) {
1179 (*gp)[indices_[i]] = -(fem_->mesh_spacing());
1221 template<
class Real>
1225 std::vector<Real> x_lo_;
1226 std::vector<Real> x_up_;
1229 Teuchos::RCP<BurgersFEM<Real> > fem_;
1234 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1237 catch (std::exception &e) {
1238 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1249 catch (std::exception &e) {
1255 void axpy(std::vector<Real> &out,
const Real a,
1256 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1257 out.resize(dim_,0.0);
1258 for (
unsigned i = 0; i < dim_; i++) {
1259 out[i] = a*x[i] + y[i];
1264 for (
int i = 0; i < dim_; i++ ) {
1265 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1272 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1273 dim_ = x_lo_.size();
1274 for (
int i = 0; i < dim_; i++ ) {
1276 min_diff_ = x_up_[i] - x_lo_[i];
1279 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1286 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1289 for (
int i = 0; i < dim_; i++ ) {
1290 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1293 if ( cnt == 0 ) { val =
false; }
1298 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1303 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1304 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1305 Real epsn = std::min(scale_*eps,min_diff_);
1306 for (
int i = 0; i < dim_; i++ ) {
1307 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1314 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1315 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1316 Real epsn = std::min(scale_*eps,min_diff_);
1317 for (
int i = 0; i < dim_; i++ ) {
1318 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1325 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1326 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1327 Real epsn = std::min(scale_*eps,min_diff_);
1328 for (
int i = 0; i < dim_; i++ ) {
1329 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1330 ((*ex)[i] >= x_up_[i]-epsn) ) {
1337 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1338 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1339 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1340 Real epsn = std::min(scale_*eps,min_diff_);
1341 for (
int i = 0; i < dim_; i++ ) {
1342 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1349 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1350 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1351 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1352 Real epsn = std::min(scale_*eps,min_diff_);
1353 for (
int i = 0; i < dim_; i++ ) {
1354 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1361 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1362 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1363 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1364 Real epsn = std::min(scale_*eps,min_diff_);
1365 for (
int i = 0; i < dim_; i++ ) {
1366 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1367 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1374 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1375 us->assign(x_up_.begin(),x_up_.end());
1381 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1382 ls->assign(x_lo_.begin(),x_lo_.end());
1388 template<
class Real>
1392 std::vector<Real> x_lo_;
1393 std::vector<Real> x_up_;
1396 Teuchos::RCP<BurgersFEM<Real> > fem_;
1401 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1404 catch (std::exception &e) {
1405 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1416 catch (std::exception &e) {
1422 void axpy(std::vector<Real> &out,
const Real a,
1423 const std::vector<Real> &x,
const std::vector<Real> &y)
const{
1424 out.resize(dim_,0.0);
1425 for (
unsigned i = 0; i < dim_; i++) {
1426 out[i] = a*x[i] + y[i];
1431 for (
int i = 0; i < dim_; i++ ) {
1432 x[i] = std::max(x_lo_[i],std::min(x_up_[i],x[i]));
1439 : x_lo_(l), x_up_(u), scale_(
scale), fem_(fem) {
1440 dim_ = x_lo_.size();
1441 for (
int i = 0; i < dim_; i++ ) {
1443 min_diff_ = x_up_[i] - x_lo_[i];
1446 min_diff_ = ( (min_diff_ < (x_up_[i] - x_lo_[i])) ? min_diff_ : (x_up_[i] - x_lo_[i]) );
1453 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1456 for (
int i = 0; i < dim_; i++ ) {
1457 if ( (*ex)[i] >= x_lo_[i] && (*ex)[i] <= x_up_[i] ) { cnt *= 1; }
1460 if ( cnt == 0 ) { val =
false; }
1465 Teuchos::RCP<std::vector<Real> > ex; cast_vector(ex,x);
1470 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1471 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1472 Real epsn = std::min(scale_*eps,min_diff_);
1473 for (
int i = 0; i < dim_; i++ ) {
1474 if ( ((*ex)[i] <= x_lo_[i]+epsn) ) {
1481 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1482 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1483 Real epsn = std::min(scale_*eps,min_diff_);
1484 for (
int i = 0; i < dim_; i++ ) {
1485 if ( ((*ex)[i] >= x_up_[i]-epsn) ) {
1492 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1493 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1494 Real epsn = std::min(scale_*eps,min_diff_);
1495 for (
int i = 0; i < dim_; i++ ) {
1496 if ( ((*ex)[i] <= x_lo_[i]+epsn) ||
1497 ((*ex)[i] >= x_up_[i]-epsn) ) {
1504 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1505 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1506 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1507 Real epsn = std::min(scale_*eps,min_diff_);
1508 for (
int i = 0; i < dim_; i++ ) {
1509 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ) {
1516 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1517 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1518 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1519 Real epsn = std::min(scale_*eps,min_diff_);
1520 for (
int i = 0; i < dim_; i++ ) {
1521 if ( ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1528 Teuchos::RCP<const std::vector<Real> > ex; cast_const_vector(ex,x);
1529 Teuchos::RCP<const std::vector<Real> > eg; cast_const_vector(eg,g);
1530 Teuchos::RCP<std::vector<Real> > ev; cast_vector(ev,v);
1531 Real epsn = std::min(scale_*eps,min_diff_);
1532 for (
int i = 0; i < dim_; i++ ) {
1533 if ( ((*ex)[i] <= x_lo_[i]+epsn && (*eg)[i] > 0.0) ||
1534 ((*ex)[i] >= x_up_[i]-epsn && (*eg)[i] < 0.0) ) {
1541 Teuchos::RCP<std::vector<Real> > us = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1542 us->assign(x_up_.begin(),x_up_.end());
1548 Teuchos::RCP<std::vector<Real> > ls = Teuchos::rcp(
new std::vector<Real>(dim_,0.0) );
1549 ls->assign(x_lo_.begin(),x_lo_.end());
1555 template<
class Real,
class Ordinal>
1561 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1564 catch (std::exception &e) {
1565 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1572 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1574 Teuchos::RCP<std::vector<Real> > input_ptr;
1575 cast_vector(input_ptr,input);
1576 int dim_i = input_ptr->size();
1577 Teuchos::RCP<std::vector<Real> > output_ptr;
1578 cast_vector(output_ptr,output);
1579 int dim_o = output_ptr->size();
1580 if ( dim_i != dim_o ) {
1581 std::cout <<
"L2VectorBatchManager: DIMENSION MISMATCH ON RANK " 1590 template<
class Real,
class Ordinal>
1596 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1599 catch (std::exception &e) {
1600 xvec = Teuchos::rcp_const_cast<std::vector<Real> >(
1607 :
ROL::TeuchosBatchManager<Real,Ordinal>(comm) {}
1609 Teuchos::RCP<std::vector<Real> > input_ptr;
1610 cast_vector(input_ptr,input);
1611 int dim_i = input_ptr->size();
1612 Teuchos::RCP<std::vector<Real> > output_ptr;
1613 cast_vector(output_ptr,output);
1614 int dim_o = output_ptr->size();
1615 if ( dim_i != dim_o ) {
1616 std::cout <<
"H1VectorBatchManager: DIMENSION MISMATCH ON RANK " 1625 template<
class Real>
1626 Real
random(
const Teuchos::RCP<
const Teuchos::Comm<int> > &comm) {
1628 if ( Teuchos::rank<int>(*comm)==0 ) {
1629 val = (Real)rand()/(Real)RAND_MAX;
1631 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
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)
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.
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.
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.