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-------------------------------------------------------------------------------
11License
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
35namespace Foam
36{
37namespace viscosityModels
38{
40
42 (
46 );
47}
48}
49
50
51// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52
54(
55 const word& name,
56 const dictionary& viscosityProperties,
57 const volVectorField& U,
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 (
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
surfaceScalarField & phi
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:96
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
virtual bool read()
Re-read model coefficients if they have changed.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
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
void clear()
Clear the dictionary.
Definition: dictionary.C:857
A class for managing temporary objects.
Definition: tmp.H:65
An abstract base class for incompressible viscosityModels.
Run-time selected strain-rate function non-Newtonian viscosity model.
virtual void correct()
Correct the laminar viscosity.
virtual tmp< volScalarField > nu() const
Return the laminar viscosity.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
U
Definition: pEqn.H:72
dynamicFvMesh & mesh
word timeName
Definition: getTimeIndex.H:3
Namespace for OpenFOAM.
const dimensionSet dimViscosity
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
Foam::surfaceFields.