adjointSpalartAllmaras.H
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-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019 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 Class
30  Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras
31 
32 Description
33  Continuous adjoint to the Spalart-Allmaras one-eqn mixing-length model for
34  incompressible flows.
35 
36  Reference:
37  \verbatim
38  For the adjoint to the Spalart-Allmaras PDE
39 
40  Zymaris, A., Papadimitriou, D., Giannakoglou, K., &
41  Othmer, C. (2009).
42  Continuous adjoint approach to the Spalart-Allmaras turbulence
43  model for incompressible flows.
44  Computers & Fluids, 38(8), 1528-538.
45  http://doi.org/10.1016/j.compfluid.2008.12.006
46 
47  For the FI sensitivity terms
48 
49  Papoutsis-Kiachagias, E. M., Asouti, V. G., Giannakoglou, K. C.,
50  Gkagkas, K., Shimokawa, S., & Itakura, E. (2018).
51  Multi-point aerodynamic shape optimization of cars based on
52  continuous adjoint.
53  Structural and Multidisciplinary Optimization, 59(2), 675-694.
54  http://doi.org/10.1007/s00158-018-2091-3
55 
56  \endverbatim
57 
58  Both of the above-mentioned papers develop the adjoint to the
59  Spalart-Allmaras PDE that includes the fv3 term. The current
60  implementation corresponds to the Spalart-Allmaras PDE as programmed within
61  OpenFOAM and is, thus, slightly different than the one developed in the
62  cited papers
63 
64 SourceFiles
65  adjointSpalartAllmaras.C
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #ifndef adjointSpalartAllmaras_H
70 #define adjointSpalartAllmaras_H
71 
72 #include "adjointRASModel.H"
73 #include "wallDist.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 namespace incompressibleAdjoint
80 {
81 namespace adjointRASModels
82 {
83 
84 /*---------------------------------------------------------------------------*\
85  Class adjointSpalartAllmaras Declaration
86 \*---------------------------------------------------------------------------*/
87 
89 :
90  public adjointRASModel
91 {
92  // Private Member Functions
93 
94  //- No copy construct
96 
97  //- No copy assignment
98  void operator=(const adjointSpalartAllmaras&) = delete;
99 
100 
101 protected:
102 
103  // Protected data
104 
105  // Model coefficients
106 
109 
117 
118  //- Whether to limit the adjoint production term to enhance
119  //- stability
121 
122 
123  // Fields
124 
125  //- Wall distance
126  // Note: reference to the distance known by the primal model
127  const volScalarField& y_;
128 
129  //- Field for masking (convergence enhancement)
131 
132  // Fields that depend only on primal fields and are very expensive
133  // to compute in each iteration.
134  // Store and update them when the primal solution has been updated
144 
145  // Useful quantities for bounding
147 
148 
149  // Protected Member Functions
150 
151  // Primal Spalart - Allmaras
152 
153  tmp<volScalarField> chi() const;
154 
156 
158  (
159  const volScalarField& chi,
160  const volScalarField& fv1
161  ) const;
162 
164  (
165  const volScalarField& chi,
166  const volScalarField& fv1
167  ) const;
168 
170 
172 
174 
175  //- References to the primal turbulence model variables
176  const volScalarField& nuTilda() const;
177 
178  const volScalarField& nut() const;
179 
180 
181  // Adjoint Spalart - Allmaras
182 
183  // Differentiation of the primal Spalart - Allmaras terms
184 
186  (
187  const volScalarField& chi
188  ) const;
189 
191  (
192  const volScalarField& chi,
193  const volScalarField& fv1,
194  const volScalarField& dFv1dChi
195  ) const;
196 
198  (
199  const volScalarField& Omega,
200  const volScalarField& fv2
201  ) const;
202 
204  (
205  const volScalarField& Omega,
206  const volScalarField& fv2,
207  const volScalarField& dFv2dChi
208  ) const;
209 
211  (
212  const volScalarField& Omega,
213  const volScalarField& fv2
214  ) const;
215 
217  (
218  const volScalarField& Stilda
219  ) const;
220 
222  (
223  const volScalarField& Stilda
224  ) const;
225 
227  (
228  const volScalarField& Stilda
229  ) const;
230 
232  (
233  const volScalarField& Stilda
234  ) const;
235 
237  (
238  const volScalarField& Stilda,
239  const volScalarField& dfwdr,
240  const volScalarField& dStildadNuTilda
241  ) const;
242 
244  (
245  const volScalarField& Stilda,
246  const volScalarField& dfwdr,
247  const volScalarField& dStildadOmega
248  ) const;
249 
251  (
252  const volScalarField& Stilda,
253  const volScalarField& dfwdr,
254  const volScalarField& dStildadDelta
255  ) const;
256 
258  (
259  const volScalarField& fw,
260  const volScalarField& dfwdNuTilda
261  ) const;
262 
264  (
265  const volScalarField& dStildadNuTilda
266  ) const;
267 
269  (
270  const volScalarField& fv1,
271  const volScalarField& dFv1dChi
272  ) const;
273 
274 
275  //- Conservative source term for the adjoint momentum equations
276  // Sets also the adjointMomentumBCSource
278 
279  //- Access to the adjoint Spalart - Allmaras field
280  inline volScalarField& nuaTilda()
281  {
282  return adjointTMVariable1Ptr_();
283  };
284 
285  //- Update the constant primal-related fields
287 
288  //- Allocate the mask field
290 
291 
292 public:
293 
294  //- Runtime type information
295  TypeName("adjointSpalartAllmaras");
296 
297 
298  // Constructors
299 
300  //- Construct from components
302  (
303  incompressibleVars& primalVars,
305  objectiveManager& objManager,
306  const word& adjointTurbulenceModelName
307  = adjointTurbulenceModel::typeName,
308  const word& modelName = typeName
309  );
310 
311 
312  //- Destructor
313  virtual ~adjointSpalartAllmaras() = default;
314 
315 
316  // Member Functions
317 
318  virtual tmp<volSymmTensorField> devReff() const;
319 
320  virtual tmp<volSymmTensorField> devReff(const volVectorField& U) const;
321 
323 
325 
326  virtual tmp<volScalarField> nutJacobianTMVar1() const;
327 
328  virtual tmp<scalarField> diffusionCoeffVar1(label patchI) const;
329 
330  virtual const boundaryVectorField& adjointMomentumBCSource() const;
331 
333 
335 
337 
339 
340  //- Nullify all adjoint turbulence model fields and their old times
341  virtual void nullify();
342 
343  //- Solve the adjoint turbulence equations
344  virtual void correct();
345 
346  //- Read adjointRASProperties dictionary
347  virtual bool read();
348 
349 };
350 
351 
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 
354 } // End namespace adjointRASModels
355 } // End namespace incompressibleAdjoint
356 } // End namespace Foam
357 
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
359 
360 #endif
361 
362 // ************************************************************************* //
wallDist.H
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::kappa_
dimensionedScalar kappa_
Definition: adjointSpalartAllmaras.H:107
Foam::incompressibleAdjointMeanFlowVars
Manages the adjoint mean flow fields and their mean values.
Definition: incompressibleAdjointMeanFlowVars.H:51
Foam::objectiveManager
class for managing incompressible objective functions.
Definition: objectiveManager.H:54
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cdnut_
volScalarField Cdnut_
Definition: adjointSpalartAllmaras.H:139
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::fv1
tmp< volScalarField > fv1(const volScalarField &chi) const
Definition: adjointSpalartAllmaras.C:69
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::gradNuTilda_
volVectorField gradNuTilda_
Definition: adjointSpalartAllmaras.H:142
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::r
tmp< volScalarField > r(const volScalarField &Stilda) const
Definition: adjointSpalartAllmaras.C:107
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cv1_
dimensionedScalar Cv1_
Definition: adjointSpalartAllmaras.H:114
adjointRASModel.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras
Continuous adjoint to the Spalart-Allmaras one-eqn mixing-length model for incompressible flows.
Definition: adjointSpalartAllmaras.H:87
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dStilda_dNuTilda
tmp< volScalarField > dStilda_dNuTilda(const volScalarField &Omega, const volScalarField &fv2, const volScalarField &dFv2dChi) const
Definition: adjointSpalartAllmaras.C:200
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::sigmaNut_
dimensionedScalar sigmaNut_
Definition: adjointSpalartAllmaras.H:106
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::TypeName
TypeName("adjointSpalartAllmaras")
Runtime type information.
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::fv2
tmp< volScalarField > fv2(const volScalarField &chi, const volScalarField &fv1) const
Definition: adjointSpalartAllmaras.C:77
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::adjointMeanFlowSource
virtual tmp< volVectorField > adjointMeanFlowSource()
Definition: adjointSpalartAllmaras.C:744
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cw1_
dimensionedScalar Cw1_
Definition: adjointSpalartAllmaras.H:111
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dStilda_dOmega
tmp< volScalarField > dStilda_dOmega(const volScalarField &Omega, const volScalarField &fv2) const
Definition: adjointSpalartAllmaras.C:185
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dnut_dNuTilda
tmp< volScalarField > dnut_dNuTilda(const volScalarField &fv1, const volScalarField &dFv1dChi) const
Definition: adjointSpalartAllmaras.C:346
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dfw_dOmega
tmp< volScalarField > dfw_dOmega(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadOmega) const
Definition: adjointSpalartAllmaras.C:305
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::adjointMomentumBCSource
virtual const boundaryVectorField & adjointMomentumBCSource() const
Definition: adjointSpalartAllmaras.C:782
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dfw_dDelta
tmp< volScalarField > dfw_dDelta(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadDelta) const
Definition: adjointSpalartAllmaras.C:316
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dr_dNuTilda
tmp< volScalarField > dr_dNuTilda(const volScalarField &Stilda) const
Definition: adjointSpalartAllmaras.C:227
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::minStilda_
dimensionedScalar minStilda_
Definition: adjointSpalartAllmaras.H:145
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::fw_
volScalarField fw_
Definition: adjointSpalartAllmaras.H:138
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dFv2_dChi
tmp< volScalarField > dFv2_dChi(const volScalarField &chi, const volScalarField &fv1, const volScalarField &dFv1dChi) const
Definition: adjointSpalartAllmaras.C:174
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::distanceSensitivities
virtual tmp< volScalarField > distanceSensitivities()
Definition: adjointSpalartAllmaras.C:830
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dr_dDelta
tmp< volScalarField > dr_dDelta(const volScalarField &Stilda) const
Definition: adjointSpalartAllmaras.C:259
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::gradU_
volTensorField gradU_
Definition: adjointSpalartAllmaras.H:141
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::nuaTilda
volScalarField & nuaTilda()
Access to the adjoint Spalart - Allmaras field.
Definition: adjointSpalartAllmaras.H:279
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dfw_dNuTilda
tmp< volScalarField > dfw_dNuTilda(const volScalarField &Stilda, const volScalarField &dfwdr, const volScalarField &dStildadNuTilda) const
Definition: adjointSpalartAllmaras.C:291
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dfw_dr
tmp< volScalarField > dfw_dr(const volScalarField &Stilda) const
Definition: adjointSpalartAllmaras.C:275
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cb2_
dimensionedScalar Cb2_
Definition: adjointSpalartAllmaras.H:110
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::read
virtual bool read()
Read adjointRASProperties dictionary.
Definition: adjointSpalartAllmaras.C:1090
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::symmAdjointProductionU_
volSymmTensorField symmAdjointProductionU_
Definition: adjointSpalartAllmaras.H:134
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::conservativeMomentumSource
tmp< volVectorField > conservativeMomentumSource()
Conservative source term for the adjoint momentum equations.
Definition: adjointSpalartAllmaras.C:355
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dD_dNuTilda
tmp< volScalarField > dD_dNuTilda(const volScalarField &fw, const volScalarField &dfwdNuTilda) const
Definition: adjointSpalartAllmaras.C:327
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::FISensitivityTerm
virtual tmp< volTensorField > FISensitivityTerm()
Term contributing to the computation of FI-based sensitivities.
Definition: adjointSpalartAllmaras.C:949
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::nuTilda
const volScalarField & nuTilda() const
References to the primal turbulence model variables.
Definition: adjointSpalartAllmaras.C:148
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::nullify
virtual void nullify()
Nullify all adjoint turbulence model fields and their old times.
Definition: adjointSpalartAllmaras.C:1024
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::diffusionCoeffVar1
virtual tmp< scalarField > diffusionCoeffVar1(label patchI) const
Definition: adjointSpalartAllmaras.C:764
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::r_
volScalarField r_
Definition: adjointSpalartAllmaras.H:137
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cs_
dimensionedScalar Cs_
Definition: adjointSpalartAllmaras.H:115
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::nut
const volScalarField & nut() const
Return the turbulence viscosity.
Definition: adjointSpalartAllmaras.C:154
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::y_
const volScalarField & y_
Wall distance.
Definition: adjointSpalartAllmaras.H:126
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cw3_
dimensionedScalar Cw3_
Definition: adjointSpalartAllmaras.H:113
Foam::dimensioned< scalar >
Foam::incompressibleAdjoint::adjointRASModel
Abstract base class for incompressible turbulence models.
Definition: adjointRASModel.H:77
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dFv1_dChi
tmp< volScalarField > dFv1_dChi(const volScalarField &chi) const
Definition: adjointSpalartAllmaras.C:163
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::allocateMask
tmp< volScalarField > allocateMask()
Allocate the mask field.
Definition: adjointSpalartAllmaras.C:441
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dr_dStilda
tmp< volScalarField > dr_dStilda(const volScalarField &Stilda) const
Definition: adjointSpalartAllmaras.C:243
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cw2_
dimensionedScalar Cw2_
Definition: adjointSpalartAllmaras.H:112
U
U
Definition: pEqn.H:72
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Stilda
tmp< volScalarField > Stilda(const volScalarField &chi, const volScalarField &fv1) const
Definition: adjointSpalartAllmaras.C:87
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::nutJacobianTMVar1
virtual tmp< volScalarField > nutJacobianTMVar1() const
Jacobian of nut wrt the first turbulence model variable.
Definition: adjointSpalartAllmaras.C:754
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::fw
tmp< volScalarField > fw(const volScalarField &Stilda) const
Definition: adjointSpalartAllmaras.C:129
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::momentumSourceMult_
volTensorField momentumSourceMult_
Definition: adjointSpalartAllmaras.H:140
Foam::GeometricField::Boundary
The boundary fields.
Definition: GeometricField.H:115
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::updatePrimalRelatedFields
void updatePrimalRelatedFields()
Update the constant primal-related fields.
Definition: adjointSpalartAllmaras.C:375
Foam::incompressibleAdjoint::adjointRASModel::adjointTMVariable1Ptr_
autoPtr< volScalarField > adjointTMVariable1Ptr_
Adjoint turbulence model variable 1.
Definition: adjointRASModel.H:113
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::chi
tmp< volScalarField > chi() const
Definition: adjointSpalartAllmaras.C:63
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Cb1_
dimensionedScalar Cb1_
Definition: adjointSpalartAllmaras.H:109
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::limitAdjointProduction_
bool limitAdjointProduction_
Definition: adjointSpalartAllmaras.H:119
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::devReff
virtual tmp< volSymmTensorField > devReff() const
Return the effective stress tensor including the laminar stress.
Definition: adjointSpalartAllmaras.C:703
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dP_dNuTilda
tmp< volScalarField > dP_dNuTilda(const volScalarField &dStildadNuTilda) const
Definition: adjointSpalartAllmaras.C:337
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::mask_
volScalarField mask_
Field for masking (convergence enhancement)
Definition: adjointSpalartAllmaras.H:129
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::divDevReff
virtual tmp< fvVectorMatrix > divDevReff(volVectorField &U) const
Return the diffusion term for the momentum equation.
Definition: adjointSpalartAllmaras.C:731
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::dStilda_dDelta
tmp< volScalarField > dStilda_dDelta(const volScalarField &Omega, const volScalarField &fv2) const
Definition: adjointSpalartAllmaras.C:214
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::wallShapeSensitivities
virtual const boundaryVectorField & wallShapeSensitivities()
Sensitivity terms for shape optimisation, emerging from.
Definition: adjointSpalartAllmaras.C:789
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::correct
virtual void correct()
Solve the adjoint turbulence equations.
Definition: adjointSpalartAllmaras.C:1030
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::productionDestructionSource_
volScalarField productionDestructionSource_
Definition: adjointSpalartAllmaras.H:135
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::DnuTildaEff
tmp< volScalarField > DnuTildaEff() const
Definition: adjointSpalartAllmaras.C:139
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::~adjointSpalartAllmaras
virtual ~adjointSpalartAllmaras()=default
Destructor.
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::Stilda_
volScalarField Stilda_
Definition: adjointSpalartAllmaras.H:136
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54
Foam::incompressibleAdjoint::adjointRASModels::adjointSpalartAllmaras::wallFloCoSensitivities
virtual const boundaryVectorField & wallFloCoSensitivities()
Sensitivity terms for flow control, emerging from the.
Definition: adjointSpalartAllmaras.C:812