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) 2018-2020 OpenFOAM Foundation
9  Copyright (C) 2020 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"
30 #include "volFields.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace laminarModels
38 {
39 namespace generalizedNewtonianViscosityModels
40 {
41  defineTypeNameAndDebug(strainRateFunction, 0);
42 
44  (
45  generalizedNewtonianViscosityModel,
46  strainRateFunction,
47  dictionary
48  );
49 }
50 }
51 }
52 
53 
54 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 
58 (
59  const dictionary& viscosityProperties
60 )
61 :
62  generalizedNewtonianViscosityModel(viscosityProperties),
63  strainRateFunctionCoeffs_
64  (
65  viscosityProperties.optionalSubDict(typeName + "Coeffs")
66  ),
67  strainRateFunction_
68  (
69  Function1<scalar>::New("function", strainRateFunctionCoeffs_)
70  )
71 {}
72 
73 
74 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
75 
78 (
79  const dictionary& viscosityProperties
80 )
81 {
82  generalizedNewtonianViscosityModel::read(viscosityProperties);
83 
84  strainRateFunctionCoeffs_ =
85  viscosityProperties.optionalSubDict(typeName + "Coeffs");
86 
87  strainRateFunction_.reset();
88  strainRateFunction_ = Function1<scalar>::New
89  (
90  "function",
91  strainRateFunctionCoeffs_
92  );
93 
94  return true;
95 }
96 
97 
100 nu
101 (
102  const volScalarField& nu0,
103  const volScalarField& strainRate
104 ) const
105 {
106  auto tnu =
108  (
109  IOobject::groupName(type() + ":nu", nu0.group()),
110  nu0.mesh(),
112  );
113 
114  tnu.ref().primitiveFieldRef() = strainRateFunction_->value(strainRate);
115 
116  volScalarField::Boundary& nuBf = tnu.ref().boundaryFieldRef();
117  const volScalarField::Boundary& sigmaBf = strainRate.boundaryField();
118 
119  forAll(nuBf, patchi)
120  {
121  nuBf[patchi] = strainRateFunction_->value(sigmaBf[patchi]);
122  }
123 
124  return tnu;
125 }
126 
127 
128 // ************************************************************************* //
volFields.H
Foam::laminarModels::generalizedNewtonianViscosityModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(generalizedNewtonianViscosityModel, BirdCarreau, dictionary)
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
Foam::laminarModels::generalizedNewtonianViscosityModels::strainRateFunction::read
virtual bool read(const dictionary &viscosityProperties)
Read transportProperties dictionary.
Definition: strainRateFunction.C:78
Foam::laminarModels::generalizedNewtonianViscosityModels::strainRateFunction::nu
virtual tmp< volScalarField > nu(const volScalarField &nu0, const volScalarField &strainRate) const
Return the laminar viscosity.
Definition: strainRateFunction.C:101
Foam::laminarModels::generalizedNewtonianViscosityModels::strainRateFunction::strainRateFunction
strainRateFunction(const dictionary &viscosityProperties)
Construct from dictionary (components)
Definition: strainRateFunction.C:58
strainRateFunction.H
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::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
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
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::laminarModels::generalizedNewtonianViscosityModel
An abstract base class for generalized Newtonian viscosity models.
Definition: generalizedNewtonianViscosityModel.H:63
Foam::laminarModels::generalizedNewtonianViscosityModels::defineTypeNameAndDebug
defineTypeNameAndDebug(BirdCarreau, 0)
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::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62