From 657c2909ed646481e4cb2bd91117e69298561377 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Thu, 9 Jun 2016 17:17:19 +0100 Subject: [PATCH] createTurbulenceFields: utility replaced by 'turbulenceFields' functionObject used with the '-postProcess' option --- .../createTurbulenceFields/Make/files | 3 - .../createTurbulenceFields/Make/options | 16 -- .../createTurbulenceFields/createFields.H | 22 --- .../createTurbulenceFields.C | 157 ------------------ bin/createTurbulenceFields | 40 +++++ etc/caseDicts/postProcessing/fields/R | 2 +- .../postProcessing/fields/turbulenceFields | 20 +++ .../field/turbulenceFields/turbulenceFields.C | 29 +++- .../field/turbulenceFields/turbulenceFields.H | 11 +- .../turbulenceFieldsTemplates.C | 30 ++++ 10 files changed, 124 insertions(+), 206 deletions(-) delete mode 100644 applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/files delete mode 100644 applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/options delete mode 100644 applications/utilities/postProcessing/turbulence/createTurbulenceFields/createFields.H delete mode 100644 applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C create mode 100755 bin/createTurbulenceFields create mode 100644 etc/caseDicts/postProcessing/fields/turbulenceFields diff --git a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/files b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/files deleted file mode 100644 index 4d5a4464aaa..00000000000 --- a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -createTurbulenceFields.C - -EXE = $(FOAM_APPBIN)/createTurbulenceFields diff --git a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/options b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/options deleted file mode 100644 index 9443f06071a..00000000000 --- a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/Make/options +++ /dev/null @@ -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 diff --git a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createFields.H b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createFields.H deleted file mode 100644 index 08f2c286069..00000000000 --- a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createFields.H +++ /dev/null @@ -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) - ); diff --git a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C b/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C deleted file mode 100644 index f1d37ed6a56..00000000000 --- a/applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C +++ /dev/null @@ -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; -} - - -// ************************************************************************* // diff --git a/bin/createTurbulenceFields b/bin/createTurbulenceFields new file mode 100755 index 00000000000..0c0eaa9db66 --- /dev/null +++ b/bin/createTurbulenceFields @@ -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)'" + +#------------------------------------------------------------------------------ diff --git a/etc/caseDicts/postProcessing/fields/R b/etc/caseDicts/postProcessing/fields/R index e7c63b3dec6..7cade562409 100644 --- a/etc/caseDicts/postProcessing/fields/R +++ b/etc/caseDicts/postProcessing/fields/R @@ -11,7 +11,7 @@ R type turbulenceFields; libs ("libfieldFunctionObjects.so"); - fields (R); + field R; executeControl writeTime; writeControl writeTime; diff --git a/etc/caseDicts/postProcessing/fields/turbulenceFields b/etc/caseDicts/postProcessing/fields/turbulenceFields new file mode 100644 index 00000000000..91aa2542059 --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/turbulenceFields @@ -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; +} + +// ************************************************************************* // diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/functionObjects/field/turbulenceFields/turbulenceFields.C index 20733ba273f..ee58e8e47fd 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -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()); diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.H b/src/functionObjects/field/turbulenceFields/turbulenceFields.H index 064664a17e2..6b2d8b15ef1 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.H +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.H @@ -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: diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C index b8c2b6440f3..248fcbf2a01 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -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() + ) + ); +} + + // ************************************************************************* // -- GitLab