sensitivitySurfaceIncompressible.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2007-2020 PCOpt/NTUA
9  Copyright (C) 2013-2020 FOSS GP
10  Copyright (C) 2019-2020 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 \*---------------------------------------------------------------------------*/
29 
32 #include "syncTools.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 namespace incompressible
41 {
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 defineTypeNameAndDebug(sensitivitySurface, 0);
47 (
48  adjointSensitivity,
49  sensitivitySurface,
50  dictionary
51 );
52 
53 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
54 
56 {
58  {
59  // Grab objective refs
60  PtrList<objective>& functions
62  // Compute sens for all points in parameterized patches.
63  // Interfacing points will be accumulated later
65  (
66  createZeroBoundaryPointFieldPtr<vector>(mesh_)
67  );
69  (
70  createZeroBoundaryPointFieldPtr<vector>(mesh_)
71  );
72  // Geometric (or "direct") sensitivities are better computed directly
73  // on the points
74  for (const label patchI : sensitivityPatchIDs_)
75  {
76  const fvPatch& patch = mesh_.boundary()[patchI];
77  vectorField nf(patch.nf());
78 
79  // point sens result for patch
80  vectorField& patchdSdb = pointSensdSdb()[patchI];
81  vectorField& patchdndb = pointSensdndb()[patchI];
82 
83  vectorField dSdbMultiplierTot(patch.size(), Zero);
84  vectorField dndbMultiplierTot(patch.size(), Zero);
85  forAll(functions, funcI)
86  {
87  dSdbMultiplierTot +=
88  functions[funcI].weight()
89  *functions[funcI].dSdbMultiplier(patchI);
90  dndbMultiplierTot +=
91  functions[funcI].weight()
92  *functions[funcI].dndbMultiplier(patchI);
93  }
94  // Correspondence of local point addressing to global point
95  // addressing
96  const labelList& meshPoints = patch.patch().meshPoints();
97  // List with mesh faces. Global addressing
98  const faceList& faces = mesh_.faces();
99  // Each local patch point belongs to these local patch faces
100  // (local numbering)
101  const labelListList& patchPointFaces = patch.patch().pointFaces();
102  // index of first face in patch
103  const label patchStartIndex = patch.start();
104  // geometry differentiation engine
105  deltaBoundary dBoundary(mesh_);
106  // Loop over patch points.
107  // Collect contributions from each boundary face this point
108  // belongs to
109  forAll(meshPoints, ppI)
110  {
111  const labelList& pointFaces = patchPointFaces[ppI];
112  forAll(pointFaces, pfI)
113  {
114  label localFaceIndex = pointFaces[pfI];
115  label globalFaceIndex = patchStartIndex + localFaceIndex;
116  const face& faceI = faces[globalFaceIndex];
117  // Point coordinates. All indices in global numbering
118  pointField p(faceI.points(mesh_.points()));
119  tensorField p_d(faceI.size(), Zero);
120  forAll(faceI, facePointI)
121  {
122  if (faceI[facePointI] == meshPoints[ppI])
123  {
124  p_d[facePointI] = tensor::I;
125  }
126  }
127  tensorField deltaNormals =
128  dBoundary.makeFaceCentresAndAreas_d(p, p_d);
129 
130  // Element [1] is the variation in the (dimensional) normal
131  const tensor& deltaSf = deltaNormals[1];
132  patchdSdb[ppI] +=
133  dSdbMultiplierTot[localFaceIndex] & deltaSf;
134 
135  // Element [2] is the variation in the unit normal
136  const tensor& deltaNf = deltaNormals[2];
137  patchdndb[ppI] +=
138  dndbMultiplierTot[localFaceIndex] & deltaNf;
139  }
140  }
141  }
142  // Do parallel communications to avoid wrong values at processor
143  // boundaries
144  vectorField dSdbGlobal(mesh_.nPoints(), Zero);
145  vectorField dndbGlobal(mesh_.nPoints(), Zero);
146  for (const label patchI : sensitivityPatchIDs_)
147  {
148  const labelList& meshPoints =
149  mesh_.boundaryMesh()[patchI].meshPoints();
150  forAll(meshPoints, ppI)
151  {
152  const label globaPointI = meshPoints[ppI];
153  dSdbGlobal[globaPointI] += pointSensdSdb()[patchI][ppI];
154  dndbGlobal[globaPointI] += pointSensdndb()[patchI][ppI];
155  }
156  }
157  // Accumulate over processors
159  (
160  mesh_, dSdbGlobal, plusEqOp<vector>(), vector::zero
161  );
163  (
164  mesh_, dndbGlobal, plusEqOp<vector>(), vector::zero
165  );
166  // Transfer back to local fields and map to faces
167  for (const label patchI : sensitivityPatchIDs_)
168  {
169  const fvPatch& patch = mesh_.boundary()[patchI];
170  const labelList& meshPoints = patch.patch().meshPoints();
171  const scalarField& magSf = patch.magSf();
172  pointSensdSdb()[patchI].map(dSdbGlobal, meshPoints);
173  pointSensdndb()[patchI].map(dndbGlobal, meshPoints);
174  // Map dSf/dx and dnf/dx term from points to faces. Ideally, all
175  // sensitivities should be computed at points rather than faces.
176  PrimitivePatchInterpolation<polyPatch> patchInter(patch.patch());
177  vectorField dSdbFace
178  (
179  patchInter.pointToFaceInterpolate(pointSensdSdb()[patchI])
180  );
181  // dSdb already contains the face area. Divide with it to make it
182  // compatible with the rest of the terms
183  dSdbFace /= magSf;
184 
185  tmp<vectorField> tdndbFace =
186  patchInter.pointToFaceInterpolate(pointSensdndb()[patchI]);
187  const vectorField& dndbFace = tdndbFace();
188 
189  // Add to sensitivity fields
190  wallFaceSensVecPtr_()[patchI] += dSdbFace + dndbFace;
191  }
192  }
193 }
194 
195 
197 {
198  word suffix(dict().getOrDefault<word>("suffix", word::null));
199  // Determine suffix for fields holding the sens
201  {
203  (
204  adjointVars_.solverName() + "ESI" + suffix
205  );
206  }
207  else
208  {
210  (
211  adjointVars_.solverName() + "SI" + suffix
212  );
213  }
214 }
215 
216 
217 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
218 
219 sensitivitySurface::sensitivitySurface
220 (
221  const fvMesh& mesh,
222  const dictionary& dict,
223  incompressibleVars& primalVars,
224  incompressibleAdjointVars& adjointVars,
226 )
227 :
229  (
230  mesh,
231  dict,
232  primalVars,
233  adjointVars,
235  ),
237  includeSurfaceArea_(false),
238  includePressureTerm_(false),
239  includeGradStressTerm_(false),
240  includeTransposeStresses_(false),
241  useSnGradInTranposeStresses_(false),
242  includeDivTerm_(false),
243  includeDistance_(false),
244  includeMeshMovement_(false),
245  includeObjective_(false),
246  writeGeometricInfo_(false),
247  eikonalSolver_(nullptr),
248  meshMovementSolver_(nullptr),
249 
250  nfOnPatchPtr_(nullptr),
251  SfOnPatchPtr_(nullptr),
252  CfOnPatchPtr_(nullptr)
253 {
254  read();
255  setSuffixName();
256 
257  // Allocate boundary field pointer
258  wallFaceSensVecPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
259  wallFaceSensNormalPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
260  wallFaceSensNormalVecPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
261 
262  // Allocate fields to contain geometric info
263  if (writeGeometricInfo_)
264  {
265  nfOnPatchPtr_.reset
266  (
267  new volVectorField
268  (
269  IOobject
270  (
271  "nfOnPatch",
272  mesh.time().timeName(),
273  mesh,
276  ),
277  mesh,
279  )
280  );
281 
282  SfOnPatchPtr_.reset
283  (
284  new volVectorField
285  (
286  IOobject
287  (
288  "SfOnPatch",
289  mesh.time().timeName(),
290  mesh,
293  ),
294  mesh,
296  )
297  );
298 
299  CfOnPatchPtr_.reset
300  (
301  new volVectorField
302  (
303  IOobject
304  (
305  "CfOnPatch",
306  mesh.time().timeName(),
307  mesh,
310  ),
311  mesh,
313  )
314  );
315  }
316 
317  // Allocate appropriate space for the sensitivity field
318  computeDerivativesSize();
319 }
320 
321 
322 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
323 
325 {
327  dict().getOrDefault<bool>("includeSurfaceArea", true);
329  dict().getOrDefault<bool>("includePressure", true);
331  dict().getOrDefault<bool>("includeGradStressTerm", true);
333  dict().getOrDefault<bool>("includeTransposeStresses", true);
335  dict().getOrDefault<bool>("useSnGradInTranposeStresses", false);
336  includeDivTerm_ = dict().getOrDefault<bool>("includeDivTerm", false);
338  dict().getOrDefault<bool>
339  (
340  "includeDistance",
341  adjointVars_.adjointTurbulence().ref().includeDistance()
342  );
344  dict().getOrDefault<bool>("includeMeshMovement", true);
346  dict().getOrDefault<bool>("includeObjectiveContribution", true);
348  dict().getOrDefault<bool>("writeGeometricInfo", false);
349 
350  // Allocate new solvers if necessary
352  {
353  eikonalSolver_.reset
354  (
356  (
357  mesh_,
358  dict_,
360  adjointVars_,
361  sensitivityPatchIDs_
362  )
363  );
364  }
366  {
367  meshMovementSolver_.reset
368  (
370  (
371  mesh_,
372  dict_,
373  *this,
374  sensitivityPatchIDs_,
376  )
377  );
378  }
379 }
380 
381 
383 {
385  {
386  if (eikonalSolver_)
387  {
388  eikonalSolver_().readDict(dict);
389  }
390 
392  {
393  meshMovementSolver_().readDict(dict);
394  }
395 
396  return true;
397  }
398 
399  return false;
400 }
401 
402 
404 {
405  label nFaces(0);
406  for (const label patchI : sensitivityPatchIDs_)
407  {
408  nFaces += mesh_.boundary()[patchI].size();
409  }
410  derivatives_.setSize(nFaces);
411 }
412 
413 
415 {
416  // Grab references
417  const volScalarField& p = primalVars_.p();
418  const volVectorField& U = primalVars_.U();
419 
420  const volScalarField& pa = adjointVars_.pa();
421  const volVectorField& Ua = adjointVars_.Ua();
424 
425  Info<< " Calculating auxiliary quantities " << endl;
426  // Fields needed to calculate adjoint sensitivities
428  turbVars = primalVars_.RASModelVariables();
430  volScalarField nuEff(lamTransp.nu() + turbVars->nutRef());
431  volTensorField gradUa(fvc::grad(Ua));
432  volTensorField gradU(fvc::grad(U));
433 
434  // Explicitly correct the boundary gradient to get rid of the tangential
435  // component
436  forAll(mesh_.boundary(), patchI)
437  {
438  const fvPatch& patch = mesh_.boundary()[patchI];
439  if (isA<wallFvPatch>(patch))
440  {
441  tmp<vectorField> tnf = mesh_.boundary()[patchI].nf();
442  const vectorField& nf = tnf();
443  gradU.boundaryFieldRef()[patchI] =
444  nf*U.boundaryField()[patchI].snGrad();
445  }
446  }
447 
448  // Auxiliary terms
449  volVectorField gradp(fvc::grad(p));
450  volTensorField stress(nuEff*(gradU + T(gradU)));
451  autoPtr<volVectorField> stressXPtr
452  (
453  createZeroFieldPtr<vector>(mesh_, "stressX", stress.dimensions())
454  );
455  autoPtr<volVectorField> stressYPtr
456  (
457  createZeroFieldPtr<vector>(mesh_, "stressY", stress.dimensions())
458  );
459  autoPtr<volVectorField> stressZPtr
460  (
461  createZeroFieldPtr<vector>(mesh_, "stressZ", stress.dimensions())
462  );
463 
464  stressXPtr().replace(0, stress.component(0));
465  stressXPtr().replace(1, stress.component(1));
466  stressXPtr().replace(2, stress.component(2));
467 
468  stressYPtr().replace(0, stress.component(3));
469  stressYPtr().replace(1, stress.component(4));
470  stressYPtr().replace(2, stress.component(5));
471 
472  stressZPtr().replace(0, stress.component(6));
473  stressZPtr().replace(1, stress.component(7));
474  stressZPtr().replace(2, stress.component(8));
475 
476  volTensorField gradStressX(fvc::grad(stressXPtr()));
477  volTensorField gradStressY(fvc::grad(stressYPtr()));
478  volTensorField gradStressZ(fvc::grad(stressZPtr()));
479 
480  // Accumulate source for additional post-processing PDEs, if necessary
481  if (includeDistance_)
482  {
483  eikonalSolver_->accumulateIntegrand(dt);
484  }
485 
487  {
488  meshMovementSolver_->accumulateIntegrand(dt);
489  }
490 
491  // Terms from the adjoint turbulence model
492  const boundaryVectorField& adjointTMsensitivities =
493  adjointTurbulence->wallShapeSensitivities();
494 
495  DebugInfo
496  << " Calculating adjoint sensitivity. " << endl;
497 
498  // Sensitivities do not include locale surface area by default.
499  // Part of the sensitivities that multiplies dxFace/db
500  for (const label patchI : sensitivityPatchIDs_)
501  {
502  const fvPatch& patch = mesh_.boundary()[patchI];
503  tmp<vectorField> tnf = patch.nf();
504  const vectorField& nf = tnf();
505 
506  // Includes spurious tangential gradU part. Deprecated
507  /*
508  vectorField stressAndPressureTerm =
509  (
510  - (
511  Ua.boundaryField()[patchI].snGrad()
512  + (gradUa.boundaryField()[patchI] & nf)
513  ) * nuEff.boundaryField()[patchI]
514  + pa.boundaryField()[patchI] *nf
515  ) & gradU.boundaryField()[patchI].T();
516  */
517 
518  // Adjoint stress term
519  vectorField stressTerm
520  (
521  - (
522  Ua.boundaryField()[patchI].snGrad()
523  & U.boundaryField()[patchI].snGrad()
524  )
525  * nuEff.boundaryField()[patchI]
526  * nf
527  );
528 
529 
531  {
532  vectorField gradUaNf
533  (
535  (Ua.boundaryField()[patchI].snGrad() & nf)*nf :
536  (gradUa.boundaryField()[patchI] & nf)
537  );
538 
539  stressTerm -=
540  nuEff.boundaryField()[patchI]
541  *(gradUaNf & U.boundaryField()[patchI].snGrad())
542  *nf;
543  }
544 
545  if (includeDivTerm_)
546  {
547  stressTerm +=
548  scalar(1./3.)*nuEff.boundaryField()[patchI]
549  * (
550  ((Ua.boundaryField()[patchI].snGrad() &nf)*nf)
551  & U.boundaryField()[patchI].snGrad()
552  )
553  * nf;
554  }
555 
556  vectorField gradStressTerm(patch.size(), Zero);
558  {
559  // Terms corresponding to contributions from converting delta to
560  // thetas are added through the corresponding adjoint boundary
561  // conditions instead of grabbing contributions from the objective
562  // function. Useful to have a unified formulation for low- and
563  // high-re meshes
564  const fvPatchVectorField& Uab = Ua.boundaryField()[patchI];
565  gradStressTerm = - ((Uab & nf)*gradp.boundaryField()[patchI]);
566  gradStressTerm +=
567  (
568  Uab.component(0) * gradStressX.boundaryField()[patchI]
569  + Uab.component(1) * gradStressY.boundaryField()[patchI]
570  + Uab.component(2) * gradStressZ.boundaryField()[patchI]
571  ) & nf;
572  }
573 
574  // Adjoint pressure terms
575  vectorField pressureTerm(patch.size(), Zero);
577  {
578  pressureTerm =
579  (
580  (nf*pa.boundaryField()[patchI])
581  & U.boundaryField()[patchI].snGrad()
582  )* nf;
583  }
584 
585  PtrList<objective>& functions
587 
588  // Term from objectives including x directly (e.g. moments)
589  vectorField dxdbMultiplierTot(pressureTerm.size(), Zero);
590  if (includeObjective_)
591  {
592  forAll(functions, funcI)
593  {
594  dxdbMultiplierTot +=
595  functions[funcI].weight()
596  * (
597  functions[funcI].dxdbDirectMultiplier(patchI)
598  );
599  }
600  }
601 
602  // Fill in sensitivity fields
603  wallFaceSensVecPtr_()[patchI] +=
604  (
605  stressTerm
606  + gradStressTerm
607  + pressureTerm
608  + adjointTMsensitivities[patchI]
609  + dxdbMultiplierTot
610  )*dt;
611  }
612 
613  // Add the sensitivity part corresponding to changes of the normal vector
614  // Computed at points and mapped to faces
616 }
617 
618 
620 {
621  // Update geometric fields for use by external users
623  {
624  for (const label patchI : sensitivityPatchIDs_)
625  {
626  const fvPatch& patch = mesh_.boundary()[patchI];
627  tmp<vectorField> tnf = patch.nf();
628  const vectorField& nf = tnf();
629  const vectorField& Sf = patch.Sf();
630  const vectorField& Cf = patch.Cf();
631 
632  nfOnPatchPtr_().boundaryFieldRef()[patchI] = nf;
633  SfOnPatchPtr_().boundaryFieldRef()[patchI] = Sf;
634  CfOnPatchPtr_().boundaryFieldRef()[patchI] = Cf;
635  }
636  }
637 
638  // Solve extra equations if necessary
639  // Solved using accumulated sources over time
640  autoPtr<boundaryVectorField> distanceSensPtr(nullptr);
641  if (includeDistance_)
642  {
643  eikonalSolver_->solve();
644  distanceSensPtr.reset(createZeroBoundaryPtr<vector>(mesh_));
645  const boundaryVectorField& sens =
646  eikonalSolver_->distanceSensitivities();
647  for (const label patchI : sensitivityPatchIDs_)
648  {
649  distanceSensPtr()[patchI] = sens[patchI];
650  }
651  }
652 
653  autoPtr<boundaryVectorField> meshMovementSensPtr(nullptr);
655  {
656  meshMovementSolver_->solve();
657  meshMovementSensPtr.reset(createZeroBoundaryPtr<vector>(mesh_));
658  const boundaryVectorField& sens =
659  meshMovementSolver_->meshMovementSensitivities();
660  for (const label patchI : sensitivityPatchIDs_)
661  {
662  meshMovementSensPtr()[patchI] = sens[patchI];
663  }
664  }
665 
666 
667  // Project to normal face vector
668  label nPassedFaces(0);
669  for (const label patchI : sensitivityPatchIDs_)
670  {
671  const fvPatch& patch = mesh_.boundary()[patchI];
672  tmp<vectorField> tnf(patch.nf());
673  const vectorField& nf = tnf();
674 
675  // Distance related terms
676  if (includeDistance_)
677  {
678  wallFaceSensVecPtr_()[patchI] += distanceSensPtr()[patchI];
679  }
680 
681  // Mesh movement related terms
683  {
684  wallFaceSensVecPtr_()[patchI] += meshMovementSensPtr()[patchI];
685  }
686 
688  {
689  wallFaceSensVecPtr_()[patchI] *= patch.magSf();
690  }
691 
692  wallFaceSensNormalPtr_()[patchI] = wallFaceSensVecPtr_()[patchI] & nf;
693  wallFaceSensNormalVecPtr_()[patchI] =
694  wallFaceSensNormalPtr_()[patchI] * nf;
695 
696  forAll(patch, fI)
697  {
698  derivatives_[nPassedFaces + fI]
699  = wallFaceSensNormalPtr_()[patchI][fI];
700  }
701  nPassedFaces += patch.size();
702  }
703 }
704 
705 
707 {
708  // Reset terms in post-processing PDEs
709  if (includeDistance_)
710  {
711  eikonalSolver_->reset();
712  }
714  {
715  meshMovementSolver_->reset();
716  }
717  // Reset sensitivity fields
720 }
721 
722 
724 {
725  return eikonalSolver_;
726 }
727 
728 
729 void sensitivitySurface::write(const word& baseName)
730 {
731  setSuffixName();
734 
736  {
737  nfOnPatchPtr_().write();
738  SfOnPatchPtr_().write();
739  CfOnPatchPtr_().write();
740  }
741 }
742 
743 
744 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
745 
746 } // End namespace Foam
747 } // End namespace incompressible
748 
749 // ************************************************************************* //
Foam::fvPatchField< vector >
Foam::sensitivity::dict
const dictionary & dict() const
Return the construction dictionary.
Definition: sensitivity.C:57
Foam::incompressible::adjointSensitivity::derivatives_
scalarField derivatives_
Definition: adjointSensitivityIncompressible.H:83
Foam::autoPtr::reset
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:109
Foam::Tensor< scalar >
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::objectiveManager
class for managing incompressible objective functions.
Definition: objectiveManager.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::incompressible::sensitivitySurface::assembleSensitivities
virtual void assembleSensitivities()
Assemble sensitivities.
Definition: sensitivitySurfaceIncompressible.C:619
Foam::GeometricField::component
tmp< GeometricField< cmptType, PatchField, GeoMesh > > component(const direction) const
Return a component of the field.
Foam::variablesSet::solverName
const word & solverName() const
Return solver name.
Definition: variablesSet.C:84
Foam::incompressible::sensitivitySurface::includePressureTerm_
bool includePressureTerm_
Include the adjoint pressure term in sens computation.
Definition: sensitivitySurfaceIncompressible.H:73
Foam::incompressible::sensitivitySurface::includeObjective_
bool includeObjective_
Include terms directly emerging from the objective function.
Definition: sensitivitySurfaceIncompressible.H:94
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:129
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
Foam::deltaBoundary
Differentiation of the mesh data structure.
Definition: deltaBoundary.H:58
Foam::face::points
pointField points(const UList< point > &points) const
Return the points corresponding to this face.
Definition: faceI.H:102
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Tensor::I
static const Tensor I
Definition: Tensor.H:85
Foam::incompressible::defineTypeNameAndDebug
defineTypeNameAndDebug(adjointEikonalSolver, 0)
PrimitivePatchInterpolation.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::incompressible::sensitivitySurface::eikonalSolver_
autoPtr< adjointEikonalSolver > eikonalSolver_
Definition: sensitivitySurfaceIncompressible.H:99
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::incompressible::sensitivitySurface::write
virtual void write(const word &baseName=word::null)
Write sensitivity maps.
Definition: sensitivitySurfaceIncompressible.C:729
Foam::singlePhaseTransportModel
A simple single-phase transport model based on viscosityModel.
Definition: singlePhaseTransportModel.H:57
Foam::incompressibleVars::p
const volScalarField & p() const
Return const reference to pressure.
Definition: incompressibleVars.C:305
syncTools.H
Foam::incompressibleAdjointVars
Class including all adjoint fields for incompressible flows.
Definition: incompressibleAdjointVars.H:52
Foam::syncTools::syncPointList
static void syncPointList(const polyMesh &mesh, List< T > &pointValues, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
Definition: syncToolsTemplates.C:724
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::incompressibleVars::RASModelVariables
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
Definition: incompressibleVars.C:444
Foam::shapeSensitivitiesBase
Definition: shapeSensitivitiesBase.H:63
Foam::incompressible::sensitivitySurface::meshMovementSolver_
autoPtr< adjointMeshMovementSolver > meshMovementSolver_
Definition: sensitivitySurfaceIncompressible.H:101
Foam::incompressible::adjointEikonalSolver
Solver of the adjoint to the eikonal PDE.
Definition: adjointEikonalSolverIncompressible.H:146
Foam::incompressible::sensitivitySurface::includeGradStressTerm_
bool includeGradStressTerm_
Include the term containing the grad of the stress at the boundary.
Definition: sensitivitySurfaceIncompressible.H:76
Foam::incompressible::addToRunTimeSelectionTable
addToRunTimeSelectionTable(adjointSensitivity, sensitivityBezier, dictionary)
Foam::shapeSensitivitiesBase::write
void write()
Write sensitivity fields.
Definition: shapeSensitivitiesBase.C:216
Foam::incompressible::adjointSensitivity
Abstract base class for adjoint-based sensitivities in incompressible flows.
Definition: adjointSensitivityIncompressible.H:75
Foam::incompressible::sensitivitySurface::includeDivTerm_
bool includeDivTerm_
Include the term from the deviatoric part of the stresses.
Definition: sensitivitySurfaceIncompressible.H:85
Foam::sensitivity::mesh_
const fvMesh & mesh_
Definition: sensitivity.H:69
Foam::Field< vector >
Foam::incompressible::sensitivitySurface::computeDerivativesSize
void computeDerivativesSize()
Compute the number of faces on sensitivityPatchIDs_.
Definition: sensitivitySurfaceIncompressible.C:403
Foam::sensitivity::readDict
virtual bool readDict(const dictionary &dict)
Read dictionary if changed.
Definition: sensitivity.C:63
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::incompressible::sensitivitySurface::writeGeometricInfo_
bool writeGeometricInfo_
Write geometric info for use by external programs.
Definition: sensitivitySurfaceIncompressible.H:97
Foam::incompressible::sensitivitySurface::accumulateIntegrand
virtual void accumulateIntegrand(const scalar dt)
Accumulate sensitivity integrands.
Definition: sensitivitySurfaceIncompressible.C:414
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::incompressibleVars::laminarTransport
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
Definition: incompressibleVars.C:418
Foam::incompressible::sensitivitySurface::useSnGradInTranposeStresses_
bool useSnGradInTranposeStresses_
Use snGrad in the transpose part of the adjoint stresses.
Definition: sensitivitySurfaceIncompressible.H:82
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::incompressibleAdjointMeanFlowVars::pa
const volScalarField & pa() const
Return const reference to pressure.
Definition: incompressibleAdjointMeanFlowVars.C:147
Foam::incompressible::sensitivitySurface::getAdjointEikonalSolver
autoPtr< adjointEikonalSolver > & getAdjointEikonalSolver()
Get adjoint eikonal solver.
Definition: sensitivitySurfaceIncompressible.C:723
Foam::incompressibleVars::U
const volVectorField & U() const
Return const reference to velocity.
Definition: incompressibleVars.C:331
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:62
Foam::incompressible::adjointSensitivity::clearSensitivities
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
Definition: adjointSensitivityIncompressible.C:127
Foam::incompressible::sensitivitySurface::nfOnPatchPtr_
autoPtr< volVectorField > nfOnPatchPtr_
Definition: sensitivitySurfaceIncompressible.H:104
Foam::incompressibleAdjointMeanFlowVars::Ua
const volVectorField & Ua() const
Return const reference to velocity.
Definition: incompressibleAdjointMeanFlowVars.C:173
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::incompressible::sensitivitySurface::includeSurfaceArea_
bool includeSurfaceArea_
Include surface area in sens computation.
Definition: sensitivitySurfaceIncompressible.H:70
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::deltaBoundary::makeFaceCentresAndAreas_d
vectorField makeFaceCentresAndAreas_d(const pointField &p, const pointField &p_d)
Definition: deltaBoundary.C:72
Foam::incompressible::adjointSensitivity::adjointVars_
incompressibleAdjointVars & adjointVars_
Definition: adjointSensitivityIncompressible.H:85
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressible::sensitivitySurface::includeDistance_
bool includeDistance_
Include distance variation in sens computation.
Definition: sensitivitySurfaceIncompressible.H:88
Foam::incompressible::adjointSensitivity::primalVars_
incompressibleVars & primalVars_
Definition: adjointSensitivityIncompressible.H:84
Foam::incompressible::sensitivitySurface::includeTransposeStresses_
bool includeTransposeStresses_
Include the transpose part of the adjoint stresses.
Definition: sensitivitySurfaceIncompressible.H:79
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:679
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
U
U
Definition: pEqn.H:72
Foam::sensitivity::dict_
dictionary dict_
Definition: sensitivity.H:70
Foam::incompressible::sensitivitySurface::read
void read()
Read controls and update solver pointers if necessary.
Definition: sensitivitySurfaceIncompressible.C:324
sensitivitySurfaceIncompressible.H
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1094
Foam::GeometricField::Boundary
The boundary fields.
Definition: GeometricField.H:115
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:359
Foam::PrimitivePatchInterpolation
Interpolation class within a primitive patch. Allows interpolation from points to faces and vice vers...
Definition: PrimitivePatchInterpolation.H:53
Foam::incompressible::sensitivitySurface::clearSensitivities
virtual void clearSensitivities()
Zero sensitivity fields and their constituents.
Definition: sensitivitySurfaceIncompressible.C:706
Foam::singlePhaseTransportModel::nu
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
Definition: singlePhaseTransportModel.C:72
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::GeometricField::boundaryFieldRef
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
Definition: GeometricField.C:783
Foam::incompressibleAdjointVars::adjointTurbulence
const autoPtr< incompressibleAdjoint::adjointRASModel > & adjointTurbulence() const
Return const reference to the adjointRASModel.
Definition: incompressibleAdjointVars.C:70
Foam::List< label >
Foam::incompressible::adjointMeshMovementSolver
Solver of the adjoint to the Laplace grid displacement equation.
Definition: adjointMeshMovementSolverIncompressible.H:68
Foam::shapeSensitivitiesBase::clearSensitivities
void clearSensitivities()
Zero sensitivity fields and their constituents.
Definition: shapeSensitivitiesBase.C:175
Foam::primitiveMesh::nPoints
label nPoints() const
Number of mesh points.
Definition: primitiveMeshI.H:37
Foam::incompressible::sensitivitySurface::CfOnPatchPtr_
autoPtr< volVectorField > CfOnPatchPtr_
Definition: sensitivitySurfaceIncompressible.H:106
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::incompressible::sensitivitySurface::addGeometricSens
void addGeometricSens()
Definition: sensitivitySurfaceIncompressible.C:55
Foam::VectorSpace< Vector< Cmpt >, Cmpt, 3 >::zero
static const Vector< Cmpt > zero
Definition: VectorSpace.H:115
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
Foam::plusEqOp
Definition: ops.H:72
Foam::incompressible::sensitivitySurface::includeMeshMovement_
bool includeMeshMovement_
Include mesh movement variation in sens computation.
Definition: sensitivitySurfaceIncompressible.H:91
Foam::incompressible::sensitivitySurface::setSuffixName
void setSuffixName()
Set suffix name for sensitivity fields.
Definition: sensitivitySurfaceIncompressible.C:196
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:122
Foam::shapeSensitivitiesBase::setSuffix
void setSuffix(const word &suffix)
Set suffix.
Definition: shapeSensitivitiesBase.C:223
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::incompressible::sensitivitySurface::readDict
virtual bool readDict(const dictionary &dict)
Read dict if changed.
Definition: sensitivitySurfaceIncompressible.C:382
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62
Foam::incompressible::adjointSensitivity::write
virtual void write(const word &baseName=word::null)
Write sensitivity fields.
Definition: adjointSensitivityIncompressible.C:137
Foam::incompressible::sensitivitySurface::SfOnPatchPtr_
autoPtr< volVectorField > SfOnPatchPtr_
Definition: sensitivitySurfaceIncompressible.H:105
Foam::objectiveManager::getObjectiveFunctions
PtrList< objective > & getObjectiveFunctions()
Return reference to objective functions.
Definition: objectiveManager.C:296
Foam::incompressible::adjointSensitivity::objectiveManager_
objectiveManager & objectiveManager_
Definition: adjointSensitivityIncompressible.H:86