Debian Codegraph @

packages/rol/example/PDE-OPT/flow-opt/3dim/models/darcy/pde_darcy.hpp

raw
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 pde_darcy.hpp
11 \brief Implements the local PDE interface for the Darcy porosity optimization problem.
12 */
13
14 #ifndef PDE_DARCY_HPP
15 #define PDE_DARCY_HPP
16
17 #include "../../../../TOOLS/pde.hpp"
18 #include "../../../../TOOLS/fe.hpp"
19 #include "../../../../TOOLS/fieldhelper.hpp"
20 #include "permeability.hpp"
21
22 #include "../../../../TOOLS/Intrepid_HGRAD_C0_FEM.hpp"
23 #include "Intrepid_HGRAD_QUAD_C1_FEM.hpp"
24 #include "Intrepid_HGRAD_QUAD_C2_FEM.hpp"
25 #include "Intrepid_HGRAD_TRI_C1_FEM.hpp"
26 #include "Intrepid_HGRAD_TRI_C2_FEM.hpp"
27 #include "Intrepid_DefaultCubatureFactory.hpp"
28 #include "Intrepid_FunctionSpaceTools.hpp"
29
30 #include "ROL_Ptr.hpp"
31
32 template <class Real>
33 class PDE_Darcy : public PDE<Real> {
34 private:
35 // Finite element basis information
36 ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>> basisPtrPrs_, basisPtrCtrl_;
37 std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> basisPtrs_, basisPtrsCtrl_;
38 // Cell cubature information
39 ROL::Ptr<Intrepid::Cubature<Real>> cellCub_, bdryCub_;
40 // Cell node information
41 ROL::Ptr<Intrepid::FieldContainer<Real>> volCellNodes_;
42 std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> bdryCellNodes_;
43 std::vector<std::vector<std::vector<int>>> bdryCellLocIds_;
44 // Finite element definition
45 ROL::Ptr<FE<Real>> fePrs_, feCtrl_;
46 std::vector<std::vector<ROL::Ptr<FE<Real>>>> fePrsBdry_, feCtrlBdry_;
47 // Local degrees of freedom on boundary, for each side of the reference cell (first index).
48 std::vector<std::vector<int>> fpidx_;
49 // Field pattern, offsets, etc.
50 std::vector<std::vector<int>> fieldPattern_; // local Field/DOF pattern; set from DOF manager
51 int numFields_; // number of fields (equations in the PDE)
52 int numDofs_; // total number of degrees of freedom for all (local) fields
53 std::vector<int> offset_; // for each field, a counting offset
54 std::vector<int> numFieldDofs_; // for each field, number of degrees of freedom
55 std::vector<std::vector<int>> fieldPatternCtrl_; // local Field/DOF pattern; set from DOF manager
56 int numFieldsCtrl_; // number of fields (equations in the PDE)
57 int numDofsCtrl_; // total number of degrees of freedom for all (local) fields
58 std::vector<int> offsetCtrl_; // for each field, a counting offset
59 std::vector<int> numFieldDofsCtrl_; // for each field, number of degrees of freedom
60
61 // Problem parameters.
62 Real Patm_, inVelocity_, dynvisco_;
63 bool useNoSlip_;
64
65 ROL::Ptr<Permeability<Real>> perm_;
66 ROL::Ptr<FieldUtils::FieldInfo> fieldInfo_, fieldInfoCtrl_;
67
68 void multiplyByRadius(ROL::Ptr<Intrepid::FieldContainer<Real>> &input,
69 const ROL::Ptr<const Intrepid::FieldContainer<Real>> &cubPts,
70 bool isField, bool useReciprocal = false) const {
71 int c = cubPts->dimension(0);
72 int p = cubPts->dimension(1);
73 Intrepid::FieldContainer<Real> r(c,p);
74 for (int i = 0; i < c; ++i) {
75 for (int j = 0; j < p; ++j) {
76 if (!useReciprocal) r(i,j) = (*cubPts)(i,j,0);
77 else r(i,j) = static_cast<Real>(1)/(*cubPts)(i,j,0);
78 }
79 }
80 Intrepid::FieldContainer<Real> in = *input;
81 if (!isField)
82 Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*input,r,in);
83 else
84 Intrepid::FunctionSpaceTools::scalarMultiplyDataField<Real>(*input,r,in);
85 }
86
87 public:
88 PDE_Darcy(Teuchos::ParameterList &parlist) : Patm_(101.325 /* kg/mm-s^2 */) {
89 // Finite element fields.
90 int cubDegree = parlist.sublist("Problem").get("Cubature Degree",4);
91 int bdryCubDegree = parlist.sublist("Problem").get("Boundary Cubature Degree",2);
92 int basisDegPres = parlist.sublist("Problem").get("Pressure Basis Degree",1);
93 int basisDegCtrl = parlist.sublist("Problem").get("Density Basis Degree",1);
94 std::string elemType = parlist.sublist("Problem").get("Element Type","TET");
95 if (elemType == "TET") {
96 if (basisDegPres == 2) {
97 basisPtrPrs_ = ROL::makePtr<Intrepid::Basis_HGRAD_TET_C2_FEM<Real, Intrepid::FieldContainer<Real>>>();
98 }
99 else {
100 std::cout << "\nFirst-order TET basis selected.\n";
101 basisPtrPrs_ = ROL::makePtr<Intrepid::Basis_HGRAD_TET_C1_FEM<Real, Intrepid::FieldContainer<Real>>>();
102 }
103 if (basisDegCtrl == 1) {
104 basisPtrCtrl_ = ROL::makePtr<Intrepid::Basis_HGRAD_TET_C1_FEM<Real, Intrepid::FieldContainer<Real>>>();
105 }
106 else {
107 basisPtrCtrl_ = ROL::makePtr<Intrepid::Basis_HGRAD_C0_FEM<Real, Intrepid::FieldContainer<Real>>>();
108 }
109 }
110 else {
111 if (basisDegPres == 2) {
112 basisPtrPrs_ = ROL::makePtr<Intrepid::Basis_HGRAD_HEX_C2_FEM<Real, Intrepid::FieldContainer<Real>>>();
113 }
114 else {
115 basisPtrPrs_ = ROL::makePtr<Intrepid::Basis_HGRAD_HEX_C1_FEM<Real, Intrepid::FieldContainer<Real>>>();
116 }
117 if (basisDegCtrl == 1) {
118 basisPtrCtrl_ = ROL::makePtr<Intrepid::Basis_HGRAD_HEX_C1_FEM<Real, Intrepid::FieldContainer<Real>>>();
119 }
120 else {
121 basisPtrCtrl_ = ROL::makePtr<Intrepid::Basis_HGRAD_C0_FEM<Real, Intrepid::FieldContainer<Real>>>();
122 }
123 }
124 basisPtrs_.push_back(basisPtrPrs_); // Pressure component
125 basisPtrsCtrl_.push_back(basisPtrCtrl_); // Control component
126 // Quadrature rules.
127 shards::CellTopology cellType = basisPtrs_[0]->getBaseCellTopology(); // get the cell type from any basis
128 Intrepid::DefaultCubatureFactory<Real> cubFactory; // create cubature factory
129 cellCub_ = cubFactory.create(cellType, cubDegree); // create default cubature
130
131 shards::CellTopology bdryCellType = cellType.getCellTopologyData(1, 0);
132 bdryCub_ = cubFactory.create(bdryCellType, bdryCubDegree);
133
134 // Other problem parameters.
135 dynvisco_ = parlist.sublist("Problem").get("Dynamic Viscosity", 0.84e-8); // kg/mm-s
136 Real density = parlist.sublist("Problem").get("Fluid Density", 8.988e-11); // kg/mm^3
137 Real inRadius = parlist.sublist("Problem").get("Inlet Radius", 0.6875); // mm
138 Real Reynolds = parlist.sublist("Problem").get("Reynolds Number", 50.0); // dimensionless
139 inVelocity_ = Reynolds * dynvisco_ / (density*static_cast<Real>(2)*inRadius); // mm/s
140 perm_ = ROL::makePtr<Permeability<Real>>(parlist);
141 useNoSlip_ = parlist.sublist("Problem").get("Use No Slip", false);
142
143 numDofs_ = 0;
144 numFields_ = basisPtrs_.size();
145 offset_.resize(numFields_);
146 numFieldDofs_.resize(numFields_);
147 for (int i=0; i<numFields_; ++i) {
148 offset_[i] = i==0 ? 0 : offset_[i-1] + basisPtrs_[i-1]->getCardinality();
149 numFieldDofs_[i] = basisPtrs_[i]->getCardinality();
150 numDofs_ += numFieldDofs_[i];
151 }
152 numDofsCtrl_ = 0;
153 numFieldsCtrl_ = basisPtrsCtrl_.size();
154 offsetCtrl_.resize(numFieldsCtrl_);
155 numFieldDofsCtrl_.resize(numFieldsCtrl_);
156 for (int i=0; i<numFieldsCtrl_; ++i) {
157 offsetCtrl_[i] = i==0 ? 0 : offsetCtrl_[i-1] + basisPtrsCtrl_[i-1]->getCardinality();
158 numFieldDofsCtrl_[i] = basisPtrsCtrl_[i]->getCardinality();
159 numDofsCtrl_ += numFieldDofsCtrl_[i];
160 }
161 }
162
163 void residual(ROL::Ptr<Intrepid::FieldContainer<Real>> & res,
164 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
165 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
166 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
167 // Retrieve dimensions.
168 const int c = fePrs_->gradN()->dimension(0);
169 const int f = fePrs_->gradN()->dimension(1);
170 const int p = fePrs_->gradN()->dimension(2);
171 const int d = fePrs_->gradN()->dimension(3);
172 // Initialize residuals.
173 res = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f);
174 // Evaluate/interpolate finite element fields on cells.
175 ROL::Ptr<Intrepid::FieldContainer<Real>> gradP, AgradP, valCtrl, alpha;
176 gradP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
177 AgradP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
178 valCtrl = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
179 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
180 fePrs_->evaluateGradient(gradP, u_coeff);
181 feCtrl_->evaluateValue(valCtrl, z_coeff);
182 perm_->compute(alpha, valCtrl, fePrs_->cubPts(), 0);
183 Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*AgradP,*alpha,*gradP);
184 /*** Evaluate weak form of the residual. ***/
185 //multiplyByRadius(AgradP,fePrs_->cubPts(),false);
186 Intrepid::FunctionSpaceTools::integrate<Real>(*res,
187 *AgradP, // p
188 *fePrs_->gradNdetJ(), // dPhi/dx
189 Intrepid::COMP_CPP,
190 false);
191 // Boundary conditions.
192 int numSideSets = bdryCellLocIds_.size();
193 if (numSideSets > 0) {
194 // APPLY DIRICHLET CONDITIONS
195 for (int i = 0; i < numSideSets; ++i) {
196 if (i==0) /* inflow condition */ {
197 const int numLocalSideIds = bdryCellLocIds_[i].size();
198 for (int j = 0; j < numLocalSideIds; ++j) {
199 const int numCellsSide = bdryCellLocIds_[i][j].size();
200 if (numCellsSide > 0) {
201 const int numCubPerSide = fePrsBdry_[i][j]->cubPts()->dimension(1);
202 ROL::Ptr<Intrepid::FieldContainer<Real>> nRes, nVal;
203 nRes = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, f);
204 nVal = ROL::makePtr<Intrepid::FieldContainer<Real>>(numCellsSide, numCubPerSide);
205 nVal->initialize(-inVelocity_);
206 //multiplyByRadius(nVal,fePrsBdry_[i][j]->cubPts(),false);
207 Intrepid::FunctionSpaceTools::integrate<Real>(*nRes,
208 *nVal,
209 *fePrsBdry_[i][j]->NdetJ(),
210 Intrepid::COMP_CPP,
211 false);
212 for (int k = 0; k < numCellsSide; ++k) {
213 const int cidx = bdryCellLocIds_[i][j][k];
214 for (int l = 0; l < f; ++l) {
215 (*res)(cidx,l) += (*nRes)(k,l);
216 }
217 }
218 }
219 }
220 }
221 else if (i==1) /* outflow condition */ {
222 int numLocalSideIds = bdryCellLocIds_[i].size();
223 for (int j = 0; j < numLocalSideIds; ++j) {
224 int numCellsSide = bdryCellLocIds_[i][j].size();
225 int numBdryDofs = fpidx_[j].size();
226 for (int k = 0; k < numCellsSide; ++k) {
227 int cidx = bdryCellLocIds_[i][j][k];
228 for (int l = 0; l < numBdryDofs; ++l) {
229 (*res)(cidx,fpidx_[j][l]) = (*u_coeff)(cidx,fpidx_[j][l]) - Patm_;
230 }
231 }
232 }
233 }
234 else if (useNoSlip_ && i==2) /* do-nothing condition */ {}
235 }
236 }
237 }
238
239 void Jacobian_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & jac,
240 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
241 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
242 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
243 // Retrieve dimensions.
244 const int c = fePrs_->gradN()->dimension(0);
245 const int f = fePrs_->gradN()->dimension(1);
246 const int p = fePrs_->gradN()->dimension(2);
247 const int d = fePrs_->gradN()->dimension(3);
248 // Initialize Jacobians.
249 jac = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, f);
250 // Evaluate/interpolate finite element fields on cells.
251 ROL::Ptr<Intrepid::FieldContainer<Real>> alpha, alphaPhi, valCtrl;
252 valCtrl = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
253 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
254 alphaPhi = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p, d);
255 feCtrl_->evaluateValue(valCtrl, z_coeff);
256 perm_->compute(alpha, valCtrl, fePrs_->cubPts(), 0);
257 // Multiply velocity with alpha
258 Intrepid::FunctionSpaceTools::scalarMultiplyDataField<Real>(*alphaPhi, *alpha, *fePrs_->gradN());
259 /*** Evaluate weak form of the Jacobian. ***/
260 //multiplyByRadius(alphaPhi,fePrs_->cubPts(),true);
261 Intrepid::FunctionSpaceTools::integrate<Real>(*jac,
262 *alphaPhi, // alpha dPhi/dx
263 *fePrs_->gradNdetJ(), // dPhi/dx
264 Intrepid::COMP_CPP,
265 false);
266 // APPLY DIRICHLET CONDITIONS
267 int numSideSets = bdryCellLocIds_.size();
268 if (numSideSets > 0) {
269 for (int i = 0; i < numSideSets; ++i) {
270 if (i==0) /* inflow condition */ {}
271 else if (i==1) /* outflow condition */ {
272 int numLocalSideIds = bdryCellLocIds_[i].size();
273 for (int j = 0; j < numLocalSideIds; ++j) {
274 int numCellsSide = bdryCellLocIds_[i][j].size();
275 int numBdryDofs = fpidx_[j].size();
276 for (int k = 0; k < numCellsSide; ++k) {
277 int cidx = bdryCellLocIds_[i][j][k];
278 for (int l = 0; l < numBdryDofs; ++l) {
279 for (int m = 0; m < f; ++m) {
280 (*jac)(cidx,fpidx_[j][l],m) = static_cast<Real>(0);
281 }
282 (*jac)(cidx,fpidx_[j][l],fpidx_[j][l]) = static_cast<Real>(1);
283 }
284 }
285 }
286 }
287 else if (useNoSlip_ && i==2) /* do-nothing condition */ {}
288 }
289 }
290 }
291
292 void Jacobian_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & jac,
293 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
294 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
295 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
296 // Retrieve dimensions.
297 const int c = fePrs_->gradN()->dimension(0);
298 const int f = fePrs_->gradN()->dimension(1);
299 const int fc = feCtrl_->gradN()->dimension(1);
300 const int p = fePrs_->gradN()->dimension(2);
301 const int d = fePrs_->gradN()->dimension(3);
302 // Initialize Jacobians.
303 jac = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, fc);
304 // Evaluate on FE basis.
305 ROL::Ptr<Intrepid::FieldContainer<Real>> valZ, alpha, alphaN, gradP, gradPgradN;
306 valZ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
307 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
308 alphaN = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fc, p);
309 gradP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
310 gradPgradN = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p);
311 fePrs_->evaluateGradient(gradP, u_coeff);
312 feCtrl_->evaluateValue(valZ, z_coeff);
313 perm_->compute(alpha, valZ, fePrs_->cubPts(), 1);
314 Intrepid::FunctionSpaceTools::scalarMultiplyDataField<Real>(*alphaN,*alpha,*feCtrl_->N());
315 Intrepid::FunctionSpaceTools::dotMultiplyDataField<Real>(*gradPgradN,*gradP,*fePrs_->gradNdetJ());
316 /*** Evaluate weak form of the residual. ***/
317 //multiplyByRadius(gradPgradN,fePrs_->cubPts(),true);
318 Intrepid::FunctionSpaceTools::integrate<Real>(*jac,
319 *gradPgradN, // dP/dx dPhi/dx
320 *alphaN, // alpha' Phi
321 Intrepid::COMP_CPP,
322 false);
323 // APPLY DIRICHLET CONDITIONS
324 int numSideSets = bdryCellLocIds_.size();
325 if (numSideSets > 0) {
326 for (int i = 0; i < numSideSets; ++i) {
327 if (i==0) /* inflow condition */ {}
328 else if (i==1) /* outflow condition*/ {
329 int numLocalSideIds = bdryCellLocIds_[i].size();
330 for (int j = 0; j < numLocalSideIds; ++j) {
331 int numCellsSide = bdryCellLocIds_[i][j].size();
332 int numBdryDofs = fpidx_[j].size();
333 for (int k = 0; k < numCellsSide; ++k) {
334 int cidx = bdryCellLocIds_[i][j][k];
335 for (int l = 0; l < numBdryDofs; ++l) {
336 for (int m=0; m < fc; ++m) {
337 (*jac)(cidx,fpidx_[j][l],m) = static_cast<Real>(0);
338 }
339 }
340 }
341 }
342 }
343 else if (useNoSlip_ && i==2) /* do-nothing condition */ {}
344 }
345 }
346 }
347
348 void Jacobian_3(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> & jac,
349 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
350 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
351 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
352 throw Exception::Zero(">>> Jacobian_3 is zero!");
353 }
354
355 void Hessian_11(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess,
356 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
357 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
358 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
359 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
360 throw Exception::Zero(">>> Hessian_11 is zero!");
361 }
362
363 void Hessian_12(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess,
364 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
365 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
366 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
367 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
368 // Retrieve dimensions.
369 const int c = fePrs_->gradN()->dimension(0);
370 const int f = fePrs_->gradN()->dimension(1);
371 const int fc = feCtrl_->gradN()->dimension(1);
372 const int p = fePrs_->gradN()->dimension(2);
373 const int d = fePrs_->gradN()->dimension(3);
374 // Initialize hessians.
375 hess = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fc, f);
376 // Apply Dirichlet conditions
377 ROL::Ptr<Intrepid::FieldContainer<Real>> l0_coeff;
378 l0_coeff = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
379 *l0_coeff = *l_coeff;
380 int numSideSets = bdryCellLocIds_.size();
381 if (numSideSets > 0) {
382 for (int i = 0; i < numSideSets; ++i) {
383 if (i==0) /* inflow condition */ {}
384 else if (i==1) /* outflow condition */ {
385 int numLocalSideIds = bdryCellLocIds_[i].size();
386 for (int j = 0; j < numLocalSideIds; ++j) {
387 int numCellsSide = bdryCellLocIds_[i][j].size();
388 int numBdryDofs = fpidx_[j].size();
389 for (int k = 0; k < numCellsSide; ++k) {
390 int cidx = bdryCellLocIds_[i][j][k];
391 for (int l = 0; l < numBdryDofs; ++l) {
392 (*l0_coeff)(cidx,fpidx_[j][l]) = static_cast<Real>(0);
393 }
394 }
395 }
396 }
397 else if (useNoSlip_ && i==2) /* do-nothing condition */ {}
398 }
399 }
400 // Evaluate/interpolate finite element fields on cells.
401 ROL::Ptr<Intrepid::FieldContainer<Real>> valZ, alpha, gradL, alphaL;
402 valZ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
403 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
404 gradL = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
405 alphaL = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fc, p, d);
406 fePrs_->evaluateGradient(gradL, l0_coeff);
407 feCtrl_->evaluateValue(valZ, z_coeff);
408 perm_->compute(alpha, valZ, fePrs_->cubPts(), 1);
409 /*** Evaluate weak form of the Hessian. ***/
410 // Multiply velocity with alpha
411 for (int j = 0; j < c; ++j) {
412 for (int k = 0; k < fc; ++k) {
413 for (int l = 0; l < p; ++l) {
414 for (int m = 0; m < d; ++m) {
415 (*alphaL)(j,k,l,m) = (*alpha)(j,l) * (*feCtrl_->N())(j,k,l) * (*gradL)(j,l,m);
416 }
417 }
418 }
419 }
420 //multiplyByRadius(alphaL,fePrs_->cubPts(),true);
421 Intrepid::FunctionSpaceTools::integrate<Real>(*hess,
422 *alphaL, // alpha' dL/dx Phi
423 *fePrs_->gradNdetJ(), // dPhi/dx
424 Intrepid::COMP_CPP,
425 false);
426 }
427
428 void Hessian_13(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> & hess,
429 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
430 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
431 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
432 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
433 throw Exception::Zero(">>> Hessian_13 is zero!");
434 }
435
436 void Hessian_21(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess,
437 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
438 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
439 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
440 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
441 // Retrieve dimensions.
442 const int c = fePrs_->gradN()->dimension(0);
443 const int f = fePrs_->gradN()->dimension(1);
444 const int fc = feCtrl_->gradN()->dimension(1);
445 const int p = fePrs_->gradN()->dimension(2);
446 const int d = fePrs_->gradN()->dimension(3);
447 // Initialize hessians.
448 hess = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, fc);
449 // Apply Dirichlet conditions
450 ROL::Ptr<Intrepid::FieldContainer<Real>> l0_coeff;
451 l0_coeff = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
452 *l0_coeff = *l_coeff;
453 int numSideSets = bdryCellLocIds_.size();
454 if (numSideSets > 0) {
455 for (int i = 0; i < numSideSets; ++i) {
456 if (i==0) /* inflow condition*/ {}
457 else if (i==1) /* outflow condition */ {
458 int numLocalSideIds = bdryCellLocIds_[i].size();
459 for (int j = 0; j < numLocalSideIds; ++j) {
460 int numCellsSide = bdryCellLocIds_[i][j].size();
461 int numBdryDofs = fpidx_[j].size();
462 for (int k = 0; k < numCellsSide; ++k) {
463 int cidx = bdryCellLocIds_[i][j][k];
464 for (int l = 0; l < numBdryDofs; ++l) {
465 (*l0_coeff)(cidx,fpidx_[j][l]) = static_cast<Real>(0);
466 }
467 }
468 }
469 }
470 else if (useNoSlip_ && i==2) /* do-nothing condition */ {}
471 }
472 }
473 // Evaluate/interpolate finite element fields on cells.
474 ROL::Ptr<Intrepid::FieldContainer<Real>> valZ, alpha, gradL, alphaL;
475 valZ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
476 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
477 gradL = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
478 alphaL = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fc, p, d);
479 fePrs_->evaluateGradient(gradL, l0_coeff);
480 feCtrl_->evaluateValue(valZ, z_coeff);
481 perm_->compute(alpha, valZ, fePrs_->cubPts(), 1);
482 /*** Evaluate weak form of the Hessian. ***/
483 for (int j = 0; j < c; ++j) {
484 for (int k = 0; k < fc; ++k) {
485 for (int l = 0; l < p; ++l) {
486 for (int m = 0; m < d; ++m) {
487 (*alphaL)(j,k,l,m) = (*alpha)(j,l) * (*feCtrl_->N())(j,k,l) * (*gradL)(j,l,m);
488 }
489 }
490 }
491 }
492 //multiplyByRadius(alphaL,fePrs_->cubPts(),true);
493 Intrepid::FunctionSpaceTools::integrate<Real>(*hess,
494 *fePrs_->gradNdetJ(), // dPhi/dx
495 *alphaL, // alpha' dL/dx Phi
496 Intrepid::COMP_CPP,
497 false);
498 }
499
500 void Hessian_22(ROL::Ptr<Intrepid::FieldContainer<Real>> & hess,
501 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
502 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
503 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
504 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
505 // Retrieve dimensions.
506 const int c = fePrs_->gradN()->dimension(0);
507 const int fc = feCtrl_->gradN()->dimension(1);
508 const int p = fePrs_->gradN()->dimension(2);
509 const int d = fePrs_->gradN()->dimension(3);
510 // Initialize hessians.
511 hess = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fc, fc);
512 // Apply Dirichlet conditions
513 ROL::Ptr<Intrepid::FieldContainer<Real>> l0_coeff;
514 l0_coeff = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
515 *l0_coeff = *l_coeff;
516 int numSideSets = bdryCellLocIds_.size();
517 if (numSideSets > 0) {
518 for (int i = 0; i < numSideSets; ++i) {
519 if (i==0) /* inflow condition */ {}
520 else if (i==1) /* outflow condition */ {
521 int numLocalSideIds = bdryCellLocIds_[i].size();
522 for (int j = 0; j < numLocalSideIds; ++j) {
523 int numCellsSide = bdryCellLocIds_[i][j].size();
524 int numBdryDofs = fpidx_[j].size();
525 for (int k = 0; k < numCellsSide; ++k) {
526 int cidx = bdryCellLocIds_[i][j][k];
527 for (int l = 0; l < numBdryDofs; ++l) {
528 (*l0_coeff)(cidx,fpidx_[j][l]) = static_cast<Real>(0);
529 }
530 }
531 }
532 }
533 else if (useNoSlip_ && i==2) /* do-nothing condition */ {}
534 }
535 }
536 // Evaluate/interpolate finite element fields on cells.
537 ROL::Ptr<Intrepid::FieldContainer<Real>> valZ, alpha, alphaUL, gradL, gradU;
538 valZ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
539 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
540 alphaUL = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, fc, p);
541 gradL = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
542 gradU = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
543 fePrs_->evaluateGradient(gradL, l0_coeff);
544 fePrs_->evaluateGradient(gradU, u_coeff);
545 feCtrl_->evaluateValue(valZ, z_coeff);
546 perm_->compute(alpha, valZ, fePrs_->cubPts(), 2);
547 // Multiply velocity with alpha
548 Real dot(0);
549 for (int i = 0; i < c; ++i) {
550 for (int j = 0; j < fc; ++j) {
551 for (int k = 0; k < p; ++k) {
552 dot = static_cast<Real>(0);
553 for (int l = 0; l < d; ++l) {
554 dot += (*gradU)(i,k,l) * (*gradL)(i,k,l);
555 }
556 (*alphaUL)(i,j,k) = (*alpha)(i,k) * (*feCtrl_->N())(i,j,k) * dot;
557 }
558 }
559 }
560 /*** Evaluate weak form of the Hessian. ***/
561 // Velocity equation.
562 //multiplyByRadius(alphaUL,fePrs_->cubPts(),true);
563 Intrepid::FunctionSpaceTools::integrate<Real>(*hess,
564 *alphaUL, // alpha'' dU/dx dL/dx Phi
565 *feCtrl_->NdetJ(), // Phi
566 Intrepid::COMP_CPP,
567 false);
568 }
569
570 void Hessian_23(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> & hess,
571 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
572 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
573 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
574 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
575 throw Exception::Zero(">>> Hessian_23 is zero!");
576 }
577
578 void Hessian_31(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> & hess,
579 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
580 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
581 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
582 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
583 throw Exception::Zero(">>> Hessian_31 is zero!");
584 }
585
586 void Hessian_32(std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> & hess,
587 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
588 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
589 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
590 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
591 throw Exception::Zero(">>> Hessian_32 is zero!");
592 }
593
594 void Hessian_33(std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> & hess,
595 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & l_coeff,
596 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
597 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
598 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
599 throw Exception::Zero(">>> Hessian_33 is zero!");
600 }
601
602 void RieszMap_1(ROL::Ptr<Intrepid::FieldContainer<Real>> & riesz) override {
603 // Retrieve dimensions.
604 const int c = fePrs_->gradN()->dimension(0);
605 const int f = fePrs_->gradN()->dimension(1);
606 const int p = fePrs_->gradN()->dimension(2);
607 const int d = fePrs_->gradN()->dimension(3);
608 // Initialize Jacobians.
609 riesz = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, f);
610 // Evaluate/interpolate finite element fields on cells.
611 ROL::Ptr<Intrepid::FieldContainer<Real>> valPhi, gradPhi;
612 valPhi = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p);
613 gradPhi = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p, d);
614 *valPhi = *fePrs_->N();
615 *gradPhi = *fePrs_->gradN();
616 /*** Evaluate weak form of the Jacobian. ***/
617 //multiplyByRadius(gradPhi,fePrs_->cubPts(),true);
618 //multiplyByRadius(valPhi,fePrs_->cubPts(),true);
619 Intrepid::FunctionSpaceTools::integrate<Real>(*riesz,
620 *gradPhi, // alpha dPhi/dx
621 *fePrs_->gradNdetJ(), // dPhi/dx
622 Intrepid::COMP_CPP,
623 false);
624 Intrepid::FunctionSpaceTools::integrate<Real>(*riesz,
625 *valPhi, // alpha dPhi/dx
626 *fePrs_->NdetJ(), // dPhi/dx
627 Intrepid::COMP_CPP,
628 true);
629 }
630
631 void RieszMap_2(ROL::Ptr<Intrepid::FieldContainer<Real>> & riesz) override {
632 // Retrieve dimensions.
633 const int c = feCtrl_->gradN()->dimension(0);
634 const int f = feCtrl_->gradN()->dimension(1);
635 const int p = feCtrl_->gradN()->dimension(2);
636 // Initialize Jacobians.
637 riesz = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, f);
638 // Evaluate on FE basis.
639 ROL::Ptr<Intrepid::FieldContainer<Real>> valPsi;
640 valPsi = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, f, p);
641 *valPsi = *feCtrl_->N();
642 /*** Evaluate weak form of the residual. ***/
643 //multiplyByRadius(valPsi,feCtrl_->cubPts(),true);
644 Intrepid::FunctionSpaceTools::integrate<Real>(*riesz,
645 *valPsi, // Psi
646 *feCtrl_->NdetJ(), // Psi
647 Intrepid::COMP_CPP,
648 false);
649 }
650
651 std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> getFields() override {
652 return basisPtrs_;
653 }
654
655 std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> getFields2() override {
656 return basisPtrsCtrl_;
657 }
658
659 void setCellNodes(const ROL::Ptr<Intrepid::FieldContainer<Real>> &volCellNodes,
660 const std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> &bdryCellNodes,
661 const std::vector<std::vector<std::vector<int>>> &bdryCellLocIds) override {
662 volCellNodes_ = volCellNodes;
663 bdryCellNodes_ = bdryCellNodes;
664 bdryCellLocIds_ = bdryCellLocIds;
665 // Finite element definition.
666 fePrs_ = ROL::makePtr<FE<Real>>(volCellNodes_,basisPtrPrs_,cellCub_);
667 feCtrl_ = ROL::makePtr<FE<Real>>(volCellNodes_,basisPtrCtrl_,cellCub_,false);
668 fpidx_ = fePrs_->getBoundaryDofs();
669 // Construct control boundary FE
670 int numSideSets = bdryCellLocIds_.size();
671 if (numSideSets > 0) {
672 fePrsBdry_.resize(numSideSets);
673 feCtrlBdry_.resize(numSideSets);
674 for (int i = 0; i < numSideSets; ++i) {
675 int numLocSides = bdryCellNodes[i].size();
676 fePrsBdry_[i].resize(numLocSides);
677 feCtrlBdry_[i].resize(numLocSides);
678 for (int j = 0; j < numLocSides; ++j) {
679 if (bdryCellNodes[i][j] != ROL::nullPtr) {
680 fePrsBdry_[i][j] = ROL::makePtr<FE<Real>>(bdryCellNodes[i][j],basisPtrPrs_,bdryCub_,j);
681 feCtrlBdry_[i][j] = ROL::makePtr<FE<Real>>(bdryCellNodes[i][j],basisPtrCtrl_,bdryCub_,j);
682 }
683 }
684 }
685 }
686 }
687
688 void setFieldPattern(const std::vector<std::vector<int>> &fieldPattern,
689 const std::vector<std::vector<int>> &fieldPattern2) override {
690 fieldPattern_ = fieldPattern;
691 fieldInfo_ = ROL::makePtr<FieldUtils::FieldInfo>(numFields_,numDofs_,numFieldDofs_,fieldPattern_);
692 fieldPatternCtrl_ = fieldPattern2;
693 fieldInfoCtrl_ = ROL::makePtr<FieldUtils::FieldInfo>(numFieldsCtrl_,numDofsCtrl_,numFieldDofsCtrl_,fieldPatternCtrl_);
694 }
695
696 void printData(std::string tag,
697 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
698 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
699 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
700 // Retrieve dimensions.
701 const int c = fePrs_->gradN()->dimension(0);
702 const int p = fePrs_->gradN()->dimension(2);
703 const int d = fePrs_->gradN()->dimension(3);
704 // Evaluate/interpolate finite element fields on cells.
705 ROL::Ptr<Intrepid::FieldContainer<Real>> gradP, AgradP, valCtrl, alpha;
706 gradP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
707 AgradP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
708 valCtrl = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
709 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
710 fePrs_->evaluateGradient(gradP, u_coeff);
711 feCtrl_->evaluateValue(valCtrl, z_coeff);
712 perm_->compute(alpha, valCtrl, fePrs_->cubPts(), 0);
713 Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*AgradP,*alpha,*gradP);
714 // Print to velocity file
715 std::stringstream nameVel;
716 nameVel << "velocity" << tag << ".txt";
717 std::ofstream fileVel;
718 fileVel.open(nameVel.str());
719 for (int i = 0; i < c; ++i) {
720 for (int j = 0; j < p; ++j) {
721 fileVel << std::scientific << std::setprecision(15);
722 for (int k = 0; k < d; ++k) fileVel << std::setw(25) << (*fePrs_->cubPts())(i,j,k);
723 for (int k = 0; k < d; ++k) fileVel << std::setw(25) << -(*AgradP)(i,j,k);
724 fileVel << std::endl;
725 }
726 }
727 fileVel.close();
728 // Print to permeability file
729 std::stringstream namePer;
730 namePer << "permeability" << tag << ".txt";
731 std::ofstream filePer;
732 filePer.open(namePer.str());
733 for (int i = 0; i < c; ++i) {
734 for (int j = 0; j < p; ++j) {
735 filePer << std::scientific << std::setprecision(15);
736 for (int k = 0; k < d; ++k) filePer << std::setw(25) << (*fePrs_->cubPts())(i,j,k);
737 filePer << std::setw(25) << dynvisco_*(*alpha)(i,j);
738 filePer << std::endl;
739 }
740 }
741 filePer.close();
742 }
743
744 void printCellAverages(std::string tag,
745 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & u_coeff,
746 const ROL::Ptr<const Intrepid::FieldContainer<Real>> & z_coeff = ROL::nullPtr,
747 const ROL::Ptr<const std::vector<Real>> & z_param = ROL::nullPtr) override {
748 // Retrieve dimensions.
749 const int c = fePrs_->gradN()->dimension(0);
750 const int p = fePrs_->gradN()->dimension(2);
751 const int d = fePrs_->gradN()->dimension(3);
752 // Evaluate/interpolate finite element fields on cells.
753 ROL::Ptr<Intrepid::FieldContainer<Real>> gradP, AgradP, velX, velY, velZ, valCtrl, alpha;
754 ROL::Ptr<Intrepid::FieldContainer<Real>> onesVec, cellVol, avgX, avgY, avgZ, avgP;
755 gradP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
756 AgradP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p, d);
757 velX = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
758 velY = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
759 velZ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
760 valCtrl = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
761 alpha = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
762 onesVec = ROL::makePtr<Intrepid::FieldContainer<Real>>(c, p);
763 cellVol = ROL::makePtr<Intrepid::FieldContainer<Real>>(c);
764 avgX = ROL::makePtr<Intrepid::FieldContainer<Real>>(c);
765 avgY = ROL::makePtr<Intrepid::FieldContainer<Real>>(c);
766 avgZ = ROL::makePtr<Intrepid::FieldContainer<Real>>(c);
767 avgP = ROL::makePtr<Intrepid::FieldContainer<Real>>(c);
768 fePrs_->evaluateGradient(gradP, u_coeff);
769 feCtrl_->evaluateValue(valCtrl, z_coeff);
770 onesVec->initialize(1.0);
771 perm_->compute(alpha, valCtrl, fePrs_->cubPts(), 0);
772 Intrepid::FunctionSpaceTools::scalarMultiplyDataData<Real>(*AgradP,*alpha,*gradP);
773 // Extract velocity components.
774 for (int i = 0; i < c; ++i) {
775 for (int j = 0; j < p; ++j) {
776 (*velX)(i,j) = -(*AgradP)(i,j,0);
777 (*velY)(i,j) = -(*AgradP)(i,j,1);
778 (*velZ)(i,j) = -(*AgradP)(i,j,2);
779 }
780 }
781 // Compute cell volumes.
782 Intrepid::FunctionSpaceTools::integrate<Real>(*cellVol,
783 *onesVec, // 1
784 *onesVec, // 1
785 Intrepid::COMP_CPP,
786 false);
787 // Compute velocity X cell average.
788 Intrepid::FunctionSpaceTools::integrate<Real>(*avgX,
789 *velX, // scalar data
790 *onesVec, // 1
791 Intrepid::COMP_CPP,
792 false);
793 for (int i = 0; i < c; ++i) {(*avgX)(i) /= (*cellVol)(i);}
794 // Compute velocity Y cell average.
795 Intrepid::FunctionSpaceTools::integrate<Real>(*avgY,
796 *velY, // scalar data
797 *onesVec, // 1
798 Intrepid::COMP_CPP,
799 false);
800 for (int i = 0; i < c; ++i) {(*avgY)(i) /= (*cellVol)(i);}
801 // Compute velocity Z cell average.
802 Intrepid::FunctionSpaceTools::integrate<Real>(*avgZ,
803 *velZ, // scalar data
804 *onesVec, // 1
805 Intrepid::COMP_CPP,
806 false);
807 for (int i = 0; i < c; ++i) {(*avgZ)(i) /= (*cellVol)(i);}
808 // Compute permeability cell average.
809 Intrepid::FunctionSpaceTools::integrate<Real>(*avgP,
810 *alpha, // scalar data
811 *onesVec, // 1
812 Intrepid::COMP_CPP,
813 false);
814 for (int i = 0; i < c; ++i) {(*avgP)(i) /= (*cellVol)(i);}
815 Intrepid::RealSpaceTools<Real>::scale(*avgP, dynvisco_);
816
817 // Print to velocity file
818 std::stringstream nameVel;
819 nameVel << "velocity" << tag << ".txt";
820 std::ofstream fileVel;
821 fileVel.open(nameVel.str());
822 for (int i = 0; i < c; ++i) {
823 fileVel << std::scientific << std::setprecision(15);
824 fileVel << std::setw(25) << (*avgX)(i);
825 fileVel << std::setw(25) << (*avgY)(i);
826 fileVel << std::setw(25) << (*avgZ)(i);
827 fileVel << std::endl;
828 }
829 fileVel.close();
830 // Print to permeability file
831 std::stringstream namePer;
832 namePer << "permeability" << tag << ".txt";
833 std::ofstream filePer;
834 filePer.open(namePer.str());
835 for (int i = 0; i < c; ++i) {
836 filePer << std::scientific << std::setprecision(15);
837 filePer << std::setw(25) << (*avgP)(i);
838 filePer << std::endl;
839 }
840 filePer.close();
841 }
842
843 const ROL::Ptr<FE<Real>> getPressureFE(void) const {
844 return fePrs_;
845 }
846
847 const ROL::Ptr<FE<Real>> getControlFE(void) const {
848 return feCtrl_;
849 }
850
851 const std::vector<ROL::Ptr<FE<Real>>> getPressureBdryFE(const int sideset = -1) const {
852 int side = (sideset < 0 || sideset > 3) ? 0 : sideset;
853 return fePrsBdry_[side];
854 }
855
856 const std::vector<ROL::Ptr<FE<Real>>> getControlBdryFE(const int sideset = -1) const {
857 int side = (sideset < 0 || sideset > 3) ? 0 : sideset;
858 return feCtrlBdry_[side];
859 }
860
861 const std::vector<std::vector<int>> getBdryCellLocIds(const int sideset = -1) const {
862 int side = (sideset < 0 || sideset > 3) ? 0 : sideset;
863 return bdryCellLocIds_[side];
864 }
865
866 const ROL::Ptr<Permeability<Real>> getPermeability(void) const {
867 return perm_;
868 }
869
870 const ROL::Ptr<const FieldUtils::FieldInfo> getStateFieldInfo(void) const {
871 return fieldInfo_;
872 }
873
874 const ROL::Ptr<const FieldUtils::FieldInfo> getControlFieldInfo(void) const {
875 return fieldInfoCtrl_;
876 }
877
878 }; // PDE_Darcy
879
880 #endif