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  (
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 {
89  correct();
90 }
91 
92 
93 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
94 
97 {
98  return nu_;
99 }
100 
101 
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::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::viscosityModel
An abstract base class for incompressible viscosityModels.
Definition: viscosityModel.H:67
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
surfaceFields.H
Foam::surfaceFields.
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::viscosityModel::read
virtual bool read(const dictionary &viscosityProperties)=0
Read transportProperties dictionary.
Definition: viscosityModel.C:66
Foam::viscosityModels::strainRateFunction::strainRateFunction
strainRateFunction(const word &name, const dictionary &viscosityProperties, const volVectorField &U, const surfaceScalarField &phi)
Construct from components.
Definition: strainRateFunction.C:54
correct
fvOptions correct(rho)
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::viscosityModels::defineTypeNameAndDebug
defineTypeNameAndDebug(BirdCarreau, 0)
Foam::dimViscosity
const dimensionSet dimViscosity
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
strainRateFunction.H
U
U
Definition: pEqn.H:72
Foam::viscosityModels::strainRateFunction::nu_
volScalarField nu_
Definition: strainRateFunction.H:86
Foam::viscosityModels::strainRateFunction::correct
virtual void correct()
Correct the laminar viscosity.
Definition: strainRateFunction.C:109
Foam::viscosityModels::strainRateFunction::nu
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
Definition: strainRateFunction.C:96
Foam::dictionary::optionalSubDict
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:577
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Foam::viscosityModels::strainRateFunction::read
virtual bool read(const dictionary &viscosityProperties)
Read transportProperties dictionary.
Definition: strainRateFunction.C:127
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::dictionary::clear
void clear()
Clear the dictionary.
Definition: dictionary.C:857
Foam::viscosityModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(viscosityModel, BirdCarreau, dictionary)