initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / turbulenceModels / incompressible / LES / GenSGSStress / GenSGSStress.C
blob19b660df6cd5cab843e557913d49a406a66c80c3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "GenSGSStress.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
33 namespace incompressible
35 namespace LESModels
38 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
40 GenSGSStress::GenSGSStress
42     const volVectorField& U,
43     const surfaceScalarField& phi,
44     transportModel& transport
47     LESModel(word("GenSGSStress"), U, phi, transport),
49     ce_
50     (
51         dimensioned<scalar>::lookupOrAddToDict
52         (
53             "ce",
54             coeffDict_,
55             1.048
56         )
57     ),
59     couplingFactor_
60     (
61         dimensioned<scalar>::lookupOrAddToDict
62         (
63             "couplingFactor",
64             coeffDict_,
65             0.0
66         )
67     ),
69     B_
70     (
71         IOobject
72         (
73             "B",
74             runTime_.timeName(),
75             mesh_,
76             IOobject::MUST_READ,
77             IOobject::AUTO_WRITE
78         ),
79         mesh_
80     ),
82     nuSgs_
83     (
84         IOobject
85         (
86             "nuSgs",
87             runTime_.timeName(),
88             mesh_,
89             IOobject::NO_READ,
90             IOobject::NO_WRITE
91         ),
92         nu(),
93         B_.boundaryField().types()
94     )
96     if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
97     {
98         FatalErrorIn
99         (
100             "GenSGSStress::GenSGSStress"
101             "(const volVectorField& U, const surfaceScalarField& phi,"
102             "transportModel& lamTransportModel)"
103         )   << "couplingFactor = " << couplingFactor_
104             << " is not in range 0 - 1" << nl
105             << exit(FatalError);
106     }
110 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
112 tmp<volSymmTensorField> GenSGSStress::devBeff() const
114     return tmp<volSymmTensorField>
115     (
116         new volSymmTensorField
117         (
118             IOobject
119             (
120                 "devRhoReff",
121                 runTime_.timeName(),
122                 mesh_,
123                 IOobject::NO_READ,
124                 IOobject::NO_WRITE
125             ),
126             B_ - nu()*dev(twoSymm(fvc::grad(U())))
127         )
128     );
132 tmp<fvVectorMatrix> GenSGSStress::divDevBeff
134     volVectorField& U
135 ) const
137     if (couplingFactor_.value() > 0.0)
138     {
139         return
140         (
141             fvc::div(B_ + couplingFactor_*nuSgs_*fvc::grad(U))
142           + fvc::laplacian
143             (
144                 (1.0 - couplingFactor_)*nuSgs_, U, "laplacian(nuEff,U)"
145             )
146           - fvm::laplacian(nuEff(), U)
147         );
148     }
149     else
150     {
151         return
152         (
153             fvc::div(B_)
154           + fvc::laplacian(nuSgs_, U, "laplacian(nuEff,U)")
155           - fvm::laplacian(nuEff(), U)
156         );
157     }
161 bool GenSGSStress::read()
163     if (LESModel::read())
164     {
165         ce_.readIfPresent(coeffDict());
167         couplingFactor_.readIfPresent(coeffDict());
169         if (couplingFactor_.value() < 0.0 || couplingFactor_.value() > 1.0)
170         {
171             FatalErrorIn("GenSGSStress::read()")
172                 << "couplingFactor = " << couplingFactor_
173                 << " is not in range 0 - 1"
174                 << exit(FatalError);
175         }
177         return true;
178     }
179     else
180     {
181         return false;
182     }
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 } // End namespace LESModels
189 } // End namespace incompressible
190 } // End namespace Foam
192 // ************************************************************************* //