adjointTurbulenceModel.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 Namespace
30  Foam::incompressibleAdjoint
31 
32 Description
33  Namespace for incompressible adjoint turbulence models.
34 
35 Class
36  Foam::incompressibleAdjoint::adjointTurbulenceModel
37 
38 Description
39  Abstract base class for incompressible adjoint turbulence models
40  (RAS, LES and laminar).
41 
42 SourceFiles
43  adjointTurbulenceModel.C
44  newTurbulenceModel.C
45 
46 \*---------------------------------------------------------------------------*/
47 
48 #ifndef adjointTurbulenceModel_H
49 #define adjointTurbulenceModel_H
50 
51 #include "incompressibleVars.H"
53 #include "objectiveManager.H"
54 #include "Time.H"
55 #include "runTimeSelectionTables.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 // Forward declarations
63 class fvMesh;
64 
65 namespace incompressibleAdjoint
66 {
67 
68 /*---------------------------------------------------------------------------*\
69  Class adjointTurbulenceModel Declaration
70 \*---------------------------------------------------------------------------*/
71 
73 :
74  public regIOobject
75 {
76 private:
77 
78  // Private Member Functions
79 
80  //- No copy construct
82 
83  //- No copy assignment
84  void operator=(const adjointTurbulenceModel&) = delete;
85 
86 
87 protected:
88 
89  // Protected data
90 
93  const Time& runTime_;
94  const fvMesh& mesh_;
95 
96 
97 public:
98 
99  //- Runtime type information
100  TypeName("adjointTurbulenceModel");
101 
102 
103  // Declare run-time New selection table
104 
106  (
107  autoPtr,
110  (
111  incompressibleVars& primalVars,
113  objectiveManager& objManager,
114  const word& adjointTurbulenceModelName
115  ),
116  (
117  primalVars,
118  adjointVars,
119  objManager,
120  adjointTurbulenceModelName
121  )
122  );
123 
124 
125  // Constructors
126 
127  //- Construct from components
129  (
130  incompressibleVars& primalVars,
132  objectiveManager& objManager,
133  const word& adjointTurbulenceModelName = typeName
134  );
135 
136 
137  // Selectors
138 
139  //- Return a reference to the selected turbulence model
141  (
142  incompressibleVars& primalVars,
144  objectiveManager& objManager,
145  const word& adjointTurbulenceModelName = typeName
146  );
147 
148 
149  //- Destructor
150  virtual ~adjointTurbulenceModel() = default;
151 
152 
153  // Member Functions
154 
155  //- Return the laminar viscosity
156  inline tmp<volScalarField> nu() const
157  {
158  return primalVars_.laminarTransport().nu();
159  }
160 
161  //- Return the turbulence viscosity
162  virtual const volScalarField& nut() const
163  {
164  return primalVars_.RASModelVariables()().nutRef();
165  }
166 
167  //- Return the effective viscosity
168  virtual tmp<volScalarField> nuEff() const
169  {
170  // Go through RASModelVariables::nutRef in order to obtain
171  // the mean field, if present
172  const singlePhaseTransportModel& lamTrans =
175  turbVars = primalVars_.RASModelVariables();
176 
177  return
179  (
180  "nuEff",
181  lamTrans.nu()() + turbVars().nutRef()
182  );
183  //return primalVars_.turbulence()().nuEff();
184  }
185 
186  //- Return the effective stress tensor including the laminar stress
187  virtual tmp<volSymmTensorField> devReff() const = 0;
188 
189  //- Return the effective stress tensor based on a given velocity field
191  (
192  const volVectorField& U
193  ) const = 0;
194 
195  //- Return the diffusion term for the momentum equation
196  virtual tmp<fvVectorMatrix> divDevReff(volVectorField& U) const = 0;
197 
198  //- Source term added to the adjoint mean flow due to the
199  // differentiation of the turbulence model
201 
202  //- Solve the adjoint turbulence equations
203  virtual void correct() = 0;
204 
205  //- Read adjointLESProperties or adjointRASProperties dictionary
206  virtual bool read() = 0;
207 
208  //- Default dummy write function
209  virtual bool writeData(Ostream&) const
210  {
211  return true;
212  }
213 
214  //- Nullify all adjoint turbulence model fields and their old times
215  virtual void nullify() = 0;
216 };
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace incompressibleAdjoint
222 } // End namespace Foam
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
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::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::incompressibleAdjoint::adjointTurbulenceModel::read
virtual bool read()=0
Read adjointLESProperties or adjointRASProperties dictionary.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::incompressibleAdjoint::adjointTurbulenceModel::New
static autoPtr< adjointTurbulenceModel > New(incompressibleVars &primalVars, incompressibleAdjointMeanFlowVars &adjointVars, objectiveManager &objManager, const word &adjointTurbulenceModelName=typeName)
Return a reference to the selected turbulence model.
Definition: adjointTurbulenceModel.C:77
incompressibleVars.H
Foam::incompressibleAdjoint::adjointTurbulenceModel::nuEff
virtual tmp< volScalarField > nuEff() const
Return the effective viscosity.
Definition: adjointTurbulenceModel.H:167
Foam::incompressibleAdjoint::adjointTurbulenceModel::TypeName
TypeName("adjointTurbulenceModel")
Runtime type information.
Foam::singlePhaseTransportModel
A simple single-phase transport model based on viscosityModel.
Definition: singlePhaseTransportModel.H:57
objectiveManager.H
Foam::incompressibleVars::RASModelVariables
const autoPtr< incompressible::RASModelVariables > & RASModelVariables() const
Return const reference to the turbulence model variables.
Definition: incompressibleVars.C:444
Foam::incompressibleAdjoint::adjointTurbulenceModel::declareRunTimeNewSelectionTable
declareRunTimeNewSelectionTable(autoPtr, adjointTurbulenceModel, adjointTurbulenceModel,(incompressibleVars &primalVars, incompressibleAdjointMeanFlowVars &adjointVars, objectiveManager &objManager, const word &adjointTurbulenceModelName),(primalVars, adjointVars, objManager, adjointTurbulenceModelName))
Foam::incompressibleAdjoint::adjointTurbulenceModel::mesh_
const fvMesh & mesh_
Definition: adjointTurbulenceModel.H:93
incompressibleAdjointMeanFlowVars.H
Foam::incompressibleVars::laminarTransport
const singlePhaseTransportModel & laminarTransport() const
Return const reference to transport model.
Definition: incompressibleVars.C:418
Foam::incompressibleAdjoint::adjointTurbulenceModel
Abstract base class for incompressible adjoint turbulence models (RAS, LES and laminar).
Definition: adjointTurbulenceModel.H:71
Foam::incompressibleAdjoint::adjointTurbulenceModel::writeData
virtual bool writeData(Ostream &) const
Default dummy write function.
Definition: adjointTurbulenceModel.H:208
Foam::incompressibleAdjoint::adjointTurbulenceModel::correct
virtual void correct()=0
Solve the adjoint turbulence equations.
Definition: adjointTurbulenceModel.C:129
Foam::incompressibleAdjoint::adjointTurbulenceModel::nullify
virtual void nullify()=0
Nullify all adjoint turbulence model fields and their old times.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressibleAdjoint::adjointTurbulenceModel::adjointMeanFlowSource
virtual tmp< volVectorField > adjointMeanFlowSource()=0
Source term added to the adjoint mean flow due to the.
Foam::incompressibleAdjoint::adjointTurbulenceModel::runTime_
const Time & runTime_
Definition: adjointTurbulenceModel.H:92
Time.H
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::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::incompressibleAdjoint::adjointTurbulenceModel::~adjointTurbulenceModel
virtual ~adjointTurbulenceModel()=default
Destructor.
Foam::singlePhaseTransportModel::nu
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
Definition: singlePhaseTransportModel.C:72
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::incompressibleAdjoint::adjointTurbulenceModel::adjointVars_
incompressibleAdjointMeanFlowVars & adjointVars_
Definition: adjointTurbulenceModel.H:91
Foam::incompressibleAdjoint::adjointTurbulenceModel::primalVars_
incompressibleVars & primalVars_
Definition: adjointTurbulenceModel.H:90
Foam::incompressibleAdjoint::adjointTurbulenceModel::divDevReff
virtual tmp< fvVectorMatrix > divDevReff(volVectorField &U) const =0
Return the diffusion term for the momentum equation.
Foam::incompressibleAdjoint::adjointTurbulenceModel::devReff
virtual tmp< volSymmTensorField > devReff() const =0
Return the effective stress tensor including the laminar stress.
Foam::incompressibleAdjoint::adjointTurbulenceModel::nu
tmp< volScalarField > nu() const
Return the laminar viscosity.
Definition: adjointTurbulenceModel.H:155
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::incompressibleAdjoint::adjointTurbulenceModel::nut
virtual const volScalarField & nut() const
Return the turbulence viscosity.
Definition: adjointTurbulenceModel.H:161
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54