/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-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 . \*---------------------------------------------------------------------------*/ #include "turbulenceFields.H" #include "turbulentTransportModel.H" #include "turbulentFluidThermoModel.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { defineTypeNameAndDebug(turbulenceFields, 0); addToRunTimeSelectionTable ( functionObject, turbulenceFields, dictionary ); } } template<> const char* Foam::NamedEnum < Foam::functionObjects::turbulenceFields::compressibleField, 9 >::names[] = { "k", "epsilon", "omega", "mut", "muEff", "alphat", "alphaEff", "R", "devRhoReff" }; const Foam::NamedEnum < Foam::functionObjects::turbulenceFields::compressibleField, 9 > Foam::functionObjects::turbulenceFields::compressibleFieldNames_; template<> const char* Foam::NamedEnum < Foam::functionObjects::turbulenceFields::incompressibleField, 7 >::names[] = { "k", "epsilon", "omega", "nut", "nuEff", "R", "devReff" }; const Foam::NamedEnum < Foam::functionObjects::turbulenceFields::incompressibleField, 7 > Foam::functionObjects::turbulenceFields::incompressibleFieldNames_; const Foam::word Foam::functionObjects::turbulenceFields::modelName ( Foam::turbulenceModel::propertiesName ); // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // bool Foam::functionObjects::turbulenceFields::compressible() { if (obr_.foundObject(modelName)) { return true; } else if (obr_.foundObject(modelName)) { return false; } else { FatalErrorInFunction << "Turbulence model not found in database, deactivating" << exit(FatalError); } return false; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::turbulenceFields::turbulenceFields ( const word& name, const Time& runTime, const dictionary& dict ) : fvMeshFunctionObject(name, runTime, dict), fieldSet_() { read(dict); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::functionObjects::turbulenceFields::~turbulenceFields() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 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"))); } Info<< type() << " " << name() << ": "; if (fieldSet_.size()) { Info<< "storing fields:" << nl; forAllConstIter(wordHashSet, fieldSet_, iter) { Info<< " " << modelName << ':' << iter.key() << nl; } Info<< endl; } else { Info<< "no fields requested to be stored" << nl << endl; } return true; } bool Foam::functionObjects::turbulenceFields::execute() { bool comp = compressible(); if (comp) { const compressible::turbulenceModel& model = obr_.lookupObject(modelName); forAllConstIter(wordHashSet, fieldSet_, iter) { const word& f = iter.key(); switch (compressibleFieldNames_[f]) { case cfK: { processField(f, model.k()); break; } case cfEpsilon: { processField(f, model.epsilon()); break; } case cfOmega: { processField(f, omega(model)); break; } case cfMut: { processField(f, model.mut()); break; } case cfMuEff: { processField(f, model.muEff()); break; } case cfAlphat: { processField(f, model.alphat()); break; } case cfAlphaEff: { processField(f, model.alphaEff()); break; } case cfR: { processField(f, model.R()); break; } case cfDevRhoReff: { processField(f, model.devRhoReff()); break; } default: { FatalErrorInFunction << "Invalid field selection" << abort(FatalError); } } } } else { const incompressible::turbulenceModel& model = obr_.lookupObject(modelName); forAllConstIter(wordHashSet, fieldSet_, iter) { const word& f = iter.key(); switch (incompressibleFieldNames_[f]) { case ifK: { processField(f, model.k()); break; } case ifEpsilon: { processField(f, model.epsilon()); break; } case ifOmega: { processField(f, omega(model)); break; } case ifNut: { processField(f, model.nut()); break; } case ifNuEff: { processField(f, model.nuEff()); break; } case ifR: { processField(f, model.R()); break; } case ifDevReff: { processField(f, model.devReff()); break; } default: { FatalErrorInFunction << "Invalid field selection" << abort(FatalError); } } } } return true; } bool Foam::functionObjects::turbulenceFields::write() { forAllConstIter(wordHashSet, fieldSet_, iter) { const word fieldName = modelName + ':' + iter.key(); writeObject(fieldName); } return true; } // ************************************************************************* //