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
31
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_(true),
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.isTmp())
116 {
117 fieldNames_[0] = tepsilon().name();
118
119 const dictionary& turbDict = turbPtr->coeffDict();
120
121 C2_.read("C2", turbDict);
122 }
123 else if (!tomega.isTmp())
124 {
125 isEpsilon_ = false;
126 fieldNames_[0] = tomega().name();
127
128 const dictionary& turbDict = turbPtr->coeffDict();
129
130 Cmu_.read("betaStar", turbDict);
131 C2_.read("C2", turbDict);
132 }
133 else
134 {
136 << "Unable to find neither epsilon nor omega field." << nl
137 << "atmAmbientTurbSource 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 (
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:35
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:126
bool read(Istream &is)
Read dictionary from Istream. Discards the header.
Definition: dictionaryIO.C:141
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:121
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
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)
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:127
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:48
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:65
bool isTmp() const noexcept
Identical to is_pointer()
Definition: tmp.H:295
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:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
const dimensionSet dimless
Dimensionless.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
dimensionedScalar pow3(const dimensionedScalar &ds)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
labelList fv(nPoints)
volScalarField & alpha
dictionary dict