ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / turbulenceModels / incompressible / LES / GenSGSStress / GenSGSStress.C
blob9d385c21eb1687c6e72d5e43b965716c746deb95
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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 "GenSGSStress.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 namespace Foam
32 namespace incompressible
34 namespace LESModels
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 defineTypeNameWithName(GenSGSStress, "GenSGSStress");
42 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
44 GenSGSStress::GenSGSStress
46     const volVectorField& U,
47     const surfaceScalarField& phi,
48     transportModel& transport,
49     const word& turbulenceModelName,
50     const word& modelName
53     LESModel(modelName, U, phi, transport, turbulenceModelName),
55     ce_
56     (
57         dimensioned<scalar>::lookupOrAddToDict
58         (
59             "ce",
60             coeffDict_,
61             1.048
62         )
63     ),
65     couplingFactor_
66     (
67         dimensioned<scalar>::lookupOrAddToDict
68         (
69             "couplingFactor",
70             coeffDict_,
71             0.0
72         )
73     ),
75     B_
76     (
77         IOobject
78         (
79             "B",
80             runTime_.timeName(),
81             mesh_,
82             IOobject::MUST_READ,
83             IOobject::AUTO_WRITE
84         ),
85         mesh_
86     ),
88     nuSgs_
89     (
90         IOobject
91         (
92             "nuSgs",
93             runTime_.timeName(),
94             mesh_,
95             IOobject::NO_READ,
96             IOobject::NO_WRITE
97         ),
98         nu(),
99         B_.boundaryField().types()
100     )
102     if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
103     {
104         FatalErrorIn
105         (
106             "GenSGSStress::GenSGSStress"
107             "(const volVectorField& U, const surfaceScalarField& phi,"
108             "transportModel& transport)"
109         )   << "couplingFactor = " << couplingFactor_
110             << " is not in range 0 - 1" << nl
111             << exit(FatalError);
112     }
116 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
118 tmp<volSymmTensorField> GenSGSStress::devBeff() const
120     return tmp<volSymmTensorField>
121     (
122         new volSymmTensorField
123         (
124             IOobject
125             (
126                 "devRhoReff",
127                 runTime_.timeName(),
128                 mesh_,
129                 IOobject::NO_READ,
130                 IOobject::NO_WRITE
131             ),
132             B_ - nu()*dev(twoSymm(fvc::grad(U())))
133         )
134     );
138 tmp<fvVectorMatrix> GenSGSStress::divDevBeff
140     volVectorField& U
141 ) const
143     if (couplingFactor_.value() > 0.0)
144     {
145         return
146         (
147             fvc::div(B_ + couplingFactor_*nuSgs_*fvc::grad(U))
148           + fvc::laplacian
149             (
150                 (1.0 - couplingFactor_)*nuSgs_, U, "laplacian(nuEff,U)"
151             )
152           - fvm::laplacian(nuEff(), U)
153         );
154     }
155     else
156     {
157         return
158         (
159             fvc::div(B_)
160           + fvc::laplacian(nuSgs_, U, "laplacian(nuEff,U)")
161           - fvm::laplacian(nuEff(), U)
162         );
163     }
167 bool GenSGSStress::read()
169     if (LESModel::read())
170     {
171         ce_.readIfPresent(coeffDict());
173         couplingFactor_.readIfPresent(coeffDict());
175         if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
176         {
177             FatalErrorIn("GenSGSStress::read()")
178                 << "couplingFactor = " << couplingFactor_
179                 << " is not in range 0 - 1"
180                 << exit(FatalError);
181         }
183         return true;
184     }
185     else
186     {
187         return false;
188     }
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 } // End namespace LESModels
195 } // End namespace incompressible
196 } // End namespace Foam
198 // ************************************************************************* //