turbulenceFieldsTemplates.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) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2020 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 "volFields.H"
30 
31 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const word& fieldName,
38 )
39 {
41 
42  const word scopedName = modelName_ + ':' + fieldName;
43 
44  FieldType* fldPtr = obr_.getObjectPtr<FieldType>(scopedName);
45 
46  if (fldPtr)
47  {
48  (*fldPtr) == tvalue();
49  }
50  else if (obr_.found(scopedName))
51  {
53  << "Cannot store turbulence field " << scopedName
54  << " since an object with that name already exists"
55  << nl << endl;
56  }
57  else
58  {
59  obr_.store
60  (
61  new FieldType
62  (
63  IOobject
64  (
65  scopedName,
66  obr_.time().timeName(),
67  obr_,
68  IOobject::READ_IF_PRESENT,
69  IOobject::NO_WRITE
70  ),
71  tvalue
72  )
73  );
74  }
75 }
76 
77 
78 template<class Model>
81 (
82  const Model& model
83 ) const
84 {
85  const scalar Cmu = 0.09;
86 
87  // Assume k and epsilon are available
88  const volScalarField k(model.k());
89  const volScalarField epsilon(model.epsilon());
90 
92  (
93  IOobject
94  (
95  "omega.tmp",
96  k.mesh().time().timeName(),
97  k.mesh()
98  ),
99  epsilon/(Cmu*k),
100  epsilon.boundaryField().types()
101  );
102 }
103 
104 
105 template<class Model>
108 (
109  const Model& model
110 ) const
111 {
113  (
114  "nuTilda.tmp",
115  model.k()/omega(model)
116  );
117 }
118 
119 
120 template<class Model>
123 (
124  const Model& model
125 ) const
126 {
127  const scalar Cmu = 0.09;
128 
129  // Assume k and epsilon are available
130  const volScalarField k(model.k());
131  const volScalarField epsilon(model.epsilon());
132  const dimensionedScalar eps0("eps0", epsilon.dimensions(), SMALL);
133 
135  (
136  "L.tmp",
137  pow(Cmu, 0.75)*pow(k, 1.5)/(epsilon + eps0)
138  );
139 }
140 
141 
142 template<class Model>
145 (
146  const Model& model
147 ) const
148 {
149  // Assume k is available
150  const volScalarField uPrime(sqrt((2.0/3.0)*model.k()));
151  const dimensionedScalar U0("U0", dimVelocity, SMALL);
152 
154  (
155  "I.tmp",
156  uPrime/max(max(uPrime, mag(model.U())), U0)
157  );
158 }
159 
160 
161 // ************************************************************************* //
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::functionObjects::turbulenceFields::processField
void processField(const word &fieldName, const tmp< GeometricField< Type, fvPatchField, volMesh >> &tvalue)
Process the turbulence field.
Definition: turbulenceFieldsTemplates.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::functionObjects::turbulenceFields::L
tmp< volScalarField > L(const Model &model) const
Return integral length scale, L, calculated from k and epsilon.
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::dimensioned< scalar >
Foam::functionObjects::turbulenceFields::nuTilda
tmp< volScalarField > nuTilda(const Model &model) const
Return nuTilda calculated from k and omega.
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::functionObjects::turbulenceFields::I
tmp< volScalarField > I(const Model &model) const
Return turbulence intensity, I, calculated from k and U.
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::functionObjects::turbulenceFields::omega
tmp< volScalarField > omega(const Model &model) const
Return omega calculated from k and epsilon.
epsilon
scalar epsilon
Definition: evaluateNearWall.H:7
Foam::GeometricField< Type, fvPatchField, volMesh >
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:303