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 
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_(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 // ************************************************************************* //
dictionary dict
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.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
dimensionedSymmTensor sqr(const dimensionedVector &dv)
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
label k
Boltzmann constant.
const dimensionSet dimless
Dimensionless.
Macros for easy insertion into run-time selection tables.
Applies sources on k and either epsilon or omega to prevent them droping below a specified ambient va...
dynamicFvMesh & mesh
A class representing the concept of a GeometricField of 1 used to avoid unnecessary manipulations for...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
static const word propertiesName
Default name of the turbulence properties dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:63
labelList fv(nPoints)
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:64
atmAmbientTurbSource(const word &sourceName, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from explicit source name and mesh.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
virtual void addSup(fvMatrix< scalar > &eqn, const label fieldi)
Add explicit contribution to epsilon or omega equation for incompressible flow computations.
dimensionedScalar pow3(const dimensionedScalar &ds)
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:41
#define Log
Definition: PDRblock.C:28
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Namespace for OpenFOAM.
Base abstract class for handling finite volume options (i.e. fvOption).
Definition: fvOption.H:123
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127