Skip to content
Snippets Groups Projects
Commit 657c2909 authored by Henry Weller's avatar Henry Weller
Browse files

createTurbulenceFields: utility replaced by 'turbulenceFields' functionObject...

createTurbulenceFields: utility replaced by 'turbulenceFields' functionObject used with the '-postProcess' option
parent 0f5b4f3c
No related branches found
No related tags found
No related merge requests found
Showing
with 124 additions and 206 deletions
createTurbulenceFields.C
EXE = $(FOAM_APPBIN)/createTurbulenceFields
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
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)
);
/*---------------------------------------------------------------------------*\
========= |
\\ / 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;
}
// ************************************************************************* //
#!/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;
libs ("libfieldFunctionObjects.so");
fields (R);
field R;
executeControl writeTime;
writeControl writeTime;
......
/*--------------------------------*- 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
<
Foam::functionObjects::turbulenceFields::compressibleField,
8
9
>::names[] =
{
"k",
"epsilon",
"omega",
"mut",
"muEff",
"alphat",
......@@ -65,18 +66,19 @@ const char* Foam::NamedEnum
const Foam::NamedEnum
<
Foam::functionObjects::turbulenceFields::compressibleField,
8
9
> Foam::functionObjects::turbulenceFields::compressibleFieldNames_;
template<>
const char* Foam::NamedEnum
<
Foam::functionObjects::turbulenceFields::incompressibleField,
6
7
>::names[] =
{
"k",
"epsilon",
"omega",
"nut",
"nuEff",
"R",
......@@ -86,7 +88,7 @@ const char* Foam::NamedEnum
const Foam::NamedEnum
<
Foam::functionObjects::turbulenceFields::incompressibleField,
6
7
> Foam::functionObjects::turbulenceFields::incompressibleFieldNames_;
const Foam::word Foam::functionObjects::turbulenceFields::modelName
......@@ -144,7 +146,14 @@ Foam::functionObjects::turbulenceFields::~turbulenceFields()
bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
{
fieldSet_.insert(wordList(dict.lookup("fields")));
if (dict.found("field"))
{
fieldSet_.insert(word(dict.lookup("field")));
}
else
{
fieldSet_.insert(wordList(dict.lookup("fields")));
}
Info<< type() << " " << name() << ": ";
if (fieldSet_.size())
......@@ -189,6 +198,11 @@ bool Foam::functionObjects::turbulenceFields::execute(const bool postProcess)
processField<scalar>(f, model.epsilon());
break;
}
case cfOmega:
{
processField<scalar>(f, omega(model));
break;
}
case cfMut:
{
processField<scalar>(f, model.mut());
......@@ -247,6 +261,11 @@ bool Foam::functionObjects::turbulenceFields::execute(const bool postProcess)
processField<scalar>(f, model.epsilon());
break;
}
case ifOmega:
{
processField<scalar>(f, omega(model));
break;
}
case ifNut:
{
processField<scalar>(f, model.nut());
......
......@@ -64,6 +64,7 @@ Description
\plaintable
k | turbulence kinetic energy
epsilon | turbulence kinetic energy dissipation rate
omega | turbulence specific dissipation rate
nut | turbulence viscosity (incompressible)
nuEff | effective turbulence viscosity (incompressible)
mut | turbulence viscosity (compressible)
......@@ -113,6 +114,7 @@ public:
{
cfK,
cfEpsilon,
cfOmega,
cfMut,
cfMuEff,
cfAlphat,
......@@ -120,18 +122,19 @@ public:
cfR,
cfDevRhoReff
};
static const NamedEnum<compressibleField, 8> compressibleFieldNames_;
static const NamedEnum<compressibleField, 9> compressibleFieldNames_;
enum incompressibleField
{
ifK,
ifEpsilon,
ifOmega,
ifNut,
ifNuEff,
ifR,
ifDevReff
};
static const NamedEnum<incompressibleField, 6> incompressibleFieldNames_;
static const NamedEnum<incompressibleField, 7> incompressibleFieldNames_;
static const word modelName;
......@@ -157,6 +160,10 @@ protected:
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:
......
......@@ -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()
)
);
}
// ************************************************************************* //
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment