ROL
test_04.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
48 #include "ROL_Types.hpp"
49 #include "ROL_StdVector.hpp"
50 #include "ROL_BoundConstraint.hpp"
52 #include "ROL_Objective_SimOpt.hpp"
53 
54 #include "Teuchos_LAPACK.hpp"
55 
56 template<class Real>
58 
59 template<class Real>
61 
62 template<class Real>
64 
65 template<class Real>
67 
68 template<class Real>
69 class BurgersFEM {
70 private:
71  int nx_;
72  Real dx_;
73  Real nu_;
74  Real nl_;
75  Real u0_;
76  Real u1_;
77  Real f_;
78  Real cH1_;
79  Real cL2_;
80 
81 private:
82  void update(std::vector<Real> &u, const std::vector<Real> &s, const Real alpha=1.0) const {
83  for (unsigned i=0; i<u.size(); i++) {
84  u[i] += alpha*s[i];
85  }
86  }
87 
88  void axpy(std::vector<Real> &out, const Real a, const std::vector<Real> &x, const std::vector<Real> &y) const {
89  for (unsigned i=0; i < x.size(); i++) {
90  out[i] = a*x[i] + y[i];
91  }
92  }
93 
94  void scale(std::vector<Real> &u, const Real alpha=0.0) const {
95  for (unsigned i=0; i<u.size(); i++) {
96  u[i] *= alpha;
97  }
98  }
99 
100  void linear_solve(std::vector<Real> &u, std::vector<Real> &dl, std::vector<Real> &d, std::vector<Real> &du,
101  const std::vector<Real> &r, const bool transpose = false) const {
102  if ( r.size() == 1 ) {
103  u.resize(1,r[0]/d[0]);
104  }
105  else if ( r.size() == 2 ) {
106  u.resize(2,0.0);
107  Real det = d[0]*d[1] - dl[0]*du[0];
108  u[0] = (d[1]*r[0] - du[0]*r[1])/det;
109  u[1] = (d[0]*r[1] - dl[0]*r[0])/det;
110  }
111  else {
112  u.assign(r.begin(),r.end());
113  // Perform LDL factorization
114  Teuchos::LAPACK<int,Real> lp;
115  std::vector<Real> du2(r.size()-2,0.0);
116  std::vector<int> ipiv(r.size(),0);
117  int info;
118  int dim = r.size();
119  int ldb = r.size();
120  int nhrs = 1;
121  lp.GTTRF(dim,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&info);
122  char trans = 'N';
123  if ( transpose ) {
124  trans = 'T';
125  }
126  lp.GTTRS(trans,dim,nhrs,&dl[0],&d[0],&du[0],&du2[0],&ipiv[0],&u[0],ldb,&info);
127  }
128  }
129 
130 public:
131  BurgersFEM(int nx = 128, Real nl = 1.0, Real cH1 = 1.0, Real cL2 = 1.0)
132  : nx_(nx), dx_(1.0/((Real)nx+1.0)), nl_(nl), cH1_(cH1), cL2_(cL2) {
133  nu_ = 1.e-2;
134  f_ = 0.0;
135  u0_ = 1.0;
136  u1_ = 0.0;
137  }
138 
139  void set_problem_data(const Real nu, const Real f, const Real u0, const Real u1) {
140  nu_ = std::pow(10.0,nu-2.0);
141  f_ = 0.01*f;
142  u0_ = 1.0+0.001*u0;
143  u1_ = 0.001*u1;
144  }
145 
146  int num_dof(void) const {
147  return nx_;
148  }
149 
150  Real mesh_spacing(void) const {
151  return dx_;
152  }
153 
154  /***************************************************************************/
155  /*********************** L2 INNER PRODUCT FUNCTIONS ************************/
156  /***************************************************************************/
157  // Compute L2 inner product
158  Real compute_L2_dot(const std::vector<Real> &x, const std::vector<Real> &y) const {
159  Real ip = 0.0;
160  Real c = (((int)x.size()==nx_) ? 4.0 : 2.0);
161  for (unsigned i=0; i<x.size(); i++) {
162  if ( i == 0 ) {
163  ip += dx_/6.0*(c*x[i] + x[i+1])*y[i];
164  }
165  else if ( i == x.size()-1 ) {
166  ip += dx_/6.0*(x[i-1] + c*x[i])*y[i];
167  }
168  else {
169  ip += dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i];
170  }
171  }
172  return ip;
173  }
174 
175  // compute L2 norm
176  Real compute_L2_norm(const std::vector<Real> &r) const {
177  return std::sqrt(compute_L2_dot(r,r));
178  }
179 
180  // Apply L2 Reisz operator
181  void apply_mass(std::vector<Real> &Mu, const std::vector<Real> &u ) const {
182  Mu.resize(u.size(),0.0);
183  Real c = (((int)u.size()==nx_) ? 4.0 : 2.0);
184  for (unsigned i=0; i<u.size(); i++) {
185  if ( i == 0 ) {
186  Mu[i] = dx_/6.0*(c*u[i] + u[i+1]);
187  }
188  else if ( i == u.size()-1 ) {
189  Mu[i] = dx_/6.0*(u[i-1] + c*u[i]);
190  }
191  else {
192  Mu[i] = dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1]);
193  }
194  }
195  }
196 
197  // Apply L2 inverse Reisz operator
198  void apply_inverse_mass(std::vector<Real> &Mu, const std::vector<Real> &u) const {
199  unsigned nx = u.size();
200  // Build mass matrix
201  std::vector<Real> dl(nx-1,dx_/6.0);
202  std::vector<Real> d(nx,2.0*dx_/3.0);
203  std::vector<Real> du(nx-1,dx_/6.0);
204  if ( (int)nx != nx_ ) {
205  d[ 0] = dx_/3.0;
206  d[nx-1] = dx_/3.0;
207  }
208  linear_solve(Mu,dl,d,du,u);
209  }
210 
211  void test_inverse_mass(std::ostream &outStream = std::cout) {
212  // State Mass Matrix
213  std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
214  for (int i = 0; i < nx_; i++) {
215  u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
216  }
217  apply_mass(Mu,u);
218  apply_inverse_mass(iMMu,Mu);
219  axpy(diff,-1.0,iMMu,u);
220  Real error = compute_L2_norm(diff);
221  Real normu = compute_L2_norm(u);
222  outStream << "\nTest Inverse State Mass Matrix\n";
223  outStream << " ||u - inv(M)Mu|| = " << error << "\n";
224  outStream << " ||u|| = " << normu << "\n";
225  outStream << " Relative Error = " << error/normu << "\n";
226  outStream << "\n";
227  // Control Mass Matrix
228  u.resize(nx_+2,0.0); Mu.resize(nx_+2,0.0); iMMu.resize(nx_+2,0.0); diff.resize(nx_+2,0.0);
229  for (int i = 0; i < nx_+2; i++) {
230  u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
231  }
232  apply_mass(Mu,u);
233  apply_inverse_mass(iMMu,Mu);
234  axpy(diff,-1.0,iMMu,u);
235  error = compute_L2_norm(diff);
236  normu = compute_L2_norm(u);
237  outStream << "\nTest Inverse Control Mass Matrix\n";
238  outStream << " ||z - inv(M)Mz|| = " << error << "\n";
239  outStream << " ||z|| = " << normu << "\n";
240  outStream << " Relative Error = " << error/normu << "\n";
241  outStream << "\n";
242  }
243 
244  /***************************************************************************/
245  /*********************** H1 INNER PRODUCT FUNCTIONS ************************/
246  /***************************************************************************/
247  // Compute H1 inner product
248  Real compute_H1_dot(const std::vector<Real> &x, const std::vector<Real> &y) const {
249  Real ip = 0.0;
250  for (int i=0; i<nx_; i++) {
251  if ( i == 0 ) {
252  ip += cL2_*dx_/6.0*(4.0*x[i] + x[i+1])*y[i]; // Mass term
253  ip += cH1_*(2.0*x[i] - x[i+1])/dx_*y[i]; // Stiffness term
254  }
255  else if ( i == nx_-1 ) {
256  ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i])*y[i]; // Mass term
257  ip += cH1_*(2.0*x[i] - x[i-1])/dx_*y[i]; // Stiffness term
258  }
259  else {
260  ip += cL2_*dx_/6.0*(x[i-1] + 4.0*x[i] + x[i+1])*y[i]; // Mass term
261  ip += cH1_*(2.0*x[i] - x[i-1] - x[i+1])/dx_*y[i]; // Stiffness term
262  }
263  }
264  return ip;
265  }
266 
267  // compute H1 norm
268  Real compute_H1_norm(const std::vector<Real> &r) const {
269  return std::sqrt(compute_H1_dot(r,r));
270  }
271 
272  // Apply H2 Reisz operator
273  void apply_H1(std::vector<Real> &Mu, const std::vector<Real> &u ) const {
274  Mu.resize(nx_,0.0);
275  for (int i=0; i<nx_; i++) {
276  if ( i == 0 ) {
277  Mu[i] = cL2_*dx_/6.0*(4.0*u[i] + u[i+1])
278  + cH1_*(2.0*u[i] - u[i+1])/dx_;
279  }
280  else if ( i == nx_-1 ) {
281  Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i])
282  + cH1_*(2.0*u[i] - u[i-1])/dx_;
283  }
284  else {
285  Mu[i] = cL2_*dx_/6.0*(u[i-1] + 4.0*u[i] + u[i+1])
286  + cH1_*(2.0*u[i] - u[i-1] - u[i+1])/dx_;
287  }
288  }
289  }
290 
291  // Apply H1 inverse Reisz operator
292  void apply_inverse_H1(std::vector<Real> &Mu, const std::vector<Real> &u) const {
293  // Build mass matrix
294  std::vector<Real> dl(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
295  std::vector<Real> d(nx_,2.0*(cL2_*dx_/3.0 + cH1_/dx_));
296  std::vector<Real> du(nx_-1,cL2_*dx_/6.0 - cH1_/dx_);
297  linear_solve(Mu,dl,d,du,u);
298  }
299 
300  void test_inverse_H1(std::ostream &outStream = std::cout) {
301  std::vector<Real> u(nx_,0.0), Mu(nx_,0.0), iMMu(nx_,0.0), diff(nx_,0.0);
302  for (int i = 0; i < nx_; i++) {
303  u[i] = 2.0*(Real)rand()/(Real)RAND_MAX - 1.0;
304  }
305  apply_H1(Mu,u);
306  apply_inverse_H1(iMMu,Mu);
307  axpy(diff,-1.0,iMMu,u);
308  Real error = compute_H1_norm(diff);
309  Real normu = compute_H1_norm(u);
310  outStream << "\nTest Inverse State H1 Matrix\n";
311  outStream << " ||u - inv(M)Mu|| = " << error << "\n";
312  outStream << " ||u|| = " << normu << "\n";
313  outStream << " Relative Error = " << error/normu << "\n";
314  outStream << "\n";
315  }
316 
317  /***************************************************************************/
318  /*********************** PDE RESIDUAL AND SOLVE ****************************/
319  /***************************************************************************/
320  // Compute current PDE residual
321  void compute_residual(std::vector<Real> &r, const std::vector<Real> &u,
322  const std::vector<Real> &z) const {
323  r.clear();
324  r.resize(nx_,0.0);
325  for (int i=0; i<nx_; i++) {
326  // Contribution from stiffness term
327  if ( i==0 ) {
328  r[i] = nu_/dx_*(2.0*u[i]-u[i+1]);
329  }
330  else if (i==nx_-1) {
331  r[i] = nu_/dx_*(2.0*u[i]-u[i-1]);
332  }
333  else {
334  r[i] = nu_/dx_*(2.0*u[i]-u[i-1]-u[i+1]);
335  }
336  // Contribution from nonlinear term
337  if (i<nx_-1){
338  r[i] += nl_*u[i+1]*(u[i]+u[i+1])/6.0;
339  }
340  if (i>0) {
341  r[i] -= nl_*u[i-1]*(u[i-1]+u[i])/6.0;
342  }
343  // Contribution from control
344  r[i] -= dx_/6.0*(z[i]+4.0*z[i+1]+z[i+2]);
345  // Contribution from right-hand side
346  r[i] -= dx_*f_;
347  }
348  // Contribution from Dirichlet boundary terms
349  r[0] -= nl_*(u0_*u[ 0]/6.0 + u0_*u0_/6.0) + nu_*u0_/dx_;
350  r[nx_-1] += nl_*(u1_*u[nx_-1]/6.0 + u1_*u1_/6.0) - nu_*u1_/dx_;
351  }
352 
353  /***************************************************************************/
354  /*********************** PDE JACOBIAN FUNCTIONS ****************************/
355  /***************************************************************************/
356  // Build PDE Jacobian trigiagonal matrix
357  void compute_pde_jacobian(std::vector<Real> &dl, // Lower diagonal
358  std::vector<Real> &d, // Diagonal
359  std::vector<Real> &du, // Upper diagonal
360  const std::vector<Real> &u) const { // State variable
361  // Get Diagonal and Off-Diagonal Entries of linear PDE Jacobian
362  d.clear();
363  d.resize(nx_,nu_*2.0/dx_);
364  dl.clear();
365  dl.resize(nx_-1,-nu_/dx_);
366  du.clear();
367  du.resize(nx_-1,-nu_/dx_);
368  // Contribution from nonlinearity
369  for (int i=0; i<nx_; i++) {
370  if (i<nx_-1) {
371  dl[i] += nl_*(-2.0*u[i]-u[i+1])/6.0;
372  d[i] += nl_*u[i+1]/6.0;
373  }
374  if (i>0) {
375  d[i] -= nl_*u[i-1]/6.0;
376  du[i-1] += nl_*(u[i-1]+2.0*u[i])/6.0;
377  }
378  }
379  // Contribution from Dirichlet boundary conditions
380  d[ 0] -= nl_*u0_/6.0;
381  d[nx_-1] += nl_*u1_/6.0;
382  }
383 
384  // Apply PDE Jacobian to a vector
385  void apply_pde_jacobian(std::vector<Real> &jv,
386  const std::vector<Real> &v,
387  const std::vector<Real> &u,
388  const std::vector<Real> &z) const {
389  // Fill jv
390  for (int i = 0; i < nx_; i++) {
391  jv[i] = nu_/dx_*2.0*v[i];
392  if ( i > 0 ) {
393  jv[i] += -nu_/dx_*v[i-1]-nl_*(u[i-1]/6.0*v[i]+(u[i]+2.0*u[i-1])/6.0*v[i-1]);
394  }
395  if ( i < nx_-1 ) {
396  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  }
398  }
399  jv[ 0] -= nl_*u0_/6.0*v[0];
400  jv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
401  }
402 
403  // Apply inverse PDE Jacobian to a vector
404  void apply_inverse_pde_jacobian(std::vector<Real> &ijv,
405  const std::vector<Real> &v,
406  const std::vector<Real> &u,
407  const std::vector<Real> &z) const {
408  // Get PDE Jacobian
409  std::vector<Real> d(nx_,0.0);
410  std::vector<Real> dl(nx_-1,0.0);
411  std::vector<Real> du(nx_-1,0.0);
412  compute_pde_jacobian(dl,d,du,u);
413  // Solve solve state sensitivity system at current time step
414  linear_solve(ijv,dl,d,du,v);
415  }
416 
417  // Apply adjoint PDE Jacobian to a vector
418  void apply_adjoint_pde_jacobian(std::vector<Real> &ajv,
419  const std::vector<Real> &v,
420  const std::vector<Real> &u,
421  const std::vector<Real> &z) const {
422  // Fill jvp
423  for (int i = 0; i < nx_; i++) {
424  ajv[i] = nu_/dx_*2.0*v[i];
425  if ( i > 0 ) {
426  ajv[i] += -nu_/dx_*v[i-1]-nl_*(u[i-1]/6.0*v[i]
427  -(u[i-1]+2.0*u[i])/6.0*v[i-1]);
428  }
429  if ( i < nx_-1 ) {
430  ajv[i] += -nu_/dx_*v[i+1]+nl_*(u[i+1]/6.0*v[i]
431  -(u[i+1]+2.0*u[i])/6.0*v[i+1]);
432  }
433  }
434  ajv[ 0] -= nl_*u0_/6.0*v[0];
435  ajv[nx_-1] += nl_*u1_/6.0*v[nx_-1];
436  }
437 
438  // Apply inverse adjoint PDE Jacobian to a vector
439  void apply_inverse_adjoint_pde_jacobian(std::vector<Real> &iajv,
440  const std::vector<Real> &v,
441  const std::vector<Real> &u,
442  const std::vector<Real> &z) const {
443  // Get PDE Jacobian
444  std::vector<Real> d(nx_,0.0);
445  std::vector<Real> du(nx_-1,0.0);
446  std::vector<Real> dl(nx_-1,0.0);
447  compute_pde_jacobian(dl,d,du,u);
448  // Solve solve adjoint system at current time step
449  linear_solve(iajv,dl,d,du,v,true);
450  }
451 
452  /***************************************************************************/
453  /*********************** CONTROL JACOBIAN FUNCTIONS ************************/
454  /***************************************************************************/
455  // Apply control Jacobian to a vector
456  void apply_control_jacobian(std::vector<Real> &jv,
457  const std::vector<Real> &v,
458  const std::vector<Real> &u,
459  const std::vector<Real> &z) const {
460  for (int i=0; i<nx_; i++) {
461  // Contribution from control
462  jv[i] = -dx_/6.0*(v[i]+4.0*v[i+1]+v[i+2]);
463  }
464  }
465 
466  // Apply adjoint control Jacobian to a vector
467  void apply_adjoint_control_jacobian(std::vector<Real> &jv,
468  const std::vector<Real> &v,
469  const std::vector<Real> &u,
470  const std::vector<Real> &z) const {
471  for (int i=0; i<nx_+2; i++) {
472  if ( i == 0 ) {
473  jv[i] = -dx_/6.0*v[i];
474  }
475  else if ( i == 1 ) {
476  jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i]);
477  }
478  else if ( i == nx_ ) {
479  jv[i] = -dx_/6.0*(4.0*v[i-1]+v[i-2]);
480  }
481  else if ( i == nx_+1 ) {
482  jv[i] = -dx_/6.0*v[i-2];
483  }
484  else {
485  jv[i] = -dx_/6.0*(v[i-2]+4.0*v[i-1]+v[i]);
486  }
487  }
488  }
489 
490  /***************************************************************************/
491  /*********************** AJDOINT HESSIANS **********************************/
492  /***************************************************************************/
493  void apply_adjoint_pde_hessian(std::vector<Real> &ahwv,
494  const std::vector<Real> &w,
495  const std::vector<Real> &v,
496  const std::vector<Real> &u,
497  const std::vector<Real> &z) const {
498  for (int i=0; i<nx_; i++) {
499  // Contribution from nonlinear term
500  ahwv[i] = 0.0;
501  if (i<nx_-1){
502  ahwv[i] += (w[i]*v[i+1] - w[i+1]*(2.0*v[i]+v[i+1]))/6.0;
503  }
504  if (i>0) {
505  ahwv[i] += (w[i-1]*(v[i-1]+2.0*v[i]) - w[i]*v[i-1])/6.0;
506  }
507  }
508  //ahwv.assign(u.size(),0.0);
509  }
510  void apply_adjoint_pde_control_hessian(std::vector<Real> &ahwv,
511  const std::vector<Real> &w,
512  const std::vector<Real> &v,
513  const std::vector<Real> &u,
514  const std::vector<Real> &z) {
515  ahwv.assign(u.size(),0.0);
516  }
517  void apply_adjoint_control_pde_hessian(std::vector<Real> &ahwv,
518  const std::vector<Real> &w,
519  const std::vector<Real> &v,
520  const std::vector<Real> &u,
521  const std::vector<Real> &z) {
522  ahwv.assign(z.size(),0.0);
523  }
524  void apply_adjoint_control_hessian(std::vector<Real> &ahwv,
525  const std::vector<Real> &w,
526  const std::vector<Real> &v,
527  const std::vector<Real> &u,
528  const std::vector<Real> &z) {
529  ahwv.assign(z.size(),0.0);
530  }
531 };
532 
533 template<class Real>
534 class L2VectorPrimal : public ROL::StdVector<Real> {
535 private:
536  ROL::Ptr<BurgersFEM<Real>> fem_;
537  mutable ROL::Ptr<L2VectorDual<Real>> dual_vec_;
538  mutable bool isDualInitialized_;
539 
540 public:
541  L2VectorPrimal(const ROL::Ptr<std::vector<Real>> & vec,
542  const ROL::Ptr<BurgersFEM<Real>> &fem)
543  : ROL::StdVector<Real>(vec),
544  fem_(fem), dual_vec_(ROL::nullPtr), isDualInitialized_(false) {}
545 
546  Real dot( const ROL::Vector<Real> &x ) const override {
547  const L2VectorPrimal & ex = dynamic_cast<const L2VectorPrimal&>(x);
548  const std::vector<Real>& xval = *ex.getVector();
549  const std::vector<Real>& yval = *ROL::StdVector<Real>::getVector();
550  return fem_->compute_L2_dot(xval,yval);
551  }
552 
553  ROL::Ptr<ROL::Vector<Real>> clone() const override {
554  size_t dimension = ROL::StdVector<Real>::getVector()->size();
555  return ROL::makePtr<L2VectorPrimal>(
556  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
557  }
558 
559  const ROL::Vector<Real>& dual() const override {
560  size_t dimension = ROL::StdVector<Real>::getVector()->size();
561  if ( !isDualInitialized_ ) {
562  dual_vec_ = ROL::makePtr<L2VectorDual<Real>>(
563  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
564  isDualInitialized_ = true;
565  }
566  fem_->apply_mass(*ROL::constPtrCast<std::vector<Real>>(dual_vec_->getVector()),
568  return *dual_vec_;
569  }
570 };
571 
572 template<class Real>
573 class L2VectorDual : public ROL::StdVector<Real> {
574 private:
575  ROL::Ptr<BurgersFEM<Real>> fem_;
576  mutable ROL::Ptr<L2VectorPrimal<Real>> dual_vec_;
577  mutable bool isDualInitialized_;
578 
579 public:
580  L2VectorDual(const ROL::Ptr<std::vector<Real>> & vec,
581  const ROL::Ptr<BurgersFEM<Real>> &fem)
582  : ROL::StdVector<Real>(vec),
583  fem_(fem), dual_vec_(ROL::nullPtr), isDualInitialized_(false) {}
584 
585  Real dot( const ROL::Vector<Real> &x ) const override {
586  const L2VectorDual & ex = dynamic_cast<const L2VectorDual&>(x);
587  const std::vector<Real>& xval = *ex.getVector();
588  const std::vector<Real>& yval = *ROL::StdVector<Real>::getVector();
589  size_t dimension = yval.size();
590  std::vector<Real> Mx(dimension,Real(0));
591  fem_->apply_inverse_mass(Mx,xval);
592  Real val(0);
593  for (size_t i = 0; i < dimension; i++) {
594  val += Mx[i]*yval[i];
595  }
596  return val;
597  }
598 
599  ROL::Ptr<ROL::Vector<Real>> clone() const override {
600  size_t dimension = ROL::StdVector<Real>::getVector()->size();
601  return ROL::makePtr<L2VectorDual>(
602  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
603  }
604 
605  const ROL::Vector<Real>& dual() const override {
606  size_t dimension = ROL::StdVector<Real>::getVector()->size();
607  if ( !isDualInitialized_ ) {
608  dual_vec_ = ROL::makePtr<L2VectorPrimal<Real>>(
609  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
610  isDualInitialized_ = true;
611  }
612  fem_->apply_inverse_mass(*ROL::constPtrCast<std::vector<Real>>(dual_vec_->getVector()),
614  return *dual_vec_;
615  }
616 };
617 
618 template<class Real>
619 class H1VectorPrimal : public ROL::StdVector<Real> {
620 private:
621  ROL::Ptr<BurgersFEM<Real>> fem_;
622  mutable ROL::Ptr<H1VectorDual<Real>> dual_vec_;
623  mutable bool isDualInitialized_;
624 
625 public:
626  H1VectorPrimal(const ROL::Ptr<std::vector<Real>> & vec,
627  const ROL::Ptr<BurgersFEM<Real>> &fem)
628  : ROL::StdVector<Real>(vec),
629  fem_(fem), dual_vec_(ROL::nullPtr), isDualInitialized_(false) {}
630 
631  Real dot( const ROL::Vector<Real> &x ) const override {
632  const H1VectorPrimal & ex = dynamic_cast<const H1VectorPrimal&>(x);
633  const std::vector<Real>& xval = *ex.getVector();
634  const std::vector<Real>& yval = *ROL::StdVector<Real>::getVector();
635  return fem_->compute_H1_dot(xval,yval);
636  }
637 
638  ROL::Ptr<ROL::Vector<Real>> clone() const override {
639  size_t dimension = ROL::StdVector<Real>::getVector()->size();
640  return ROL::makePtr<H1VectorPrimal>(
641  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
642  }
643 
644  const ROL::Vector<Real>& dual() const override {
645  size_t dimension = ROL::StdVector<Real>::getVector()->size();
646  if ( !isDualInitialized_ ) {
647  dual_vec_ = ROL::makePtr<H1VectorDual<Real>>(
648  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
649  isDualInitialized_ = true;
650  }
651  fem_->apply_H1(*ROL::constPtrCast<std::vector<Real>>(dual_vec_->getVector()),
653  return *dual_vec_;
654  }
655 };
656 
657 template<class Real>
658 class H1VectorDual : public ROL::StdVector<Real> {
659 private:
660  ROL::Ptr<BurgersFEM<Real>> fem_;
661  mutable ROL::Ptr<H1VectorPrimal<Real>> dual_vec_;
662  mutable bool isDualInitialized_;
663 
664 public:
665  H1VectorDual(const ROL::Ptr<std::vector<Real>> & vec,
666  const ROL::Ptr<BurgersFEM<Real>> &fem)
667  : ROL::StdVector<Real>(vec),
668  fem_(fem), dual_vec_(ROL::nullPtr), isDualInitialized_(false) {}
669 
670  Real dot( const ROL::Vector<Real> &x ) const override {
671  const H1VectorDual & ex = dynamic_cast<const H1VectorDual&>(x);
672  const std::vector<Real>& xval = *ex.getVector();
673  const std::vector<Real>& yval = *ROL::StdVector<Real>::getVector();
674  size_t dimension = yval.size();
675  std::vector<Real> Mx(dimension,0.0);
676  fem_->apply_inverse_H1(Mx,xval);
677  Real val(0);
678  for (size_t i = 0; i < dimension; i++) {
679  val += Mx[i]*yval[i];
680  }
681  return val;
682  }
683 
684  ROL::Ptr<ROL::Vector<Real>> clone() const override {
685  size_t dimension = ROL::StdVector<Real>::getVector()->size();
686  return ROL::makePtr<H1VectorDual>(
687  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
688  }
689 
690  const ROL::Vector<Real>& dual() const override {
691  size_t dimension = ROL::StdVector<Real>::getVector()->size();
692  if ( !isDualInitialized_ ) {
693  dual_vec_ = ROL::makePtr<H1VectorPrimal<Real>>(
694  ROL::makePtr<std::vector<Real>>(dimension,Real(0)),fem_);
695  isDualInitialized_ = true;
696  }
697  fem_->apply_inverse_H1(*ROL::constPtrCast<std::vector<Real>>(dual_vec_->getVector()),
699  return *dual_vec_;
700  }
701 };
702 
703 template<class Real>
705 private:
706 
709 
712 
715 
716  ROL::Ptr<BurgersFEM<Real> > fem_;
718 
719 public:
721  const bool useHessian = true)
722  : fem_(fem), useHessian_(useHessian) {}
723 
725  const ROL::Vector<Real> &z, Real &tol) {
726  ROL::Ptr<std::vector<Real> > cp =
727  dynamic_cast<PrimalConstraintVector&>(c).getVector();
728  ROL::Ptr<const std::vector<Real> > up =
729  dynamic_cast<const PrimalStateVector&>(u).getVector();
730  ROL::Ptr<const std::vector<Real> > zp =
731  dynamic_cast<const PrimalControlVector&>(z).getVector();
732 
733  fem_->compute_residual(*cp,*up,*zp);
734  }
735 
737  const ROL::Vector<Real> &z, Real &tol) {
738  ROL::Ptr<std::vector<Real> > jvp =
739  dynamic_cast<PrimalConstraintVector&>(jv).getVector();
740  ROL::Ptr<const std::vector<Real> > vp =
741  dynamic_cast<const PrimalStateVector&>(v).getVector();
742  ROL::Ptr<const std::vector<Real> > up =
743  dynamic_cast<const PrimalStateVector&>(u).getVector();
744  ROL::Ptr<const std::vector<Real> > zp =
745  dynamic_cast<const PrimalControlVector&>(z).getVector();
746 
747  fem_->apply_pde_jacobian(*jvp,*vp,*up,*zp);
748  }
749 
751  const ROL::Vector<Real> &z, Real &tol) {
752  ROL::Ptr<std::vector<Real> > jvp =
753  dynamic_cast<PrimalConstraintVector&>(jv).getVector();
754  ROL::Ptr<const std::vector<Real> > vp =
755  dynamic_cast<const PrimalControlVector&>(v).getVector();
756  ROL::Ptr<const std::vector<Real> > up =
757  dynamic_cast<const PrimalStateVector&>(u).getVector();
758  ROL::Ptr<const std::vector<Real> > zp =
759  dynamic_cast<const PrimalControlVector&>(z).getVector();
760 
761  fem_->apply_control_jacobian(*jvp,*vp,*up,*zp);
762  }
763 
765  const ROL::Vector<Real> &z, Real &tol) {
766  ROL::Ptr<std::vector<Real> > ijvp =
767  dynamic_cast<PrimalStateVector&>(ijv).getVector();
768  ROL::Ptr<const std::vector<Real> > vp =
769  dynamic_cast<const PrimalConstraintVector&>(v).getVector();
770  ROL::Ptr<const std::vector<Real> > up =
771  dynamic_cast<const PrimalStateVector&>(u).getVector();
772  ROL::Ptr<const std::vector<Real> > zp =
773  dynamic_cast<const PrimalControlVector&>(z).getVector();
774 
775  fem_->apply_inverse_pde_jacobian(*ijvp,*vp,*up,*zp);
776  }
777 
779  const ROL::Vector<Real> &z, Real &tol) {
780  ROL::Ptr<std::vector<Real> > jvp =
781  dynamic_cast<DualStateVector&>(ajv).getVector();
782  ROL::Ptr<const std::vector<Real> > vp =
783  dynamic_cast<const DualConstraintVector&>(v).getVector();
784  ROL::Ptr<const std::vector<Real> > up =
785  dynamic_cast<const PrimalStateVector&>(u).getVector();
786  ROL::Ptr<const std::vector<Real> > zp =
787  dynamic_cast<const PrimalControlVector&>(z).getVector();
788 
789  fem_->apply_adjoint_pde_jacobian(*jvp,*vp,*up,*zp);
790  }
791 
793  const ROL::Vector<Real> &z, Real &tol) {
794  ROL::Ptr<std::vector<Real> > jvp =
795  dynamic_cast<DualControlVector&>(jv).getVector();
796  ROL::Ptr<const std::vector<Real> > vp =
797  dynamic_cast<const DualConstraintVector&>(v).getVector();
798  ROL::Ptr<const std::vector<Real> > up =
799  dynamic_cast<const PrimalStateVector&>(u).getVector();
800  ROL::Ptr<const std::vector<Real> > zp =
801  dynamic_cast<const PrimalControlVector&>(z).getVector();
802 
803  fem_->apply_adjoint_control_jacobian(*jvp,*vp,*up,*zp);
804  }
805 
807  const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) {
808  ROL::Ptr<std::vector<Real> > iajvp =
809  dynamic_cast<DualConstraintVector&>(iajv).getVector();
810  ROL::Ptr<const std::vector<Real> > vp =
811  dynamic_cast<const DualStateVector&>(v).getVector();
812  ROL::Ptr<const std::vector<Real> > up =
813  dynamic_cast<const PrimalStateVector&>(u).getVector();
814  ROL::Ptr<const std::vector<Real> > zp =
815  dynamic_cast<const PrimalControlVector&>(z).getVector();
816 
817  fem_->apply_inverse_adjoint_pde_jacobian(*iajvp,*vp,*up,*zp);
818  }
819 
821  const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) {
822  if ( useHessian_ ) {
823  ROL::Ptr<std::vector<Real> > ahwvp =
824  dynamic_cast<DualStateVector&>(ahwv).getVector();
825  ROL::Ptr<const std::vector<Real> > wp =
826  dynamic_cast<const DualConstraintVector&>(w).getVector();
827  ROL::Ptr<const std::vector<Real> > vp =
828  dynamic_cast<const PrimalStateVector&>(v).getVector();
829  ROL::Ptr<const std::vector<Real> > up =
830  dynamic_cast<const PrimalStateVector&>(u).getVector();
831  ROL::Ptr<const std::vector<Real> > zp =
832  dynamic_cast<const PrimalControlVector&>(z).getVector();
833 
834  fem_->apply_adjoint_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
835  }
836  else {
837  ahwv.zero();
838  }
839  }
840 
842  const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) {
843  if ( useHessian_ ) {
844  ROL::Ptr<std::vector<Real> > ahwvp =
845  dynamic_cast<DualControlVector&>(ahwv).getVector();
846  ROL::Ptr<const std::vector<Real> > wp =
847  dynamic_cast<const DualConstraintVector&>(w).getVector();
848  ROL::Ptr<const std::vector<Real> > vp =
849  dynamic_cast<const PrimalStateVector&>(v).getVector();
850  ROL::Ptr<const std::vector<Real> > up =
851  dynamic_cast<const PrimalStateVector&>(u).getVector();
852  ROL::Ptr<const std::vector<Real> > zp =
853  dynamic_cast<const PrimalControlVector&>(z).getVector();
854 
855  fem_->apply_adjoint_control_pde_hessian(*ahwvp,*wp,*vp,*up,*zp);
856  }
857  else {
858  ahwv.zero();
859  }
860  }
862  const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) {
863  if ( useHessian_ ) {
864  ROL::Ptr<std::vector<Real> > ahwvp =
865  dynamic_cast<DualStateVector&>(ahwv).getVector();
866  ROL::Ptr<const std::vector<Real> > wp =
867  dynamic_cast<const DualConstraintVector&>(w).getVector();
868  ROL::Ptr<const std::vector<Real> > vp =
869  dynamic_cast<const PrimalControlVector&>(v).getVector();
870  ROL::Ptr<const std::vector<Real> > up =
871  dynamic_cast<const PrimalStateVector&>(u).getVector();
872  ROL::Ptr<const std::vector<Real> > zp =
873  dynamic_cast<const PrimalControlVector&>(z).getVector();
874 
875  fem_->apply_adjoint_pde_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
876  }
877  else {
878  ahwv.zero();
879  }
880  }
882  const ROL::Vector<Real> &u, const ROL::Vector<Real> &z, Real &tol) {
883  if ( useHessian_ ) {
884  ROL::Ptr<std::vector<Real> > ahwvp =
885  dynamic_cast<DualControlVector&>(ahwv).getVector();
886  ROL::Ptr<const std::vector<Real> > wp =
887  dynamic_cast<const DualConstraintVector&>(w).getVector();
888  ROL::Ptr<const std::vector<Real> > vp =
889  dynamic_cast<const PrimalControlVector&>(v).getVector();
890  ROL::Ptr<const std::vector<Real> > up =
891  dynamic_cast<const PrimalStateVector&>(u).getVector();
892  ROL::Ptr<const std::vector<Real> > zp =
893  dynamic_cast<const PrimalControlVector&>(z).getVector();
894 
895  fem_->apply_adjoint_control_hessian(*ahwvp,*wp,*vp,*up,*zp);
896  }
897  else {
898  ahwv.zero();
899  }
900  }
901 };
H1VectorPrimal< Real > DualConstraintVector
Definition: test_04.hpp:714
BurgersFEM(int nx=128, Real nl=1.0, Real cH1=1.0, Real cL2=1.0)
Definition: test_04.hpp:131
Real dx_
Definition: test_04.hpp:72
Real compute_H1_dot(const std::vector< Real > &x, const std::vector< Real > &y) const
Definition: test_04.hpp:248
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...
Definition: test_04.hpp:778
Real cL2_
Definition: test_04.hpp:79
void apply_mass(std::vector< Real > &Mu, const std::vector< Real > &u) const
Definition: test_04.hpp:181
void axpy(std::vector< Real > &out, const Real a, const std::vector< Real > &x, const std::vector< Real > &y) const
Definition: test_04.hpp:88
ROL::Ptr< ROL::Vector< Real > > clone() const override
Clone to make a new (uninitialized) vector.
Definition: test_04.hpp:638
Real dot(const ROL::Vector< Real > &x) const override
Compute where .
Definition: test_04.hpp:670
bool isDualInitialized_
Definition: test_04.hpp:662
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)
Definition: test_04.hpp:510
const ROL::Vector< Real > & dual() const override
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: test_04.hpp:559
int dimension() const
Return dimension of the vector space.
Definition: example_04.hpp:592
ROL::Ptr< L2VectorDual< Real > > dual_vec_
Definition: test_04.hpp:537
StdVector(const Ptr< std::vector< Real >> &std_vec)
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...
Definition: test_04.hpp:841
Constraint_BurgersControl(const ROL::Ptr< BurgersFEM< Real > > &fem, const bool useHessian=true)
Definition: test_04.hpp:720
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
Definition: test_04.hpp:493
ROL::Ptr< BurgersFEM< Real > > fem_
Definition: test_04.hpp:660
bool isDualInitialized_
Definition: test_04.hpp:577
Real u0_
Definition: test_04.hpp:75
Contains definitions of custom data types in ROL.
Ptr< const std::vector< Element > > getVector() const
void applyAdjointHessian_11(ROL::Vector< Real > &ahwv, const ROL::Vector< Real > &w, const ROL::Vector< Real > &v, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Apply the simulation-space derivative of the adjoint of the constraint simulation-space Jacobian at ...
Definition: test_04.hpp:820
ROL::Ptr< const std::vector< Real > > getVector() const
Definition: example_04.hpp:577
ROL::Ptr< BurgersFEM< Real > > fem_
Definition: test_04.hpp:621
Real compute_H1_norm(const std::vector< Real > &r) const
Definition: test_04.hpp:268
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 ...
Definition: test_04.hpp:806
const ROL::Vector< Real > & dual() const override
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: test_04.hpp:690
ROL::Ptr< ROL::Vector< Real > > clone() const override
Clone to make a new (uninitialized) vector.
Definition: test_04.hpp:553
bool isDualInitialized_
Definition: test_04.hpp:538
virtual void zero()
Set to zero vector.
Definition: ROL_Vector.hpp:167
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
H1VectorDual< Real > PrimalConstraintVector
Definition: test_04.hpp:713
L2VectorPrimal(const ROL::Ptr< std::vector< Real >> &vec, const ROL::Ptr< BurgersFEM< Real >> &fem)
Definition: test_04.hpp:541
Real dot(const ROL::Vector< Real > &x) const override
Compute where .
Definition: test_04.hpp:631
int num_dof(void) const
Definition: test_04.hpp:146
ROL::Ptr< ROL::Vector< Real > > clone() const override
Clone to make a new (uninitialized) vector.
Definition: test_04.hpp:599
H1VectorPrimal< Real > PrimalStateVector
Definition: test_04.hpp:707
Real mesh_spacing(void) const
Definition: test_04.hpp:150
int dimension() const
Return dimension of the vector space.
Definition: example_04.hpp:771
void test_inverse_mass(std::ostream &outStream=std::cout)
Definition: test_04.hpp:211
void apply_pde_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
Definition: test_04.hpp:385
H1VectorDual(const ROL::Ptr< std::vector< Real >> &vec, const ROL::Ptr< BurgersFEM< Real >> &fem)
Definition: test_04.hpp:665
ROL::Ptr< BurgersFEM< Real > > fem_
Definition: test_04.hpp:716
Real nl_
Definition: test_04.hpp:74
Real cH1_
Definition: test_04.hpp:78
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...
Definition: test_04.hpp:861
Real u1_
Definition: test_04.hpp:76
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
ROL::Ptr< const std::vector< Real > > getVector() const
Definition: example_04.hpp:756
ROL::Ptr< const std::vector< Real > > getVector() const
Definition: example_04.hpp:670
void compute_pde_jacobian(std::vector< Real > &dl, std::vector< Real > &d, std::vector< Real > &du, const std::vector< Real > &u) const
Definition: test_04.hpp:357
H1VectorDual< Real > DualStateVector
Definition: test_04.hpp:708
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 .
Definition: test_04.hpp:736
Real compute_L2_dot(const std::vector< Real > &x, const std::vector< Real > &y) const
Definition: test_04.hpp:158
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
Definition: test_04.hpp:100
L2VectorPrimal< Real > PrimalControlVector
Definition: test_04.hpp:710
void apply_inverse_mass(std::vector< Real > &Mu, const std::vector< Real > &u) const
Definition: test_04.hpp:198
L2VectorDual(const ROL::Ptr< std::vector< Real >> &vec, const ROL::Ptr< BurgersFEM< Real >> &fem)
Definition: test_04.hpp:580
ROL::Ptr< BurgersFEM< Real > > fem_
Definition: test_04.hpp:536
ROL::Ptr< const std::vector< Real > > getVector() const
Definition: example_04.hpp:849
ROL::Ptr< BurgersFEM< Real > > fem_
Definition: test_04.hpp:575
void update(std::vector< Real > &u, const std::vector< Real > &s, const Real alpha=1.0) const
Definition: test_04.hpp:82
const ROL::Vector< Real > & dual() const override
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: test_04.hpp:605
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)
Definition: test_04.hpp:524
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 .
Definition: test_04.hpp:764
void compute_residual(std::vector< Real > &r, const std::vector< Real > &u, const std::vector< Real > &z) const
Definition: test_04.hpp:321
Real nu_
Definition: test_04.hpp:73
void set_problem_data(const Real nu, const Real f, const Real u0, const Real u1)
Definition: test_04.hpp:139
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 .
Definition: test_04.hpp:750
void apply_control_jacobian(std::vector< Real > &jv, const std::vector< Real > &v, const std::vector< Real > &u, const std::vector< Real > &z) const
Definition: test_04.hpp:456
Real dot(const ROL::Vector< Real > &x) const override
Compute where .
Definition: test_04.hpp:585
void test_inverse_H1(std::ostream &outStream=std::cout)
Definition: test_04.hpp:300
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
Definition: test_04.hpp:467
H1VectorPrimal(const ROL::Ptr< std::vector< Real >> &vec, const ROL::Ptr< BurgersFEM< Real >> &fem)
Definition: test_04.hpp:626
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
Definition: test_04.hpp:404
L2VectorDual< Real > DualControlVector
Definition: test_04.hpp:711
Real f_
Definition: test_04.hpp:77
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 ...
Definition: test_04.hpp:881
void apply_H1(std::vector< Real > &Mu, const std::vector< Real > &u) const
Definition: test_04.hpp:273
void apply_inverse_H1(std::vector< Real > &Mu, const std::vector< Real > &u) const
Definition: test_04.hpp:292
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
Definition: test_04.hpp:418
ROL::Ptr< ROL::Vector< Real > > clone() const override
Clone to make a new (uninitialized) vector.
Definition: test_04.hpp:684
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
Definition: test_04.hpp:439
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)
Definition: test_04.hpp:517
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...
Definition: test_04.hpp:792
int dimension() const
Return dimension of the vector space.
Definition: example_04.hpp:864
Defines the constraint operator interface for simulation-based optimization.
ROL::Ptr< H1VectorPrimal< Real > > dual_vec_
Definition: test_04.hpp:661
void value(ROL::Vector< Real > &c, const ROL::Vector< Real > &u, const ROL::Vector< Real > &z, Real &tol)
Evaluate the constraint operator at .
Definition: test_04.hpp:724
void scale(std::vector< Real > &u, const Real alpha=0.0) const
Definition: test_04.hpp:94
bool isDualInitialized_
Definition: test_04.hpp:623
constexpr auto dim
const ROL::Vector< Real > & dual() const override
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: test_04.hpp:644
ROL::Ptr< H1VectorDual< Real > > dual_vec_
Definition: test_04.hpp:622
Real dot(const ROL::Vector< Real > &x) const override
Compute where .
Definition: test_04.hpp:546
int dimension() const
Return dimension of the vector space.
Definition: example_04.hpp:685
Real compute_L2_norm(const std::vector< Real > &r) const
Definition: test_04.hpp:176
ROL::Ptr< L2VectorPrimal< Real > > dual_vec_
Definition: test_04.hpp:576