| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// Rapid Optimization Library (ROL) Package |
| 4 |
// |
| 5 |
// Copyright 2014 NTESS and the ROL contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
/*! \file obj.hpp |
| 11 |
\brief Provides the interface for local (cell-based) objective function computations. |
| 12 |
*/ |
| 13 |
|
| 14 |
#ifndef PDEOPT_QOI_DYNAMIC_NAVIERSTOKES_HPP |
| 15 |
#define PDEOPT_QOI_DYNAMIC_NAVIERSTOKES_HPP |
| 16 |
|
| 17 |
#include "../../TOOLS/qoi.hpp" |
| 18 |
#include "pde_navier-stokes.hpp" |
| 19 |
|
| 20 |
template <class Real> |
| 21 |
class QoI_Vorticity_NavierStokes : public QoI<Real> { |
| 22 |
private: |
| 23 |
const ROL::Ptr<FE<Real>> feVel_; |
| 24 |
const ROL::Ptr<FE<Real>> fePrs_; |
| 25 |
const ROL::Ptr<FieldHelper<Real>> fieldHelper_; |
| 26 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weight_; |
| 27 |
|
| 28 |
const Real eps_; |
| 29 |
|
| 30 |
Real weightFunc(const std::vector<Real> & x) const { |
| 31 |
return static_cast<Real>(1); |
| 32 |
} |
| 33 |
|
| 34 |
public: |
| 35 |
QoI_Vorticity_NavierStokes(const ROL::Ptr<FE<Real>> &feVel, |
| 36 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 37 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) |
| 38 |
: feVel_(feVel), fePrs_(fePrs), fieldHelper_(fieldHelper), eps_(std::sqrt(ROL::ROL_EPSILON<Real>())) { |
| 39 |
int c = feVel_->cubPts()->dimension(0); |
| 40 |
int p = feVel_->cubPts()->dimension(1); |
| 41 |
int d = feVel_->cubPts()->dimension(2); |
| 42 |
std::vector<Real> pt(d); |
| 43 |
weight_ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c,p); |
| 44 |
for (int i = 0; i < c; ++i) { |
| 45 |
for (int j = 0; j < p; ++j) { |
| 46 |
for (int k = 0; k < d; ++k) { |
| 47 |
pt[k] = (*feVel_->cubPts())(i,j,k); |
| 48 |
} |
| 49 |
(*weight_)(i,j) = weightFunc(pt); |
| 50 |
} |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> & val, |
| 55 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 56 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 57 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 58 |
// Get relevant dimensions |
| 59 |
int c = feVel_->cubPts()->dimension(0); |
| 60 |
int p = feVel_->cubPts()->dimension(1); |
| 61 |
int d = feVel_->cubPts()->dimension(2); |
| 62 |
// Initialize output val |
| 63 |
val = ROL::makePtr<Intrepid::FieldContainer<Real>>(c); |
| 64 |
// Get components of the control |
| 65 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 66 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 67 |
// Evaluate on FE basis |
| 68 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradUX_eval = |
| 69 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 70 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradUY_eval = |
| 71 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 72 |
feVel_->evaluateGradient(gradUX_eval, U[0]); |
| 73 |
feVel_->evaluateGradient(gradUY_eval, U[1]); |
| 74 |
// Compute curl |
| 75 |
ROL::Ptr<Intrepid::FieldContainer<Real>> curlU_eval = |
| 76 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 77 |
for (int i = 0; i < c; ++i) { |
| 78 |
for (int j = 0; j < p; ++j) { |
| 79 |
(*curlU_eval)(i,j) = (*gradUY_eval)(i,j,0) - (*gradUX_eval)(i,j,1); |
| 80 |
} |
| 81 |
} |
| 82 |
// Multiply by weight |
| 83 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weighted_curlU_eval = |
| 84 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 85 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*weighted_curlU_eval, |
| 86 |
*weight_, |
| 87 |
*curlU_eval); |
| 88 |
// Compute L2 norm squared |
| 89 |
feVel_->computeIntegral(val,curlU_eval,weighted_curlU_eval,false); |
| 90 |
Intrepid::RealSpaceTools<Real>::scale(*val,static_cast<Real>(0.5)); |
| 91 |
return static_cast<Real>(0); |
| 92 |
} |
| 93 |
|
| 94 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 95 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 96 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 97 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 98 |
// Get relevant dimensions |
| 99 |
int c = feVel_->cubPts()->dimension(0); |
| 100 |
int fv = feVel_->N()->dimension(1); |
| 101 |
int fp = fePrs_->N()->dimension(1); |
| 102 |
int p = feVel_->cubPts()->dimension(1); |
| 103 |
int d = feVel_->cubPts()->dimension(2); |
| 104 |
// Initialize output grad |
| 105 |
Intrepid::FieldContainer<Real> velUX_grad(c, fv); |
| 106 |
Intrepid::FieldContainer<Real> velUY_grad(c, fv); |
| 107 |
Intrepid::FieldContainer<Real> presU_grad(c, fp); |
| 108 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G; |
| 109 |
G.resize(fieldHelper_->numFields()); |
| 110 |
G[0] = ROL::makePtrFromRef(velUX_grad); |
| 111 |
G[1] = ROL::makePtrFromRef(velUY_grad); |
| 112 |
G[2] = ROL::makePtrFromRef(presU_grad); |
| 113 |
// Get components of the control |
| 114 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 115 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 116 |
// Evaluate on FE basis |
| 117 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradUX_eval = |
| 118 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 119 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradUY_eval = |
| 120 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 121 |
feVel_->evaluateGradient(gradUX_eval, U[0]); |
| 122 |
feVel_->evaluateGradient(gradUY_eval, U[1]); |
| 123 |
// Compute curl |
| 124 |
ROL::Ptr<Intrepid::FieldContainer<Real>> curlU_eval = |
| 125 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 126 |
for (int i = 0; i < c; ++i) { |
| 127 |
for (int j = 0; j < p; ++j) { |
| 128 |
(*curlU_eval)(i,j) = (*weight_)(i,j)*((*gradUY_eval)(i,j,0) - (*gradUX_eval)(i,j,1)); |
| 129 |
} |
| 130 |
} |
| 131 |
// Build local gradient of state tracking term |
| 132 |
Intrepid::FunctionSpaceTools::integrate<Real>(velUX_grad, |
| 133 |
*curlU_eval, |
| 134 |
*(feVel_->DNDdetJ(1)), |
| 135 |
Intrepid::COMP_CPP, false); |
| 136 |
Intrepid::RealSpaceTools<Real>::scale(velUX_grad,static_cast<Real>(-1)); |
| 137 |
Intrepid::FunctionSpaceTools::integrate<Real>(velUY_grad, |
| 138 |
*curlU_eval, |
| 139 |
*(feVel_->DNDdetJ(0)), |
| 140 |
Intrepid::COMP_CPP, false); |
| 141 |
|
| 142 |
fieldHelper_->combineFieldCoeff(grad, G); |
| 143 |
} |
| 144 |
|
| 145 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 146 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 147 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 148 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 149 |
throw Exception::Zero(">>> QoI_Vorticity_NavierStokes::gradient_2 is zero."); |
| 150 |
} |
| 151 |
|
| 152 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 153 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 154 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 155 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 156 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 157 |
// Get relevant dimensions |
| 158 |
int c = feVel_->cubPts()->dimension(0); |
| 159 |
int p = feVel_->cubPts()->dimension(1); |
| 160 |
int fv = feVel_->N()->dimension(1); |
| 161 |
int fp = fePrs_->N()->dimension(1); |
| 162 |
int d = feVel_->cubPts()->dimension(2); |
| 163 |
// Initialize output grad |
| 164 |
Intrepid::FieldContainer<Real> velVX_grad(c, fv); |
| 165 |
Intrepid::FieldContainer<Real> velVY_grad(c, fv); |
| 166 |
Intrepid::FieldContainer<Real> presV_grad(c, fp); |
| 167 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G; |
| 168 |
G.resize(fieldHelper_->numFields()); |
| 169 |
G[0] = ROL::makePtrFromRef(velVX_grad); |
| 170 |
G[1] = ROL::makePtrFromRef(velVY_grad); |
| 171 |
G[2] = ROL::makePtrFromRef(presV_grad); |
| 172 |
// Get components of the control |
| 173 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> V; |
| 174 |
fieldHelper_->splitFieldCoeff(V, v_coeff); |
| 175 |
// Evaluate on FE basis |
| 176 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradVX_eval = |
| 177 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 178 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradVY_eval = |
| 179 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 180 |
feVel_->evaluateGradient(gradVX_eval, V[0]); |
| 181 |
feVel_->evaluateGradient(gradVY_eval, V[1]); |
| 182 |
// Compute curl |
| 183 |
ROL::Ptr<Intrepid::FieldContainer<Real>> curlV_eval = |
| 184 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 185 |
for (int i = 0; i < c; ++i) { |
| 186 |
for (int j = 0; j < p; ++j) { |
| 187 |
(*curlV_eval)(i,j) = (*weight_)(i,j)*((*gradVY_eval)(i,j,0) - (*gradVX_eval)(i,j,1)); |
| 188 |
} |
| 189 |
} |
| 190 |
// Build local gradient of state tracking term |
| 191 |
Intrepid::FunctionSpaceTools::integrate<Real>(velVX_grad, |
| 192 |
*curlV_eval, |
| 193 |
*(feVel_->DNDdetJ(1)), |
| 194 |
Intrepid::COMP_CPP, false); |
| 195 |
Intrepid::RealSpaceTools<Real>::scale(velVX_grad,static_cast<Real>(-1)); |
| 196 |
Intrepid::FunctionSpaceTools::integrate<Real>(velVY_grad, |
| 197 |
*curlV_eval, |
| 198 |
*(feVel_->DNDdetJ(0)), |
| 199 |
Intrepid::COMP_CPP, false); |
| 200 |
|
| 201 |
fieldHelper_->combineFieldCoeff(hess, G); |
| 202 |
} |
| 203 |
|
| 204 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 205 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 206 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 207 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 208 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 209 |
throw Exception::Zero(">>> QoI_Vorticity_NavierStokes::HessVec_12 is zero."); |
| 210 |
} |
| 211 |
|
| 212 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 213 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 214 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 215 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 216 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 217 |
throw Exception::Zero(">>> QoI_Vorticity_NavierStokes::HessVec_21 is zero."); |
| 218 |
} |
| 219 |
|
| 220 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 221 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 222 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 223 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 224 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 225 |
throw Exception::Zero(">>> QoI_Vorticity_NavierStokes::HessVec_22 is zero."); |
| 226 |
} |
| 227 |
|
| 228 |
}; // QoI_Vorticity_NavierStokes |
| 229 |
|
| 230 |
template <class Real> |
| 231 |
class QoI_Circulation_NavierStokes : public QoI<Real> { |
| 232 |
private: |
| 233 |
const ROL::Ptr<FE<Real>> feVel_; |
| 234 |
const ROL::Ptr<FE<Real>> fePrs_; |
| 235 |
const ROL::Ptr<FieldHelper<Real>> fieldHelper_; |
| 236 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weight_; |
| 237 |
|
| 238 |
const Real eps_; |
| 239 |
|
| 240 |
Real weightFunc(const std::vector<Real> & x) const { |
| 241 |
return static_cast<Real>(1); |
| 242 |
} |
| 243 |
|
| 244 |
public: |
| 245 |
QoI_Circulation_NavierStokes(const ROL::Ptr<FE<Real>> &feVel, |
| 246 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 247 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) |
| 248 |
: feVel_(feVel), fePrs_(fePrs), fieldHelper_(fieldHelper), eps_(std::sqrt(ROL::ROL_EPSILON<Real>())) { |
| 249 |
int c = feVel_->cubPts()->dimension(0); |
| 250 |
int p = feVel_->cubPts()->dimension(1); |
| 251 |
int d = feVel_->cubPts()->dimension(2); |
| 252 |
std::vector<Real> pt(d); |
| 253 |
weight_ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c,p); |
| 254 |
for (int i = 0; i < c; ++i) { |
| 255 |
for (int j = 0; j < p; ++j) { |
| 256 |
for (int k = 0; k < d; ++k) { |
| 257 |
pt[k] = (*feVel_->cubPts())(i,j,k); |
| 258 |
} |
| 259 |
(*weight_)(i,j) = weightFunc(pt); |
| 260 |
} |
| 261 |
} |
| 262 |
} |
| 263 |
|
| 264 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> & val, |
| 265 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 266 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 267 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 268 |
// Get relevant dimensions |
| 269 |
int c = feVel_->cubPts()->dimension(0); |
| 270 |
int p = feVel_->cubPts()->dimension(1); |
| 271 |
int d = feVel_->cubPts()->dimension(2); |
| 272 |
// Initialize output val |
| 273 |
val = ROL::makePtr<Intrepid::FieldContainer<Real>>(c); |
| 274 |
// Get components of the control |
| 275 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 276 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 277 |
// Evaluate on FE basis |
| 278 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradUX_eval = |
| 279 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 280 |
ROL::Ptr<Intrepid::FieldContainer<Real>> gradUY_eval = |
| 281 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 282 |
feVel_->evaluateGradient(gradUX_eval, U[0]); |
| 283 |
feVel_->evaluateGradient(gradUY_eval, U[1]); |
| 284 |
// Compute curl |
| 285 |
ROL::Ptr<Intrepid::FieldContainer<Real>> curlU_eval = |
| 286 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 287 |
for (int i = 0; i < c; ++i) { |
| 288 |
for (int j = 0; j < p; ++j) { |
| 289 |
(*curlU_eval)(i,j) = (*gradUY_eval)(i,j,0) - (*gradUX_eval)(i,j,1); |
| 290 |
} |
| 291 |
} |
| 292 |
// Compute circulation |
| 293 |
feVel_->computeIntegral(val,curlU_eval,weight_,false); |
| 294 |
return static_cast<Real>(0); |
| 295 |
} |
| 296 |
|
| 297 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 298 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 299 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 300 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 301 |
// Get relevant dimensions |
| 302 |
int c = feVel_->cubPts()->dimension(0); |
| 303 |
int fv = feVel_->N()->dimension(1); |
| 304 |
int fp = fePrs_->N()->dimension(1); |
| 305 |
// Initialize output grad |
| 306 |
Intrepid::FieldContainer<Real> velUX_grad(c, fv); |
| 307 |
Intrepid::FieldContainer<Real> velUY_grad(c, fv); |
| 308 |
Intrepid::FieldContainer<Real> presU_grad(c, fp); |
| 309 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G; |
| 310 |
G.resize(fieldHelper_->numFields()); |
| 311 |
G[0] = ROL::makePtrFromRef(velUX_grad); |
| 312 |
G[1] = ROL::makePtrFromRef(velUY_grad); |
| 313 |
G[2] = ROL::makePtrFromRef(presU_grad); |
| 314 |
// Build local gradient of state tracking term |
| 315 |
Intrepid::FunctionSpaceTools::integrate<Real>(velUX_grad, |
| 316 |
*weight_, |
| 317 |
*(feVel_->DNDdetJ(1)), |
| 318 |
Intrepid::COMP_CPP, false); |
| 319 |
Intrepid::RealSpaceTools<Real>::scale(velUX_grad,static_cast<Real>(-1)); |
| 320 |
Intrepid::FunctionSpaceTools::integrate<Real>(velUY_grad, |
| 321 |
*weight_, |
| 322 |
*(feVel_->DNDdetJ(0)), |
| 323 |
Intrepid::COMP_CPP, false); |
| 324 |
|
| 325 |
fieldHelper_->combineFieldCoeff(grad, G); |
| 326 |
} |
| 327 |
|
| 328 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 329 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 330 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 331 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 332 |
throw Exception::Zero(">>> QoI_Circulation_NavierStokes::gradient_2 is zero."); |
| 333 |
} |
| 334 |
|
| 335 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 336 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 337 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 338 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 339 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 340 |
throw Exception::Zero(">>> QoI_Circulation_NavierStokes::HessVec_11 is zero."); |
| 341 |
} |
| 342 |
|
| 343 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 344 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 345 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 346 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 347 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 348 |
throw Exception::Zero(">>> QoI_Circulation_NavierStokes::HessVec_12 is zero."); |
| 349 |
} |
| 350 |
|
| 351 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 352 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 353 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 354 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 355 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 356 |
throw Exception::Zero(">>> QoI_Circulation_NavierStokes::HessVec_21 is zero."); |
| 357 |
} |
| 358 |
|
| 359 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 360 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 361 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 362 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 363 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 364 |
throw Exception::Zero(">>> QoI_Circulation_NavierStokes::HessVec_22 is zero."); |
| 365 |
} |
| 366 |
|
| 367 |
}; // QoI_Circulation_NavierStokes |
| 368 |
|
| 369 |
template <class Real> |
| 370 |
class QoI_Horizontal_NavierStokes : public QoI<Real> { |
| 371 |
private: |
| 372 |
const ROL::Ptr<FE<Real>> feVel_; |
| 373 |
const ROL::Ptr<FE<Real>> fePrs_; |
| 374 |
const ROL::Ptr<FieldHelper<Real>> fieldHelper_; |
| 375 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weight_; |
| 376 |
|
| 377 |
const Real eps_; |
| 378 |
|
| 379 |
Real weightFunc(const std::vector<Real> & x) const { |
| 380 |
return static_cast<Real>(1); |
| 381 |
} |
| 382 |
|
| 383 |
public: |
| 384 |
QoI_Horizontal_NavierStokes(const ROL::Ptr<FE<Real>> &feVel, |
| 385 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 386 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) |
| 387 |
: feVel_(feVel), fePrs_(fePrs), fieldHelper_(fieldHelper), eps_(std::sqrt(ROL::ROL_EPSILON<Real>())) { |
| 388 |
int c = feVel_->cubPts()->dimension(0); |
| 389 |
int p = feVel_->cubPts()->dimension(1); |
| 390 |
int d = feVel_->cubPts()->dimension(2); |
| 391 |
std::vector<Real> pt(d); |
| 392 |
weight_ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c,p); |
| 393 |
for (int i = 0; i < c; ++i) { |
| 394 |
for (int j = 0; j < p; ++j) { |
| 395 |
for (int k = 0; k < d; ++k) { |
| 396 |
pt[k] = (*feVel_->cubPts())(i,j,k); |
| 397 |
} |
| 398 |
(*weight_)(i,j) = weightFunc(pt); |
| 399 |
} |
| 400 |
} |
| 401 |
} |
| 402 |
|
| 403 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> & val, |
| 404 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 405 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 406 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 407 |
// Get relevant dimensions |
| 408 |
int c = feVel_->cubPts()->dimension(0); |
| 409 |
int p = feVel_->cubPts()->dimension(1); |
| 410 |
// Initialize output val |
| 411 |
val = ROL::makePtr<Intrepid::FieldContainer<Real>>(c); |
| 412 |
// Get components of the control |
| 413 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 414 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 415 |
// Evaluate on FE basis |
| 416 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valUX_eval = |
| 417 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 418 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valUY_eval = |
| 419 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 420 |
feVel_->evaluateValue(valUX_eval, U[0]); |
| 421 |
feVel_->evaluateValue(valUY_eval, U[1]); |
| 422 |
// Compute negative part of x-velocity |
| 423 |
ROL::Ptr<Intrepid::FieldContainer<Real>> minUX_eval = |
| 424 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 425 |
for (int i = 0; i < c; ++i) { |
| 426 |
for (int j = 0; j < p; ++j) { |
| 427 |
(*minUX_eval)(i,j) = std::min(static_cast<Real>(0),(*valUX_eval)(i,j)); |
| 428 |
} |
| 429 |
} |
| 430 |
// Multiply by weight |
| 431 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weighted_minUX_eval = |
| 432 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 433 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*weighted_minUX_eval, |
| 434 |
*weight_, |
| 435 |
*minUX_eval); |
| 436 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weighted_valUY_eval = |
| 437 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 438 |
Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*weighted_valUY_eval, |
| 439 |
*weight_, |
| 440 |
*valUY_eval); |
| 441 |
// Compute L2 norm squared |
| 442 |
feVel_->computeIntegral(val,minUX_eval,weighted_minUX_eval,false); |
| 443 |
feVel_->computeIntegral(val,valUY_eval,weighted_valUY_eval,true); |
| 444 |
|
| 445 |
Intrepid::RealSpaceTools<Real>::scale(*val,static_cast<Real>(0.5)); |
| 446 |
return static_cast<Real>(0); |
| 447 |
} |
| 448 |
|
| 449 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 450 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 451 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 452 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 453 |
// Get relevant dimensions |
| 454 |
int c = feVel_->cubPts()->dimension(0); |
| 455 |
int fv = feVel_->N()->dimension(1); |
| 456 |
int fp = fePrs_->N()->dimension(1); |
| 457 |
int p = feVel_->cubPts()->dimension(1); |
| 458 |
// Initialize output grad |
| 459 |
Intrepid::FieldContainer<Real> velUX_grad(c, fv); |
| 460 |
Intrepid::FieldContainer<Real> velUY_grad(c, fv); |
| 461 |
Intrepid::FieldContainer<Real> presU_grad(c, fp); |
| 462 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G; |
| 463 |
G.resize(fieldHelper_->numFields()); |
| 464 |
G[0] = ROL::makePtrFromRef(velUX_grad); |
| 465 |
G[1] = ROL::makePtrFromRef(velUY_grad); |
| 466 |
G[2] = ROL::makePtrFromRef(presU_grad); |
| 467 |
// Get components of the control |
| 468 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 469 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 470 |
// Evaluate on FE basis |
| 471 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valUX_eval = |
| 472 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 473 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valUY_eval = |
| 474 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 475 |
feVel_->evaluateValue(valUX_eval, U[0]); |
| 476 |
feVel_->evaluateValue(valUY_eval, U[1]); |
| 477 |
// Compute negative part of x-velocity |
| 478 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weighted_minUX_eval = |
| 479 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 480 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weighted_valUY_eval = |
| 481 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 482 |
for (int i = 0; i < c; ++i) { |
| 483 |
for (int j = 0; j < p; ++j) { |
| 484 |
(*weighted_minUX_eval)(i,j) |
| 485 |
= (*weight_)(i,j) * std::min(static_cast<Real>(0),(*valUX_eval)(i,j)); |
| 486 |
(*weighted_valUY_eval)(i,j) |
| 487 |
= (*weight_)(i,j) * (*valUY_eval)(i,j); |
| 488 |
} |
| 489 |
} |
| 490 |
// Build local gradient of state tracking term |
| 491 |
Intrepid::FunctionSpaceTools::integrate<Real>(velUX_grad, |
| 492 |
*weighted_minUX_eval, |
| 493 |
*(feVel_->NdetJ()), |
| 494 |
Intrepid::COMP_CPP, false); |
| 495 |
Intrepid::FunctionSpaceTools::integrate<Real>(velUY_grad, |
| 496 |
*weighted_valUY_eval, |
| 497 |
*(feVel_->NdetJ()), |
| 498 |
Intrepid::COMP_CPP, false); |
| 499 |
|
| 500 |
fieldHelper_->combineFieldCoeff(grad, G); |
| 501 |
} |
| 502 |
|
| 503 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 504 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 505 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 506 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 507 |
throw Exception::Zero(">>> QoI_Horizontal_NavierStokes::gradient_2 is zero."); |
| 508 |
} |
| 509 |
|
| 510 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 511 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 512 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 513 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 514 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 515 |
// Get relevant dimensions |
| 516 |
int c = feVel_->cubPts()->dimension(0); |
| 517 |
int p = feVel_->cubPts()->dimension(1); |
| 518 |
int fv = feVel_->N()->dimension(1); |
| 519 |
int fp = fePrs_->N()->dimension(1); |
| 520 |
// Initialize output grad |
| 521 |
Intrepid::FieldContainer<Real> velVX_grad(c, fv); |
| 522 |
Intrepid::FieldContainer<Real> velVY_grad(c, fv); |
| 523 |
Intrepid::FieldContainer<Real> presV_grad(c, fp); |
| 524 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G; |
| 525 |
G.resize(fieldHelper_->numFields()); |
| 526 |
G[0] = ROL::makePtrFromRef(velVX_grad); |
| 527 |
G[1] = ROL::makePtrFromRef(velVY_grad); |
| 528 |
G[2] = ROL::makePtrFromRef(presV_grad); |
| 529 |
// Get components of the control |
| 530 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 531 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 532 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> V; |
| 533 |
fieldHelper_->splitFieldCoeff(V, v_coeff); |
| 534 |
// Evaluate on FE basis |
| 535 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valUX_eval = |
| 536 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 537 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valVX_eval = |
| 538 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 539 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valVY_eval = |
| 540 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 541 |
feVel_->evaluateValue(valUX_eval, U[0]); |
| 542 |
feVel_->evaluateValue(valVX_eval, V[0]); |
| 543 |
feVel_->evaluateValue(valVY_eval, V[1]); |
| 544 |
// Compute negative part of x-velocity |
| 545 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weighted_minVX_eval = |
| 546 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 547 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weighted_valVY_eval = |
| 548 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 549 |
Real scale(0); |
| 550 |
for (int i = 0; i < c; ++i) { |
| 551 |
for (int j = 0; j < p; ++j) { |
| 552 |
if ( (*valUX_eval)(i,j) < static_cast<Real>(0) ) { |
| 553 |
scale = static_cast<Real>(1); |
| 554 |
} |
| 555 |
else if ( (*valUX_eval)(i,j) > static_cast<Real>(0) ) { |
| 556 |
scale = static_cast<Real>(0); |
| 557 |
} |
| 558 |
else { |
| 559 |
//scale = static_cast<Real>(0); |
| 560 |
//scale = static_cast<Real>(0.5); |
| 561 |
scale = static_cast<Real>(1); |
| 562 |
} |
| 563 |
(*weighted_minVX_eval)(i,j) |
| 564 |
= scale * (*weight_)(i,j) * (*valVX_eval)(i,j); |
| 565 |
(*weighted_valVY_eval)(i,j) |
| 566 |
= (*weight_)(i,j) * (*valVY_eval)(i,j); |
| 567 |
} |
| 568 |
} |
| 569 |
// Build local gradient of state tracking term |
| 570 |
Intrepid::FunctionSpaceTools::integrate<Real>(velVX_grad, |
| 571 |
*weighted_minVX_eval, |
| 572 |
*(feVel_->NdetJ()), |
| 573 |
Intrepid::COMP_CPP, false); |
| 574 |
Intrepid::FunctionSpaceTools::integrate<Real>(velVY_grad, |
| 575 |
*weighted_valVY_eval, |
| 576 |
*(feVel_->NdetJ()), |
| 577 |
Intrepid::COMP_CPP, false); |
| 578 |
|
| 579 |
fieldHelper_->combineFieldCoeff(hess, G); |
| 580 |
} |
| 581 |
|
| 582 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 583 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 584 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 585 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 586 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 587 |
throw Exception::Zero(">>> QoI_Horizontal_NavierStokes::HessVec_12 is zero."); |
| 588 |
} |
| 589 |
|
| 590 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 591 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 592 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 593 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 594 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 595 |
throw Exception::Zero(">>> QoI_Horizontal_NavierStokes::HessVec_21 is zero."); |
| 596 |
} |
| 597 |
|
| 598 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 599 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 600 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 601 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 602 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 603 |
throw Exception::Zero(">>> QoI_Horizontal_NavierStokes::HessVec_22 is zero."); |
| 604 |
} |
| 605 |
|
| 606 |
}; // QoI_Horizontal_NavierStokes |
| 607 |
|
| 608 |
template <class Real> |
| 609 |
class QoI_Tracking_NavierStokes : public QoI<Real> { |
| 610 |
private: |
| 611 |
const ROL::Ptr<FE<Real>> feVel_; |
| 612 |
const ROL::Ptr<FE<Real>> fePrs_; |
| 613 |
const ROL::Ptr<FieldHelper<Real>> fieldHelper_; |
| 614 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weight_; |
| 615 |
ROL::Ptr<Intrepid::FieldContainer<Real>> target_; |
| 616 |
bool useParabolicInflow_; |
| 617 |
|
| 618 |
const Real eps_; |
| 619 |
|
| 620 |
Real weightFunc(const std::vector<Real> & x) const { |
| 621 |
const Real one(1); |
| 622 |
return one; |
| 623 |
} |
| 624 |
|
| 625 |
Real target(const std::vector<Real> &x, const int dir) const { |
| 626 |
const Real one(1), two(2); |
| 627 |
Real val(0); |
| 628 |
if (dir == 0) { |
| 629 |
val = (useParabolicInflow_ ? (two + x[1])*(two - x[1]) : one); |
| 630 |
} |
| 631 |
return val; |
| 632 |
} |
| 633 |
|
| 634 |
public: |
| 635 |
QoI_Tracking_NavierStokes(Teuchos::ParameterList &parlist, |
| 636 |
const ROL::Ptr<FE<Real>> &feVel, |
| 637 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 638 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) |
| 639 |
: feVel_(feVel), fePrs_(fePrs), fieldHelper_(fieldHelper), eps_(std::sqrt(ROL::ROL_EPSILON<Real>())) { |
| 640 |
int c = feVel_->cubPts()->dimension(0); |
| 641 |
int p = feVel_->cubPts()->dimension(1); |
| 642 |
int d = feVel_->cubPts()->dimension(2); |
| 643 |
useParabolicInflow_ = parlist.sublist("Problem").get("Use Parabolic Inflow", true); |
| 644 |
weight_ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 645 |
target_ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 646 |
std::vector<Real> pt(d); |
| 647 |
for (int i = 0; i < c; ++i) { |
| 648 |
for (int j = 0; j < p; ++j) { |
| 649 |
for (int k = 0; k < d; ++k) { |
| 650 |
pt[k] = (*feVel_->cubPts())(i, j, k); |
| 651 |
} |
| 652 |
(*weight_)(i, j) = weightFunc(pt); |
| 653 |
for (int k = 0; k < d; ++k) { |
| 654 |
(*target_)(i, j, k) = target(pt, k); |
| 655 |
} |
| 656 |
} |
| 657 |
} |
| 658 |
} |
| 659 |
|
| 660 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> & val, |
| 661 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 662 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 663 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 664 |
// Get relevant dimensions |
| 665 |
int c = feVel_->gradN()->dimension(0); |
| 666 |
int p = feVel_->gradN()->dimension(2); |
| 667 |
int d = feVel_->gradN()->dimension(3); |
| 668 |
// Initialize output val |
| 669 |
val = ROL::makePtr<Intrepid::FieldContainer<Real>>(c); |
| 670 |
// Get components of the control |
| 671 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 672 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 673 |
// Compute tracking term and integrate |
| 674 |
ROL::Ptr<Intrepid::FieldContainer<Real>> U_eval |
| 675 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 676 |
for (int i = 0; i < d; ++i) { |
| 677 |
// Evaluate u value on FE basis |
| 678 |
U_eval->initialize(); |
| 679 |
feVel_->evaluateValue(U_eval, U[i]); |
| 680 |
// Compute distance to target |
| 681 |
for (int j = 0; j < c; ++j) { |
| 682 |
for (int k = 0; k < p; ++k) { |
| 683 |
(*U_eval)(j, k) -= (*target_)(j, k, i); |
| 684 |
(*U_eval)(j, k) *= std::sqrt((*weight_)(j, k)); |
| 685 |
} |
| 686 |
} |
| 687 |
// Compute L2 norm squared |
| 688 |
feVel_->computeIntegral(val,U_eval,U_eval,true); |
| 689 |
} |
| 690 |
Intrepid::RealSpaceTools<Real>::scale(*val,static_cast<Real>(0.5)); |
| 691 |
return static_cast<Real>(0); |
| 692 |
} |
| 693 |
|
| 694 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 695 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 696 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 697 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 698 |
// Get relevant dimensions |
| 699 |
int c = feVel_->gradN()->dimension(0); |
| 700 |
int fv = feVel_->gradN()->dimension(1); |
| 701 |
int fp = fePrs_->gradN()->dimension(1); |
| 702 |
int p = feVel_->gradN()->dimension(2); |
| 703 |
int d = feVel_->gradN()->dimension(3); |
| 704 |
// Get components of the control |
| 705 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 706 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 707 |
// Compute weighted u value and integrate |
| 708 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G(d+1, ROL::nullPtr); |
| 709 |
ROL::Ptr<Intrepid::FieldContainer<Real>> U_eval |
| 710 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 711 |
for (int i = 0; i < d; ++i) { |
| 712 |
// Evaluate on FE basis |
| 713 |
U_eval->initialize(); |
| 714 |
feVel_->evaluateValue(U_eval, U[i]); |
| 715 |
// Compute tracking term |
| 716 |
for (int j = 0; j < c; ++j) { |
| 717 |
for (int k = 0; k < p; ++k) { |
| 718 |
(*U_eval)(j, k) -= (*target_)(j, k, i); |
| 719 |
(*U_eval)(j, k) *= (*weight_)(j, k); |
| 720 |
} |
| 721 |
} |
| 722 |
// Build local gradient of state tracking term |
| 723 |
G[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fv); |
| 724 |
Intrepid::FunctionSpaceTools::integrate<Real>(*G[i], |
| 725 |
*U_eval, |
| 726 |
*(feVel_->NdetJ()), |
| 727 |
Intrepid::COMP_CPP, |
| 728 |
false); |
| 729 |
} |
| 730 |
G[d] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fp); |
| 731 |
fieldHelper_->combineFieldCoeff(grad, G); |
| 732 |
} |
| 733 |
|
| 734 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 735 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 736 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 737 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 738 |
throw Exception::Zero(">>> QoI_Tracking_NavierStokes::gradient_2 is zero."); |
| 739 |
} |
| 740 |
|
| 741 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 742 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 743 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 744 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 745 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 746 |
// Get relevant dimensions |
| 747 |
int c = feVel_->gradN()->dimension(0); |
| 748 |
int fv = feVel_->gradN()->dimension(1); |
| 749 |
int fp = fePrs_->gradN()->dimension(1); |
| 750 |
int p = feVel_->gradN()->dimension(2); |
| 751 |
int d = feVel_->gradN()->dimension(3); |
| 752 |
// Get components of the control |
| 753 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> V; |
| 754 |
fieldHelper_->splitFieldCoeff(V, v_coeff); |
| 755 |
// Compute weighted v value and integrate |
| 756 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> H(d+1, ROL::nullPtr); |
| 757 |
ROL::Ptr<Intrepid::FieldContainer<Real>> V_eval |
| 758 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 759 |
for (int i = 0; i < d; ++i) { |
| 760 |
// Evaluate v value on FE basis |
| 761 |
V_eval->initialize(); |
| 762 |
feVel_->evaluateValue(V_eval, V[i]); |
| 763 |
// Weight v value |
| 764 |
for (int j = 0; j < c; ++j) { |
| 765 |
for (int k = 0; k < p; ++k) { |
| 766 |
(*V_eval)(j, k) *= (*weight_)(j, k); |
| 767 |
} |
| 768 |
} |
| 769 |
// Integrate v value |
| 770 |
H[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fv); |
| 771 |
Intrepid::FunctionSpaceTools::integrate<Real>(*H[i], |
| 772 |
*V_eval, |
| 773 |
*(feVel_->NdetJ()), |
| 774 |
Intrepid::COMP_CPP, |
| 775 |
false); |
| 776 |
} |
| 777 |
H[d] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fp); |
| 778 |
fieldHelper_->combineFieldCoeff(hess, H); |
| 779 |
} |
| 780 |
|
| 781 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 782 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 783 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 784 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 785 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 786 |
throw Exception::Zero(">>> QoI_Tracking_NavierStokes::HessVec_12 is zero."); |
| 787 |
} |
| 788 |
|
| 789 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 790 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 791 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 792 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 793 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 794 |
throw Exception::Zero(">>> QoI_Tracking_NavierStokes::HessVec_21 is zero."); |
| 795 |
} |
| 796 |
|
| 797 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 798 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 799 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 800 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 801 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 802 |
throw Exception::Zero(">>> QoI_Tracking_NavierStokes::HessVec_22 is zero."); |
| 803 |
} |
| 804 |
|
| 805 |
}; // QoI_Tracking_NavierStokes |
| 806 |
|
| 807 |
template <class Real> |
| 808 |
class QoI_Dissipation_NavierStokes : public QoI<Real> { |
| 809 |
private: |
| 810 |
const ROL::Ptr<FE<Real>> feVel_; |
| 811 |
const ROL::Ptr<FE<Real>> fePrs_; |
| 812 |
const ROL::Ptr<FieldHelper<Real>> fieldHelper_; |
| 813 |
ROL::Ptr<Intrepid::FieldContainer<Real>> weight_; |
| 814 |
|
| 815 |
Real nu_; |
| 816 |
|
| 817 |
Real weightFunc(const std::vector<Real> & x) const { |
| 818 |
return static_cast<Real>(1); |
| 819 |
} |
| 820 |
|
| 821 |
public: |
| 822 |
QoI_Dissipation_NavierStokes(Teuchos::ParameterList &parlist, |
| 823 |
const ROL::Ptr<FE<Real>> &feVel, |
| 824 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 825 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) |
| 826 |
: feVel_(feVel), fePrs_(fePrs), fieldHelper_(fieldHelper) { |
| 827 |
Real Re = parlist.sublist("Problem").get("Reynolds Number", 40.0); |
| 828 |
nu_ = static_cast<Real>(1.0)/Re; |
| 829 |
int c = feVel_->cubPts()->dimension(0); |
| 830 |
int p = feVel_->cubPts()->dimension(1); |
| 831 |
int d = feVel_->cubPts()->dimension(2); |
| 832 |
std::vector<Real> pt(d); |
| 833 |
weight_ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c,p); |
| 834 |
for (int i = 0; i < c; ++i) { |
| 835 |
for (int j = 0; j < p; ++j) { |
| 836 |
for (int k = 0; k < d; ++k) { |
| 837 |
pt[k] = (*feVel_->cubPts())(i,j,k); |
| 838 |
} |
| 839 |
(*weight_)(i,j) = weightFunc(pt); |
| 840 |
} |
| 841 |
} |
| 842 |
} |
| 843 |
|
| 844 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> & val, |
| 845 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 846 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 847 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 848 |
const Real half(0.5); |
| 849 |
// Get relevant dimensions |
| 850 |
const int c = feVel_->gradN()->dimension(0); |
| 851 |
const int p = feVel_->gradN()->dimension(2); |
| 852 |
const int d = feVel_->gradN()->dimension(3); |
| 853 |
// Initialize output val |
| 854 |
val = ROL::makePtr<Intrepid::FieldContainer<Real>>(c); |
| 855 |
// Get components of the control |
| 856 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 857 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 858 |
// Evaluate on FE basis |
| 859 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradU(d); |
| 860 |
for (int i = 0; i < d; ++i) { |
| 861 |
gradU[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 862 |
feVel_->evaluateGradient(gradU[i], U[i]); |
| 863 |
} |
| 864 |
// Compute energy dissipation rate |
| 865 |
ROL::Ptr<Intrepid::FieldContainer<Real>> sigmaU |
| 866 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 867 |
for (int i = 0; i < d; ++i) { |
| 868 |
for (int j = 0; j < d; ++j) { |
| 869 |
for (int k = 0; k < c; ++k) { |
| 870 |
for (int l = 0; l < p; ++l) { |
| 871 |
(*sigmaU)(k,l) = (*weight_)(k,l)*((*gradU[i])(k,l,j)+(*gradU[j])(k,l,i)); |
| 872 |
} |
| 873 |
} |
| 874 |
feVel_->computeIntegral(val,sigmaU,sigmaU,true); |
| 875 |
} |
| 876 |
} |
| 877 |
Intrepid::RealSpaceTools<Real>::scale(*val, half*nu_); |
| 878 |
return static_cast<Real>(0); |
| 879 |
} |
| 880 |
|
| 881 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 882 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 883 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 884 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 885 |
// Get relevant dimensions |
| 886 |
const int c = feVel_->gradN()->dimension(0); |
| 887 |
const int fv = feVel_->gradN()->dimension(1); |
| 888 |
const int fp = fePrs_->gradN()->dimension(1); |
| 889 |
const int p = feVel_->gradN()->dimension(2); |
| 890 |
const int d = feVel_->gradN()->dimension(3); |
| 891 |
// Initialize output grad |
| 892 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G(d+1); |
| 893 |
for (int i = 0; i < d; ++i) { |
| 894 |
G[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fv); |
| 895 |
} |
| 896 |
G[d] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fp); |
| 897 |
// Get components of the control |
| 898 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U; |
| 899 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 900 |
// Evaluate on FE basis |
| 901 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradU(d); |
| 902 |
for (int i = 0; i < d; ++i) { |
| 903 |
gradU[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 904 |
feVel_->evaluateGradient(gradU[i], U[i]); |
| 905 |
} |
| 906 |
// Compute energy dissipation gradient |
| 907 |
ROL::Ptr<Intrepid::FieldContainer<Real>> sigmaU |
| 908 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 909 |
for (int i = 0; i < d; ++i) { |
| 910 |
for (int j = 0; j < d; ++j) { |
| 911 |
for (int k = 0; k < c; ++k) { |
| 912 |
for (int l = 0; l < p; ++l) { |
| 913 |
(*sigmaU)(k,l) = std::pow((*weight_)(k,l),2)*((*gradU[i])(k,l,j)+(*gradU[j])(k,l,i)); |
| 914 |
} |
| 915 |
} |
| 916 |
Intrepid::FunctionSpaceTools::integrate<Real>(*G[j], |
| 917 |
*sigmaU, |
| 918 |
*(feVel_->DNDdetJ(i)), |
| 919 |
Intrepid::COMP_CPP, |
| 920 |
true); |
| 921 |
Intrepid::FunctionSpaceTools::integrate<Real>(*G[i], |
| 922 |
*sigmaU, |
| 923 |
*(feVel_->DNDdetJ(j)), |
| 924 |
Intrepid::COMP_CPP, |
| 925 |
true); |
| 926 |
} |
| 927 |
} |
| 928 |
fieldHelper_->combineFieldCoeff(grad, G); |
| 929 |
Intrepid::RealSpaceTools<Real>::scale(*grad, nu_); |
| 930 |
} |
| 931 |
|
| 932 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 933 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 934 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 935 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 936 |
throw Exception::Zero(">>> QoI_Dissipation_NavierStokes::gradient_2 is zero."); |
| 937 |
} |
| 938 |
|
| 939 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 940 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 941 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 942 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 943 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 944 |
// Get relevant dimensions |
| 945 |
const int c = feVel_->gradN()->dimension(0); |
| 946 |
const int fv = feVel_->gradN()->dimension(1); |
| 947 |
const int fp = fePrs_->gradN()->dimension(1); |
| 948 |
const int p = feVel_->gradN()->dimension(2); |
| 949 |
const int d = feVel_->gradN()->dimension(3); |
| 950 |
// Initialize output grad |
| 951 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> H(d+1); |
| 952 |
for (int i = 0; i < d; ++i) { |
| 953 |
H[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fv); |
| 954 |
} |
| 955 |
H[d] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fp); |
| 956 |
// Get components of the control |
| 957 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> V; |
| 958 |
fieldHelper_->splitFieldCoeff(V, v_coeff); |
| 959 |
// Evaluate on FE basis |
| 960 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> gradV(d); |
| 961 |
for (int i = 0; i < d; ++i) { |
| 962 |
gradV[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d); |
| 963 |
feVel_->evaluateGradient(gradV[i], V[i]); |
| 964 |
} |
| 965 |
// Compute energy dissipation gradient |
| 966 |
ROL::Ptr<Intrepid::FieldContainer<Real>> sigmaV |
| 967 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p); |
| 968 |
for (int i = 0; i < d; ++i) { |
| 969 |
for (int j = 0; j < d; ++j) { |
| 970 |
for (int k = 0; k < c; ++k) { |
| 971 |
for (int l = 0; l < p; ++l) { |
| 972 |
(*sigmaV)(k,l) = std::pow((*weight_)(k,l),2)*((*gradV[i])(k,l,j)+(*gradV[j])(k,l,i)); |
| 973 |
} |
| 974 |
} |
| 975 |
Intrepid::FunctionSpaceTools::integrate<Real>(*H[j], |
| 976 |
*sigmaV, |
| 977 |
*(feVel_->DNDdetJ(i)), |
| 978 |
Intrepid::COMP_CPP, |
| 979 |
true); |
| 980 |
Intrepid::FunctionSpaceTools::integrate<Real>(*H[i], |
| 981 |
*sigmaV, |
| 982 |
*(feVel_->DNDdetJ(j)), |
| 983 |
Intrepid::COMP_CPP, |
| 984 |
true); |
| 985 |
} |
| 986 |
} |
| 987 |
fieldHelper_->combineFieldCoeff(hess, H); |
| 988 |
Intrepid::RealSpaceTools<Real>::scale(*hess, nu_); |
| 989 |
} |
| 990 |
|
| 991 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 992 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 993 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 994 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 995 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 996 |
throw Exception::Zero(">>> QoI_Dissipation_NavierStokes::HessVec_12 is zero."); |
| 997 |
} |
| 998 |
|
| 999 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1000 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1001 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1002 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1003 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1004 |
throw Exception::Zero(">>> QoI_Dissipation_NavierStokes::HessVec_21 is zero."); |
| 1005 |
} |
| 1006 |
|
| 1007 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1008 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1009 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1010 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1011 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1012 |
throw Exception::Zero(">>> QoI_Dissipation_NavierStokes::HessVec_22 is zero."); |
| 1013 |
} |
| 1014 |
|
| 1015 |
}; // QoI_Dissipation_NavierStokes |
| 1016 |
|
| 1017 |
template <class Real> |
| 1018 |
class QoI_State_NavierStokes : public QoI<Real> { |
| 1019 |
private: |
| 1020 |
ROL::Ptr<QoI<Real>> qoi_; |
| 1021 |
|
| 1022 |
void initialize(const std::string &stateObj, |
| 1023 |
Teuchos::ParameterList &parlist, |
| 1024 |
const ROL::Ptr<FE<Real>> &feVel, |
| 1025 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 1026 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) { |
| 1027 |
if ( stateObj == "Circulation" ) { |
| 1028 |
qoi_ = ROL::makePtr<QoI_Circulation_NavierStokes<Real>>(feVel,fePrs,fieldHelper); |
| 1029 |
} |
| 1030 |
else if ( stateObj == "Vorticity" ) { |
| 1031 |
qoi_ = ROL::makePtr<QoI_Vorticity_NavierStokes<Real>>(feVel,fePrs,fieldHelper); |
| 1032 |
} |
| 1033 |
else if ( stateObj == "Directional" ) { |
| 1034 |
qoi_ = ROL::makePtr<QoI_Horizontal_NavierStokes<Real>>(feVel,fePrs,fieldHelper); |
| 1035 |
} |
| 1036 |
else if ( stateObj == "Tracking" ) { |
| 1037 |
qoi_ = ROL::makePtr<QoI_Tracking_NavierStokes<Real>>(parlist,feVel,fePrs,fieldHelper); |
| 1038 |
} |
| 1039 |
else if ( stateObj == "Dissipation" ) { |
| 1040 |
qoi_ = ROL::makePtr<QoI_Dissipation_NavierStokes<Real>>(parlist,feVel,fePrs,fieldHelper); |
| 1041 |
} |
| 1042 |
else { |
| 1043 |
throw Exception::NotImplemented(">>> (QoI_State_NavierStokes): Unknown objective type."); |
| 1044 |
} |
| 1045 |
} |
| 1046 |
|
| 1047 |
public: |
| 1048 |
QoI_State_NavierStokes(Teuchos::ParameterList &parlist, |
| 1049 |
const ROL::Ptr<FE<Real>> &feVel, |
| 1050 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 1051 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) { |
| 1052 |
std::string stateObj = parlist.sublist("Problem").get("Objective type","Vorticity"); |
| 1053 |
initialize(stateObj,parlist,feVel,fePrs,fieldHelper); |
| 1054 |
} |
| 1055 |
|
| 1056 |
QoI_State_NavierStokes(const std::string &stateObj, |
| 1057 |
Teuchos::ParameterList &parlist, |
| 1058 |
const ROL::Ptr<FE<Real>> &feVel, |
| 1059 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 1060 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) { |
| 1061 |
initialize(stateObj,parlist,feVel,fePrs,fieldHelper); |
| 1062 |
} |
| 1063 |
|
| 1064 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> & val, |
| 1065 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1066 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1067 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1068 |
return qoi_->value(val, u_coeff, z_coeff, z_param); |
| 1069 |
} |
| 1070 |
|
| 1071 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 1072 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1073 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1074 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1075 |
qoi_->gradient_1(grad, u_coeff, z_coeff, z_param); |
| 1076 |
} |
| 1077 |
|
| 1078 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 1079 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1080 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1081 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1082 |
qoi_->gradient_2(grad, u_coeff, z_coeff, z_param); |
| 1083 |
} |
| 1084 |
|
| 1085 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1086 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1087 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1088 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1089 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1090 |
qoi_->HessVec_11(hess, v_coeff, u_coeff, z_coeff, z_param); |
| 1091 |
} |
| 1092 |
|
| 1093 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1094 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1095 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1096 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1097 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1098 |
qoi_->HessVec_12(hess, v_coeff, u_coeff, z_coeff, z_param); |
| 1099 |
} |
| 1100 |
|
| 1101 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1102 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1103 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1104 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1105 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1106 |
qoi_->HessVec_21(hess, v_coeff, u_coeff, z_coeff, z_param); |
| 1107 |
} |
| 1108 |
|
| 1109 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1110 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1111 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1112 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1113 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1114 |
qoi_->HessVec_22(hess, v_coeff, u_coeff, z_coeff, z_param); |
| 1115 |
} |
| 1116 |
|
| 1117 |
}; |
| 1118 |
|
| 1119 |
template <class Real> |
| 1120 |
class QoI_DownStreamPower_NavierStokes : public QoI<Real> { |
| 1121 |
private: |
| 1122 |
const ROL::Ptr<FE<Real>> feVel_; |
| 1123 |
const ROL::Ptr<FE<Real>> fePrs_; |
| 1124 |
const std::vector<ROL::Ptr<FE<Real>>> feVelBdry_; |
| 1125 |
const std::vector<std::vector<int>> bdryCellLocIds_; |
| 1126 |
const ROL::Ptr<FieldHelper<Real>> fieldHelper_; |
| 1127 |
const std::vector<Real> target_; |
| 1128 |
|
| 1129 |
ROL::Ptr<Intrepid::FieldContainer<Real>> getBoundaryCoeff( |
| 1130 |
const Intrepid::FieldContainer<Real> &cell_coeff, |
| 1131 |
const int locSideId) const { |
| 1132 |
std::vector<int> bdryCellLocId = bdryCellLocIds_[locSideId]; |
| 1133 |
const int numCellsSide = bdryCellLocId.size(); |
| 1134 |
const int f = feVel_->N()->dimension(1); |
| 1135 |
|
| 1136 |
ROL::Ptr<Intrepid::FieldContainer<Real >> bdry_coeff = |
| 1137 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, f); |
| 1138 |
for (int i = 0; i < numCellsSide; ++i) { |
| 1139 |
for (int j = 0; j < f; ++j) { |
| 1140 |
(*bdry_coeff)(i, j) = cell_coeff(bdryCellLocId[i], j); |
| 1141 |
} |
| 1142 |
} |
| 1143 |
return bdry_coeff; |
| 1144 |
} |
| 1145 |
|
| 1146 |
public: |
| 1147 |
QoI_DownStreamPower_NavierStokes(const ROL::Ptr<FE<Real>> &feVel, |
| 1148 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 1149 |
const std::vector<ROL::Ptr<FE<Real>>> &feVelBdry, |
| 1150 |
const std::vector<std::vector<int>> &bdryCellLocIds, |
| 1151 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) |
| 1152 |
: feVel_(feVel), fePrs_(fePrs), feVelBdry_(feVelBdry), |
| 1153 |
bdryCellLocIds_(bdryCellLocIds), fieldHelper_(fieldHelper), |
| 1154 |
target_({1, 0, 0}) {} |
| 1155 |
|
| 1156 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> &val, |
| 1157 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &u_coeff, |
| 1158 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &z_coeff = ROL::nullPtr, |
| 1159 |
const ROL::Ptr<const std::vector<Real>> &z_param = ROL::nullPtr) { |
| 1160 |
const Real half(0.5); |
| 1161 |
const int c = feVel_->gradN()->dimension(0); |
| 1162 |
const int d = feVel_->gradN()->dimension(3); |
| 1163 |
const int numLocSides = bdryCellLocIds_.size(); |
| 1164 |
// Initialize storage |
| 1165 |
int numCellsSide(0), numCubPerSide(0), cidx(0); |
| 1166 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> U, u(d); |
| 1167 |
ROL::Ptr<Intrepid::FieldContainer<Real>> tmp, u_diff, intVal; |
| 1168 |
val = ROL::makePtr<Intrepid::FieldContainer<Real>>(c); |
| 1169 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 1170 |
// Compute cost integral |
| 1171 |
for (int l = 0; l < numLocSides; ++l) { |
| 1172 |
numCellsSide = bdryCellLocIds_[l].size(); |
| 1173 |
if ( numCellsSide ) { |
| 1174 |
numCubPerSide = feVelBdry_[l]->cubPts()->dimension(1); |
| 1175 |
u_diff = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1176 |
intVal = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide); |
| 1177 |
// Evaluate objective function value |
| 1178 |
for (int i = 0; i < d; ++i) { |
| 1179 |
u[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1180 |
tmp = getBoundaryCoeff(*U[i], l); |
| 1181 |
feVelBdry_[l]->evaluateValue(u[i], tmp); |
| 1182 |
for (int j = 0; j < numCellsSide; ++j) { |
| 1183 |
for (int k = 0; k < numCubPerSide; ++k) { |
| 1184 |
(*u_diff)(j,k) += std::pow((*u[i])(j,k)-target_[i],2); |
| 1185 |
} |
| 1186 |
} |
| 1187 |
} |
| 1188 |
// Integrate objective function |
| 1189 |
feVelBdry_[l]->computeIntegral(intVal,u_diff,u[0],false); |
| 1190 |
// Add to volume integral value |
| 1191 |
for (int i = 0; i < numCellsSide; ++i) { |
| 1192 |
cidx = bdryCellLocIds_[l][i]; |
| 1193 |
(*val)(cidx) += half*(*intVal)(i); |
| 1194 |
} |
| 1195 |
} |
| 1196 |
} |
| 1197 |
return static_cast<Real>(0); |
| 1198 |
} |
| 1199 |
|
| 1200 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> &grad, |
| 1201 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &u_coeff, |
| 1202 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &z_coeff = ROL::nullPtr, |
| 1203 |
const ROL::Ptr<const std::vector<Real>> &z_param = ROL::nullPtr) { |
| 1204 |
const Real half(0.5); |
| 1205 |
const int c = feVel_->gradN()->dimension(0); |
| 1206 |
const int fv = feVel_->gradN()->dimension(1); |
| 1207 |
const int fp = fePrs_->gradN()->dimension(1); |
| 1208 |
const int d = feVel_->gradN()->dimension(3); |
| 1209 |
const int numLocSides = bdryCellLocIds_.size(); |
| 1210 |
// Initialize output grad |
| 1211 |
int numCellsSide(0), numCubPerSide(0), cidx(0); |
| 1212 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G(d+1), u(d), U; |
| 1213 |
ROL::Ptr<Intrepid::FieldContainer<Real>> tmp, du, intGrad; |
| 1214 |
for (int i = 0; i < d; ++i) { |
| 1215 |
G[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fv); |
| 1216 |
} |
| 1217 |
G[d] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fp); |
| 1218 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 1219 |
// Compute cost integral |
| 1220 |
for (int l = 0; l < numLocSides; ++l) { |
| 1221 |
numCellsSide = bdryCellLocIds_[l].size(); |
| 1222 |
if ( numCellsSide ) { |
| 1223 |
numCubPerSide = feVelBdry_[l]->cubPts()->dimension(1); |
| 1224 |
// Evaluate objective function gradient |
| 1225 |
du = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1226 |
intGrad = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, fv); |
| 1227 |
for (int i = 0; i < d; ++i) { |
| 1228 |
tmp = getBoundaryCoeff(*U[i], l); |
| 1229 |
u[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1230 |
feVelBdry_[l]->evaluateValue(u[i], tmp); |
| 1231 |
} |
| 1232 |
for (int i = 0; i < d; ++i) { |
| 1233 |
for (int j = 0; j < numCellsSide; ++j) { |
| 1234 |
for (int k = 0; k < numCubPerSide; ++k) { |
| 1235 |
(*du)(j,k) = ((*u[i])(j,k)-target_[i])*(*u[0])(j,k); |
| 1236 |
if (i==0) { |
| 1237 |
for (int m = 0; m < d; ++m) { |
| 1238 |
(*du)(j,k) += half*std::pow((*u[m])(j,k)-target_[m],2); |
| 1239 |
} |
| 1240 |
} |
| 1241 |
} |
| 1242 |
} |
| 1243 |
// Integrate gradient |
| 1244 |
Intrepid::FunctionSpaceTools::integrate<Real>(*intGrad, |
| 1245 |
*du, |
| 1246 |
*(feVelBdry_[l]->NdetJ()), |
| 1247 |
Intrepid::COMP_CPP, |
| 1248 |
false); |
| 1249 |
for (int j = 0; j < numCellsSide; ++j) { |
| 1250 |
cidx = bdryCellLocIds_[l][j]; |
| 1251 |
for (int k = 0; k < fv; ++k) { |
| 1252 |
(*G[i])(cidx,k) += (*intGrad)(j,k); |
| 1253 |
} |
| 1254 |
} |
| 1255 |
} |
| 1256 |
} |
| 1257 |
} |
| 1258 |
fieldHelper_->combineFieldCoeff(grad, G); |
| 1259 |
} |
| 1260 |
|
| 1261 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> &grad, |
| 1262 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &u_coeff, |
| 1263 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &z_coeff = ROL::nullPtr, |
| 1264 |
const ROL::Ptr<const std::vector<Real>> &z_param = ROL::nullPtr) { |
| 1265 |
throw Exception::Zero(">>> QoI_DownStreamPower_NavierStokes::gradient_2 is zero."); |
| 1266 |
} |
| 1267 |
|
| 1268 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> &hess, |
| 1269 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &v_coeff, |
| 1270 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &u_coeff, |
| 1271 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &z_coeff = ROL::nullPtr, |
| 1272 |
const ROL::Ptr<const std::vector<Real>> &z_param = ROL::nullPtr) { |
| 1273 |
const int c = feVel_->gradN()->dimension(0); |
| 1274 |
const int fv = feVel_->gradN()->dimension(1); |
| 1275 |
const int fp = fePrs_->gradN()->dimension(1); |
| 1276 |
const int d = feVel_->gradN()->dimension(3); |
| 1277 |
const int numLocSides = bdryCellLocIds_.size(); |
| 1278 |
// Initialize output hess |
| 1279 |
int numCellsSide(0), numCubPerSide(0), cidx(0); |
| 1280 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> H(d+1), U, V, u(d), v(d); |
| 1281 |
ROL::Ptr<Intrepid::FieldContainer<Real>> tmp, du, intHess; |
| 1282 |
for (int i = 0; i < d; ++i) { |
| 1283 |
H[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fv); |
| 1284 |
} |
| 1285 |
H[d] = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fp); |
| 1286 |
fieldHelper_->splitFieldCoeff(U, u_coeff); |
| 1287 |
fieldHelper_->splitFieldCoeff(V, v_coeff); |
| 1288 |
// Compute cost integral |
| 1289 |
for (int l = 0; l < numLocSides; ++l) { |
| 1290 |
numCellsSide = bdryCellLocIds_[l].size(); |
| 1291 |
if ( numCellsSide ) { |
| 1292 |
numCubPerSide = feVelBdry_[l]->cubPts()->dimension(1); |
| 1293 |
// Evaluate state and direction on FE basis |
| 1294 |
du = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1295 |
intHess = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, fv); |
| 1296 |
for (int i = 0; i < d; ++i) { |
| 1297 |
tmp = getBoundaryCoeff(*U[i], l); |
| 1298 |
u[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1299 |
feVelBdry_[l]->evaluateValue(u[i], tmp); |
| 1300 |
tmp = getBoundaryCoeff(*V[i], l); |
| 1301 |
v[i] = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1302 |
feVelBdry_[l]->evaluateValue(v[i], tmp); |
| 1303 |
} |
| 1304 |
// Compute hessian times a vector |
| 1305 |
for (int i = 0; i < d; ++i) { |
| 1306 |
for (int j = 0; j < numCellsSide; ++j) { |
| 1307 |
for (int k = 0; k < numCubPerSide; ++k) { |
| 1308 |
if (i==0) { |
| 1309 |
(*du)(j,k) = (((*u[0])(j,k)-target_[i])+(*u[0])(j,k))*(*v[0])(j,k); |
| 1310 |
for (int m = 0; m < d; ++m) { |
| 1311 |
(*du)(j,k) += ((*u[m])(j,k)-target_[m])*(*v[m])(j,k); |
| 1312 |
} |
| 1313 |
} |
| 1314 |
else { |
| 1315 |
(*du)(j,k) = (*u[i])(j,k)*(*v[0])(j,k) + (*u[0])(j,k)*(*v[i])(j,k); |
| 1316 |
} |
| 1317 |
} |
| 1318 |
} |
| 1319 |
// Integrate hessian |
| 1320 |
Intrepid::FunctionSpaceTools::integrate<Real>(*intHess, |
| 1321 |
*du, |
| 1322 |
*(feVelBdry_[l]->NdetJ()), |
| 1323 |
Intrepid::COMP_CPP, |
| 1324 |
false); |
| 1325 |
for (int j = 0; j < numCellsSide; ++j) { |
| 1326 |
cidx = bdryCellLocIds_[l][j]; |
| 1327 |
for (int k = 0; k < fv; ++k) { |
| 1328 |
(*H[i])(cidx,k) += (*intHess)(j,k); |
| 1329 |
} |
| 1330 |
} |
| 1331 |
} |
| 1332 |
} |
| 1333 |
} |
| 1334 |
fieldHelper_->combineFieldCoeff(hess, H); |
| 1335 |
} |
| 1336 |
|
| 1337 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> &hess, |
| 1338 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &v_coeff, |
| 1339 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &u_coeff, |
| 1340 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &z_coeff = ROL::nullPtr, |
| 1341 |
const ROL::Ptr<const std::vector<Real>> &z_param = ROL::nullPtr) { |
| 1342 |
throw Exception::Zero(">>> QoI_DownStreamPower_NavierStokes::HessVec_12 is zero."); |
| 1343 |
} |
| 1344 |
|
| 1345 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> &hess, |
| 1346 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &v_coeff, |
| 1347 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &u_coeff, |
| 1348 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &z_coeff = ROL::nullPtr, |
| 1349 |
const ROL::Ptr<const std::vector<Real>> &z_param = ROL::nullPtr) { |
| 1350 |
throw Exception::Zero(">>> QoI_DownStreamPower_NavierStokes::HessVec_21 is zero."); |
| 1351 |
} |
| 1352 |
|
| 1353 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> &hess, |
| 1354 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &v_coeff, |
| 1355 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &u_coeff, |
| 1356 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> &z_coeff = ROL::nullPtr, |
| 1357 |
const ROL::Ptr<const std::vector<Real>> &z_param = ROL::nullPtr) { |
| 1358 |
throw Exception::Zero(">>> QoI_DownStreamPower_NavierStokes::HessVec_22 is zero."); |
| 1359 |
} |
| 1360 |
|
| 1361 |
}; // QoI_DownStreamPower_NavierStokes |
| 1362 |
|
| 1363 |
template <class Real> |
| 1364 |
class QoI_L2Penalty_NavierStokes : public QoI<Real> { |
| 1365 |
private: |
| 1366 |
const ROL::Ptr<FE<Real>> feVel_; |
| 1367 |
const ROL::Ptr<FE<Real>> fePrs_; |
| 1368 |
const std::vector<ROL::Ptr<FE<Real>>> feVelBdry_; |
| 1369 |
const std::vector<std::vector<int>> bdryCellLocIds_; |
| 1370 |
const ROL::Ptr<FieldHelper<Real>> fieldHelper_; |
| 1371 |
|
| 1372 |
ROL::Ptr<Intrepid::FieldContainer<Real>> getBoundaryCoeff( |
| 1373 |
const Intrepid::FieldContainer<Real> & cell_coeff, |
| 1374 |
int locSideId) const { |
| 1375 |
std::vector<int> bdryCellLocId = bdryCellLocIds_[locSideId]; |
| 1376 |
const int numCellsSide = bdryCellLocId.size(); |
| 1377 |
const int f = feVel_->N()->dimension(1); |
| 1378 |
|
| 1379 |
ROL::Ptr<Intrepid::FieldContainer<Real >> bdry_coeff = |
| 1380 |
ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, f); |
| 1381 |
for (int i = 0; i < numCellsSide; ++i) { |
| 1382 |
for (int j = 0; j < f; ++j) { |
| 1383 |
(*bdry_coeff)(i, j) = cell_coeff(bdryCellLocId[i], j); |
| 1384 |
} |
| 1385 |
} |
| 1386 |
return bdry_coeff; |
| 1387 |
} |
| 1388 |
|
| 1389 |
public: |
| 1390 |
QoI_L2Penalty_NavierStokes(const ROL::Ptr<FE<Real>> &feVel, |
| 1391 |
const ROL::Ptr<FE<Real>> &fePrs, |
| 1392 |
const std::vector<ROL::Ptr<FE<Real>>> &feVelBdry, |
| 1393 |
const std::vector<std::vector<int>> &bdryCellLocIds, |
| 1394 |
const ROL::Ptr<FieldHelper<Real>> &fieldHelper) |
| 1395 |
: feVel_(feVel), fePrs_(fePrs), feVelBdry_(feVelBdry), |
| 1396 |
bdryCellLocIds_(bdryCellLocIds), fieldHelper_(fieldHelper) {} |
| 1397 |
|
| 1398 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real>> & val, |
| 1399 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1400 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1401 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1402 |
const int c = feVel_->gradN()->dimension(0); |
| 1403 |
// Get components of the control |
| 1404 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> Z; |
| 1405 |
fieldHelper_->splitFieldCoeff(Z, z_coeff); |
| 1406 |
// Initialize output val |
| 1407 |
val = ROL::makePtr<Intrepid::FieldContainer<Real>>(c); |
| 1408 |
// Compute cost integral |
| 1409 |
const int numLocSides = bdryCellLocIds_.size(); |
| 1410 |
for (int l = 0; l < numLocSides; ++l) { |
| 1411 |
const int numCellsSide = bdryCellLocIds_[l].size(); |
| 1412 |
if ( numCellsSide ) { |
| 1413 |
const int numCubPerSide = feVelBdry_[l]->cubPts()->dimension(1); |
| 1414 |
// Evaluate x-component of control on FE basis |
| 1415 |
ROL::Ptr<Intrepid::FieldContainer<Real>> zx_coeff_bdry |
| 1416 |
= getBoundaryCoeff(*Z[0], l); |
| 1417 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valZX_eval |
| 1418 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1419 |
feVelBdry_[l]->evaluateValue(valZX_eval, zx_coeff_bdry); |
| 1420 |
// Evaluate y-component of control on FE basis |
| 1421 |
ROL::Ptr<Intrepid::FieldContainer<Real>> zy_coeff_bdry |
| 1422 |
= getBoundaryCoeff(*Z[1], l); |
| 1423 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valZY_eval |
| 1424 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1425 |
feVelBdry_[l]->evaluateValue(valZY_eval, zy_coeff_bdry); |
| 1426 |
// Integrate cell L2 norm squared |
| 1427 |
ROL::Ptr<Intrepid::FieldContainer<Real>> intVal |
| 1428 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide); |
| 1429 |
feVelBdry_[l]->computeIntegral(intVal,valZX_eval,valZX_eval,false); |
| 1430 |
feVelBdry_[l]->computeIntegral(intVal,valZY_eval,valZY_eval,true); |
| 1431 |
// Add to integral value |
| 1432 |
for (int i = 0; i < numCellsSide; ++i) { |
| 1433 |
int cidx = bdryCellLocIds_[l][i]; |
| 1434 |
(*val)(cidx) += static_cast<Real>(0.5)*(*intVal)(i); |
| 1435 |
} |
| 1436 |
} |
| 1437 |
} |
| 1438 |
return static_cast<Real>(0); |
| 1439 |
} |
| 1440 |
|
| 1441 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 1442 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1443 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1444 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1445 |
throw Exception::Zero(">>> QoI_L2Penalty_NavierStokes::gradient_1 is zero."); |
| 1446 |
} |
| 1447 |
|
| 1448 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & grad, |
| 1449 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1450 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1451 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1452 |
const int c = feVel_->gradN()->dimension(0); |
| 1453 |
const int fv = feVel_->gradN()->dimension(1); |
| 1454 |
const int fp = fePrs_->gradN()->dimension(1); |
| 1455 |
// Initialize output grad |
| 1456 |
Intrepid::FieldContainer<Real> velZX_grad(c, fv); |
| 1457 |
Intrepid::FieldContainer<Real> velZY_grad(c, fv); |
| 1458 |
Intrepid::FieldContainer<Real> presZ_grad(c, fp); |
| 1459 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G; |
| 1460 |
G.resize(fieldHelper_->numFields()); |
| 1461 |
G[0] = ROL::makePtrFromRef(velZX_grad); |
| 1462 |
G[1] = ROL::makePtrFromRef(velZY_grad); |
| 1463 |
G[2] = ROL::makePtrFromRef(presZ_grad); |
| 1464 |
// Get components of the control |
| 1465 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> Z; |
| 1466 |
fieldHelper_->splitFieldCoeff(Z, z_coeff); |
| 1467 |
// Compute cost integral |
| 1468 |
const int numLocSides = bdryCellLocIds_.size(); |
| 1469 |
for (int l = 0; l < numLocSides; ++l) { |
| 1470 |
const int numCellsSide = bdryCellLocIds_[l].size(); |
| 1471 |
if ( numCellsSide ) { |
| 1472 |
const int numCubPerSide = feVelBdry_[l]->cubPts()->dimension(1); |
| 1473 |
// Evaluate x-component of control on FE basis |
| 1474 |
ROL::Ptr<Intrepid::FieldContainer<Real>> zx_coeff_bdry |
| 1475 |
= getBoundaryCoeff(*Z[0], l); |
| 1476 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valZX_eval |
| 1477 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1478 |
feVelBdry_[l]->evaluateValue(valZX_eval, zx_coeff_bdry); |
| 1479 |
// Evaluate y-component of control on FE basis |
| 1480 |
ROL::Ptr<Intrepid::FieldContainer<Real>> zy_coeff_bdry |
| 1481 |
= getBoundaryCoeff(*Z[1], l); |
| 1482 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valZY_eval |
| 1483 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1484 |
feVelBdry_[l]->evaluateValue(valZY_eval, zy_coeff_bdry); |
| 1485 |
// Compute gradient of squared L2-norm of diff |
| 1486 |
ROL::Ptr<Intrepid::FieldContainer<Real>> intGradX |
| 1487 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, fv); |
| 1488 |
Intrepid::FunctionSpaceTools::integrate<Real>(*intGradX, |
| 1489 |
*valZX_eval, |
| 1490 |
*(feVelBdry_[l]->NdetJ()), |
| 1491 |
Intrepid::COMP_CPP, false); |
| 1492 |
ROL::Ptr<Intrepid::FieldContainer<Real>> intGradY |
| 1493 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, fv); |
| 1494 |
Intrepid::FunctionSpaceTools::integrate<Real>(*intGradY, |
| 1495 |
*valZY_eval, |
| 1496 |
*(feVelBdry_[l]->NdetJ()), |
| 1497 |
Intrepid::COMP_CPP, false); |
| 1498 |
// Add to integral value |
| 1499 |
for (int i = 0; i < numCellsSide; ++i) { |
| 1500 |
int cidx = bdryCellLocIds_[l][i]; |
| 1501 |
for (int j = 0; j < fv; ++j) { |
| 1502 |
(*G[0])(cidx,j) += (*intGradX)(i,j); |
| 1503 |
(*G[1])(cidx,j) += (*intGradY)(i,j); |
| 1504 |
} |
| 1505 |
} |
| 1506 |
} |
| 1507 |
} |
| 1508 |
|
| 1509 |
fieldHelper_->combineFieldCoeff(grad, G); |
| 1510 |
} |
| 1511 |
|
| 1512 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1513 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1514 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1515 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1516 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1517 |
throw Exception::Zero(">>> QoI_L2Penalty_NavierStokes::HessVec_11 is zero."); |
| 1518 |
} |
| 1519 |
|
| 1520 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1521 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1522 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1523 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1524 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1525 |
throw Exception::Zero(">>> QoI_L2Penalty_NavierStokes::HessVec_12 is zero."); |
| 1526 |
} |
| 1527 |
|
| 1528 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1529 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1530 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1531 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1532 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1533 |
throw Exception::Zero(">>> QoI_L2Penalty_NavierStokes::HessVec_21 is zero."); |
| 1534 |
} |
| 1535 |
|
| 1536 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess, |
| 1537 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & v_coeff, |
| 1538 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff, |
| 1539 |
const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr, |
| 1540 |
const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) { |
| 1541 |
const int c = feVel_->gradN()->dimension(0); |
| 1542 |
const int fv = feVel_->gradN()->dimension(1); |
| 1543 |
const int fp = fePrs_->gradN()->dimension(1); |
| 1544 |
// Initialize output grad |
| 1545 |
Intrepid::FieldContainer<Real> velVX_grad(c, fv); |
| 1546 |
Intrepid::FieldContainer<Real> velVY_grad(c, fv); |
| 1547 |
Intrepid::FieldContainer<Real> presV_grad(c, fp); |
| 1548 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> G; |
| 1549 |
G.resize(fieldHelper_->numFields()); |
| 1550 |
G[0] = ROL::makePtrFromRef(velVX_grad); |
| 1551 |
G[1] = ROL::makePtrFromRef(velVY_grad); |
| 1552 |
G[2] = ROL::makePtrFromRef(presV_grad); |
| 1553 |
// Get components of the control |
| 1554 |
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> V; |
| 1555 |
fieldHelper_->splitFieldCoeff(V, v_coeff); |
| 1556 |
// Compute cost integral |
| 1557 |
const int numLocSides = bdryCellLocIds_.size(); |
| 1558 |
for (int l = 0; l < numLocSides; ++l) { |
| 1559 |
const int numCellsSide = bdryCellLocIds_[l].size(); |
| 1560 |
if ( numCellsSide ) { |
| 1561 |
const int numCubPerSide = feVelBdry_[l]->cubPts()->dimension(1); |
| 1562 |
// Evaluate x-component of control on FE basis |
| 1563 |
ROL::Ptr<Intrepid::FieldContainer<Real>> vx_coeff_bdry |
| 1564 |
= getBoundaryCoeff(*V[0], l); |
| 1565 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valVX_eval |
| 1566 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1567 |
feVelBdry_[l]->evaluateValue(valVX_eval, vx_coeff_bdry); |
| 1568 |
// Evaluate y-component of control on FE basis |
| 1569 |
ROL::Ptr<Intrepid::FieldContainer<Real>> vy_coeff_bdry |
| 1570 |
= getBoundaryCoeff(*V[1], l); |
| 1571 |
ROL::Ptr<Intrepid::FieldContainer<Real>> valVY_eval |
| 1572 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide); |
| 1573 |
feVelBdry_[l]->evaluateValue(valVY_eval, vy_coeff_bdry); |
| 1574 |
// Compute gradient of squared L2-norm of diff |
| 1575 |
ROL::Ptr<Intrepid::FieldContainer<Real>> intHessX |
| 1576 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, fv); |
| 1577 |
Intrepid::FunctionSpaceTools::integrate<Real>(*intHessX, |
| 1578 |
*valVX_eval, |
| 1579 |
*(feVelBdry_[l]->NdetJ()), |
| 1580 |
Intrepid::COMP_CPP, false); |
| 1581 |
ROL::Ptr<Intrepid::FieldContainer<Real>> intHessY |
| 1582 |
= ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, fv); |
| 1583 |
Intrepid::FunctionSpaceTools::integrate<Real>(*intHessY, |
| 1584 |
*valVY_eval, |
| 1585 |
*(feVelBdry_[l]->NdetJ()), |
| 1586 |
Intrepid::COMP_CPP, false); |
| 1587 |
// Add to integral value |
| 1588 |
for (int i = 0; i < numCellsSide; ++i) { |
| 1589 |
int cidx = bdryCellLocIds_[l][i]; |
| 1590 |
for (int j = 0; j < fv; ++j) { |
| 1591 |
(*G[0])(cidx,j) += (*intHessX)(i,j); |
| 1592 |
(*G[1])(cidx,j) += (*intHessY)(i,j); |
| 1593 |
} |
| 1594 |
} |
| 1595 |
} |
| 1596 |
} |
| 1597 |
|
| 1598 |
fieldHelper_->combineFieldCoeff(hess, G); |
| 1599 |
} |
| 1600 |
|
| 1601 |
}; // QoI_L2Penalty_NavierStokes |
| 1602 |
|
| 1603 |
template <class Real> |
| 1604 |
class QoI_RotationControl_NavierStokes : public QoI<Real> { |
| 1605 |
public: |
| 1606 |
QoI_RotationControl_NavierStokes(void) {} |
| 1607 |
|
| 1608 |
Real value(ROL::Ptr<Intrepid::FieldContainer<Real> > & val, |
| 1609 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1610 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1611 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1612 |
const int size = z_param->size(); |
| 1613 |
Real half(0.5), sum(0); |
| 1614 |
for (int i = 0; i < size; ++i) { |
| 1615 |
sum += std::pow((*z_param)[i],2); |
| 1616 |
} |
| 1617 |
val = ROL::nullPtr; |
| 1618 |
return half * sum; |
| 1619 |
} |
| 1620 |
|
| 1621 |
void gradient_1(ROL::Ptr<Intrepid::FieldContainer<Real> > & grad, |
| 1622 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1623 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1624 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1625 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::gradient_1 is zero."); |
| 1626 |
} |
| 1627 |
|
| 1628 |
void gradient_2(ROL::Ptr<Intrepid::FieldContainer<Real> > & grad, |
| 1629 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1630 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1631 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1632 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::gradient_2 is zero."); |
| 1633 |
} |
| 1634 |
|
| 1635 |
std::vector<Real> gradient_3(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real> > > & grad, |
| 1636 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1637 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1638 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1639 |
std::vector<Real> g; g.assign(z_param->begin(),z_param->end()); |
| 1640 |
return g; |
| 1641 |
} |
| 1642 |
|
| 1643 |
void HessVec_11(ROL::Ptr<Intrepid::FieldContainer<Real> > & hess, |
| 1644 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & v_coeff, |
| 1645 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1646 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1647 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1648 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_11 is zero."); |
| 1649 |
} |
| 1650 |
|
| 1651 |
void HessVec_12(ROL::Ptr<Intrepid::FieldContainer<Real> > & hess, |
| 1652 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & v_coeff, |
| 1653 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1654 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1655 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1656 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_12 is zero."); |
| 1657 |
} |
| 1658 |
|
| 1659 |
void HessVec_13(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real> > > & hess, |
| 1660 |
const ROL::Ptr<const std::vector<Real> > & v_param, |
| 1661 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1662 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1663 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1664 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_13 is zero."); |
| 1665 |
} |
| 1666 |
|
| 1667 |
void HessVec_21(ROL::Ptr<Intrepid::FieldContainer<Real> > & hess, |
| 1668 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & v_coeff, |
| 1669 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1670 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1671 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1672 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_21 is zero."); |
| 1673 |
} |
| 1674 |
|
| 1675 |
void HessVec_22(ROL::Ptr<Intrepid::FieldContainer<Real> > & hess, |
| 1676 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & v_coeff, |
| 1677 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1678 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1679 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1680 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_22 is zero."); |
| 1681 |
} |
| 1682 |
|
| 1683 |
void HessVec_23(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real> > > & hess, |
| 1684 |
const ROL::Ptr<const std::vector<Real> > & v_param, |
| 1685 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1686 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1687 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1688 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_23 is zero."); |
| 1689 |
} |
| 1690 |
|
| 1691 |
std::vector<Real> HessVec_31(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real> > > & hess, |
| 1692 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & v_coeff, |
| 1693 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1694 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1695 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1696 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_31 is zero."); |
| 1697 |
} |
| 1698 |
|
| 1699 |
std::vector<Real> HessVec_32(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real> > > & hess, |
| 1700 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & v_coeff, |
| 1701 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1702 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1703 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1704 |
throw Exception::Zero(">>> QoI_RotationControl_NavierStokes::HessVec_32 is zero."); |
| 1705 |
} |
| 1706 |
|
| 1707 |
std::vector<Real> HessVec_33(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real> > > & hess, |
| 1708 |
const ROL::Ptr<const std::vector<Real> > & v_param, |
| 1709 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & u_coeff, |
| 1710 |
const ROL::Ptr<const Intrepid::FieldContainer<Real> > & z_coeff = ROL::nullPtr, |
| 1711 |
const ROL::Ptr<const std::vector<Real> > & z_param = ROL::nullPtr) { |
| 1712 |
std::vector<Real> h; h.assign(v_param->begin(),v_param->end()); |
| 1713 |
return h; |
| 1714 |
} |
| 1715 |
|
| 1716 |
}; // QoI_RotationControl_NavierStoke |
| 1717 |
|
| 1718 |
#endif |