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,
227 )
228 :
230  (
231  mesh,
232  dict,
233  primalVars,
234  adjointVars,
237  ),
239  includeSurfaceArea_(false),
240  includePressureTerm_(false),
241  includeGradStressTerm_(false),
242  includeTransposeStresses_(false),
243  includeDivTerm_(false),
244  includeDistance_(false),
245  includeMeshMovement_(false),
246  includeObjective_(false),
247  writeGeometricInfo_(false),
248  eikonalSolver_(nullptr),
249  meshMovementSolver_(nullptr),
250 
251  nfOnPatchPtr_(nullptr),
252  SfOnPatchPtr_(nullptr),
253  CfOnPatchPtr_(nullptr)
254 {
255  read();
256  setSuffixName();
257 
258  // Allocate boundary field pointer
259  wallFaceSensVecPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
260  wallFaceSensNormalPtr_.reset(createZeroBoundaryPtr<scalar>(mesh_));
261  wallFaceSensNormalVecPtr_.reset(createZeroBoundaryPtr<vector>(mesh_));
262 
263  // Allocate fields to contain geometric info
264  if (writeGeometricInfo_)
265  {
266  nfOnPatchPtr_.reset
267  (
268  new volVectorField
269  (
270  IOobject
271  (
272  "nfOnPatch",
273  mesh.time().timeName(),
274  mesh,
277  ),
278  mesh,
280  )
281  );
282 
283  SfOnPatchPtr_.reset
284  (
285  new volVectorField
286  (
287  IOobject
288  (
289  "SfOnPatch",
290  mesh.time().timeName(),
291  mesh,
294  ),
295  mesh,
297  )
298  );
299 
300  CfOnPatchPtr_.reset
301  (
302  new volVectorField
303  (
304  IOobject
305  (
306  "CfOnPatch",
307  mesh.time().timeName(),
308  mesh,
311  ),
312  mesh,
314  )
315  );
316  }
317 
318  // Allocate appropriate space for the sensitivity field
319  computeDerivativesSize();
320 }
321 
322 
323 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
324 
326 {
328  dict().getOrDefault<bool>("includeSurfaceArea", true);
330  dict().getOrDefault<bool>("includePressure", true);
332  dict().getOrDefault<bool>("includeGradStressTerm", true);
334  dict().getOrDefault<bool>("includeTransposeStresses", true);
335  includeDivTerm_ = dict().getOrDefault<bool>("includeDivTerm", false);
337  dict().getOrDefault<bool>
338  (
339  "includeDistance",
340  adjointVars_.adjointTurbulence().ref().includeDistance()
341  );
343  dict().getOrDefault<bool>("includeMeshMovement", true);
345  dict().getOrDefault<bool>("includeObjectiveContribution", true);
347  dict().getOrDefault<bool>("writeGeometricInfo", false);
348 
349  // Allocate new solvers if necessary
350  if (includeDistance_ && eikonalSolver_.empty())
351  {
352  eikonalSolver_.reset
353  (
355  (
356  mesh_,
357  dict_,
360  sensitivityPatchIDs_
361  )
362  );
363  }
365  {
366  meshMovementSolver_.reset
367  (
369  (
370  mesh_,
371  dict_,
372  *this,
373  sensitivityPatchIDs_,
375  )
376  );
377  }
378 }
379 
380 
382 {
384  {
385  if (eikonalSolver_.valid())
386  {
387  eikonalSolver_().readDict(dict);
388  }
389 
390  if (meshMovementSolver_.valid())
391  {
392  meshMovementSolver_().readDict(dict);
393  }
394 
395  return true;
396  }
397 
398  return false;
399 }
400 
401 
403 {
404  label nFaces(0);
405  for (const label patchI : sensitivityPatchIDs_)
406  {
407  nFaces += mesh_.boundary()[patchI].size();
408  }
409  derivatives_.setSize(nFaces);
410 }
411 
412 
414 {
415  // Grab references
416  const volScalarField& p = primalVars_.p();
417  const volVectorField& U = primalVars_.U();
418 
419  const volScalarField& pa = adjointVars_.pa();
420  const volVectorField& Ua = adjointVars_.Ua();
423 
424  Info<< " Calculating auxiliary quantities " << endl;
425  // Fields needed to calculate adjoint sensitivities
427  turbVars = primalVars_.RASModelVariables();
429  volScalarField nuEff(lamTransp.nu() + turbVars->nutRef());
430  volTensorField gradUa(fvc::grad(Ua));
431  volTensorField gradU(fvc::grad(U));
432 
433  // Explicitly correct the boundary gradient to get rid of the tangential
434  // component
435  forAll(mesh_.boundary(), patchI)
436  {
437  const fvPatch& patch = mesh_.boundary()[patchI];
438  if (isA<wallFvPatch>(patch))
439  {
440  tmp<vectorField> tnf = mesh_.boundary()[patchI].nf();
441  const vectorField& nf = tnf();
442  gradU.boundaryFieldRef()[patchI] =
443  nf*U.boundaryField()[patchI].snGrad();
444  }
445  }
446 
447  // Auxiliary terms
448  volVectorField gradp(fvc::grad(p));
449  volTensorField stress(nuEff*(gradU + T(gradU)));
450  autoPtr<volVectorField> stressXPtr
451  (
452  createZeroFieldPtr<vector>(mesh_, "stressX", stress.dimensions())
453  );
454  autoPtr<volVectorField> stressYPtr
455  (
456  createZeroFieldPtr<vector>(mesh_, "stressY", stress.dimensions())
457  );
458  autoPtr<volVectorField> stressZPtr
459  (
460  createZeroFieldPtr<vector>(mesh_, "stressZ", stress.dimensions())
461  );
462 
463  stressXPtr().replace(0, stress.component(0));
464  stressXPtr().replace(1, stress.component(1));
465  stressXPtr().replace(2, stress.component(2));
466 
467  stressYPtr().replace(0, stress.component(3));
468  stressYPtr().replace(1, stress.component(4));
469  stressYPtr().replace(2, stress.component(5));
470 
471  stressZPtr().replace(0, stress.component(6));
472  stressZPtr().replace(1, stress.component(7));
473  stressZPtr().replace(2, stress.component(8));
474 
475  volTensorField gradStressX(fvc::grad(stressXPtr()));
476  volTensorField gradStressY(fvc::grad(stressYPtr()));
477  volTensorField gradStressZ(fvc::grad(stressZPtr()));
478 
479  // Accumulate source for additional post-processing PDEs, if necessary
480  if (includeDistance_)
481  {
482  eikonalSolver_->accumulateIntegrand(dt);
483  }
484 
486  {
487  meshMovementSolver_->accumulateIntegrand(dt);
488  }
489 
490  // Terms from the adjoint turbulence model
491  const boundaryVectorField& adjointTMsensitivities =
492  adjointTurbulence->wallShapeSensitivities();
493 
494  DebugInfo
495  << " Calculating adjoint sensitivity. " << endl;
496 
497  // Sensitivities do not include locale surface area by default.
498  // Part of the sensitivities that multiplies dxFace/db
499  for (const label patchI : sensitivityPatchIDs_)
500  {
501  const fvPatch& patch = mesh_.boundary()[patchI];
502  tmp<vectorField> tnf = patch.nf();
503  const vectorField& nf = tnf();
504 
505  // Includes spurious tangential gradU part. Deprecated
506  /*
507  vectorField stressAndPressureTerm =
508  (
509  - (
510  Ua.boundaryField()[patchI].snGrad()
511  + (gradUa.boundaryField()[patchI] & nf)
512  ) * nuEff.boundaryField()[patchI]
513  + pa.boundaryField()[patchI] *nf
514  ) & gradU.boundaryField()[patchI].T();
515  */
516 
517  // Adjoint stress term
518  vectorField stressTerm
519  (
520  - (
521  Ua.boundaryField()[patchI].snGrad()
522  & U.boundaryField()[patchI].snGrad()
523  )
524  * nuEff.boundaryField()[patchI]
525  * nf
526  );
527 
528 
530  {
531  stressTerm -=
532  nuEff.boundaryField()[patchI]
533  * (
534  // Note: in case of laminar or low-Re flows,
535  // includes a spurious tangential gradUa component
536  // (gradUa.boundaryField()[patchI] & nf)
537  ((Ua.boundaryField()[patchI].snGrad() &nf)*nf)
538  & U.boundaryField()[patchI].snGrad()
539  )
540  * nf;
541  }
542 
543  if (includeDivTerm_)
544  {
545  stressTerm +=
546  scalar(1./3.)*nuEff.boundaryField()[patchI]
547  * (
548  ((Ua.boundaryField()[patchI].snGrad() &nf)*nf)
549  & U.boundaryField()[patchI].snGrad()
550  )
551  * nf;
552  }
553 
554  vectorField gradStressTerm(patch.size(), Zero);
556  {
557  // Terms corresponding to contributions from converting delta to
558  // thetas are added through the corresponding adjoint boundary
559  // conditions instead of grabbing contributions from the objective
560  // function. Useful to have a unified formulation for low- and
561  // high-re meshes
562  const fvPatchVectorField& Uab = Ua.boundaryField()[patchI];
563  gradStressTerm = - ((Uab & nf)*gradp.boundaryField()[patchI]);
564  gradStressTerm +=
565  (
566  Uab.component(0) * gradStressX.boundaryField()[patchI]
567  + Uab.component(1) * gradStressY.boundaryField()[patchI]
568  + Uab.component(2) * gradStressZ.boundaryField()[patchI]
569  ) & nf;
570  }
571 
572  // Adjoint pressure terms
573  vectorField pressureTerm(patch.size(), Zero);
575  {
576  pressureTerm =
577  (
578  (nf*pa.boundaryField()[patchI])
579  & U.boundaryField()[patchI].snGrad()
580  )* nf;
581  }
582 
583  PtrList<objective>& functions
585 
586  // Term from objectives including x directly (e.g. moments)
587  vectorField dxdbMultiplierTot(pressureTerm.size(), Zero);
588  if (includeObjective_)
589  {
590  forAll(functions, funcI)
591  {
592  dxdbMultiplierTot +=
593  functions[funcI].weight()
594  * (
595  functions[funcI].dxdbDirectMultiplier(patchI)
596  );
597  }
598  }
599 
600  // Fill in sensitivity fields
601  wallFaceSensVecPtr_()[patchI] +=
602  (
603  stressTerm
604  + gradStressTerm
605  + pressureTerm
606  + adjointTMsensitivities[patchI]
607  + dxdbMultiplierTot
608  )*dt;
609  }
610 
611  // Add the sensitivity part corresponding to changes of the normal vector
612  // Computed at points and mapped to faces
614 }
615 
616 
618 {
619  // Update geometric fields for use by external users
621  {
622  for (const label patchI : sensitivityPatchIDs_)
623  {
624  const fvPatch& patch = mesh_.boundary()[patchI];
625  tmp<vectorField> tnf = patch.nf();
626  const vectorField& nf = tnf();
627  const vectorField& Sf = patch.Sf();
628  const vectorField& Cf = patch.Cf();
629 
630  nfOnPatchPtr_().boundaryFieldRef()[patchI] = nf;
631  SfOnPatchPtr_().boundaryFieldRef()[patchI] = Sf;
632  CfOnPatchPtr_().boundaryFieldRef()[patchI] = Cf;
633  }
634  }
635 
636  // Solve extra equations if necessary
637  // Solved using accumulated sources over time
638  autoPtr<boundaryVectorField> distanceSensPtr(nullptr);
639  if (includeDistance_)
640  {
641  eikonalSolver_->solve();
642  distanceSensPtr.reset(createZeroBoundaryPtr<vector>(mesh_));
643  const boundaryVectorField& sens =
644  eikonalSolver_->distanceSensitivities();
645  for (const label patchI : sensitivityPatchIDs_)
646  {
647  distanceSensPtr()[patchI] = sens[patchI];
648  }
649  }
650 
651  autoPtr<boundaryVectorField> meshMovementSensPtr(nullptr);
653  {
654  meshMovementSolver_->solve();
655  meshMovementSensPtr.reset(createZeroBoundaryPtr<vector>(mesh_));
656  const boundaryVectorField& sens =
657  meshMovementSolver_->meshMovementSensitivities();
658  for (const label patchI : sensitivityPatchIDs_)
659  {
660  meshMovementSensPtr()[patchI] = sens[patchI];
661  }
662  }
663 
664 
665  // Project to normal face vector
666  label nPassedFaces(0);
667  for (const label patchI : sensitivityPatchIDs_)
668  {
669  const fvPatch& patch = mesh_.boundary()[patchI];
670  tmp<vectorField> tnf(patch.nf());
671  const vectorField& nf = tnf();
672 
673  // Distance related terms
674  if (includeDistance_)
675  {
676  wallFaceSensVecPtr_()[patchI] += distanceSensPtr()[patchI];
677  }
678 
679  // Mesh movement related terms
681  {
682  wallFaceSensVecPtr_()[patchI] += meshMovementSensPtr()[patchI];
683  }
684 
686  {
687  wallFaceSensVecPtr_()[patchI] *= patch.magSf();
688  }
689 
690  wallFaceSensNormalPtr_()[patchI] = wallFaceSensVecPtr_()[patchI] & nf;
691  wallFaceSensNormalVecPtr_()[patchI] =
692  wallFaceSensNormalPtr_()[patchI] * nf;
693 
694  forAll(patch, fI)
695  {
696  derivatives_[nPassedFaces + fI]
697  = wallFaceSensNormalPtr_()[patchI][fI];
698  }
699  nPassedFaces += patch.size();
700  }
701 }
702 
703 
705 {
706  // Reset terms in post-processing PDEs
707  if (includeDistance_)
708  {
709  eikonalSolver_->reset();
710  }
712  {
713  meshMovementSolver_->reset();
714  }
715  // Reset sensitivity fields
718 }
719 
720 
722 {
723  return eikonalSolver_;
724 }
725 
726 
727 void sensitivitySurface::write(const word& baseName)
728 {
729  setSuffixName();
732 
734  {
735  nfOnPatchPtr_().write();
736  SfOnPatchPtr_().write();
737  CfOnPatchPtr_().write();
738  }
739 }
740 
741 
742 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
743 
744 } // End namespace Foam
745 } // End namespace incompressible
746 
747 // ************************************************************************* //
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:84
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:1038
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:617
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:91
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:85
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Tensor< scalar >::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:59
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:107
Foam::incompressible::sensitivitySurface::eikonalSolver_
autoPtr< adjointEikonalSolver > eikonalSolver_
Definition: sensitivitySurfaceIncompressible.H:96
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
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:727
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::fv::optionAdjointList
Definition: fvOptionAdjointList.H:59
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:747
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:98
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:76
Foam::incompressible::sensitivitySurface::includeDivTerm_
bool includeDivTerm_
Include the term from the deviatoric part of the stresses.
Definition: sensitivitySurfaceIncompressible.H:82
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:402
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:94
Foam::incompressible::sensitivitySurface::accumulateIntegrand
virtual void accumulateIntegrand(const scalar dt)
Accumulate sensitivity integrands.
Definition: sensitivitySurfaceIncompressible.C:413
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::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:721
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:130
Foam::incompressible::sensitivitySurface::nfOnPatchPtr_
autoPtr< volVectorField > nfOnPatchPtr_
Definition: sensitivitySurfaceIncompressible.H:101
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:86
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressible::sensitivitySurface::includeDistance_
bool includeDistance_
Include distance variation in sens computation.
Definition: sensitivitySurfaceIncompressible.H:85
Foam::incompressible::adjointSensitivity::primalVars_
incompressibleVars & primalVars_
Definition: adjointSensitivityIncompressible.H:85
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:555
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:325
sensitivitySurfaceIncompressible.H
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1063
Foam::GeometricField::Boundary
Definition: GeometricField.H:114
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:354
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:704
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:103
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< scalar >, scalar, 3 >::zero
static const Vector< scalar > 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:88
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
fvOptionsAdjoint
fv::IOoptionListAdjoint fvOptionsAdjoint(mesh)
Foam::incompressible::sensitivitySurface::readDict
virtual bool readDict(const dictionary &dict)
Read dict if changed.
Definition: sensitivitySurfaceIncompressible.C:381
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:140
Foam::incompressible::sensitivitySurface::SfOnPatchPtr_
autoPtr< volVectorField > SfOnPatchPtr_
Definition: sensitivitySurfaceIncompressible.H:102
Foam::objectiveManager::getObjectiveFunctions
PtrList< objective > & getObjectiveFunctions()
Return reference to objective functions.
Definition: objectiveManager.C:247
Foam::incompressible::adjointSensitivity::objectiveManager_
objectiveManager & objectiveManager_
Definition: adjointSensitivityIncompressible.H:87