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-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 "strainRateFunction.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace laminarModels
34 {
35 namespace generalisedNewtonianViscosityModels
36 {
37  defineTypeNameAndDebug(strainRateFunction, 0);
38 
40  (
41  generalisedNewtonianViscosityModel,
42  strainRateFunction,
43  dictionary
44  );
45 }
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
54 (
55  const dictionary& viscosityProperties,
56  const Foam::viscosity& viscosity,
57  const volVectorField& U
58 )
59 :
60  strainRateViscosityModel(viscosityProperties, viscosity, U),
61  strainRateFunction_
62  (
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(type() + ":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 // ************************************************************************* //
const dimensionSet dimViscosity
static word group(const word &name)
Return group (extension part of name)
Definition: IOobject.C:134
Run-time selectable general function of one variable.
Definition: Function1.H:52
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(rho0+psi *p, rhoMin);# 1 "/home/ubuntu/OpenFOAM-10/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0));alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:68
const Boundary & boundaryField() const
Return const-reference to the boundary field.
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
addToRunTimeSelectionTable(generalisedNewtonianViscosityModel, Newtonian, dictionary)
strainRateFunction(const dictionary &viscosityProperties, const Foam::viscosity &viscosity, const volVectorField &U)
Construct from components.
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Internal &, const PtrList< fvPatchField< scalar >> &)
Return a temporary field constructed from name,.
Macros for easy insertion into run-time selection tables.
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1060
static word groupName(Name name, const word &group)
virtual bool read(const dictionary &viscosityProperties)
Read transportProperties dictionary.
An abstract base class for strain-rate dependent generalised Newtonian viscosity models.
const Mesh & mesh() const
Return mesh.
Abstract base class for all fluid physical properties.
Definition: viscosity.H:49
label patchi
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
A class for managing temporary objects.
Definition: PtrList.H:53
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
Namespace for OpenFOAM.
virtual bool read(const dictionary &viscosityProperties)=0
Read transportProperties dictionary.
static autoPtr< Function1< Type > > New(const word &name, const dictionary &dict)
Selector.
Definition: Function1New.C:32