strainRateFunction.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-2022 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 "strainRateFunction.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace laminarModels
34 {
35 namespace generalisedNewtonianViscosityModels
36 {
38 
40  (
44  );
45 }
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
54 (
55  const dictionary& viscosityProperties,
57  const volVectorField& U
58 )
59 :
60  strainRateViscosityModel(viscosityProperties, viscosity, U),
61  strainRateFunction_
62  (
63  Function1<scalar>::New
64  (
65  "function",
66  viscosityProperties.optionalSubDict(typeName + "Coeffs")
67  )
68  )
69 {
70  correct();
71 }
72 
73 
74 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
75 
78 (
79  const dictionary& viscosityProperties
80 )
81 {
82  strainRateViscosityModel::read(viscosityProperties);
83 
84  strainRateFunction_.clear();
85  strainRateFunction_ = Function1<scalar>::New
86  (
87  "function",
88  viscosityProperties.optionalSubDict
89  (
90  typeName + "Coeffs"
91  )
92  );
93 
94  return true;
95 }
96 
97 
100 nu
101 (
102  const volScalarField& nu0,
103  const volScalarField& strainRate
104 ) const
105 {
107  (
109  (
110  IOobject::groupName(typedName("nu"), nu0.group()),
111  nu0.mesh(),
113  )
114  );
115 
116  tnu.ref().primitiveFieldRef() = strainRateFunction_->value(strainRate);
117 
118  volScalarField::Boundary& nuBf = tnu.ref().boundaryFieldRef();
119  const volScalarField::Boundary& sigmaBf = strainRate.boundaryField();
120 
121  forAll(nuBf, patchi)
122  {
123  nuBf[patchi] = strainRateFunction_->value(sigmaBf[patchi]);
124  }
125 
126  return tnu;
127 }
128 
129 
130 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
const Mesh & mesh() const
Return mesh.
Run-time selectable general function of one variable.
Definition: Function1.H:64
static autoPtr< Function1< Type > > New(const word &name, const dictionary &dict)
Selector.
Definition: Function1New.C:32
Generic GeometricBoundaryField class.
Generic GeometricField class.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &)
Return a temporary field constructed from name,.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:134
static word groupName(Name name, const word &group)
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1076
An abstract base class for generalised Newtonian viscosity models.
virtual bool read(const dictionary &viscosityProperties)=0
Read transportProperties dictionary.
Run-time selected strain-rate function generalised Newtonian viscosity model.
virtual bool read(const dictionary &viscosityProperties)
Read transportProperties dictionary.
strainRateFunction(const dictionary &viscosityProperties, const Foam::viscosity &viscosity, const volVectorField &U)
Construct from components.
An abstract base class for strain-rate dependent generalised Newtonian viscosity models.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
Abstract base class for all fluid physical properties.
Definition: viscosity.H:50
label patchi
U
Definition: pEqn.H:72
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
addToRunTimeSelectionTable(generalisedNewtonianViscosityModel, Newtonian, dictionary)
Namespace for OpenFOAM.
const dimensionSet dimViscosity
word typedName(Name name)
Return the name of the object within the given type.
Definition: typeInfo.H:149