diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 998d91955e..333defc2ba 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -9,6 +9,9 @@ dsmcFields/dsmcFieldsFunctionObject.C pressureCoefficient/pressureCoefficient.C pressureCoefficient/pressureCoefficientFunctionObject.C +pressureTools/pressureTools.C +pressureTools/pressureToolsFunctionObject.C + staticPressure/staticPressure.C staticPressure/staticPressureFunctionObject.C diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/IOpressureTools.H b/src/postProcessing/functionObjects/utilities/pressureTools/IOpressureTools.H new file mode 100644 index 0000000000..4d10f44720 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureTools/IOpressureTools.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 . + +Typedef + Foam::IOpressureTools + +Description + Instance of the generic IOOutputFilter for pressureTools. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOpressureTools_H +#define IOpressureTools_H + +#include "pressureTools.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter IOpressureTools; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C new file mode 100644 index 0000000000..6d70be969a --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.C @@ -0,0 +1,245 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#include "pressureTools.H" +#include "volFields.H" +#include "dictionary.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::pressureTools, 0); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::word Foam::pressureTools::pName() const +{ + word fieldName = "p"; + + if (calcTotal_) + { + fieldName = "total(" + fieldName + ")"; + } + else + { + fieldName = "static(" + fieldName + ")"; + } + + if (calcCoeff_) + { + fieldName = fieldName + "_coeff"; + } + + return fieldName; +} + + +Foam::dimensionedScalar Foam::pressureTools::rho +( + const volScalarField& p +) const +{ + if (p.dimensions() == dimPressure) + { + return dimensionedScalar("1", dimless, 1.0); + } + else + { + return dimensionedScalar("rhoRef", dimDensity, rhoRef_); + } +} + + +Foam::dimensionedScalar Foam::pressureTools::pRef() const +{ + dimensionedScalar value("pRef", dimPressure, 0.0); + + if (calcTotal_) + { + value.value() += pRef_; + } + + return pRef(); +} + + +Foam::tmp Foam::pressureTools::pDyn() const +{ + const fvMesh& mesh = refCast(obr_); + + tmp tpDyn + ( + new volScalarField + ( + IOobject + ( + "pDyn", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dimPressure, 0.0) + ) + ); + + if (calcTotal_) + { + const volVectorField& U = obr_.lookupObject(UName_); + + tpDyn() == 0.5*magSqr(U); + } + + return tpDyn; +} + + +Foam::tmp Foam::pressureTools::convertToCoeff +( + const volScalarField& p +) const +{ + tmp tCoeff(p); + + if (calcCoeff_) + { + tCoeff() /= pDyn(); + } + + return tCoeff; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pressureTools::pressureTools +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + calcTotal_(false), + calcCoeff_(false), + pName_("p"), + UName_("U"), + pRef_(0.0), + rhoRef_(1.0) +{ + // Check if the available mesh is an fvMesh, otherwise deactivate + if (!isA(obr_)) + { + active_ = false; + WarningIn + ( + "pressureTools::pressureTools" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." << nl + << endl; + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::pressureTools::~pressureTools() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::pressureTools::read(const dictionary& dict) +{ + if (active_) + { + dict.readIfPresent("pName", pName_); + dict.readIfPresent("UName", UName_); + + const volScalarField& p = obr_.lookupObject(pName_); + + if (p.dimensions() != p.dimensions()) + { + dict.lookup("rhoRef") >> rhoRef_; + } + + dict.lookup("calcTotal") >> calcTotal_; + if (calcTotal_) + { + dict.lookup("pRef") >> pRef_; + } + + dict.lookup("calcCoeff") >> calcCoeff_; + } +} + + +void Foam::pressureTools::execute() +{ + // Do nothing - only valid on write +} + + +void Foam::pressureTools::end() +{ + // Do nothing - only valid on write +} + + +void Foam::pressureTools::write() +{ + if (active_) + { + const volScalarField& p = obr_.lookupObject(pName_); + + volScalarField pResult + ( + IOobject + ( + pName(), + obr_.time().timeName(), + obr_, + IOobject::NO_READ + ), + convertToCoeff(rho(p)*(p + pDyn()) + pRef()) + ); + + pResult.write(); + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H new file mode 100644 index 0000000000..702d496199 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureTools.H @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Class + Foam::pressureTools + +Description + This function object includes tools to manipulate the pressure into + different forms. These currently include: + + - static pressure + + p_s = rho*p_k + + - total pressure + + p_T = pRef + p_s + 0.5 rho |U|^2 + + - static pressure coefficient + + Cp_s = p_s / (0.5 rho |U|^2) + + - total pressure coefficient + + Cp_T = p_T / (0.5 rho |U|^2) + + The function object will operate on both kinematic (p_k) and static + pressure (p_s) fields, and the result is written as a volScalarField. + +SourceFiles + pressureTools.C + IOpressureTools.H + +\*---------------------------------------------------------------------------*/ + +#ifndef pressureTools_H +#define pressureTools_H + +#include "volFieldsFwd.H" +#include "pointFieldFwd.H" +#include "dimensionedScalar.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class pressureTools Declaration +\*---------------------------------------------------------------------------*/ + +class pressureTools +{ + // Private data + + //- Name of this set of pressureTools objects + word name_; + + //- Reference to the database + const objectRegistry& obr_; + + //- On/off switch + bool active_; + + //- Flag to calculate total pressure + bool calcTotal_; + + //- Flag to calculate pressure coefficient + bool calcCoeff_; + + //- Name of pressure field, default is "p" + word pName_; + + //- Name of velocity field, default is "U" + word UName_; + + //- Reference pressure level (used for total pressure) + scalar pRef_; + + //- Reference density value + scalar rhoRef_; + + + // Private Member Functions + + //- Return the name of the derived pressure field + word pName() const; + + //- Return the density scaling if supplied with kinematic pressure + dimensionedScalar rho(const volScalarField& p) const; + + //- Return the reference pressure + dimensionedScalar pRef() const; + + //- Calculate and return the (kinematic) dynamic pressure + tmp pDyn() const; + + //- Convert to coeff data by applying the pDyn scaling + tmp convertToCoeff(const volScalarField& p) const; + + //- Disallow default bitwise copy construct + pressureTools(const pressureTools&); + + //- Disallow default bitwise assignment + void operator=(const pressureTools&); + + +public: + + //- Runtime type information + TypeName("pressureTools"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + pressureTools + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~pressureTools(); + + + // Member Functions + + //- Return name of the set of pressureTools + virtual const word& name() const + { + return name_; + } + + //- Read the pressureTools 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(); + + //- Calculate the pressureTools and 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 + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureToolsFunctionObject.C b/src/postProcessing/functionObjects/utilities/pressureTools/pressureToolsFunctionObject.C new file mode 100644 index 0000000000..a512c193c8 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureToolsFunctionObject.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 . + +\*---------------------------------------------------------------------------*/ + +#include "pressureToolsFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(pressureToolsFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + pressureToolsFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/pressureTools/pressureToolsFunctionObject.H b/src/postProcessing/functionObjects/utilities/pressureTools/pressureToolsFunctionObject.H new file mode 100644 index 0000000000..0b83c7d148 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureTools/pressureToolsFunctionObject.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 . + +Typedef + Foam::pressureToolsFunctionObject + +Description + FunctionObject wrapper around pressureTools to allow it to be created via + the functions entry within controlDict. + +SourceFiles + pressureToolsFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pressureToolsFunctionObject_H +#define pressureToolsFunctionObject_H + +#include "pressureTools.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject + pressureToolsFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //