mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
createTurbulenceFields: utility replaced by 'turbulenceFields' functionObject used with the '-postProcess' option
This commit is contained in:
@ -1,3 +0,0 @@
|
|||||||
createTurbulenceFields.C
|
|
||||||
|
|
||||||
EXE = $(FOAM_APPBIN)/createTurbulenceFields
|
|
||||||
@ -1,16 +0,0 @@
|
|||||||
EXE_INC = \
|
|
||||||
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
|
|
||||||
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
|
|
||||||
-I$(LIB_SRC)/transportModels \
|
|
||||||
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
|
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude
|
|
||||||
|
|
||||||
EXE_LIBS = \
|
|
||||||
-lturbulenceModels \
|
|
||||||
-lincompressibleTurbulenceModels \
|
|
||||||
-lincompressibleTransportModels \
|
|
||||||
-lgenericPatchFields \
|
|
||||||
-lfiniteVolume \
|
|
||||||
-lfvOptions \
|
|
||||||
-lmeshTools
|
|
||||||
@ -1,22 +0,0 @@
|
|||||||
Info<< "Reading field U\n" << endl;
|
|
||||||
volVectorField U
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"U",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::AUTO_WRITE
|
|
||||||
),
|
|
||||||
mesh
|
|
||||||
);
|
|
||||||
|
|
||||||
#include "createPhi.H"
|
|
||||||
|
|
||||||
singlePhaseTransportModel laminarTransport(U, phi);
|
|
||||||
|
|
||||||
autoPtr<incompressible::RASModel> RASModel
|
|
||||||
(
|
|
||||||
incompressible::New<incompressible::RASModel>(U, phi, laminarTransport)
|
|
||||||
);
|
|
||||||
@ -1,157 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------*\
|
|
||||||
========= |
|
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
|
||||||
\\ / O peration |
|
|
||||||
\\ / A nd | Copyright (C) 2011-2015 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/>.
|
|
||||||
|
|
||||||
Application
|
|
||||||
createTurbulenceFields
|
|
||||||
|
|
||||||
Description
|
|
||||||
Creates a full set of turbulence fields.
|
|
||||||
|
|
||||||
- Currently does not output nut and nuTilda
|
|
||||||
|
|
||||||
Source files:
|
|
||||||
createFields.H
|
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
#include "fvCFD.H"
|
|
||||||
#include "singlePhaseTransportModel.H"
|
|
||||||
#include "turbulentTransportModel.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
timeSelector::addOptions();
|
|
||||||
|
|
||||||
argList::addOption
|
|
||||||
(
|
|
||||||
"fields",
|
|
||||||
"wordReList",
|
|
||||||
"specify which turbulence fields (k, epsilon, omega, R) to write"
|
|
||||||
" - eg '(k omega)' or '(R)' or '(.*)'."
|
|
||||||
);
|
|
||||||
|
|
||||||
#include "setRootCase.H"
|
|
||||||
#include "createTime.H"
|
|
||||||
|
|
||||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
|
||||||
|
|
||||||
const bool selectedFields = args.optionFound("fields");
|
|
||||||
wordReList fieldPatterns;
|
|
||||||
if (selectedFields)
|
|
||||||
{
|
|
||||||
fieldPatterns = wordReList(args.optionLookup("fields")());
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "createMesh.H"
|
|
||||||
|
|
||||||
forAll(timeDirs, timeI)
|
|
||||||
{
|
|
||||||
runTime.setTime(timeDirs[timeI], timeI);
|
|
||||||
|
|
||||||
Info<< "Time = " << runTime.timeName() << endl;
|
|
||||||
|
|
||||||
#include "createFields.H"
|
|
||||||
|
|
||||||
if (findStrings(fieldPatterns, "k"))
|
|
||||||
{
|
|
||||||
if (!IOobject("k", runTime.timeName(), mesh).headerOk())
|
|
||||||
{
|
|
||||||
Info<< " Writing turbulence field k" << endl;
|
|
||||||
const volScalarField k(RASModel->k());
|
|
||||||
k.write();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< " Turbulence k field already exists" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (findStrings(fieldPatterns, "epsilon"))
|
|
||||||
{
|
|
||||||
if (!IOobject("epsilon", runTime.timeName(), mesh).headerOk())
|
|
||||||
{
|
|
||||||
Info<< " Writing turbulence field epsilon" << endl;
|
|
||||||
const volScalarField epsilon(RASModel->epsilon());
|
|
||||||
epsilon.write();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< " Turbulence epsilon field already exists" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (findStrings(fieldPatterns, "R"))
|
|
||||||
{
|
|
||||||
if (!IOobject("R", runTime.timeName(), mesh).headerOk())
|
|
||||||
{
|
|
||||||
Info<< " Writing turbulence field R" << endl;
|
|
||||||
const volSymmTensorField R(RASModel->R());
|
|
||||||
R.write();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< " Turbulence R field already exists" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (findStrings(fieldPatterns, "omega"))
|
|
||||||
{
|
|
||||||
if (!IOobject("omega", runTime.timeName(), mesh).headerOk())
|
|
||||||
{
|
|
||||||
const scalar Cmu = 0.09;
|
|
||||||
|
|
||||||
// Assume k and epsilon are available
|
|
||||||
const volScalarField k(RASModel->k());
|
|
||||||
const volScalarField epsilon(RASModel->epsilon());
|
|
||||||
|
|
||||||
volScalarField omega
|
|
||||||
(
|
|
||||||
IOobject
|
|
||||||
(
|
|
||||||
"omega",
|
|
||||||
runTime.timeName(),
|
|
||||||
mesh
|
|
||||||
),
|
|
||||||
epsilon/(Cmu*k),
|
|
||||||
epsilon.boundaryField().types()
|
|
||||||
);
|
|
||||||
|
|
||||||
Info<< " Writing turbulence field omega" << endl;
|
|
||||||
omega.write();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Info<< " Turbulence omega field already exists" << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< "\nEnd\n" << endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
40
bin/createTurbulenceFields
Executable file
40
bin/createTurbulenceFields
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# ========= |
|
||||||
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
# \\ / O peration |
|
||||||
|
# \\ / A nd | Copyright (C) 2016 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/>.
|
||||||
|
#
|
||||||
|
# Script
|
||||||
|
# createTurbulenceFields
|
||||||
|
#
|
||||||
|
# Description
|
||||||
|
# Replacement script to suggest using the new "-postProcess"
|
||||||
|
# solver command-line option.
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
Script=${0##*/}
|
||||||
|
|
||||||
|
echo $Script "has been superceded by the \
|
||||||
|
'-postProcess' solver command-line option, e.g."
|
||||||
|
|
||||||
|
echo "simpleFoam -postProcess -func 'turbulenceFields(R, omega)'"
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
@ -11,7 +11,7 @@ R
|
|||||||
type turbulenceFields;
|
type turbulenceFields;
|
||||||
libs ("libfieldFunctionObjects.so");
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
fields (R);
|
field R;
|
||||||
|
|
||||||
executeControl writeTime;
|
executeControl writeTime;
|
||||||
writeControl writeTime;
|
writeControl writeTime;
|
||||||
|
|||||||
20
etc/caseDicts/postProcessing/fields/turbulenceFields
Normal file
20
etc/caseDicts/postProcessing/fields/turbulenceFields
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
turbulenceFields
|
||||||
|
{
|
||||||
|
type turbulenceFields;
|
||||||
|
libs ("libfieldFunctionObjects.so");
|
||||||
|
|
||||||
|
fields (<list of field names>);
|
||||||
|
|
||||||
|
executeControl writeTime;
|
||||||
|
writeControl writeTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -49,11 +49,12 @@ template<>
|
|||||||
const char* Foam::NamedEnum
|
const char* Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::turbulenceFields::compressibleField,
|
Foam::functionObjects::turbulenceFields::compressibleField,
|
||||||
8
|
9
|
||||||
>::names[] =
|
>::names[] =
|
||||||
{
|
{
|
||||||
"k",
|
"k",
|
||||||
"epsilon",
|
"epsilon",
|
||||||
|
"omega",
|
||||||
"mut",
|
"mut",
|
||||||
"muEff",
|
"muEff",
|
||||||
"alphat",
|
"alphat",
|
||||||
@ -65,18 +66,19 @@ const char* Foam::NamedEnum
|
|||||||
const Foam::NamedEnum
|
const Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::turbulenceFields::compressibleField,
|
Foam::functionObjects::turbulenceFields::compressibleField,
|
||||||
8
|
9
|
||||||
> Foam::functionObjects::turbulenceFields::compressibleFieldNames_;
|
> Foam::functionObjects::turbulenceFields::compressibleFieldNames_;
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
const char* Foam::NamedEnum
|
const char* Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::turbulenceFields::incompressibleField,
|
Foam::functionObjects::turbulenceFields::incompressibleField,
|
||||||
6
|
7
|
||||||
>::names[] =
|
>::names[] =
|
||||||
{
|
{
|
||||||
"k",
|
"k",
|
||||||
"epsilon",
|
"epsilon",
|
||||||
|
"omega",
|
||||||
"nut",
|
"nut",
|
||||||
"nuEff",
|
"nuEff",
|
||||||
"R",
|
"R",
|
||||||
@ -86,7 +88,7 @@ const char* Foam::NamedEnum
|
|||||||
const Foam::NamedEnum
|
const Foam::NamedEnum
|
||||||
<
|
<
|
||||||
Foam::functionObjects::turbulenceFields::incompressibleField,
|
Foam::functionObjects::turbulenceFields::incompressibleField,
|
||||||
6
|
7
|
||||||
> Foam::functionObjects::turbulenceFields::incompressibleFieldNames_;
|
> Foam::functionObjects::turbulenceFields::incompressibleFieldNames_;
|
||||||
|
|
||||||
const Foam::word Foam::functionObjects::turbulenceFields::modelName
|
const Foam::word Foam::functionObjects::turbulenceFields::modelName
|
||||||
@ -144,7 +146,14 @@ Foam::functionObjects::turbulenceFields::~turbulenceFields()
|
|||||||
|
|
||||||
bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
||||||
{
|
{
|
||||||
|
if (dict.found("field"))
|
||||||
|
{
|
||||||
|
fieldSet_.insert(word(dict.lookup("field")));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
fieldSet_.insert(wordList(dict.lookup("fields")));
|
fieldSet_.insert(wordList(dict.lookup("fields")));
|
||||||
|
}
|
||||||
|
|
||||||
Info<< type() << " " << name() << ": ";
|
Info<< type() << " " << name() << ": ";
|
||||||
if (fieldSet_.size())
|
if (fieldSet_.size())
|
||||||
@ -189,6 +198,11 @@ bool Foam::functionObjects::turbulenceFields::execute(const bool postProcess)
|
|||||||
processField<scalar>(f, model.epsilon());
|
processField<scalar>(f, model.epsilon());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case cfOmega:
|
||||||
|
{
|
||||||
|
processField<scalar>(f, omega(model));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case cfMut:
|
case cfMut:
|
||||||
{
|
{
|
||||||
processField<scalar>(f, model.mut());
|
processField<scalar>(f, model.mut());
|
||||||
@ -247,6 +261,11 @@ bool Foam::functionObjects::turbulenceFields::execute(const bool postProcess)
|
|||||||
processField<scalar>(f, model.epsilon());
|
processField<scalar>(f, model.epsilon());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ifOmega:
|
||||||
|
{
|
||||||
|
processField<scalar>(f, omega(model));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ifNut:
|
case ifNut:
|
||||||
{
|
{
|
||||||
processField<scalar>(f, model.nut());
|
processField<scalar>(f, model.nut());
|
||||||
|
|||||||
@ -64,6 +64,7 @@ Description
|
|||||||
\plaintable
|
\plaintable
|
||||||
k | turbulence kinetic energy
|
k | turbulence kinetic energy
|
||||||
epsilon | turbulence kinetic energy dissipation rate
|
epsilon | turbulence kinetic energy dissipation rate
|
||||||
|
omega | turbulence specific dissipation rate
|
||||||
nut | turbulence viscosity (incompressible)
|
nut | turbulence viscosity (incompressible)
|
||||||
nuEff | effective turbulence viscosity (incompressible)
|
nuEff | effective turbulence viscosity (incompressible)
|
||||||
mut | turbulence viscosity (compressible)
|
mut | turbulence viscosity (compressible)
|
||||||
@ -113,6 +114,7 @@ public:
|
|||||||
{
|
{
|
||||||
cfK,
|
cfK,
|
||||||
cfEpsilon,
|
cfEpsilon,
|
||||||
|
cfOmega,
|
||||||
cfMut,
|
cfMut,
|
||||||
cfMuEff,
|
cfMuEff,
|
||||||
cfAlphat,
|
cfAlphat,
|
||||||
@ -120,18 +122,19 @@ public:
|
|||||||
cfR,
|
cfR,
|
||||||
cfDevRhoReff
|
cfDevRhoReff
|
||||||
};
|
};
|
||||||
static const NamedEnum<compressibleField, 8> compressibleFieldNames_;
|
static const NamedEnum<compressibleField, 9> compressibleFieldNames_;
|
||||||
|
|
||||||
enum incompressibleField
|
enum incompressibleField
|
||||||
{
|
{
|
||||||
ifK,
|
ifK,
|
||||||
ifEpsilon,
|
ifEpsilon,
|
||||||
|
ifOmega,
|
||||||
ifNut,
|
ifNut,
|
||||||
ifNuEff,
|
ifNuEff,
|
||||||
ifR,
|
ifR,
|
||||||
ifDevReff
|
ifDevReff
|
||||||
};
|
};
|
||||||
static const NamedEnum<incompressibleField, 6> incompressibleFieldNames_;
|
static const NamedEnum<incompressibleField, 7> incompressibleFieldNames_;
|
||||||
|
|
||||||
static const word modelName;
|
static const word modelName;
|
||||||
|
|
||||||
@ -157,6 +160,10 @@ protected:
|
|||||||
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tvalue
|
const tmp<GeometricField<Type, fvPatchField, volMesh>>& tvalue
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//- Return omega calculated from k and epsilon
|
||||||
|
template<class Model>
|
||||||
|
tmp<volScalarField> omega(const Model& model) const;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@ -72,4 +72,34 @@ void Foam::functionObjects::turbulenceFields::processField
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Model>
|
||||||
|
Foam::tmp<Foam::volScalarField>
|
||||||
|
Foam::functionObjects::turbulenceFields::omega
|
||||||
|
(
|
||||||
|
const Model& model
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const scalar Cmu = 0.09;
|
||||||
|
|
||||||
|
// Assume k and epsilon are available
|
||||||
|
const volScalarField k(model.k());
|
||||||
|
const volScalarField epsilon(model.epsilon());
|
||||||
|
|
||||||
|
return tmp<volScalarField>
|
||||||
|
(
|
||||||
|
new volScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"omega",
|
||||||
|
k.mesh().time().timeName(),
|
||||||
|
k.mesh()
|
||||||
|
),
|
||||||
|
epsilon/(Cmu*k),
|
||||||
|
epsilon.boundaryField().types()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user