generalizedNewtonian.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-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 "generalizedNewtonian.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
32 #include "fvcGrad.H"
33 #include "fvcDiv.H"
34 #include "fvmLaplacian.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 namespace laminarModels
41 {
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
45 template<class BasicMomentumTransportModel>
47 (
48  const alphaField& alpha,
49  const rhoField& rho,
50  const volVectorField& U,
51  const surfaceScalarField& alphaRhoPhi,
52  const surfaceScalarField& phi,
53  const transportModel& transport,
54  const word& propertiesName
55 )
56 :
58  (
59  typeName,
60  alpha,
61  rho,
62  U,
63  alphaRhoPhi,
64  phi,
65  transport,
66  propertiesName
67  ),
68 
69  viscosityModel_
70  (
72  (
73  this->coeffDict_
74  )
75  ),
76 
77  nu_
78  (
79  IOobject
80  (
81  IOobject::groupName("generalizedNewtonian:nu", alphaRhoPhi.group()),
82  this->runTime_.timeName(),
83  this->mesh_,
86  ),
87  viscosityModel_->nu(this->nu(), strainRate())
88  )
89 {}
90 
91 
92 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
93 
94 template<class BasicMomentumTransportModel>
97 {
98  return sqrt(scalar{2})*mag(symm(fvc::grad(this->U())));
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
104 template<class BasicMomentumTransportModel>
106 {
107  viscosityModel_->read(this->coeffDict_);
108 
109  return true;
110 }
111 
112 
113 template<class BasicMomentumTransportModel>
116 {
117  return volScalarField::New
118  (
119  IOobject::groupName("nut", this->alphaRhoPhi_.group()),
120  this->mesh_,
122  );
123 }
124 
125 
126 template<class BasicMomentumTransportModel>
129 (
130  const label patchi
131 ) const
132 {
133  return tmp<scalarField>::New(this->mesh_.boundary()[patchi].size(), Zero);
134 }
135 
136 
137 template<class BasicMomentumTransportModel>
140 {
141  return volScalarField::New
142  (
143  IOobject::groupName("nuEff", this->alphaRhoPhi_.group()),
144  nu_
145  );
146 }
147 
148 
149 template<class BasicMomentumTransportModel>
152 (
153  const label patchi
154 ) const
155 {
156  return nu_.boundaryField()[patchi];
157 }
158 
159 
160 template<class BasicMomentumTransportModel>
162 {
163  nu_ = viscosityModel_->nu(this->nu(), strainRate());
165 }
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace laminarModels
171 } // End namespace Foam
172 
173 // ************************************************************************* //
volFields.H
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:84
Foam::laminarModels::generalizedNewtonian::nut
virtual tmp< volScalarField > nut() const
Return the turbulence viscosity,.
Definition: generalizedNewtonian.C:115
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:54
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
generalizedNewtonian.H
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
fvcDiv.H
Calculate the divergence of the given field.
surfaceFields.H
Foam::surfaceFields.
rho
rho
Definition: readInitialConditions.H:88
Foam::laminarModels::generalizedNewtonian::rhoField
BasicMomentumTransportModel::rhoField rhoField
Definition: generalizedNewtonian.H:79
Foam::GeometricField< scalar, fvPatchField, volMesh >::New
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Mesh &mesh, const dimensionSet &ds, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
Return tmp field from name, mesh, dimensions and patch type.
Definition: GeometricFieldNew.C:34
Foam::laminarModels::generalizedNewtonian::read
virtual bool read()
Read turbulence (momentumTransport) dictionary.
Definition: generalizedNewtonian.C:105
nu
volScalarField & nu
Definition: readMechanicalProperties.H:176
Foam::linearViscousStress
Linear viscous stress turbulence model base class.
Definition: linearViscousStress.H:53
fvmLaplacian.H
Calculate the matrix for the laplacian of the field.
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::laminarModels::generalizedNewtonian::alphaField
BasicMomentumTransportModel::alphaField alphaField
Definition: generalizedNewtonian.H:78
Foam::dimViscosity
const dimensionSet dimViscosity
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::laminarModels::generalizedNewtonian::nuEff
virtual tmp< volScalarField > nuEff() const
Return the effective viscosity.
Definition: generalizedNewtonian.C:139
U
U
Definition: pEqn.H:72
Foam::laminarModel::correct
virtual void correct()
Correct the laminar transport.
Definition: laminarModel.C:333
Foam::laminarModels::generalizedNewtonian::generalizedNewtonian
generalizedNewtonian(const alphaField &alpha, const rhoField &rho, const volVectorField &U, const surfaceScalarField &alphaRhoPhi, const surfaceScalarField &phi, const transportModel &transport, const word &propertiesName)
Construct from components.
Definition: generalizedNewtonian.C:47
Foam::sqrt
dimensionedScalar sqrt(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:144
fvcGrad.H
Calculate the gradient of the given field.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::tmp::New
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
Foam::laminarModels::generalizedNewtonianViscosityModel::New
static autoPtr< generalizedNewtonianViscosityModel > New(const dictionary &dict)
Select a viscosity model.
Definition: generalizedNewtonianViscosityModelNew.C:35
Foam::laminarModels::generalizedNewtonian::correct
virtual void correct()
Correct the generalizedNewtonian viscosity.
Definition: generalizedNewtonian.C:161
Foam::IOobject::groupName
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
Foam::laminarModels::generalizedNewtonian::transportModel
BasicMomentumTransportModel::transportModel transportModel
Definition: generalizedNewtonian.H:80
Foam::GeometricField< vector, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::laminarModels::generalizedNewtonian::strainRate
virtual tmp< volScalarField > strainRate() const
Definition: generalizedNewtonian.C:96