Formatting
[foam-extend-3.2.git] / src / transportModels / incompressible / viscosityModels / powerLaw / powerLaw.C
blob2aef95b50aeba5d2864876f67b7580da458f3b86
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "powerLaw.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "surfaceFields.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 namespace Foam
34 namespace viscosityModels
36     defineTypeNameAndDebug(powerLaw, 0);
38     addToRunTimeSelectionTable
39     (
40         viscosityModel,
41         powerLaw,
42         dictionary
43     );
48 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
50 Foam::tmp<Foam::volScalarField>
51 Foam::viscosityModels::powerLaw::calcNu() const
53     return max
54     (
55         nuMin_,
56         min
57         (
58             nuMax_,
59             k_*pow
60             (
61                 max
62                 (
63                     dimensionedScalar("one", dimTime, 1.0)*strainRate(),
64                     dimensionedScalar("VSMALL", dimless, VSMALL)
65                 ),
66                 n_.value() - scalar(1.0)
67             )
68         )
69     );
73 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
75 Foam::viscosityModels::powerLaw::powerLaw
77     const word& name,
78     const dictionary& viscosityProperties,
79     const volVectorField& U,
80     const surfaceScalarField& phi
83     viscosityModel(name, viscosityProperties, U, phi),
84     powerLawCoeffs_(viscosityProperties.subDict(typeName + "Coeffs")),
85     k_(powerLawCoeffs_.lookup("k")),
86     n_(powerLawCoeffs_.lookup("n")),
87     nuMin_(powerLawCoeffs_.lookup("nuMin")),
88     nuMax_(powerLawCoeffs_.lookup("nuMax")),
89     nu_
90     (
91         IOobject
92         (
93             name,
94             U_.time().timeName(),
95             U_.db(),
96             IOobject::NO_READ,
97             IOobject::AUTO_WRITE
98         ),
99         calcNu()
100     )
104 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
106 bool Foam::viscosityModels::powerLaw::read
108     const dictionary& viscosityProperties
111     viscosityModel::read(viscosityProperties);
113     powerLawCoeffs_ = viscosityProperties.subDict(typeName + "Coeffs");
115     powerLawCoeffs_.lookup("k") >> k_;
116     powerLawCoeffs_.lookup("n") >> n_;
117     powerLawCoeffs_.lookup("nuMin") >> nuMin_;
118     powerLawCoeffs_.lookup("nuMax") >> nuMax_;
120     return true;
124 // ************************************************************************* //