PecletNo.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2019 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 "PecletNo.H"
30 #include "turbulenceModel.H"
31 #include "surfaceInterpolate.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace functionObjects
39 {
40  defineTypeNameAndDebug(PecletNo, 0);
41 
43  (
44  functionObject,
45  PecletNo,
46  dictionary
47  );
48 }
49 }
50 
51 
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
53 
54 Foam::tmp<Foam::surfaceScalarField> Foam::functionObjects::PecletNo::rhoScale
55 (
56  const surfaceScalarField& phi
57 ) const
58 {
59  if (phi.dimensions() == dimMass/dimTime)
60  {
61  return phi/fvc::interpolate(lookupObject<volScalarField>(rhoName_));
62  }
63 
64  return phi;
65 }
66 
67 
68 bool Foam::functionObjects::PecletNo::calc()
69 {
70  if (foundObject<surfaceScalarField>(fieldName_))
71  {
72  tmp<volScalarField> nuEff;
73  if (mesh_.foundObject<turbulenceModel>(turbulenceModel::propertiesName))
74  {
75  const turbulenceModel& model =
76  lookupObject<turbulenceModel>
77  (
79  );
80 
81  nuEff = model.nuEff();
82  }
83  else if (mesh_.foundObject<dictionary>("transportProperties"))
84  {
85  const dictionary& model =
86  mesh_.lookupObject<dictionary>("transportProperties");
87 
89  (
90  IOobject
91  (
92  "nuEff",
93  mesh_.time().timeName(),
94  mesh_,
97  ),
98  mesh_,
99  dimensionedScalar("nu", dimViscosity, model)
100  );
101  }
102  else
103  {
105  << "Unable to determine the viscosity"
106  << exit(FatalError);
107  }
108 
109 
110  const surfaceScalarField& phi =
111  mesh_.lookupObject<surfaceScalarField>(fieldName_);
112 
113  return store
114  (
115  resultName_,
116  mag(rhoScale(phi))
117  /(
118  mesh_.magSf()
119  *mesh_.surfaceInterpolation::deltaCoeffs()
120  *fvc::interpolate(nuEff)
121  )
122  );
123  }
124 
125  return false;
126 }
127 
128 
129 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
130 
132 (
133  const word& name,
134  const Time& runTime,
135  const dictionary& dict
136 )
137 :
138  fieldExpression(name, runTime, dict, "phi"),
139  rhoName_("rho")
140 {
141  setResultName("Pe", "phi");
142  read(dict);
143 }
144 
145 
146 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
147 
149 {}
150 
151 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152 
154 {
155  rhoName_ = dict.lookupOrDefault<word>("rho", "rho");
156 
157  return true;
158 }
159 
160 
161 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:100
PecletNo.H
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, add, dictionary)
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:54
Foam::functionObjects::PecletNo::PecletNo
PecletNo(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: PecletNo.C:132
Foam::compressible::turbulenceModel
ThermalDiffusivity< CompressibleTurbulenceModel< fluidThermo > > turbulenceModel
Definition: turbulentFluidThermoModel.H:63
Foam::functionObjects::PecletNo::~PecletNo
virtual ~PecletNo()
Destructor.
Definition: PecletNo.C:148
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:43
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dimViscosity
const dimensionSet dimViscosity
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::fvc::interpolate
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
Foam::functionObjects::PecletNo::read
virtual bool read(const dictionary &)
Read the PecletNo data.
Definition: PecletNo.C:153
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::functionObjects::fieldExpression
Base class for field expression function objects.
Definition: fieldExpression.H:60
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
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::IOobject::NO_READ
Definition: IOobject.H:123
turbulenceModel.H