mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -12,6 +12,9 @@ staticPressure/staticPressureFunctionObject.C
|
||||
timeActivatedFileUpdate/timeActivatedFileUpdate.C
|
||||
timeActivatedFileUpdate/timeActivatedFileUpdateFunctionObject.C
|
||||
|
||||
yPlusLES/yPlusLES.C
|
||||
yPlusLES/yPlusLESFunctionObject.C
|
||||
|
||||
yPlusRAS/yPlusRAS.C
|
||||
yPlusRAS/yPlusRASFunctionObject.C
|
||||
|
||||
|
||||
@ -8,7 +8,8 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/turbulenceModels \
|
||||
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions \
|
||||
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions \
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
|
||||
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
|
||||
-I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
@ -19,4 +20,6 @@ LIB_LIBS = \
|
||||
-lincompressibleTransportModels \
|
||||
-lcompressibleRASModels \
|
||||
-lincompressibleRASModels \
|
||||
-lcompressibleLESModels \
|
||||
-lincompressibleLESModels \
|
||||
-lbasicThermophysicalModels
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::IOyPlusLES
|
||||
|
||||
Description
|
||||
Instance of the generic IOOutputFilter for yPlusLES.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef IOyPlusLES_H
|
||||
#define IOyPlusLES_H
|
||||
|
||||
#include "yPlusLES.H"
|
||||
#include "IOOutputFilter.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef IOOutputFilter<yPlusLES> IOyPlusLES;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
334
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C
Normal file
334
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.C
Normal file
@ -0,0 +1,334 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "yPlusLES.H"
|
||||
#include "volFields.H"
|
||||
|
||||
#include "incompressible/LES/LESModel/LESModel.H"
|
||||
#include "compressible/LES/LESModel/LESModel.H"
|
||||
#include "wallFvPatch.H"
|
||||
#include "nearWallDist.H"
|
||||
//#include "wallDist.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::yPlusLES, 0);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusLES::makeFile()
|
||||
{
|
||||
// Create the output file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
outputFilePtr_() << "# y+ (LES)" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << token::TAB << "average"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::calcIncompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
)
|
||||
{
|
||||
const incompressible::LESModel& model =
|
||||
mesh.lookupObject<incompressible::LESModel>("LESProperties");
|
||||
|
||||
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
|
||||
volScalarField nuEff(model.nuEff());
|
||||
|
||||
const fvPatchList& patches = mesh.boundary();
|
||||
|
||||
const volScalarField nuLam(model.nu());
|
||||
|
||||
bool foundPatch = false;
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
const fvPatch& currPatch = patches[patchI];
|
||||
|
||||
if (isA<wallFvPatch>(currPatch))
|
||||
{
|
||||
foundPatch = true;
|
||||
yPlus.boundaryField()[patchI] =
|
||||
d[patchI]
|
||||
*sqrt
|
||||
(
|
||||
nuEff.boundaryField()[patchI]
|
||||
*mag(U.boundaryField()[patchI].snGrad())
|
||||
)
|
||||
/nuLam.boundaryField()[patchI];
|
||||
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchI];
|
||||
|
||||
scalar minYp = min(Yp);
|
||||
scalar maxYp = max(Yp);
|
||||
scalar avgYp = average(Yp);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " patch " << currPatch.name()
|
||||
<< " y+ : min = " << min(Yp) << ", max = " << max(Yp)
|
||||
<< ", average = " << average(Yp) << nl;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
<< currPatch.name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFvPatch::typeName << " patches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::calcCompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
)
|
||||
{
|
||||
const compressible::LESModel& model =
|
||||
mesh.lookupObject<compressible::LESModel>("LESProperties");
|
||||
|
||||
volScalarField::GeometricBoundaryField d = nearWallDist(mesh).y();
|
||||
volScalarField muEff(model.muEff());
|
||||
|
||||
const fvPatchList& patches = mesh.boundary();
|
||||
|
||||
const volScalarField muLam(model.mu());
|
||||
|
||||
Info<< type() << " output:" << nl;
|
||||
|
||||
bool foundPatch = false;
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
const fvPatch& currPatch = patches[patchI];
|
||||
|
||||
if (isA<wallFvPatch>(currPatch))
|
||||
{
|
||||
foundPatch = true;
|
||||
yPlus.boundaryField()[patchI] =
|
||||
d[patchI]
|
||||
*sqrt
|
||||
(
|
||||
muEff.boundaryField()[patchI]
|
||||
*mag(U.boundaryField()[patchI].snGrad())
|
||||
)
|
||||
/muLam.boundaryField()[patchI];
|
||||
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchI];
|
||||
|
||||
scalar minYp = min(Yp);
|
||||
scalar maxYp = max(Yp);
|
||||
scalar avgYp = average(Yp);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " patch " << currPatch.name()
|
||||
<< " y+ : min = " << min(Yp) << ", max = " << max(Yp)
|
||||
<< ", average = " << average(Yp) << nl;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
<< currPatch.name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFvPatch::typeName << " patches" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::yPlusLES::yPlusLES
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
log_(false),
|
||||
phiName_("phi"),
|
||||
UName_("U"),
|
||||
outputFilePtr_(NULL)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
active_ = false;
|
||||
WarningIn
|
||||
(
|
||||
"yPlusLES::yPlusLES"
|
||||
"("
|
||||
"const word&, "
|
||||
"const objectRegistry&, "
|
||||
"const dictionary&, "
|
||||
"const bool"
|
||||
")"
|
||||
) << "No fvMesh available, deactivating." << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::yPlusLES::~yPlusLES()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusLES::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::execute()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::end()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusLES::write()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
const surfaceScalarField& phi =
|
||||
obr_.lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volScalarField yPlusLES
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"yPlusLES",
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
),
|
||||
mesh,
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " output:" << nl;
|
||||
}
|
||||
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
calcCompressibleYPlus(mesh, U, yPlusLES);
|
||||
}
|
||||
else
|
||||
{
|
||||
calcIncompressibleYPlus(mesh, U, yPlusLES);
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
yPlusLES.write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
174
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H
Normal file
174
src/postProcessing/functionObjects/utilities/yPlusLES/yPlusLES.H
Normal file
@ -0,0 +1,174 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::yPlusLES
|
||||
|
||||
Description
|
||||
Evaluates and outputs turbulence y+ for LES models. Values written to
|
||||
time folders as field 'yPlusLES'
|
||||
|
||||
SourceFiles
|
||||
yPlusLES.C
|
||||
IOyPlusLES.H
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef yPlusLES_H
|
||||
#define yPlusLES_H
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class mapPolyMesh;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class yPlusLES Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class yPlusLES
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of yPlusLES objects
|
||||
word name_;
|
||||
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Name of mass/volume flux field (optional, default = phi)
|
||||
word phiName_;
|
||||
|
||||
//- Name of velocity field
|
||||
word UName_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
|
||||
//- Calculate incompressible form of y+
|
||||
void calcIncompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
);
|
||||
|
||||
//- Calculate compressible form of y+
|
||||
void calcCompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volVectorField& U,
|
||||
volScalarField& yPlus
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
yPlusLES(const yPlusLES&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const yPlusLES&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("yPlusLES");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
yPlusLES
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~yPlusLES();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the set of yPlusLES
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the yPlusLES data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual void execute();
|
||||
|
||||
//- Execute at the final time-loop, currently does nothing
|
||||
virtual void end();
|
||||
|
||||
//- Calculate the yPlusLES and write
|
||||
virtual void write();
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void updateMesh(const mapPolyMesh&)
|
||||
{}
|
||||
|
||||
//- Update for changes of mesh
|
||||
virtual void movePoints(const pointField&)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,42 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "yPlusLESFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(yPlusLESFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
yPlusLESFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,53 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::yPlusLESFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around yPlusLES to allow it to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
yPlusLESFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef yPlusLESFunctionObject_H
|
||||
#define yPlusLESFunctionObject_H
|
||||
|
||||
#include "yPlusLES.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<yPlusLES> yPlusLESFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -41,11 +41,56 @@ defineTypeNameAndDebug(Foam::yPlusRAS, 0);
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::yPlusRAS::makeFile()
|
||||
{
|
||||
// Create the output file if not already created
|
||||
if (outputFilePtr_.empty())
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Info<< "Creating output file." << endl;
|
||||
}
|
||||
|
||||
// File update
|
||||
if (Pstream::master())
|
||||
{
|
||||
fileName outputDir;
|
||||
word startTimeName =
|
||||
obr_.time().timeName(obr_.time().startTime().value());
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Put in undecomposed case (Note: gives problems for
|
||||
// distributed data running)
|
||||
outputDir =
|
||||
obr_.time().path()/".."/name_/startTimeName;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir = obr_.time().path()/name_/startTimeName;
|
||||
}
|
||||
|
||||
// Create directory if does not exist
|
||||
mkDir(outputDir);
|
||||
|
||||
// Open new file at start up
|
||||
outputFilePtr_.reset(new OFstream(outputDir/(type() + ".dat")));
|
||||
|
||||
// Add headers to output data
|
||||
outputFilePtr_() << "# y+ (RAS)" << nl
|
||||
<< "# time " << token::TAB << "patch" << token::TAB
|
||||
<< "min" << token::TAB << "max" << token::TAB << "average"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::yPlusRAS::calcIncompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
volScalarField& yPlus
|
||||
) const
|
||||
)
|
||||
{
|
||||
typedef incompressible::RASModels::nutkWallFunctionFvPatchScalarField
|
||||
wallFunctionPatchField;
|
||||
@ -57,28 +102,41 @@ void Foam::yPlusRAS::calcIncompressibleYPlus
|
||||
const volScalarField::GeometricBoundaryField& nutPatches =
|
||||
nut.boundaryField();
|
||||
|
||||
Info<< type() << " output:" << nl;
|
||||
|
||||
bool foundNutPatch = false;
|
||||
forAll(nutPatches, patchi)
|
||||
bool foundPatch = false;
|
||||
forAll(nutPatches, patchI)
|
||||
{
|
||||
if (isA<wallFunctionPatchField>(nutPatches[patchi]))
|
||||
if (isA<wallFunctionPatchField>(nutPatches[patchI]))
|
||||
{
|
||||
foundNutPatch = true;
|
||||
foundPatch = true;
|
||||
|
||||
const wallFunctionPatchField& nutPw =
|
||||
dynamic_cast<const wallFunctionPatchField&>(nutPatches[patchi]);
|
||||
dynamic_cast<const wallFunctionPatchField&>(nutPatches[patchI]);
|
||||
|
||||
yPlus.boundaryField()[patchi] = nutPw.yPlus();
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchi];
|
||||
yPlus.boundaryField()[patchI] = nutPw.yPlus();
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchI];
|
||||
|
||||
Info<< " patch " << nutPw.patch().name()
|
||||
<< " y+ : min = " << min(Yp) << ", max = " << max(Yp)
|
||||
<< ", average = " << average(Yp) << nl;
|
||||
scalar minYp = min(Yp);
|
||||
scalar maxYp = max(Yp);
|
||||
scalar avgYp = average(Yp);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " patch " << nutPw.patch().name()
|
||||
<< " y+ : min = " << minYp << ", max = " << maxYp
|
||||
<< ", average = " << avgYp << nl;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
<< nutPw.patch().name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundNutPatch)
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFunctionPatchField::typeName << " patches"
|
||||
<< endl;
|
||||
@ -90,7 +148,7 @@ void Foam::yPlusRAS::calcCompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
volScalarField& yPlus
|
||||
) const
|
||||
)
|
||||
{
|
||||
typedef compressible::RASModels::mutkWallFunctionFvPatchScalarField
|
||||
wallFunctionPatchField;
|
||||
@ -102,28 +160,41 @@ void Foam::yPlusRAS::calcCompressibleYPlus
|
||||
const volScalarField::GeometricBoundaryField& mutPatches =
|
||||
mut.boundaryField();
|
||||
|
||||
Info<< type() << " output:" << nl;
|
||||
|
||||
bool foundMutPatch = false;
|
||||
forAll(mutPatches, patchi)
|
||||
bool foundPatch = false;
|
||||
forAll(mutPatches, patchI)
|
||||
{
|
||||
if (isA<wallFunctionPatchField>(mutPatches[patchi]))
|
||||
if (isA<wallFunctionPatchField>(mutPatches[patchI]))
|
||||
{
|
||||
foundMutPatch = true;
|
||||
foundPatch = true;
|
||||
|
||||
const wallFunctionPatchField& mutPw =
|
||||
dynamic_cast<const wallFunctionPatchField&>(mutPatches[patchi]);
|
||||
dynamic_cast<const wallFunctionPatchField&>(mutPatches[patchI]);
|
||||
|
||||
yPlus.boundaryField()[patchi] = mutPw.yPlus();
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchi];
|
||||
yPlus.boundaryField()[patchI] = mutPw.yPlus();
|
||||
const scalarField& Yp = yPlus.boundaryField()[patchI];
|
||||
|
||||
Info<< " patch " << mutPw.patch().name()
|
||||
<< " y+ : min = " << min(Yp) << ", max = " << max(Yp)
|
||||
<< ", average = " << average(Yp) << nl;
|
||||
scalar minYp = min(Yp);
|
||||
scalar maxYp = max(Yp);
|
||||
scalar avgYp = average(Yp);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " patch " << mutPw.patch().name()
|
||||
<< " y+ : min = " << minYp << ", max = " << maxYp
|
||||
<< ", average = " << avgYp << nl;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
outputFilePtr_() << obr_.time().value() << token::TAB
|
||||
<< mutPw.patch().name() << token::TAB
|
||||
<< minYp << token::TAB << maxYp << token::TAB
|
||||
<< avgYp << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMutPatch)
|
||||
if (log_ && !foundPatch)
|
||||
{
|
||||
Info<< " no " << wallFunctionPatchField::typeName << " patches"
|
||||
<< endl;
|
||||
@ -144,7 +215,9 @@ Foam::yPlusRAS::yPlusRAS
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
active_(true),
|
||||
phiName_("phi")
|
||||
log_(false),
|
||||
phiName_("phi"),
|
||||
outputFilePtr_(NULL)
|
||||
{
|
||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||
if (!isA<fvMesh>(obr_))
|
||||
@ -162,6 +235,8 @@ Foam::yPlusRAS::yPlusRAS
|
||||
) << "No fvMesh available, deactivating." << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
makeFile();
|
||||
}
|
||||
|
||||
|
||||
@ -177,6 +252,7 @@ void Foam::yPlusRAS::read(const dictionary& dict)
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
log_ = dict.lookupOrDefault<Switch>("log", false);
|
||||
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
|
||||
}
|
||||
}
|
||||
@ -216,6 +292,11 @@ void Foam::yPlusRAS::write()
|
||||
dimensionedScalar("0", dimless, 0.0)
|
||||
);
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< type() << " output:" << nl;
|
||||
}
|
||||
|
||||
if (phi.dimensions() == dimMass/dimTime)
|
||||
{
|
||||
calcCompressibleYPlus(mesh, yPlusRAS);
|
||||
@ -225,7 +306,10 @@ void Foam::yPlusRAS::write()
|
||||
calcIncompressibleYPlus(mesh, yPlusRAS);
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
yPlusRAS.write();
|
||||
}
|
||||
|
||||
@ -39,7 +39,8 @@ SourceFiles
|
||||
|
||||
#include "volFieldsFwd.H"
|
||||
#include "pointFieldFwd.H"
|
||||
#include "fvMesh.H"
|
||||
#include "Switch.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -50,9 +51,10 @@ namespace Foam
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class mapPolyMesh;
|
||||
class fvMesh;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class yPlusRAS Declaration
|
||||
Class yPlusRAS Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class yPlusRAS
|
||||
@ -67,25 +69,26 @@ class yPlusRAS
|
||||
//- on/off switch
|
||||
bool active_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Name of mass/volume flux field (optional, default = phi)
|
||||
word phiName_;
|
||||
|
||||
//- Output file pointer
|
||||
autoPtr<OFstream> outputFilePtr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Make the output file
|
||||
virtual void makeFile();
|
||||
|
||||
//- Calculate incompressible form of y+
|
||||
void calcIncompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
volScalarField& yPlus
|
||||
) const;
|
||||
void calcIncompressibleYPlus(const fvMesh& mesh, volScalarField& yPlus);
|
||||
|
||||
//- Calculate compressible form of y+
|
||||
void calcCompressibleYPlus
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
volScalarField& yPlus
|
||||
) const;
|
||||
void calcCompressibleYPlus(const fvMesh& mesh, volScalarField& yPlus);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
yPlusRAS(const yPlusRAS&);
|
||||
|
||||
Reference in New Issue
Block a user