PecletNo.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) 2013-2026 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 "PecletNo.H"
29 #include "surfaceInterpolate.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace functionObjects
37 {
39 
41  (
43  PecletNo,
45  );
46 }
47 }
48 
49 
50 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
51 
52 bool Foam::functionObjects::PecletNo::calc()
53 {
54  if (foundObject<surfaceScalarField>(fieldName_))
55  {
56  const surfaceScalarField& phi =
58 
59  tmp<volScalarField> nuOrMuEff;
60  if (phi.dimensions() == dimVolumetricFlux)
61  {
62  const incompressibleMomentumTransportModel& imtm =
63  mesh_.lookupType<incompressibleMomentumTransportModel>();
64 
65  nuOrMuEff = imtm.nuEff();
66  }
67  else if (phi.dimensions() == dimMassFlux)
68  {
69  const compressibleMomentumTransportModel& cmtm =
70  mesh_.lookupType<compressibleMomentumTransportModel>();
71 
72  nuOrMuEff = cmtm.rho()*cmtm.nuEff();
73  }
74  else
75  {
77  << "dimensions of flux " << phi.name() << " are "
78  << phi.dimensions() << ", but they must be either "
79  << dimMassFlux << " (mass flux) or " << dimVolumetricFlux
80  << " (volume flux) " << exit(FatalError);
81  }
82 
83  store
84  (
86  mag(phi)
87  /(
88  mesh_.magSf()
89  *mesh_.surfaceInterpolation::deltaCoeffs()
90  *fvc::interpolate(nuOrMuEff)
91  )
92  );
93 
94  return true;
95  }
96  else
97  {
98  cannotFindObject<surfaceScalarField>(fieldName_);
99 
100  return false;
101  }
102 }
103 
104 
105 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
106 
108 (
109  const word& name,
110  const Time& runTime,
111  const dictionary& dict
112 )
113 :
114  fieldExpression(name, runTime, dict, "Pe", "phi")
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
119 
121 {}
122 
123 
124 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base-class for Time/database functionObjects.
Calculates and outputs the Peclet number as a surfaceScalarField.
Definition: PecletNo.H:57
virtual ~PecletNo()
Destructor.
Definition: PecletNo.C:120
PecletNo(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: PecletNo.C:108
word resultName_
Name of result field.
const word fieldName_
Name of field to process.
const fvMesh & mesh_
Reference to the fvMesh.
ObjectType & store(const tmp< ObjectType > &tfield)
Store the given field in the objectRegistry.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
const Type & lookupType(const word &group=word::null) const
Lookup and return the object of the given Type.
A class for handling words, derived from string.
Definition: word.H:63
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
addToRunTimeSelectionTable(functionObject, fvModel, dictionary)
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const dimensionSet & dimMassFlux
Definition: dimensions.C:179
SurfaceField< scalar > surfaceScalarField
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
error FatalError
const dimensionSet & dimVolumetricFlux
Definition: dimensions.C:178
dictionary dict