diff --git a/src/postProcessing/functionObjects/IO/Make/files b/src/postProcessing/functionObjects/IO/Make/files index a00b7575f1818723bb0aca82ae027f402b1fd8d7..8aeea600e4fd0300edad8a59d90bbd62f3d7b5cc 100644 --- a/src/postProcessing/functionObjects/IO/Make/files +++ b/src/postProcessing/functionObjects/IO/Make/files @@ -1,6 +1,9 @@ partialWrite/partialWrite.C partialWrite/partialWriteFunctionObject.C +removeRegisteredObject/removeRegisteredObject.C +removeRegisteredObject/removeRegisteredObjectFunctionObject.C + writeRegisteredObject/writeRegisteredObject.C writeRegisteredObject/writeRegisteredObjectFunctionObject.C diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/IOremoveRegisteredObject.H b/src/postProcessing/functionObjects/IO/removeRegisteredObject/IOremoveRegisteredObject.H new file mode 100644 index 0000000000000000000000000000000000000000..d786378ed234e68d1d034b06cf5ffafbcc72b583 --- /dev/null +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/IOremoveRegisteredObject.H @@ -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::IOremoveRegisteredObject + +Description + Instance of the generic IOOutputFilter for removeRegisteredObject. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOremoveRegisteredObject_H +#define IOremoveRegisteredObject_H + +#include "removeRegisteredObject.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter<removeRegisteredObject> IOremoveRegisteredObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C new file mode 100644 index 0000000000000000000000000000000000000000..f89aebd28e8287cec2a032fe7d2ad9d9e9580945 --- /dev/null +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.C @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "removeRegisteredObject.H" +#include "dictionary.H" +#include "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::removeRegisteredObject, 0); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::removeRegisteredObject::removeRegisteredObject +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + objectNames_() +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::removeRegisteredObject::~removeRegisteredObject() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::removeRegisteredObject::read(const dictionary& dict) +{ + dict.lookup("objectNames") >> objectNames_; +} + + +void Foam::removeRegisteredObject::execute() +{ + forAll(objectNames_, i) + { + if (obr_.foundObject<regIOobject>(objectNames_[i])) + { + const regIOobject& obj = + obr_.lookupObject<regIOobject>(objectNames_[i]); + + if (obj.ownedByRegistry()) + { + const_cast<regIOobject&>(obj).release(); + delete &obj; + } + } + else + { + WarningIn("Foam::removeRegisteredObject::write()") + << "Object " << objectNames_[i] << " not found in " + << "database. Available objects:" << nl << obr_.sortedToc() + << endl; + } + + } +} + + +void Foam::removeRegisteredObject::end() +{ + // Do nothing - only valid on execute +} + + +void Foam::removeRegisteredObject::write() +{ + // Do nothing - only valid on execute +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H new file mode 100644 index 0000000000000000000000000000000000000000..79bed8aa1cb984efd60d254dfca26b17dbbebb19 --- /dev/null +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObject.H @@ -0,0 +1,145 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::removeRegisteredObject + +Description + Removes registered IO objects if present in the database + +SourceFiles + removeRegisteredObject.C + IOremoveRegisteredObject.H + +\*---------------------------------------------------------------------------*/ + +#ifndef removeRegisteredObject_H +#define removeRegisteredObject_H + +#include "pointFieldFwd.H" +#include "wordList.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class removeRegisteredObject Declaration +\*---------------------------------------------------------------------------*/ + +class removeRegisteredObject +{ +protected: + + // Private data + + //- Name of this set of removeRegisteredObject + word name_; + + const objectRegistry& obr_; + + // Read from dictionary + + //- Names of objects to control + wordList objectNames_; + + + // Private Member Functions + + + //- Disallow default bitwise copy construct + removeRegisteredObject(const removeRegisteredObject&); + + //- Disallow default bitwise assignment + void operator=(const removeRegisteredObject&); + + +public: + + //- Runtime type information + TypeName("removeRegisteredObject"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + removeRegisteredObject + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~removeRegisteredObject(); + + + // Member Functions + + //- Return name of the removeRegisteredObject + virtual const word& name() const + { + return name_; + } + + //- Read the removeRegisteredObject 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(); + + //- Write the removeRegisteredObject + 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 + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.C b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.C new file mode 100644 index 0000000000000000000000000000000000000000..652e60e87d5db8b2eb53e0a7c1ca5435714b5777 --- /dev/null +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.C @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "removeRegisteredObjectFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug + ( + removeRegisteredObjectFunctionObject, + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + removeRegisteredObjectFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.H b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.H new file mode 100644 index 0000000000000000000000000000000000000000..9bc0e1be51b101aea9fa7aa35324def13b170669 --- /dev/null +++ b/src/postProcessing/functionObjects/IO/removeRegisteredObject/removeRegisteredObjectFunctionObject.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::removeRegisteredObjectFunctionObject + +Description + FunctionObject wrapper around removeRegisteredObject to allow them to be + created via the functions entry within controlDict. + +SourceFiles + removeRegisteredObjectFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef removeRegisteredObjectFunctionObject_H +#define removeRegisteredObjectFunctionObject_H + +#include "removeRegisteredObject.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject<removeRegisteredObject> + removeRegisteredObjectFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C index bee009a1bb5f5f57e0a8a0a37483f82da22b72f2..c6516b70459416fad7508e4acf038153b9ea3cb4 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C @@ -93,14 +93,11 @@ void Foam::writeRegisteredObject::write() } else { - WarningIn - ( - "Foam::writeRegisteredObject::read(const dictionary&)" - ) << "Object " << objectNames_[i] << " not found in " + WarningIn("Foam::writeRegisteredObject::write()") + << "Object " << objectNames_[i] << " not found in " << "database. Available objects:" << nl << obr_.sortedToc() << endl; } - } } diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index ab0c44e69d1a5716e54a78dea1df3ff9e2a81522..e351784bdcb4e26fa40de04f36d6995f51f9ccf3 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -29,6 +29,9 @@ streamLine/streamLineParticle.C streamLine/streamLineParticleCloud.C streamLine/streamLineFunctionObject.C +turbulenceFields/turbulenceFields.C +turbulenceFields/turbulenceFieldsFunctionObject.C + wallBoundedStreamLine/wallBoundedStreamLine.C wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C wallBoundedStreamLine/wallBoundedStreamLineParticle.C diff --git a/src/postProcessing/functionObjects/field/Make/options b/src/postProcessing/functionObjects/field/Make/options index 1e254fd4bb4cae169286a570fe144eb9d0f4c88f..d7c5f944c60caad1eb365309b14a6bb6e6913c9f 100644 --- a/src/postProcessing/functionObjects/field/Make/options +++ b/src/postProcessing/functionObjects/field/Make/options @@ -2,10 +2,17 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(LIB_SRC)/sampling/lnInclude + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude LIB_LIBS = \ -lfiniteVolume \ -lmeshTools \ -llagrangian \ - -lsampling + -lsampling \ + -lincompressibleTransportModels \ + -lcompressibleTurbulenceModel \ + -lincompressibleTurbulenceModel + diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/IOturbulenceFields.H b/src/postProcessing/functionObjects/field/turbulenceFields/IOturbulenceFields.H new file mode 100644 index 0000000000000000000000000000000000000000..3ac6a32e54f52621b33282b6c921f97c844f05ba --- /dev/null +++ b/src/postProcessing/functionObjects/field/turbulenceFields/IOturbulenceFields.H @@ -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::IOturbulenceFields + +Description + Instance of the generic IOOutputFilter for turbulenceFields. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOturbulenceFields_H +#define IOturbulenceFields_H + +#include "turbulenceFields.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter<turbulenceFields> IOturbulenceFields; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/postProcessingDict b/src/postProcessing/functionObjects/field/turbulenceFields/postProcessingDict new file mode 100644 index 0000000000000000000000000000000000000000..6d4b0409fa5f30c3a939f6cd86c237d499b37a93 --- /dev/null +++ b/src/postProcessing/functionObjects/field/turbulenceFields/postProcessingDict @@ -0,0 +1,34 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object postProcessingDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +functions +{ + turbulenceFields1 + { + type turbulenceFields; + functionObjectLibs ("libfieldFunctionObjects.so"); + enabled true; + outputControl timeStep; + outputInterval 1; + + fields + ( + R + ); + } +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C new file mode 100644 index 0000000000000000000000000000000000000000..ab21ab2242cf77639648386b09121424c30bae12 --- /dev/null +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -0,0 +1,267 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "turbulenceFields.H" +#include "dictionary.H" +#include "compressible/turbulenceModel/turbulenceModel.H" +#include "incompressible/turbulenceModel/turbulenceModel.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(Foam::turbulenceFields, 0); + + template<> + const char* NamedEnum<turbulenceFields::compressibleField, 6>::names[] = + { + "R", + "devRhoReff", + "mut", + "muEff", + "alphat", + "alphaEff" + }; + const NamedEnum<turbulenceFields::compressibleField, 6> + turbulenceFields::compressibleFieldNames_; + + template<> + const char* NamedEnum<turbulenceFields::incompressibleField, 4>::names[] = + { + "R", + "devReff", + "nut", + "nuEff" + }; + const NamedEnum<turbulenceFields::incompressibleField, 4> + turbulenceFields::incompressibleFieldNames_; + + const word turbulenceFields::modelName = "turbulenceModel"; +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool Foam::turbulenceFields::compressible() +{ + if (obr_.foundObject<compressible::turbulenceModel>(modelName)) + { + return true; + } + else if (obr_.foundObject<incompressible::turbulenceModel>(modelName)) + { + return false; + } + else + { + WarningIn("Foam::word& Foam::turbulenceFields::compressible() const") + << "Turbulence model not found in database, deactivating"; + active_ = false; + } + + return false; +} + + +Foam::IOobject Foam::turbulenceFields::io(const word& fieldName) const +{ + return + IOobject + ( + fieldName, + obr_.time().timeName(), + obr_, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::turbulenceFields::turbulenceFields +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + fieldSet_() +{ + // Check if the available mesh is an fvMesh otherise deactivate + if (!isA<fvMesh>(obr_)) + { + active_ = false; + WarningIn + ( + "turbulenceFields::turbulenceFields" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." + << endl; + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::turbulenceFields::~turbulenceFields() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::turbulenceFields::read(const dictionary& dict) +{ + if (active_) + { + dict.lookup("fields") >> fieldSet_; + + execute(); + } +} + + +void Foam::turbulenceFields::execute() +{ + bool comp = compressible(); + + if (!active_) + { + return; + } + + if (comp) + { + const compressible::turbulenceModel& model = + obr_.lookupObject<compressible::turbulenceModel>(modelName); + + forAll(fieldSet_, fieldI) + { + const word& f = fieldSet_[fieldI]; + switch (compressibleFieldNames_[f]) + { + case cfR: + { + processField<symmTensor>(f, model.R()); + break; + } + case cfDevRhoReff: + { + processField<symmTensor>(f, model.devRhoReff()); + break; + } + case cfMut: + { + processField<scalar>(f, model.mut()); + break; + } + case cfMuEff: + { + processField<scalar>(f, model.muEff()); + break; + } + case cfAlphat: + { + processField<scalar>(f, model.alphat()); + break; + } + case cfAlphaEff: + { + processField<scalar>(f, model.alphaEff()); + break; + } + default: + { + FatalErrorIn("void Foam::turbulenceFields::execute()") + << "Invalid field selection" << abort(FatalError); + } + } + } + } + else + { + const incompressible::turbulenceModel& model = + obr_.lookupObject<incompressible::turbulenceModel>(modelName); + + forAll(fieldSet_, fieldI) + { + const word& f = fieldSet_[fieldI]; + switch (incompressibleFieldNames_[f]) + { + case ifR: + { + processField<symmTensor>(f, model.R()); + break; + } + case ifDevReff: + { + processField<symmTensor>(f, model.devReff()); + break; + } + case ifNut: + { + processField<scalar>(f, model.nut()); + break; + } + case ifNuEff: + { + processField<scalar>(f, model.nuEff()); + break; + } + default: + { + FatalErrorIn("void Foam::turbulenceFields::execute()") + << "Invalid field selection" << abort(FatalError); + } + } + } + } +} + + +void Foam::turbulenceFields::end() +{ + // Do nothing +} + + +void Foam::turbulenceFields::write() +{ + // Do nothing +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.H b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.H new file mode 100644 index 0000000000000000000000000000000000000000..1d33b65792235b69a69cdb61ae52365b1712dcd2 --- /dev/null +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFields.H @@ -0,0 +1,192 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::turbulenceFields + +Description + Stores turbulence fields on the mesh database for further manipulation. + +SourceFiles + turbulenceFields.C + IOturbulenceFields.H + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulenceFields_H +#define turbulenceFields_H + +#include "wordList.H" +#include "IOobject.H" +#include "NamedEnum.H" +#include "pointField.H" +#include "volFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class turbulenceFields Declaration +\*---------------------------------------------------------------------------*/ + +class turbulenceFields +{ +public: + + enum compressibleField + { + cfR, + cfDevRhoReff, + cfMut, + cfMuEff, + cfAlphat, + cfAlphaEff + }; + static const NamedEnum<compressibleField, 6> compressibleFieldNames_; + + enum incompressibleField + { + ifR, + ifDevReff, + ifNut, + ifNuEff + }; + static const NamedEnum<incompressibleField, 4> incompressibleFieldNames_; + + static const word modelName; + + +protected: + + // Protected data + + //- Name of this set of turbulenceFields object + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- Fields to load + wordList fieldSet_; + + + // Protected Member Functions + + //- Disallow default bitwise copy construct + turbulenceFields(const turbulenceFields&); + + //- Disallow default bitwise assignment + void operator=(const turbulenceFields&); + + //- Return true if compressible turbulence model is identified + bool compressible(); + + //- Helper function to return IOobject + IOobject io(const word& fieldName) const; + + //- Process the turbulence field + template<class Type> + void processField + ( + const word& fieldName, + const GeometricField<Type, fvPatchField, volMesh>& value + ); + + +public: + + //- Runtime type information + TypeName("turbulenceFields"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + turbulenceFields + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~turbulenceFields(); + + + // Member Functions + + //- Return name of the turbulenceFields object + virtual const word& name() const + { + return name_; + } + + //- Read the field min/max 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(); + + //- 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 + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "turbulenceFieldsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsFunctionObject.C b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsFunctionObject.C new file mode 100644 index 0000000000000000000000000000000000000000..f5f542d12f321c39415ad7ee1b8715a94db4b669 --- /dev/null +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsFunctionObject.C @@ -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 "turbulenceFieldsFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(turbulenceFieldsFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + turbulenceFieldsFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsFunctionObject.H b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsFunctionObject.H new file mode 100644 index 0000000000000000000000000000000000000000..6631fb143448fdf8fea64edbef3c48bd8d6a6ade --- /dev/null +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsFunctionObject.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::turbulenceFieldsFunctionObject + +Description + FunctionObject wrapper around turbulenceFields to allow them to be created + via the functions entry within controlDict. + +SourceFiles + turbulenceFieldsFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulenceFieldsFunctionObject_H +#define turbulenceFieldsFunctionObject_H + +#include "turbulenceFields.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject<turbulenceFields> + turbulenceFieldsFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..44cd320c5fd30f3f62c87cfcc37c2d43fc74d0f7 --- /dev/null +++ b/src/postProcessing/functionObjects/field/turbulenceFields/turbulenceFieldsTemplates.C @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "volFields.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template<class Type> +void Foam::turbulenceFields::processField +( + const word& fieldName, + const GeometricField<Type, fvPatchField, volMesh>& value +) +{ + typedef GeometricField<Type, fvPatchField, volMesh> FieldType; + if (obr_.foundObject<FieldType>(fieldName)) + { + FieldType& fld = + const_cast<FieldType&>(obr_.lookupObject<FieldType>(fieldName)); + fld == value; + } + else + { + obr_.store(new FieldType(io(fieldName), value)); + } +} + + +// ************************************************************************* //