Loading...
Searching...
No Matches
atmAmbientTurbSource.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) 2020 ENERCON GmbH
9 Copyright (C) 2020-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
32// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33
34namespace Foam
35{
36namespace fv
37{
40}
41}
42
43
44// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45
47(
48 const word& sourceName,
49 const word& modelType,
50 const dictionary& dict,
51 const fvMesh& mesh
52)
53:
54 fv::cellSetOption(sourceName, modelType, dict, mesh),
55 isEpsilon_(false),
56 rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
57 kAmb_
58 (
60 (
62 coeffs_.getCheckOrDefault<scalar>
63 (
64 "kAmb",
65 SMALL,
66 [&](const scalar k){ return k > -VSMALL; }
67 )
68 )
69 ),
70 epsilonAmb_
71 (
73 (
75 coeffs_.getOrDefault<scalar>
76 (
77 "epsilonAmb",
78 Zero
79 )
80 )
81 ),
82 omegaAmb_
83 (
85 (
87 coeffs_.getOrDefault<scalar>
88 (
89 "omegaAmb",
90 Zero
91 )
92 )
93 ),
94 Cmu_(Zero),
95 C2_(Zero)
96{
97 const auto* turbPtr =
98 mesh_.findObject<turbulenceModel>
99 (
101 );
102
103 if (!turbPtr)
104 {
106 << "Unable to find a turbulence model."
107 << abort(FatalError);
108 }
109
110 fieldNames_.resize(2);
111
112 tmp<volScalarField> tepsilon = turbPtr->epsilon();
113 tmp<volScalarField> tomega = turbPtr->omega();
114
115 if (tepsilon.is_reference())
116 {
117 isEpsilon_ = true;
118 fieldNames_[0] = tepsilon().name();
119
120 const dictionary& turbDict = turbPtr->coeffDict();
121
122 C2_.read("C2", turbDict);
123 }
124 else if (tomega.is_reference())
125 {
126 isEpsilon_ = false;
127 fieldNames_[0] = tomega().name();
128
129 const dictionary& turbDict = turbPtr->coeffDict();
130
131 Cmu_.read("betaStar", turbDict);
132 C2_.read("C2", turbDict);
133 }
134 else
135 {
137 << "Needs either epsilon or omega field."
138 << abort(FatalError);
139 }
140
141 fieldNames_[1] = turbPtr->k()().name();
142
144
145 Log << " Applying atmAmbientTurbSource to: "
146 << fieldNames_[0] << " and " << fieldNames_[1]
147 << endl;
148}
149
150
151// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152
154(
155 fvMatrix<scalar>& eqn,
156 const label fieldi
157)
158{
159 if (fieldi == 1)
160 {
161 atmAmbientTurbSourceK
162 (
165 eqn,
166 fieldi
167 );
168 return;
169 }
170
171 if (isEpsilon_)
172 {
173 atmAmbientTurbSourceEpsilon
174 (
177 eqn,
178 fieldi
179 );
180 }
181 else
182 {
183 atmAmbientTurbSourceOmega
184 (
185 geometricOneField(),
186 geometricOneField(),
187 eqn,
188 fieldi
189 );
190 }
191}
192
193
195(
196 const volScalarField& rho,
197 fvMatrix<scalar>& eqn,
198 const label fieldi
199)
200{
201 if (fieldi == 1)
202 {
203 atmAmbientTurbSourceK(geometricOneField(), rho, eqn, fieldi);
204 return;
205 }
206
207 if (isEpsilon_)
208 {
209 atmAmbientTurbSourceEpsilon(geometricOneField(), rho, eqn, fieldi);
210 }
211 else
212 {
213 atmAmbientTurbSourceOmega(geometricOneField(), rho, eqn, fieldi);
214 }
215}
216
217
219(
220 const volScalarField& alpha,
221 const volScalarField& rho,
222 fvMatrix<scalar>& eqn,
223 const label fieldi
224)
225{
226 if (fieldi == 1)
227 {
228 atmAmbientTurbSourceK(alpha, rho, eqn, fieldi);
229 return;
230 }
231
232 if (isEpsilon_)
233 {
234 atmAmbientTurbSourceEpsilon(alpha, rho, eqn, fieldi);
235 }
236 else
237 {
238 atmAmbientTurbSourceOmega(alpha, rho, eqn, fieldi);
239 }
240}
241
242
243// ************************************************************************* //
label k
#define Log
Definition PDRblock.C:28
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
bool read(Istream &is)
Read dictionary from Istream (discards the header). Reads entries until EOF or when the first token i...
static dimensioned< Type > getOrDefault(const word &name, const dictionary &dict, const dimensionSet &dims=dimless, const Type &deflt=Type(Zero))
Construct dimensioned from dictionary, with default value.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Applies sources on k and either epsilon or omega to prevent them droping below a specified ambient va...
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to epsilon or omega equation for incompressible flow computations.
atmAmbientTurbSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
cellSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition fvOption.H:124
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition fvOption.H:157
dictionary coeffs_
Dictionary containing source coefficients.
Definition fvOption.H:152
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition fvOption.C:41
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition fvOptionI.H:30
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
A class for managing temporary objects.
Definition tmp.H:75
bool is_reference() const noexcept
True if this is a reference (not a pointer).
Definition tmpI.H:206
Abstract base class for turbulence models (RAS, LES and laminar).
static const word propertiesName
Default name of the turbulence properties dictionary.
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
auto & name
Namespace for finite-volume.
Namespace for OpenFOAM.
const dimensionSet dimless
Dimensionless.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
dimensionedScalar pow3(const dimensionedScalar &ds)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
volScalarField & alpha
dictionary dict