yPlus.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 | Copyright (C) 2013-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 "yPlus.H"
27 #include "volFields.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 }
37 
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
42 {
43  writeHeader(os, "y+");
44  writeCommented(os, "Time");
45  writeTabbed(os, "patch");
46  writeTabbed(os, "min");
47  writeTabbed(os, "max");
48  writeTabbed(os, "average");
49  os << endl;
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 
56 (
57  const word& name,
58  const objectRegistry& obr,
59  const dictionary& dict,
60  const bool loadFromFiles
61 )
62 :
63  functionObjectFile(obr, name, typeName, dict),
64  name_(name),
65  obr_(obr),
66  active_(true),
67  phiName_("phi"),
68  resultName_(name),
69  log_(true)
70 {
71  // Check if the available mesh is an fvMesh, otherwise deactivate
72  if (!isA<fvMesh>(obr_))
73  {
74  active_ = false;
76  << "No fvMesh available, deactivating " << name_ << nl
77  << endl;
78  }
79 
80  if (active_)
81  {
82  read(dict);
83 
84  const fvMesh& mesh = refCast<const fvMesh>(obr_);
85 
86  volScalarField* yPlusPtr
87  (
88  new volScalarField
89  (
90  IOobject
91  (
92  resultName_,
93  mesh.time().timeName(),
94  mesh,
97  ),
98  mesh,
99  dimensionedScalar("0", dimless, 0.0)
100  )
101  );
102 
103  mesh.objectRegistry::store(yPlusPtr);
104 
105  writeFileHeader(file());
106  }
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 
113 {}
114 
115 
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 
119 {
120  if (active_)
121  {
123 
124  log_.readIfPresent("log", dict);
125  dict.readIfPresent("resultName", resultName_);
126  dict.readIfPresent("phiName", phiName_);
127  }
128 }
129 
130 
132 {
133  typedef compressible::turbulenceModel cmpTurbModel;
134  typedef incompressible::turbulenceModel icoTurbModel;
135 
136  if (active_)
137  {
138  const surfaceScalarField& phi =
139  obr_.lookupObject<surfaceScalarField>(phiName_);
140 
141  const fvMesh& mesh = refCast<const fvMesh>(obr_);
142 
144  const_cast<volScalarField&>
145  (
146  mesh.lookupObject<volScalarField>(resultName_)
147  );
148 
149  if (log_) Info << type() << " " << name_ << " output:" << nl;
150 
151  if (phi.dimensions() == dimMass/dimTime)
152  {
154  {
155  const cmpTurbModel& model =
156  mesh.lookupObject<cmpTurbModel>
157  (
159  );
160 
161  calcYPlus(model, mesh, yPlus);
162  }
163  else
164  {
166  << "Unable to find compressible turbulence model in the "
167  << "database: yPlus will not be calculated" << endl;
168  }
169  }
170  else if (phi.dimensions() == dimVolume/dimTime)
171  {
173  {
174  const icoTurbModel& model =
175  mesh.lookupObject<icoTurbModel>
176  (
178  );
179 
180  calcYPlus(model, mesh, yPlus);
181  }
182  else
183  {
185  << "Unable to find incompressible turbulence model in the "
186  << "database: yPlus will not be calculated" << endl;
187  }
188  }
189  else
190  {
192  << "Unknown " << phiName_ << " dimensions: "
193  << phi.dimensions() << nl
194  << "Expected either " << dimMass/dimTime << " or "
195  << dimVolume/dimTime << nl
196  << "Unable to determine turbulence model type. "
197  << "yPlus will not be calculated" << endl;
198  }
199  }
200 }
201 
202 
204 {
205  // Do nothing
206 }
207 
208 
210 {
211  // Do nothing
212 }
213 
214 
216 {
217  if (active_)
218  {
219  const volScalarField& yPlus =
220  obr_.lookupObject<volScalarField>(resultName_);
221 
222  if (log_) Info
223  << type() << " " << name_ << " output:" << nl
224  << " writing field " << yPlus.name() << nl
225  << endl;
226 
227  yPlus.write();
228  }
229 }
230 
231 
232 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::yPlus::yPlus
yPlus(const yPlus &)
Disallow default bitwise copy construct.
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::yPlus::read
virtual void read(const dictionary &)
Read the yPlus data.
Definition: yPlus.C:118
Foam::functionObjectFile::writeTabbed
void writeTabbed(Ostream &os, const string &str) const
Write a tabbed string to stream.
Definition: functionObjectFile.C:230
turbulentTransportModel.H
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:97
Foam::yPlus::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
File header information.
Definition: yPlus.C:41
Foam::functionObjectFile::read
void read(const dictionary &dict)
Read.
Definition: functionObjectFile.C:178
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::yPlus::write
virtual void write()
Calculate the yPlus and write.
Definition: yPlus.C:215
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
yPlus.H
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::yPlus::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: yPlus.C:203
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::functionObjectFile::writeHeader
void writeHeader(Ostream &os, const string &str) const
Write a commented header to stream.
Definition: functionObjectFile.C:240
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
Foam::yPlus::~yPlus
virtual ~yPlus()
Destructor.
Definition: yPlus.C:112
Foam::yPlus::execute
virtual void execute()
Execute, currently does nothing.
Definition: yPlus.C:131
Foam::objectRegistry::foundObject
bool foundObject(const word &name) const
Is the named Type found?
Definition: objectRegistryTemplates.C:142
Foam::yPlus::name
virtual const word & name() const
Return name of the set of yPlus.
Definition: yPlus.H:181
Foam::ThermalDiffusivity
Templated wrapper class to provide compressible turbulence models thermal diffusivity based thermal t...
Definition: ThermalDiffusivity.H:48
Foam::Time::timeName
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
Foam::yPlus::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: yPlus.C:209
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
Foam::yPlus
This function object evaluates and outputs turbulence y+ for turbulence models. The field is stored o...
Definition: yPlus.H:110
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
Foam::IncompressibleTurbulenceModel
Templated abstract base class for single-phase incompressible turbulence models.
Definition: IncompressibleTurbulenceModel.H:52
yPlus
scalar yPlus
Definition: evaluateNearWall.H:16
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::functionObjectFile::writeCommented
void writeCommented(Ostream &os, const string &str) const
Write a commented string to stream.
Definition: functionObjectFile.C:219
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
turbulentFluidThermoModel.H