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 -------------------------------------------------------------------------------
11 License
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 
29 #include "atmAmbientTurbSource.H"
31 
32 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace 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  (
100  turbulenceModel::propertiesName
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 
143  fv::option::resetApplied();
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 // ************************************************************************* //
Log
#define Log
Definition: PDRblock.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:163
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
atmAmbientTurbSource.H
Foam::geometricOneField
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
Definition: geometricOneField.H:55
Foam::tmp::isTmp
bool isTmp() const noexcept
Identical to is_pointer()
Definition: tmp.H:295
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::fv::atmAmbientTurbSource::addSup
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Definition: atmAmbientTurbSource.C:154
rho
rho
Definition: readInitialConditions.H:88
Foam::fv::atmAmbientTurbSource::atmAmbientTurbSource
atmAmbientTurbSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
Definition: atmAmbientTurbSource.C:47
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::fv::option
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:126
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:89
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:63
Foam::FatalError
error FatalError
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
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned< scalar >
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::dimensioned::getOrDefault
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.
Definition: dimensionedType.C:348
Foam::dictionary::read
bool read(Istream &is)
Read dictionary from Istream. Discards the header.
Definition: dictionaryIO.C:141
fv
labelList fv(nPoints)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::fv::atmAmbientTurbSource
Applies sources on k and either epsilon or omega to prevent them droping below a specified ambient va...
Definition: atmAmbientTurbSource.H:166
Foam::nl
constexpr char nl
Definition: Ostream.H:404
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189