DASpalartAllmarasFv3FieldInversion.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 
3  DAFoam : Discrete Adjoint with OpenFOAM
4  Version : v3
5 
6  Description:
7  Child class for the SpalartAllmarasFv3 model with a betaFieldInversion field multiplying
8  to the production term. This betaFieldInversion term can then be trained to improve the
9  SA turbulence model.
10 
11  This file is modified from OpenFOAM's source code
12  src/TurbulenceModels/turbulenceModels/RAS/SpalartAllmaras/SpalartAllmaras.H
13 
14  OpenFOAM: The Open Source CFD Toolbox
15 
16  Copyright (C): 2011-2016 OpenFOAM Foundation
17 
18  OpenFOAM License:
19 
20  OpenFOAM is free software: you can redistribute it and/or modify it
21  under the terms of the GNU General Public License as published by
22  the Free Software Foundation, either version 3 of the License, or
23  (at your option) any later version.
24 
25  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
26  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
27  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28  for more details.
29 
30  You should have received a copy of the GNU General Public License
31  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef DASpalartAllmarasFv3FieldInversion_H
36 #define DASpalartAllmarasFv3FieldInversion_H
37 
38 #include "DATurbulenceModel.H"
39 #include "addToRunTimeSelectionTable.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 /*---------------------------------------------------------------------------*\
47  Class DASpalartAllmarasFv3FieldInversion Declaration
48 \*---------------------------------------------------------------------------*/
49 
51  : public DATurbulenceModel
52 {
53 
54 protected:
56 
57  dimensionedScalar sigmaNut_;
58  dimensionedScalar kappa_;
59  dimensionedScalar Cb1_;
60  dimensionedScalar Cb2_;
61  dimensionedScalar Cw1_;
62  dimensionedScalar Cw2_;
63  dimensionedScalar Cw3_;
64  dimensionedScalar Cv1_;
65  dimensionedScalar Cv2_;
67 
69 
70  tmp<volScalarField> chi() const;
71 
72  tmp<volScalarField> fv1(const volScalarField& chi) const;
73 
74  tmp<volScalarField> fv2(
75  const volScalarField& chi,
76  const volScalarField& fv1) const;
77 
78  tmp<volScalarField> fv3(
79  const volScalarField& chi,
80  const volScalarField& fv1) const;
81 
82  tmp<volScalarField> fw(const volScalarField& Stilda) const;
83 
85 
87 
88  volScalarField& nuTilda_;
89  volScalarField nuTildaRes_;
90  volScalarField nuTildaResPartDeriv_;
92 
94  volScalarField& betaFieldInversion_;
95 
97  volVectorField UData_;
98 
100  volScalarField surfaceFriction_;
101 
103  volScalarField surfaceFrictionData_;
104 
106  volScalarField pData_;
107 
109  volScalarField USingleComponentData_;
110 
112  const volScalarField& y_;
113 
115  label solveTurbState_ = 0;
116 
119 
120 public:
121  TypeName("SpalartAllmarasFv3FieldInversion");
122  // Constructors
123 
124  //- Construct from components
126  const word modelType,
127  const fvMesh& mesh,
128  const DAOption& daOption);
129 
130  //- Destructor
132  {
133  }
134 
135  // Member functions
136 
138  tmp<volScalarField> DnuTildaEff() const;
139 
141  virtual void correctModelStates(wordList& modelStates) const;
142 
144  virtual void correctNut();
145 
147  virtual void correctBoundaryConditions();
148 
150  virtual void updateIntermediateVariables();
151 
153  virtual void correctStateResidualModelCon(List<List<word>>& stateCon) const;
154 
156  virtual void addModelResidualCon(HashTable<List<List<word>>>& allCon) const;
157 
159  virtual void calcResiduals(const dictionary& options);
160 
162  virtual void correct();
163 
165  virtual void getTurbProdTerm(scalarList& prodTerm) const;
166 };
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
Foam::DASpalartAllmarasFv3FieldInversion::Cw3_
dimensionedScalar Cw3_
Definition: DASpalartAllmarasFv3FieldInversion.H:63
Foam::DASpalartAllmarasFv3FieldInversion::Cb1_
dimensionedScalar Cb1_
Definition: DASpalartAllmarasFv3FieldInversion.H:59
Foam::DASpalartAllmarasFv3FieldInversion::~DASpalartAllmarasFv3FieldInversion
virtual ~DASpalartAllmarasFv3FieldInversion()
Definition: DASpalartAllmarasFv3FieldInversion.H:131
Foam::DASpalartAllmarasFv3FieldInversion::fv3
tmp< volScalarField > fv3(const volScalarField &chi, const volScalarField &fv1) const
Definition: DASpalartAllmarasFv3FieldInversion.C:167
Foam::DASpalartAllmarasFv3FieldInversion::DnuTildaEff
tmp< volScalarField > DnuTildaEff() const
Return the effective diffusivity for nuTilda.
Definition: DASpalartAllmarasFv3FieldInversion.C:198
Foam::DASpalartAllmarasFv3FieldInversion::nuTildaResPartDeriv_
volScalarField nuTildaResPartDeriv_
Definition: DASpalartAllmarasFv3FieldInversion.H:90
Foam::DAOption
Definition: DAOption.H:29
Foam::DASpalartAllmarasFv3FieldInversion::calcResiduals
virtual void calcResiduals(const dictionary &options)
compute the turbulence residuals
Definition: DASpalartAllmarasFv3FieldInversion.C:429
Foam::DASpalartAllmarasFv3FieldInversion::USingleComponentData_
volScalarField USingleComponentData_
reference field for profile data
Definition: DASpalartAllmarasFv3FieldInversion.H:109
daOption
DAOption daOption(mesh, pyOptions_)
Foam::DASpalartAllmarasFv3FieldInversion::fv1
tmp< volScalarField > fv1(const volScalarField &chi) const
Definition: DASpalartAllmarasFv3FieldInversion.C:153
Foam::DASpalartAllmarasFv3FieldInversion::correctNut
virtual void correctNut()
update nut based on other turbulence variables and update the BCs
Definition: DASpalartAllmarasFv3FieldInversion.C:239
Foam::DASpalartAllmarasFv3FieldInversion::UData_
volVectorField UData_
reference velocity field
Definition: DASpalartAllmarasFv3FieldInversion.H:97
Foam::DASpalartAllmarasFv3FieldInversion::correctBoundaryConditions
virtual void correctBoundaryConditions()
update turbulence variable boundary values
Definition: DASpalartAllmarasFv3FieldInversion.C:259
Foam::DASpalartAllmarasFv3FieldInversion::correctModelStates
virtual void correctModelStates(wordList &modelStates) const
update the turbulence state for DAStateInfo::regStates_
Definition: DASpalartAllmarasFv3FieldInversion.C:205
mesh
fvMesh & mesh
Definition: createRefsHeatTransfer.H:4
Foam::DASpalartAllmarasFv3FieldInversion::printInterval_
label printInterval_
time step interval to print residual
Definition: DASpalartAllmarasFv3FieldInversion.H:118
Foam::DASpalartAllmarasFv3FieldInversion::fw
tmp< volScalarField > fw(const volScalarField &Stilda) const
Definition: DASpalartAllmarasFv3FieldInversion.C:180
Foam::DASpalartAllmarasFv3FieldInversion::getTurbProdTerm
virtual void getTurbProdTerm(scalarList &prodTerm) const
return the value of the production term from the turbulence model
Definition: DASpalartAllmarasFv3FieldInversion.C:516
Foam::DASpalartAllmarasFv3FieldInversion::betaFieldInversion_
volScalarField & betaFieldInversion_
A beta field multiplying to the production term.
Definition: DASpalartAllmarasFv3FieldInversion.H:94
Foam::DASpalartAllmarasFv3FieldInversion::kappa_
dimensionedScalar kappa_
Definition: DASpalartAllmarasFv3FieldInversion.H:58
Foam::DASpalartAllmarasFv3FieldInversion::Cw1_
dimensionedScalar Cw1_
Definition: DASpalartAllmarasFv3FieldInversion.H:61
Foam::DASpalartAllmarasFv3FieldInversion::chi
tmp< volScalarField > chi() const
Definition: DASpalartAllmarasFv3FieldInversion.C:148
Foam::DASpalartAllmarasFv3FieldInversion::Cv1_
dimensionedScalar Cv1_
Definition: DASpalartAllmarasFv3FieldInversion.H:64
Foam::DASpalartAllmarasFv3FieldInversion::nuTilda_
volScalarField & nuTilda_
Definition: DASpalartAllmarasFv3FieldInversion.H:88
Foam::DASpalartAllmarasFv3FieldInversion::Cw2_
dimensionedScalar Cw2_
Definition: DASpalartAllmarasFv3FieldInversion.H:62
Foam
Definition: multiFreqScalarFvPatchField.C:144
Foam::DASpalartAllmarasFv3FieldInversion::updateIntermediateVariables
virtual void updateIntermediateVariables()
update any intermediate variables that are dependent on state variables and are used in calcResiduals
Definition: DASpalartAllmarasFv3FieldInversion.C:270
Foam::DASpalartAllmarasFv3FieldInversion::DASpalartAllmarasFv3FieldInversion
DASpalartAllmarasFv3FieldInversion(const word modelType, const fvMesh &mesh, const DAOption &daOption)
Definition: DASpalartAllmarasFv3FieldInversion.C:41
Foam::DASpalartAllmarasFv3FieldInversion::correct
virtual void correct()
solve the residual equations and update the state
Definition: DASpalartAllmarasFv3FieldInversion.C:409
Foam::DASpalartAllmarasFv3FieldInversion::Cb2_
dimensionedScalar Cb2_
Definition: DASpalartAllmarasFv3FieldInversion.H:60
Foam::DASpalartAllmarasFv3FieldInversion::solveTurbState_
label solveTurbState_
whether to solve for turb states
Definition: DASpalartAllmarasFv3FieldInversion.H:115
Foam::DATurbulenceModel
Definition: DATurbulenceModel.H:61
Foam::DASpalartAllmarasFv3FieldInversion::surfaceFriction_
volScalarField surfaceFriction_
a surface friction 'field' when using skin friction data for field inversion
Definition: DASpalartAllmarasFv3FieldInversion.H:100
Foam::DASpalartAllmarasFv3FieldInversion::addModelResidualCon
virtual void addModelResidualCon(HashTable< List< List< word >>> &allCon) const
add the model residual connectivity to stateCon
Definition: DASpalartAllmarasFv3FieldInversion.C:331
Foam::DASpalartAllmarasFv3FieldInversion
Definition: DASpalartAllmarasFv3FieldInversion.H:50
Foam::DASpalartAllmarasFv3FieldInversion::Cv2_
dimensionedScalar Cv2_
Definition: DASpalartAllmarasFv3FieldInversion.H:65
Foam::DASpalartAllmarasFv3FieldInversion::sigmaNut_
dimensionedScalar sigmaNut_
Definition: DASpalartAllmarasFv3FieldInversion.H:57
Foam::DASpalartAllmarasFv3FieldInversion::nuTildaRes_
volScalarField nuTildaRes_
Definition: DASpalartAllmarasFv3FieldInversion.H:89
Foam::DASpalartAllmarasFv3FieldInversion::y_
const volScalarField & y_
3D wall distance
Definition: DASpalartAllmarasFv3FieldInversion.H:112
DATurbulenceModel.H
Foam::DASpalartAllmarasFv3FieldInversion::fv2
tmp< volScalarField > fv2(const volScalarField &chi, const volScalarField &fv1) const
Definition: DASpalartAllmarasFv3FieldInversion.C:160
Foam::DASpalartAllmarasFv3FieldInversion::TypeName
TypeName("SpalartAllmarasFv3FieldInversion")
Foam::DASpalartAllmarasFv3FieldInversion::surfaceFrictionData_
volScalarField surfaceFrictionData_
the reference field for surfaceFriction
Definition: DASpalartAllmarasFv3FieldInversion.H:103
Foam::DASpalartAllmarasFv3FieldInversion::correctStateResidualModelCon
virtual void correctStateResidualModelCon(List< List< word >> &stateCon) const
update the original variable connectivity for the adjoint state residuals in stateCon
Definition: DASpalartAllmarasFv3FieldInversion.C:281
Foam::DASpalartAllmarasFv3FieldInversion::pData_
volScalarField pData_
the reference field for pressure
Definition: DASpalartAllmarasFv3FieldInversion.H:106