Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / solvers / combustion / PDRFoam / PDRModels / XiEqModels / basicXiSubXiEq / basicXiSubXiEq.C
blob70933519bba2d9c6c9cbf1df69c929c07c3fc379
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "basicXiSubXiEq.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 namespace Foam
33 namespace XiEqModels
35     defineTypeNameAndDebug(basicSubGrid, 0);
36     addToRunTimeSelectionTable(XiEqModel, basicSubGrid, dictionary);
41 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
43 Foam::XiEqModels::basicSubGrid::basicSubGrid
45     const dictionary& XiEqProperties,
46     const hhuCombustionThermo& thermo,
47     const compressible::RASModel& turbulence,
48     const volScalarField& Su
51     XiEqModel(XiEqProperties, thermo, turbulence, Su),
53     B_
54     (
55         IOobject
56         (
57             "B",
58             Su.mesh().facesInstance(),
59             Su.mesh(),
60             IOobject::MUST_READ,
61             IOobject::NO_WRITE
62         ),
63         Su.mesh()
64     ),
66     XiEqModel_(XiEqModel::New(XiEqModelCoeffs_, thermo, turbulence, Su))
70 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
72 Foam::XiEqModels::basicSubGrid::~basicSubGrid()
76 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
78 Foam::tmp<Foam::volScalarField> Foam::XiEqModels::basicSubGrid::XiEq() const
80     const fvMesh& mesh = Su_.mesh();
81     const volVectorField& U = mesh.lookupObject<volVectorField>("U");
83     const volScalarField& Nv = mesh.lookupObject<volScalarField>("Nv");
84     const volSymmTensorField& nsv =
85         mesh.lookupObject<volSymmTensorField>("nsv");
87     volScalarField magU(mag(U));
88     volVectorField Uhat
89     (
90         U/(mag(U) + dimensionedScalar("Usmall", U.dimensions(), 1e-4))
91     );
93     const scalarField Cw = pow(mesh.V(), 2.0/3.0);
95     tmp<volScalarField> tN
96     (
97         new volScalarField
98         (
99             IOobject
100             (
101                 "tN",
102                 mesh.time().constant(),
103                 mesh,
104                 IOobject::NO_READ,
105                 IOobject::NO_WRITE
106             ),
107             mesh,
108             dimensionedScalar("zero", Nv.dimensions(), 0.0),
109             zeroGradientFvPatchVectorField::typeName
110         )
111     );
113     volScalarField& N = tN();
115     N.internalField() = Nv.internalField()*Cw;
117     tmp<volSymmTensorField> tns
118     (
119         new volSymmTensorField
120         (
121             IOobject
122             (
123                 "tns",
124                 U.mesh().time().timeName(),
125                 U.mesh(),
126                 IOobject::NO_READ,
127                 IOobject::NO_WRITE
128             ),
129             U.mesh(),
130             dimensionedSymmTensor
131             (
132                 "zero",
133                 nsv.dimensions(),
134                 pTraits<symmTensor>::zero
135             ),
136              zeroGradientFvPatchSymmTensorField::typeName
137         )
138     );
140     volSymmTensorField& ns = tns();
142     ns.internalField() = nsv.internalField()*Cw;
144     volScalarField n(max(N - (Uhat & ns & Uhat), scalar(1e-4)));
146     volScalarField b((Uhat & B_ & Uhat)/sqrt(n));
148     volScalarField up(sqrt((2.0/3.0)*turbulence_.k()));
150     volScalarField XiSubEq
151     (
152         scalar(1)
153       + max(2.2*sqrt(b), min(0.34*magU/up*sqrt(b), scalar(1.6)))
154       * min(n, scalar(1))
155     );
157     return (XiSubEq*XiEqModel_->XiEq());
161 bool Foam::XiEqModels::basicSubGrid::read(const dictionary& XiEqProperties)
163     XiEqModel::read(XiEqProperties);
165     return XiEqModel_->read(XiEqModelCoeffs_);
169 // ************************************************************************* //