25 #include "ROL_ParameterList.hpp"
28 #include "Teuchos_GlobalMPISession.hpp"
29 #include "Teuchos_LAPACK.hpp"
53 return std::sqrt(
dot(r,r));
56 Real
dot(
const std::vector<Real> &x,
const std::vector<Real> &y) {
58 Real c = ((x.size()==
nx_) ? 4.0 : 2.0);
59 for (
unsigned i = 0; i < x.size(); i++) {
61 ip +=
dx_/6.0*(c*x[i] + x[i+1])*y[i];
63 else if ( i == x.size()-1 ) {
64 ip +=
dx_/6.0*(x[i-1] + c*x[i])*y[i];
67 ip +=
dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
75 void update(std::vector<Real> &u,
const std::vector<Real> &s,
const Real alpha=1.0) {
76 for (
unsigned i = 0; i < u.size(); i++) {
81 void scale(std::vector<Real> &u,
const Real alpha=0.0) {
82 for (
unsigned i = 0; i < u.size(); i++) {
87 void compute_residual(std::vector<Real> &r,
const std::vector<Real> &uold,
const std::vector<Real> &zold,
88 const std::vector<Real> &unew,
const std::vector<Real> &znew) {
91 for (
unsigned n = 0; n <
nx_; n++) {
105 r[n] -= 0.5*
dt_*unew[n-1]*(unew[n-1]+unew[n])/6.0;
106 r[n] -= 0.5*
dt_*uold[n-1]*(uold[n-1]+uold[n])/6.0;
109 r[n] += 0.5*
dt_*unew[n+1]*(unew[n]+unew[n+1])/6.0;
110 r[n] += 0.5*
dt_*uold[n+1]*(uold[n]+uold[n+1])/6.0;
113 r[n] -= 0.5*
dt_*
dx_/6.0*(znew[n]+4.0*znew[n+1]+znew[n+2]);
114 r[n] -= 0.5*
dt_*
dx_/6.0*(zold[n]+4.0*zold[n+1]+zold[n+2]);
124 const std::vector<Real> &u) {
133 for (
unsigned n = 0; n <
nx_; n++) {
135 dl[n] += 0.5*
dt_*(-2.0*u[n]-u[n+1])/6.0;
136 d[n] += 0.5*
dt_*u[n+1]/6.0;
139 d[n] -= 0.5*
dt_*u[n-1]/6.0;
140 du[n-1] += 0.5*
dt_*(u[n-1]+2.0*u[n])/6.0;
145 d[nx_-1] += 0.5*
dt_*
u1_/6.0;
149 bool adjoint =
false) {
153 for (
unsigned n = 0; n <
nx_; n++) {
158 jv[n] -= 0.5*
dt_*(u[n-1]/6.0*v[n]-(u[n-1]+2.0*u[n])/6.0*v[n-1]);
161 jv[n] -= 0.5*
dt_*(u[n-1]/6.0*v[n]+(u[n]+2.0*u[n-1])/6.0*v[n-1]);
167 jv[n] += 0.5*
dt_*(u[n+1]/6.0*v[n]-(u[n+1]+2.0*u[n])/6.0*v[n+1]);
170 jv[n] += 0.5*
dt_*(u[n+1]/6.0*v[n]+(u[n]+2.0*u[n+1])/6.0*v[n+1]);
174 jv[0] -= 0.5*
dt_*
u0_/6.0*v[0];
175 jv[nx_-1] += 0.5*
dt_*
u1_/6.0*v[nx_-1];
179 bool adjoint =
false) {
183 for (
unsigned n = 0; n <
nx_; n++) {
188 jv[n] -= 0.5*
dt_*(u[n-1]/6.0*v[n]-(u[n-1]+2.0*u[n])/6.0*v[n-1]);
191 jv[n] -= 0.5*
dt_*(u[n-1]/6.0*v[n]+(u[n]+2.0*u[n-1])/6.0*v[n-1]);
197 jv[n] += 0.5*
dt_*(u[n+1]/6.0*v[n]-(u[n+1]+2.0*u[n])/6.0*v[n+1]);
200 jv[n] += 0.5*
dt_*(u[n+1]/6.0*v[n]+(u[n]+2.0*u[n+1])/6.0*v[n+1]);
204 jv[0] -= 0.5*
dt_*
u0_/6.0*v[0];
205 jv[nx_-1] += 0.5*
dt_*
u1_/6.0*v[nx_-1];
208 void apply_pde_jacobian(std::vector<Real> &jv,
const std::vector<Real> &vold,
const std::vector<Real> &uold,
209 const std::vector<Real> &vnew,
const std::vector<Real> unew,
bool adjoint =
false) {
213 for (
unsigned n = 0; n <
nx_; n++) {
220 jv[n] -= 0.5*
dt_*(unew[n-1]/6.0*vnew[n]-(unew[n-1]+2.0*unew[n])/6.0*vnew[n-1]);
221 jv[n] -= 0.5*
dt_*(uold[n-1]/6.0*vold[n]-(uold[n-1]+2.0*uold[n])/6.0*vold[n-1]);
224 jv[n] -= 0.5*
dt_*(unew[n-1]/6.0*vnew[n]+(unew[n]+2.0*unew[n-1])/6.0*vnew[n-1]);
225 jv[n] -= 0.5*
dt_*(uold[n-1]/6.0*vold[n]+(uold[n]+2.0*uold[n-1])/6.0*vold[n-1]);
232 jv[n] += 0.5*
dt_*(unew[n+1]/6.0*vnew[n]-(unew[n+1]+2.0*unew[n])/6.0*vnew[n+1]);
233 jv[n] += 0.5*
dt_*(uold[n+1]/6.0*vold[n]-(uold[n+1]+2.0*uold[n])/6.0*vold[n+1]);
236 jv[n] += 0.5*
dt_*(unew[n+1]/6.0*vnew[n]+(unew[n]+2.0*unew[n+1])/6.0*vnew[n+1]);
237 jv[n] += 0.5*
dt_*(uold[n+1]/6.0*vold[n]+(uold[n]+2.0*uold[n+1])/6.0*vold[n+1]);
241 jv[0] -= 0.5*
dt_*
u0_/6.0*vnew[0];
242 jv[0] -= 0.5*
dt_*
u0_/6.0*vold[0];
243 jv[nx_-1] += 0.5*
dt_*
u1_/6.0*vnew[nx_-1];
244 jv[nx_-1] += 0.5*
dt_*
u1_/6.0*vold[nx_-1];
247 void apply_pde_hessian(std::vector<Real> &hv,
const std::vector<Real> &wold,
const std::vector<Real> &vold,
248 const std::vector<Real> &wnew,
const std::vector<Real> &vnew) {
251 for (
unsigned n = 0; n <
nx_; n++) {
253 hv[n] += 0.5*
dt_*((wnew[n-1]*(vnew[n-1]+2.0*vnew[n]) - wnew[n]*vnew[n-1])/6.0);
254 hv[n] += 0.5*
dt_*((wold[n-1]*(vold[n-1]+2.0*vold[n]) - wold[n]*vold[n-1])/6.0);
257 hv[n] += 0.5*
dt_*((wnew[n]*vnew[n+1] - wnew[n+1]*(2.0*vnew[n]+vnew[n+1]))/6.0);
258 hv[n] += 0.5*
dt_*((wold[n]*vold[n+1] - wold[n+1]*(2.0*vold[n]+vold[n+1]))/6.0);
265 unsigned dim = ((adjoint ==
true) ?
nx_+2 :
nx_);
267 for (
unsigned n = 0; n <
dim; n++) {
270 jv[n] = -0.5*
dt_*
dx_/6.0*v[n];
273 jv[n] = -0.5*
dt_*
dx_/6.0*(4.0*v[n-1]+v[n]);
275 else if ( n ==
nx_ ) {
276 jv[n] = -0.5*
dt_*
dx_/6.0*(4.0*v[n-1]+v[n-2]);
278 else if ( n ==
nx_+1 ) {
279 jv[n] = -0.5*
dt_*
dx_/6.0*v[n-2];
282 jv[n] = -0.5*
dt_*
dx_/6.0*(v[n-2]+4.0*v[n-1]+v[n]);
286 jv[n] -= 0.5*
dt_*
dx_/6.0*(v[n]+4.0*v[n+1]+v[n+2]);
291 void run_newton(std::vector<Real> &u,
const std::vector<Real> &znew,
292 const std::vector<Real> &uold,
const std::vector<Real> &zold) {
296 std::vector<Real> r(
nx_,0.0);
300 Real rtol = 1.e2*ROL::ROL_EPSILON<Real>();
301 unsigned maxit = 500;
303 std::vector<Real> d(
nx_,0.0);
304 std::vector<Real> dl(
nx_-1,0.0);
305 std::vector<Real> du(
nx_-1,0.0);
307 Real alpha = 1.0, tmp = 0.0;
308 std::vector<Real> s(
nx_,0.0);
309 std::vector<Real> utmp(
nx_,0.0);
310 for (
unsigned i = 0; i < maxit; i++) {
319 utmp.assign(u.begin(),u.end());
323 while ( rnorm > (1.0-1.e-4*alpha)*tmp && alpha > std::sqrt(ROL::ROL_EPSILON<Real>()) ) {
325 utmp.assign(u.begin(),u.end());
331 u.assign(utmp.begin(),utmp.end());
332 if ( rnorm < rtol ) {
339 const std::vector<Real> &dl,
const std::vector<Real> &d,
const std::vector<Real> &du,
340 const std::vector<Real> &r,
const bool transpose =
false) {
341 bool useLAPACK =
true;
343 u.assign(r.begin(),r.end());
345 std::vector<Real> Dl(dl);
346 std::vector<Real> Du(du);
347 std::vector<Real> D(d);
349 Teuchos::LAPACK<int,Real> lp;
350 std::vector<Real> Du2(
nx_-2,0.0);
351 std::vector<int> ipiv(
nx_,0);
355 lp.GTTRF(
nx_,&Dl[0],&D[0],&Du[0],&Du2[0],&ipiv[0],&info);
356 char trans = ((transpose ==
true) ?
'T' :
'N');
357 lp.GTTRS(trans,
nx_,nhrs,&Dl[0],&D[0],&Du[0],&Du2[0],&ipiv[0],&u[0],ldb,&info);
362 unsigned maxit = 100;
363 Real rtol = std::min(1.e-12,1.e-4*std::sqrt(
dot(r,r)));
366 Real rnorm = 10.0*rtol;
367 for (
unsigned i = 0; i < maxit; i++) {
368 for (
unsigned n = 0; n <
nx_; n++) {
371 u[n] -= ((transpose ==
false) ? du[n] : dl[n])*u[n+1]/d[n];
374 u[n] -= ((transpose ==
false) ? dl[n-1] : du[n-1])*u[n-1]/d[n];
379 for (
unsigned n = 0; n <
nx_; n++) {
380 resid = r[n] - d[n]*u[n];
382 resid -= ((transpose ==
false) ? du[n] : dl[n])*u[n+1];
385 resid -= ((transpose ==
false) ? dl[n-1] : du[n-1])*u[n-1];
387 rnorm += resid*resid;
389 rnorm = std::sqrt(rnorm);
390 if ( rnorm < rtol ) {
401 Real nu = 1.e-2, Real u0 = 0.0, Real u1 = 0.0, Real f = 0.0)
403 dx_ = 1.0/((Real)nx+1.0);
408 for (
unsigned n = 0; n <
nx_; n++) {
410 u_init_[n] = ((x <= 0.5) ? 1.0 : 0.0);
415 ROL::Ptr<std::vector<Real> > cp =
417 ROL::Ptr<const std::vector<Real> > up =
419 ROL::Ptr<const std::vector<Real> > zp =
422 std::vector<Real> C(
nx_,0.0);
423 std::vector<Real> uold(
u_init_);
424 std::vector<Real> unew(
u_init_);
425 std::vector<Real> zold(
nx_+2,0.0);
426 std::vector<Real> znew(
nx_+2,0.0);
428 for (
unsigned n = 0; n <
nx_+2; n++) {
432 for (
unsigned t = 0; t <
nt_; t++) {
434 for (
unsigned n = 0; n <
nx_; n++) {
435 unew[n] = (*up)[t*nx_+n];
438 for (
unsigned n = 0; n < nx_+2; n++) {
439 znew[n] = (*zp)[(t+1)*(nx_+2)+n];
444 for (
unsigned n = 0; n <
nx_; n++) {
445 (*cp)[t*nx_+n] = C[n];
448 uold.assign(unew.begin(),unew.end());
449 zold.assign(znew.begin(),znew.end());
454 ROL::Ptr<std::vector<Real> > up =
456 up->assign(up->size(),z.
norm()/up->size());
457 ROL::Ptr<const std::vector<Real> > zp =
460 std::vector<Real> uold(
u_init_);
461 std::vector<Real> unew(
u_init_);
462 std::vector<Real> zold(
nx_+2,0.0);
463 std::vector<Real> znew(
nx_+2,0.0);
465 for (
unsigned n = 0; n <
nx_+2; n++) {
469 for (
unsigned t = 0; t <
nt_; t++) {
471 for (
unsigned n = 0; n < nx_+2; n++) {
472 znew[n] = (*zp)[(t+1)*(nx_+2)+n];
477 for (
unsigned n = 0; n <
nx_; n++) {
478 (*up)[t*nx_+n] = unew[n];
481 uold.assign(unew.begin(),unew.end());
482 zold.assign(znew.begin(),znew.end());
489 ROL::Ptr<std::vector<Real> > jvp =
491 ROL::Ptr<const std::vector<Real> > vp =
493 ROL::Ptr<const std::vector<Real> > up =
495 std::vector<Real> J(
nx_,0.0);
496 std::vector<Real> vold(
nx_,0.0);
497 std::vector<Real> vnew(
nx_,0.0);
498 std::vector<Real> uold(
nx_,0.0);
499 std::vector<Real> unew(
nx_,0.0);
500 for (
unsigned t = 0; t <
nt_; t++) {
501 for (
unsigned n = 0; n <
nx_; n++) {
502 unew[n] = (*up)[t*nx_+n];
503 vnew[n] = (*vp)[t*nx_+n];
506 for (
unsigned n = 0; n <
nx_; n++) {
507 (*jvp)[t*nx_+n] = J[n];
509 vold.assign(vnew.begin(),vnew.end());
510 uold.assign(unew.begin(),unew.end());
516 ROL::Ptr<std::vector<Real> > jvp =
518 ROL::Ptr<const std::vector<Real> > vp =
520 ROL::Ptr<const std::vector<Real> > zp =
522 std::vector<Real> vnew(
nx_+2,0.0);
523 std::vector<Real> vold(
nx_+2,0.0);
524 std::vector<Real> jnew(
nx_,0.0);
525 std::vector<Real> jold(
nx_,0.0);
526 for (
unsigned n = 0; n <
nx_+2; n++) {
530 for (
unsigned t = 0; t <
nt_; t++) {
531 for (
unsigned n = 0; n < nx_+2; n++) {
532 vnew[n] = (*vp)[(t+1)*(nx_+2)+n];
535 for (
unsigned n = 0; n <
nx_; n++) {
537 (*jvp)[t*nx_+n] = jnew[n] + jold[n];
539 jold.assign(jnew.begin(),jnew.end());
545 ROL::Ptr<std::vector<Real> > ijvp =
547 ROL::Ptr<const std::vector<Real> > vp =
549 ROL::Ptr<const std::vector<Real> > up =
551 std::vector<Real> J(
nx_,0.0);
552 std::vector<Real> r(
nx_,0.0);
553 std::vector<Real> s(
nx_,0.0);
554 std::vector<Real> uold(
nx_,0.0);
555 std::vector<Real> unew(
nx_,0.0);
556 std::vector<Real> d(
nx_,0.0);
557 std::vector<Real> dl(
nx_-1,0.0);
558 std::vector<Real> du(
nx_-1,0.0);
559 for (
unsigned t = 0; t <
nt_; t++) {
561 for (
unsigned n = 0; n <
nx_; n++) {
562 r[n] = (*vp)[t*nx_+n];
563 unew[n] = (*up)[t*nx_+n];
572 for (
unsigned n = 0; n <
nx_; n++) {
573 (*ijvp)[t*nx_+n] = s[n];
575 uold.assign(unew.begin(),unew.end());
581 ROL::Ptr<std::vector<Real> > jvp =
583 ROL::Ptr<const std::vector<Real> > vp =
585 ROL::Ptr<const std::vector<Real> > up =
587 std::vector<Real> J(
nx_,0.0);
588 std::vector<Real> vold(
nx_,0.0);
589 std::vector<Real> vnew(
nx_,0.0);
590 std::vector<Real> unew(
nx_,0.0);
591 for (
unsigned t =
nt_; t > 0; t--) {
592 for (
unsigned n = 0; n <
nx_; n++) {
593 unew[n] = (*up)[(t-1)*nx_+n];
594 vnew[n] = (*vp)[(t-1)*nx_+n];
597 for (
unsigned n = 0; n <
nx_; n++) {
598 (*jvp)[(t-1)*nx_+n] = J[n];
600 vold.assign(vnew.begin(),vnew.end());
606 ROL::Ptr<std::vector<Real> > jvp =
608 ROL::Ptr<const std::vector<Real> > vp =
610 ROL::Ptr<const std::vector<Real> > zp =
612 std::vector<Real> vnew(
nx_,0.0);
613 std::vector<Real> vold(
nx_,0.0);
614 std::vector<Real> jnew(
nx_+2,0.0);
615 std::vector<Real> jold(
nx_+2,0.0);
616 for (
unsigned t =
nt_+1; t > 0; t--) {
617 for (
unsigned n = 0; n <
nx_; n++) {
619 vnew[n] = (*vp)[(t-2)*nx_+n];
626 for (
unsigned n = 0; n < nx_+2; n++) {
628 (*jvp)[(t-1)*(nx_+2)+n] = jnew[n] + jold[n];
630 jold.assign(jnew.begin(),jnew.end());
636 ROL::Ptr<std::vector<Real> > ijvp =
638 ROL::Ptr<const std::vector<Real> > vp =
640 ROL::Ptr<const std::vector<Real> > up =
642 std::vector<Real> J(
nx_,0.0);
643 std::vector<Real> r(
nx_,0.0);
644 std::vector<Real> s(
nx_,0.0);
645 std::vector<Real> unew(
nx_,0.0);
646 std::vector<Real> d(
nx_,0.0);
647 std::vector<Real> dl(
nx_-1,0.0);
648 std::vector<Real> du(
nx_-1,0.0);
649 for (
unsigned t =
nt_; t > 0; t--) {
651 for (
unsigned n = 0; n <
nx_; n++) {
652 r[n] = (*vp)[(t-1)*nx_+n];
653 unew[n] = (*up)[(t-1)*nx_+n];
662 for (
unsigned n = 0; n <
nx_; n++) {
663 (*ijvp)[(t-1)*nx_+n] = s[n];
670 ROL::Ptr<std::vector<Real> > hwvp =
672 ROL::Ptr<const std::vector<Real> > wp =
674 ROL::Ptr<const std::vector<Real> > vp =
676 std::vector<Real> snew(
nx_,0.0);
677 std::vector<Real> wnew(
nx_,0.0);
678 std::vector<Real> wold(
nx_,0.0);
679 std::vector<Real> vnew(
nx_,0.0);
680 for (
unsigned t =
nt_; t > 0; t--) {
681 for (
unsigned n = 0; n <
nx_; n++) {
682 vnew[n] = (*vp)[(t-1)*nx_+n];
683 wnew[n] = (*wp)[(t-1)*nx_+n];
686 for (
unsigned n = 0; n <
nx_; n++) {
687 (*hwvp)[(t-1)*nx_+n] = snew[n];
689 wold.assign(wnew.begin(),wnew.end());
725 case 1: val = ((x<=0.5) ? 1.0 : 0.0);
break;
726 case 2: val = 1.0;
break;
727 case 3: val = std::abs(std::sin(8.0*M_PI*x));
break;
728 case 4: val = std::exp(-0.5*(x-0.5)*(x-0.5));
break;
733 Real
dot(
const std::vector<Real> &x,
const std::vector<Real> &y) {
735 Real c = ((x.size()==
nx_) ? 4.0 : 2.0);
736 for (
unsigned i=0; i<x.size(); i++) {
738 ip +=
dx_/6.0*(c*x[i] + x[i+1])*y[i];
740 else if ( i == x.size()-1 ) {
741 ip +=
dx_/6.0*(x[i-1] + c*x[i])*y[i];
744 ip +=
dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
750 void apply_mass(std::vector<Real> &Mu,
const std::vector<Real> &u ) {
751 Mu.resize(u.size(),0.0);
752 Real c = ((u.size()==
nx_) ? 4.0 : 2.0);
753 for (
unsigned i=0; i<u.size(); i++) {
755 Mu[i] =
dx_/6.0*(c*u[i] + u[i+1]);
757 else if ( i == u.size()-1 ) {
758 Mu[i] =
dx_/6.0*(u[i-1] + c*u[i]);
761 Mu[i] =
dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1]);
773 dx_ = 1.0/((Real)nx+1.0);
778 ROL::Ptr<const std::vector<Real> > up =
780 ROL::Ptr<const std::vector<Real> > zp =
783 std::vector<Real> U(
nx_,0.0);
784 std::vector<Real> G(
nx_,0.0);
785 std::vector<Real> Z(
nx_+2,0.0);
786 for (
unsigned n = 0; n <
nx_+2; n++) {
791 for (
unsigned t = 0; t <
nt_; t++) {
792 ss = ((t < nt_-1) ?
dt_ : 0.5*
dt_);
793 for (
unsigned n = 0; n <
nx_; n++) {
797 val += 0.5*ss*
dot(U,U);
798 val -= 0.5*ss*
dot(G,G);
799 for (
unsigned n = 0; n < nx_+2; n++) {
800 Z[n] = (*zp)[(t+1)*(nx_+2)+n];
808 ROL::Ptr<std::vector<Real> > gp =
810 ROL::Ptr<const std::vector<Real> > up =
813 std::vector<Real> U(
nx_,0.0);
814 std::vector<Real> M(
nx_,0.0);
816 for (
unsigned t = 0; t <
nt_; t++) {
817 ss = ((t < nt_-1) ?
dt_ : 0.5*
dt_);
818 for (
unsigned n = 0; n <
nx_; n++) {
822 for (
unsigned n = 0; n <
nx_; n++) {
823 (*gp)[t*nx_+n] = ss*M[n];
829 ROL::Ptr<std::vector<Real> > gp =
831 ROL::Ptr<const std::vector<Real> > zp =
834 std::vector<Real> Z(
nx_+2,0.0);
835 std::vector<Real> M(
nx_+2,0.0);
837 for (
unsigned t = 0; t <
nt_+1; t++) {
838 ss = ((t < nt_ && t > 0) ?
dt_ : 0.5*
dt_);
839 for (
unsigned n = 0; n <
nx_+2; n++) {
840 Z[n] = (*zp)[t*(nx_+2)+n];
843 for (
unsigned n = 0; n < nx_+2; n++) {
844 (*gp)[t*(nx_+2)+n] = ss*
alpha_*M[n];
851 ROL::Ptr<std::vector<Real> > hvp =
853 ROL::Ptr<const std::vector<Real> > vp =
856 std::vector<Real>
V(
nx_,0.0);
857 std::vector<Real> M(
nx_,0.0);
859 for (
unsigned t = 0; t <
nt_; t++) {
860 ss = ((t < nt_-1) ?
dt_ : 0.5*
dt_);
861 for (
unsigned n = 0; n <
nx_; n++) {
862 V[n] = (*vp)[t*nx_+n];
865 for (
unsigned n = 0; n <
nx_; n++) {
866 (*hvp)[t*nx_+n] = ss*M[n];
883 ROL::Ptr<std::vector<Real> > hvp = ROL::constPtrCast<std::vector<Real> >(
885 ROL::Ptr<const std::vector<Real> > vp =
888 std::vector<Real>
V(
nx_+2,0.0);
889 std::vector<Real> M(
nx_+2,0.0);
891 for (
unsigned t = 0; t <
nt_+1; t++) {
892 ss = ((t < nt_ && t > 0) ?
dt_ : 0.5*
dt_);
893 for (
unsigned n = 0; n <
nx_+2; n++) {
894 V[n] = (*vp)[t*(nx_+2)+n];
897 for (
unsigned n = 0; n < nx_+2; n++) {
898 (*hvp)[t*(nx_+2)+n] = ss*
alpha_*M[n];
void apply_pde_jacobian_old(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, bool adjoint=false)
Provides the interface to evaluate simulation-based objective functions.
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...
Real evaluate_target(Real x)
void applyAdjointHessian_12(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the optimization-space derivative of the adjoint of the constraint simulation-space Jacobian at...
void applyAdjointHessian_11(ROL::Vector< Real > &hwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the simulation-space derivative of the adjoint of the constraint simulation-space Jacobian at ...
void run_newton(std::vector< Real > &u, const std::vector< Real > &znew, const std::vector< Real > &uold, const std::vector< Real > &zold)
void solve(ROL::Vector< Real > &c, ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Given , solve for .
Contains definitions of custom data types in ROL.
void applyInverseAdjointJacobian_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 of the adjoint of the partial constraint Jacobian at , , to the vector ...
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
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 apply_pde_jacobian_new(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, bool adjoint=false)
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.
void apply_pde_hessian(std::vector< Real > &hv, const std::vector< Real > &wold, const std::vector< Real > &vold, const std::vector< Real > &wnew, const std::vector< Real > &vnew)
void applyAdjointHessian_21(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the simulation-space derivative of the adjoint of the constraint optimization-space Jacobian at...
void compute_pde_jacobian(std::vector< Real > &dl, std::vector< Real > &d, std::vector< Real > &du, const std::vector< Real > &u)
Real dot(const std::vector< Real > &x, const std::vector< Real > &y)
Constraint_BurgersControl(int nx=128, int nt=100, Real T=1, Real nu=1.e-2, Real u0=0.0, Real u1=0.0, Real f=0.0)
void applyJacobian_1(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the partial constraint Jacobian at , , to the vector .
void hessVec_21(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
void apply_control_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, bool adjoint=false)
void hessVec_12(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
std::vector< Real > u_init_
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.
Real dot(const std::vector< Real > &x, const std::vector< Real > &y)
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 compute_residual(std::vector< Real > &r, const std::vector< Real > &u, const std::vector< Real > &z)
void scale(std::vector< Real > &u, const Real alpha=0.0)
Objective_BurgersControl(Real alpha=1.e-4, int nx=128, int nt=100, Real T=1.0)
void hessVec_11(ROL::Vector< Real > &hv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply Hessian approximation to vector.
void applyJacobian_2(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the partial constraint Jacobian at , , to the vector .
void linear_solve(std::vector< Real > &u, const std::vector< Real > &dl, const std::vector< Real > &d, const std::vector< Real > &du, const std::vector< Real > &r, const bool transpose=false)
void apply_mass(std::vector< Real > &Mu, const std::vector< Real > &u)
void applyAdjointHessian_22(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the optimization-space derivative of the adjoint of the constraint optimization-space Jacobian ...
virtual Real norm() const =0
Returns where .
Real compute_norm(const std::vector< Real > &r)
void apply_pde_jacobian(std::vector< Real > &jv, const std::vector< Real > &vold, const std::vector< Real > &uold, const std::vector< Real > &vnew, const std::vector< Real > unew, bool adjoint=false)
void update(std::vector< Real > &u, const std::vector< Real > &s, const Real alpha=1.0)
void applyAdjointJacobian_2(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the adjoint of the partial constraint Jacobian at , , to vector . This is the primary interface...
Defines the constraint operator interface for simulation-based optimization.
void value(ROL::Vector< Real > &c, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Evaluate the constraint operator at .
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)
void compute_residual(std::vector< Real > &r, const std::vector< Real > &uold, const std::vector< Real > &zold, const std::vector< Real > &unew, const std::vector< Real > &znew)