XiEqModel.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) 2011-2017 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "XiEqModel.H"
29
30// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31
32namespace Foam
33{
34 defineTypeNameAndDebug(XiEqModel, 0);
35 defineRunTimeSelectionTable(XiEqModel, dictionary);
36}
37
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
42(
43 const dictionary& XiEqProperties,
44 const psiuReactionThermo& thermo,
45 const compressible::RASModel& turbulence,
46 const volScalarField& Su
47)
48:
49 XiEqModelCoeffs_
50 (
51 XiEqProperties.subDict
52 (
53 XiEqProperties.get<word>("XiEqModel") + "Coeffs"
54 )
55 ),
56 thermo_(thermo),
57 turbulence_(turbulence),
58 Su_(Su)
59{}
60
61
62// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
63
65{}
66
67
68// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
69
70bool Foam::XiEqModel::read(const dictionary& XiEqProperties)
71{
72 XiEqModelCoeffs_ = XiEqProperties.optionalSubDict(type() + "Coeffs");
73
74 return true;
75}
76
77
79{
80 //***HGW It is not clear why B is written here
81 if (Su_.mesh().foundObject<volSymmTensorField>("B"))
82 {
83 const volSymmTensorField& B =
84 Su_.mesh().lookupObject<volSymmTensorField>("B");
85 B.write();
86 }
87}
88
89
91Foam::XiEqModel::calculateSchelkinEffect(const scalar uPrimeCoef) const
92{
93 const fvMesh& mesh = Su_.mesh();
94
98 const volSymmTensorField& nsv =
100
101 tmp<volScalarField> tN
102 (
104 (
105 IOobject
106 (
107 "tN",
108 mesh.time().timeName(),
109 mesh,
112 false
113 ),
114 mesh,
115 dimensionedScalar(Nv.dimensions(), Zero)
116 )
117 );
118 volScalarField& N = tN.ref();
119 N.primitiveFieldRef() = Nv.primitiveField()*pow(mesh.V(), 2.0/3.0);
120
122 (
123 IOobject
124 (
125 "tns",
126 mesh.time().timeName(),
127 mesh,
130 ),
131 mesh,
132 dimensionedSymmTensor(nsv.dimensions(), Zero)
133 );
134 ns.primitiveFieldRef() = nsv.primitiveField()*pow(mesh.V(), 2.0/3.0);
135
136 const volVectorField Uhat
137 (
138 U/(mag(U) + dimensionedScalar("Usmall", U.dimensions(), 1e-4))
139 );
140
141 const volScalarField nr(sqrt(max(N - (Uhat & ns & Uhat), scalar(1e-4))));
142
143 const scalarField cellWidth(pow(mesh.V(), 1.0/3.0));
144
145 const scalarField upLocal(uPrimeCoef*sqrt((U & CT & U)*cellWidth));
146
147 const scalarField deltaUp(upLocal*(max(scalar(1), pow(nr, 0.5)) - 1.0));
148
149 // Re use tN
150 N.primitiveFieldRef() = upLocal*(max(scalar(1), pow(nr, 0.5)) - 1.0);
151
152 return tN;
153}
154
155
156// ************************************************************************* //
static const Foam::dimensionedScalar B("", Foam::dimless, 18.678)
virtual bool read()
Re-read model coefficients if they have changed.
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Base-class for all XiEq models used by the b-XiEq combustion model. The available models are : basicX...
Definition: XiEqModel.H:60
virtual ~XiEqModel()
Destructor.
tmp< volScalarField > calculateSchelkinEffect(const scalar) const
Return the sub-grid Schelkin effect.
void writeFields() const
Write fields.
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
const Type & lookupObject(const word &name, const bool recursive=false) const
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
A class for managing temporary objects.
Definition: tmp.H:65
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
U
Definition: pEqn.H:72
dynamicFvMesh & mesh
compressible::turbulenceModel & turbulence
zeroField Su
Definition: alphaSuSp.H:1
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Namespace for OpenFOAM.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:83
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:82
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dimensioned< symmTensor > dimensionedSymmTensor
Dimensioned tensor obtained from generic dimensioned type.
GeometricField< symmTensor, fvPatchField, volMesh > volSymmTensorField
Definition: volFieldsFwd.H:86
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
volScalarField & e
Definition: createFields.H:11
const Vector< label > N(dict.get< Vector< label > >("N"))