OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

powerLaw.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "powerLaw.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "surfaceFields.H"
00030 
00031 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 namespace viscosityModels
00036 {
00037     defineTypeNameAndDebug(powerLaw, 0);
00038 
00039     addToRunTimeSelectionTable
00040     (
00041         viscosityModel,
00042         powerLaw,
00043         dictionary
00044     );
00045 }
00046 }
00047 
00048 
00049 // * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * * //
00050 
00051 Foam::tmp<Foam::volScalarField>
00052 Foam::viscosityModels::powerLaw::calcNu() const
00053 {
00054     return max
00055     (
00056         nuMin_,
00057         min
00058         (
00059             nuMax_,
00060             k_*pow
00061             (
00062                 max
00063                 (
00064                     dimensionedScalar("one", dimTime, 1.0)*strainRate(),
00065                     dimensionedScalar("VSMALL", dimless, VSMALL)
00066                 ),
00067                 n_.value() - scalar(1.0)
00068             )
00069         )
00070     );
00071 }
00072 
00073 
00074 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00075 
00076 Foam::viscosityModels::powerLaw::powerLaw
00077 (
00078     const word& name,
00079     const dictionary& viscosityProperties,
00080     const volVectorField& U,
00081     const surfaceScalarField& phi
00082 )
00083 :
00084     viscosityModel(name, viscosityProperties, U, phi),
00085     powerLawCoeffs_(viscosityProperties.subDict(typeName + "Coeffs")),
00086     k_(powerLawCoeffs_.lookup("k")),
00087     n_(powerLawCoeffs_.lookup("n")),
00088     nuMin_(powerLawCoeffs_.lookup("nuMin")),
00089     nuMax_(powerLawCoeffs_.lookup("nuMax")),
00090     nu_
00091     (
00092         IOobject
00093         (
00094             name,
00095             U_.time().timeName(),
00096             U_.db(),
00097             IOobject::NO_READ,
00098             IOobject::AUTO_WRITE
00099         ),
00100         calcNu()
00101     )
00102 {}
00103 
00104 
00105 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
00106 
00107 bool Foam::viscosityModels::powerLaw::read
00108 (
00109     const dictionary& viscosityProperties
00110 )
00111 {
00112     viscosityModel::read(viscosityProperties);
00113 
00114     powerLawCoeffs_ = viscosityProperties.subDict(typeName + "Coeffs");
00115 
00116     powerLawCoeffs_.lookup("k") >> k_;
00117     powerLawCoeffs_.lookup("n") >> n_;
00118     powerLawCoeffs_.lookup("nuMin") >> nuMin_;
00119     powerLawCoeffs_.lookup("nuMax") >> nuMax_;
00120 
00121     return true;
00122 }
00123 
00124 
00125 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd