powerLaw.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "powerLaw.H"
27 #include "volFields.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace laminarModels
35 {
36 namespace generalisedNewtonianViscosityModels
37 {
38  defineTypeNameAndDebug(powerLaw, 0);
39 
41  (
42  generalisedNewtonianViscosityModel,
43  powerLaw,
44  dictionary
45  );
46 }
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
54 (
55  const dictionary& viscosityProperties
56 )
57 :
58  generalisedNewtonianViscosityModel(viscosityProperties),
59  k_("k", dimViscosity, 0),
60  n_("n", dimless, 0),
61  nuMin_("nuMin", dimViscosity, 0),
62  nuMax_("nuMax", dimViscosity, 0)
63 {
64  read(viscosityProperties);
65 }
66 
67 
68 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
69 
71 (
72  const dictionary& viscosityProperties
73 )
74 {
75  generalisedNewtonianViscosityModel::read(viscosityProperties);
76 
77  const dictionary& coeffs =
78  viscosityProperties.optionalSubDict(typeName + "Coeffs");
79 
80  coeffs.lookup("k") >> k_;
81  coeffs.lookup("n") >> n_;
82  coeffs.lookup("nuMin") >> nuMin_;
83  coeffs.lookup("nuMax") >> nuMax_;
84 
85  return true;
86 }
87 
88 
91 nu
92 (
93  const volScalarField& nu0,
94  const volScalarField& strainRate
95 ) const
96 {
97  return max
98  (
99  nuMin_,
100  min
101  (
102  nuMax_,
103  k_*pow
104  (
105  max
106  (
107  dimensionedScalar(dimTime, 1.0)*strainRate,
108  dimensionedScalar(dimless, small)
109  ),
110  n_.value() - scalar(1)
111  )
112  )
113  );
114 }
115 
116 
117 // ************************************************************************* //
const dimensionSet dimViscosity
powerLaw(const dictionary &viscosityProperties)
Construct from components.
Definition: powerLaw.C:54
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const dimensionSet dimless
Macros for easy insertion into run-time selection tables.
const dimensionSet dimTime
virtual tmp< volScalarField > nu(const volScalarField &nu0, const volScalarField &strainRate) const
Return the laminar viscosity.
Definition: powerLaw.C:92
bool read(const char *, int32_t &)
Definition: int32IO.C:85
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1040
addToRunTimeSelectionTable(generalisedNewtonianViscosityModel, BirdCarreau, dictionary)
virtual bool read(const dictionary &viscosityProperties)
Read transportProperties dictionary.
Definition: powerLaw.C:71
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
An abstract base class for generalised Newtonian viscosity models.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
virtual bool read(const dictionary &viscosityProperties)=0
Read transportProperties dictionary.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844