strainRateFunction.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2017 OpenFOAM Foundation
9  Copyright (C) 2017-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "strainRateFunction.H"
31 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace viscosityModels
38 {
39  defineTypeNameAndDebug(strainRateFunction, 0);
40 
42  (
43  viscosityModel,
44  strainRateFunction,
45  dictionary
46  );
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
54 (
55  const word& name,
56  const dictionary& viscosityProperties,
57  const volVectorField& U,
58  const surfaceScalarField& phi
59 )
60 :
61  viscosityModel(name, viscosityProperties, U, phi),
62  strainRateFunctionCoeffs_
63  (
64  viscosityProperties.optionalSubDict(typeName + "Coeffs")
65  ),
66  strainRateFunction_
67  (
68  Function1<scalar>::New
69  (
70  "function",
71  strainRateFunctionCoeffs_,
72  &U_.db()
73  )
74  ),
75  nu_
76  (
77  IOobject
78  (
79  name,
80  U_.time().timeName(),
81  U_.db(),
82  IOobject::NO_READ,
83  IOobject::AUTO_WRITE
84  ),
85  U_.mesh(),
87  )
88 {
90 }
91 
92 
93 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
94 
97 {
98  return nu_;
99 }
100 
101 
103 Foam::viscosityModels::strainRateFunction::nu(const label patchi) const
104 {
105  return nu_.boundaryField()[patchi];
106 }
107 
108 
110 {
111  tmp<volScalarField> tsigma = strainRate();
112  const volScalarField& sigma = tsigma();
113 
114  nu_.primitiveFieldRef() = strainRateFunction_->value(sigma());
115 
116  volScalarField::Boundary& nuBf = nu_.boundaryFieldRef();
117  const volScalarField::Boundary& sigmaBf = sigma.boundaryField();
118 
119  forAll(nuBf, patchi)
120  {
121  nuBf[patchi] = strainRateFunction_->value(sigmaBf[patchi]);
122  }
123 }
124 
125 
127 (
128  const dictionary& viscosityProperties
129 )
130 {
131  viscosityModel::read(viscosityProperties);
132 
133  strainRateFunctionCoeffs_ = viscosityProperties.optionalSubDict
134  (
135  typeName + "Coeffs"
136  );
137 
138  strainRateFunction_.clear();
139  strainRateFunction_ = Function1<scalar>::New
140  (
141  "function",
142  strainRateFunctionCoeffs_,
143  &U_.db()
144  );
145 
146  return true;
147 }
148 
149 
150 // ************************************************************************* //
Foam::surfaceFields.
virtual bool read(const dictionary &viscosityProperties)
Read transportProperties dictionary.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
const dimensionSet dimViscosity
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
An abstract base class for incompressible viscosityModels.
Macros for easy insertion into run-time selection tables.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
word timeName
Definition: getTimeIndex.H:3
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
Definition: dictionary.C:560
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
addToRunTimeSelectionTable(viscosityModel, BirdCarreau, dictionary)
virtual bool read(const dictionary &viscosityProperties)=0
Read transportProperties dictionary.
A class for handling words, derived from Foam::string.
Definition: word.H:63
defineTypeNameAndDebug(BirdCarreau, 0)
strainRateFunction(const word &name, const dictionary &viscosityProperties, const volVectorField &U, const surfaceScalarField &phi)
Construct from components.
U
Definition: pEqn.H:72
A class for managing temporary objects.
Definition: HashPtrTable.H:50
void clear()
Clear the dictionary.
Definition: dictionary.C:844
virtual void correct()
Correct the laminar viscosity.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Namespace for OpenFOAM.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127