RASModelVariables.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-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 Class
29  Foam::incompressible::RASModelVariables
30 
31 Description
32  Abstract base class for objective functions. No point in making this
33  runTime selectable since its children will have different constructors.
34 
35 SourceFiles
36  RASModelVariables.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef RASModelVariables_H
41 #define RASModelVariables_H
42 
43 #include "solverControl.H"
46 #include "runTimeSelectionTables.H"
47 #include "refPtr.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace incompressible
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class RASModelVariables Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62 protected:
63 
64  // Protected Data
65 
66  const fvMesh& mesh_;
68 
69  // Base names of the turbulent fields
73 
78 
79  // Initial values (demand-driven)
80  // For finite differences and optimisation runs
84 
85  // Mean values (demand-driven)
89 
90 
91  // Protected Member functions
92 
93  void allocateInitValues();
94  void allocateMeanFields();
95 
97  cloneRefPtr(const refPtr<volScalarField>& obj) const;
98 
100 
101  //- No copy assignment
102  void operator=(const RASModelVariables&) = delete;
103 
104 
105 public:
106 
107 
108  //- Runtime type information
109  TypeName("RASModelVariables");
110 
111  // Declare run-time constructor selection table
112 
114  (
115  autoPtr,
117  dictionary,
118  (
119  const fvMesh& mesh,
120  const solverControl& SolverControl
121  ),
122  (mesh, SolverControl)
123  );
124 
125 
126  // Constructors
127 
128  //- Construct from components
130  (
131  const fvMesh& mesh,
132  const solverControl& SolverControl
133  );
134 
135  //- Copy constructor
136  // Will allocate new fields (instead of referencing the ones in the
137  // turbulence model), so cannot be used directly to access the fields
138  // of the turbulence model.
139  // Mainly used for checkpointing in unsteady adjoint
141  (
142  const RASModelVariables& rmv
143  );
144 
145  //- Clone
146  // Will allocate new fields (instead of referencing the ones in the
147  // turbulence model), so cannot be used directly to access the fields
148  // of the turbulence model.
149  // Mainly used for checkpointing in unsteady adjoint
151 
152 
153  // Selectors
154 
155  //- Return a reference to the selected turbulence model
157  (
158  const fvMesh& mesh,
159  const solverControl& SolverControl
160  );
161 
162 
163  // Destructor
164 
165  // Destructor does nothing on base since depending on the case new
166  // fields might be allocated
167  // MUST be overloaded in inherited classes
168  virtual ~RASModelVariables() = default;
169 
170 
171  // Member Functions
172 
173  //- Turbulence field names
174  inline const word& TMVar1BaseName() const;
175  inline const word& TMVar2BaseName() const;
176  inline const word& nutBaseName() const;
177 
178  //- Bools to idenify which turbulent fields are present
179  inline bool hasTMVar1() const;
180  inline bool hasTMVar2() const;
181  inline bool hasNut() const;
182  inline bool hasDist() const;
183 
184  //- Return references to turbulence fields
185  // will return the mean field if it exists, otherwise the
186  // instantaneous one
187  inline const volScalarField& TMVar1() const;
188  inline volScalarField& TMVar1();
189  inline const volScalarField& TMVar2() const;
190  inline volScalarField& TMVar2();
191  inline const volScalarField& nutRef() const;
192  inline volScalarField& nutRef();
193  inline const volScalarField& d() const;
194  inline volScalarField& d();
195 
196  //- return references to instantaneous turbulence fields
197  inline const volScalarField& TMVar1Inst() const;
198  inline volScalarField& TMVar1Inst();
199  inline const volScalarField& TMVar2Inst() const;
200  inline volScalarField& TMVar2Inst();
201  inline const volScalarField& nutRefInst() const;
202  inline volScalarField& nutRefInst();
203 
204 
205  //- Return nut Jacobian wrt the TM vars
207  (
209  ) const;
210 
212  (
214  ) const;
215 
216  //- Restore turbulent fields to their initial values
217  void restoreInitValues();
218 
219  //- Reset mean fields to zero
220  void resetMeanFields();
221 
222  //- Compute mean fields on the fly
223  void computeMeanFields();
224 
225  //- Return stress tensor based on the mean flow variables
227  (
229  const volVectorField& U
230  ) const;
231 
232  //- correct bounday conditions of turbulent fields
233  virtual void correctBoundaryConditions
234  (
236  );
237 
238  //- Transfer turbulence fields from an another object
239  // Copies values since the ownership of the original fields is held
240  // by the turbulence model
241  virtual void transfer(RASModelVariables& rmv);
242 };
243 
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 } // End namespace incompressible
248 } // End namespace Foam
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #include "RASModelVariablesI.H"
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
Foam::incompressible::RASModelVariables::nutBaseName
const word & nutBaseName() const
Definition: RASModelVariablesI.H:50
Foam::incompressible::RASModelVariables::~RASModelVariables
virtual ~RASModelVariables()=default
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::incompressible::RASModelVariables::d
const volScalarField & d() const
Definition: RASModelVariablesI.H:144
Foam::incompressible::RASModelVariables::TMVar1Inst
const volScalarField & TMVar1Inst() const
return references to instantaneous turbulence fields
Definition: RASModelVariablesI.H:156
Foam::incompressible::RASModelVariables::solverControl_
const solverControl & solverControl_
Definition: RASModelVariables.H:66
turbulence
Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar("pos", dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar("neg", dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\n"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
RASModelVariablesI.H
Foam::incompressible::RASModelVariables
Abstract base class for objective functions. No point in making this runTime selectable since its chi...
Definition: RASModelVariables.H:59
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
refPtr.H
singlePhaseTransportModel.H
Foam::incompressible::RASModelVariables::operator=
void operator=(const RASModelVariables &)=delete
No copy assignment.
turbulentTransportModel.H
Foam::incompressible::RASModelVariables::TMVar1InitPtr_
refPtr< volScalarField > TMVar1InitPtr_
Definition: RASModelVariables.H:80
Foam::incompressible::RASModelVariables::TMVar2Ptr_
refPtr< volScalarField > TMVar2Ptr_
Definition: RASModelVariables.H:74
Foam::incompressible::RASModelVariables::nutInitPtr_
refPtr< volScalarField > nutInitPtr_
Definition: RASModelVariables.H:82
Foam::incompressible::RASModelVariables::restoreInitValues
void restoreInitValues()
Restore turbulent fields to their initial values.
Definition: RASModelVariables.C:349
Foam::solverControl
Base class for solver control classes.
Definition: solverControl.H:51
Foam::incompressible::RASModelVariables::allocateInitValues
void allocateInitValues()
Definition: RASModelVariables.C:48
Foam::incompressible::RASModelVariables::nutMeanPtr_
refPtr< volScalarField > nutMeanPtr_
Definition: RASModelVariables.H:87
Foam::incompressible::RASModelVariables::TMVar2BaseName_
word TMVar2BaseName_
Definition: RASModelVariables.H:70
Foam::singlePhaseTransportModel
A simple single-phase transport model based on viscosityModel.
Definition: singlePhaseTransportModel.H:57
Foam::incompressible::RASModelVariables::distPtr_
refPtr< volScalarField > distPtr_
Definition: RASModelVariables.H:76
Foam::incompressible::RASModelVariables::correctBoundaryConditions
virtual void correctBoundaryConditions(const incompressible::turbulenceModel &turbulence)
correct bounday conditions of turbulent fields
Definition: RASModelVariables.C:445
Foam::incompressible::RASModelVariables::RASModelVariables
RASModelVariables(const fvMesh &mesh, const solverControl &SolverControl)
Construct from components.
Definition: RASModelVariables.C:183
Foam::incompressible::RASModelVariables::computeMeanFields
void computeMeanFields()
Compute mean fields on the fly.
Definition: RASModelVariables.C:395
Foam::incompressible::RASModelVariables::transfer
virtual void transfer(RASModelVariables &rmv)
Transfer turbulence fields from an another object.
Definition: RASModelVariables.C:478
Foam::incompressible::RASModelVariables::nutRefInst
const volScalarField & nutRefInst() const
Definition: RASModelVariablesI.H:180
Foam::incompressible::RASModelVariables::hasDist
bool hasDist() const
Definition: RASModelVariablesI.H:74
Foam::incompressible::RASModelVariables::allocateMeanFields
void allocateMeanFields()
Definition: RASModelVariables.C:81
Foam::incompressible::RASModelVariables::resetMeanFields
void resetMeanFields()
Reset mean fields to zero.
Definition: RASModelVariables.C:369
Foam::incompressible::RASModelVariables::hasTMVar2
bool hasTMVar2() const
Definition: RASModelVariablesI.H:62
Foam::incompressible::RASModelVariables::nutBaseName_
word nutBaseName_
Definition: RASModelVariables.H:71
Foam::incompressible::RASModelVariables::mesh_
const fvMesh & mesh_
Definition: RASModelVariables.H:65
Foam::incompressible::RASModelVariables::nutPtr_
refPtr< volScalarField > nutPtr_
Definition: RASModelVariables.H:75
Foam::incompressible::RASModelVariables::nutJacobianVar2
virtual tmp< volScalarField > nutJacobianVar2(const singlePhaseTransportModel &laminarTransport) const
Definition: RASModelVariables.C:325
Foam::incompressible::RASModelVariables::New
static autoPtr< RASModelVariables > New(const fvMesh &mesh, const solverControl &SolverControl)
Return a reference to the selected turbulence model.
Definition: RASModelVariables.C:246
Foam::incompressible::RASModelVariables::TMVar1Ptr_
refPtr< volScalarField > TMVar1Ptr_
Definition: RASModelVariables.H:73
Foam::incompressible::RASModelVariables::TMVar1BaseName_
word TMVar1BaseName_
Definition: RASModelVariables.H:69
Foam::incompressible::RASModelVariables::TMVar2Inst
const volScalarField & TMVar2Inst() const
Definition: RASModelVariablesI.H:168
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::incompressible::RASModelVariables::nutRef
const volScalarField & nutRef() const
Definition: RASModelVariablesI.H:122
Foam::incompressible::RASModelVariables::hasTMVar1
bool hasTMVar1() const
Bools to idenify which turbulent fields are present.
Definition: RASModelVariablesI.H:56
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::incompressible::RASModelVariables::devReff
tmp< volSymmTensorField > devReff(const singlePhaseTransportModel &laminarTransport, const volVectorField &U) const
Return stress tensor based on the mean flow variables.
Definition: RASModelVariables.C:424
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::incompressible::RASModelVariables::TMVar2InitPtr_
refPtr< volScalarField > TMVar2InitPtr_
Definition: RASModelVariables.H:81
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::incompressible::RASModelVariables::TMVar1BaseName
const word & TMVar1BaseName() const
Turbulence field names.
Definition: RASModelVariablesI.H:38
Foam::incompressible::RASModelVariables::copyAndRename
void copyAndRename(volScalarField &f1, volScalarField &f2)
Definition: RASModelVariables.C:164
Foam::incompressible::RASModelVariables::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, RASModelVariables, dictionary,(const fvMesh &mesh, const solverControl &SolverControl),(mesh, SolverControl))
Foam::incompressible::RASModelVariables::TMVar2BaseName
const word & TMVar2BaseName() const
Definition: RASModelVariablesI.H:44
Foam::incompressible::RASModelVariables::TMVar1MeanPtr_
refPtr< volScalarField > TMVar1MeanPtr_
Definition: RASModelVariables.H:85
Foam::incompressible::RASModelVariables::TMVar1
const volScalarField & TMVar1() const
Return references to turbulence fields.
Definition: RASModelVariablesI.H:80
Foam::IncompressibleTurbulenceModel
Templated abstract base class for single-phase incompressible turbulence models.
Definition: IncompressibleTurbulenceModel.H:55
Foam::incompressible::RASModelVariables::TMVar2MeanPtr_
refPtr< volScalarField > TMVar2MeanPtr_
Definition: RASModelVariables.H:86
Foam::incompressible::RASModelVariables::nutJacobianVar1
virtual tmp< volScalarField > nutJacobianVar1(const singlePhaseTransportModel &laminarTransport) const
Return nut Jacobian wrt the TM vars.
Definition: RASModelVariables.C:300
Foam::incompressible::RASModelVariables::hasNut
bool hasNut() const
Definition: RASModelVariablesI.H:68
Foam::incompressible::RASModelVariables::TypeName
TypeName("RASModelVariables")
Runtime type information.
Foam::incompressible::RASModelVariables::TMVar2
const volScalarField & TMVar2() const
Definition: RASModelVariablesI.H:102
Foam::GeometricField< scalar, fvPatchField, volMesh >
laminarTransport
singlePhaseTransportModel laminarTransport(U, phi)
Foam::incompressible::RASModelVariables::clone
autoPtr< RASModelVariables > clone() const
Clone.
Definition: RASModelVariables.C:237
Foam::incompressible::RASModelVariables::cloneRefPtr
refPtr< volScalarField > cloneRefPtr(const refPtr< volScalarField > &obj) const
Definition: RASModelVariables.C:148
solverControl.H
Foam::refPtr
A class for managing references or pointers (no reference counting)
Definition: PtrList.H:60