diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 88d8fb9c42c9047d80236394e9207668d14bdd7c..c632fc6222f27b02bfdf0c557a5ff822962d1a45 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -1,5 +1,8 @@ codedFunctionObject/codedFunctionObject.C +pressureCoefficient/pressureCoefficient.C +pressureCoefficient/pressureCoefficientFunctionObject.C + staticPressure/staticPressure.C staticPressure/staticPressureFunctionObject.C diff --git a/src/postProcessing/functionObjects/utilities/pressureCoefficient/IOpressureCoefficient.H b/src/postProcessing/functionObjects/utilities/pressureCoefficient/IOpressureCoefficient.H new file mode 100644 index 0000000000000000000000000000000000000000..120fcc007c858064dc22dfb67574f578fdeaa30a --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureCoefficient/IOpressureCoefficient.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::IOpressureCoefficient + +Description + Instance of the generic IOOutputFilter for pressureCoefficient. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOpressureCoefficient_H +#define IOpressureCoefficient_H + +#include "pressureCoefficient.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter<pressureCoefficient> IOpressureCoefficient; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficient.C b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficient.C new file mode 100644 index 0000000000000000000000000000000000000000..5ec597f9bfe0495d2e2cf3bf868d1e299999943b --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficient.C @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "pressureCoefficient.H" +#include "volFields.H" +#include "dictionary.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::pressureCoefficient, 0); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> Foam::pressureCoefficient::rho() const +{ + if (rhoName_ == "rhoInf") + { + const fvMesh& mesh = refCast<const fvMesh>(obr_); + + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "rho", + mesh.time().timeName(), + mesh + ), + mesh, + dimensionedScalar("rho", dimDensity, rhoRef_) + ) + ); + } + else + { + return(obr_.lookupObject<volScalarField>(rhoName_)); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pressureCoefficient::pressureCoefficient +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + pName_("p"), + rhoName_(word::null), + rhoRef_(-GREAT), + magUinf_(0.0) +{ + // Check if the available mesh is an fvMesh, otherwise deactivate + if (!isA<fvMesh>(obr_)) + { + active_ = false; + WarningIn + ( + "pressureCoefficient::pressureCoefficient" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." << nl + << endl; + } + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::pressureCoefficient::~pressureCoefficient() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::pressureCoefficient::read(const dictionary& dict) +{ + if (active_) + { + pName_ = dict.lookupOrDefault<word>("pName", "p"); + + rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho"); + if (rhoName_ == "rhoInf") + { + dict.lookup("rhoInf") >> rhoRef_; + } + + dict.lookup("magUinf") >> magUinf_; + } +} + + +void Foam::pressureCoefficient::execute() +{ + // Do nothing - only valid on write +} + + +void Foam::pressureCoefficient::end() +{ + // Do nothing - only valid on write +} + + +void Foam::pressureCoefficient::write() +{ + if (active_) + { + const volScalarField& p = obr_.lookupObject<volScalarField>(pName_); + + volScalarField pressureCoefficient + ( + IOobject + ( + "pressureCoefficient", + obr_.time().timeName(), + obr_, + IOobject::NO_READ + ), + p/(0.5*rho()*sqr(magUinf_)) + ); + + pressureCoefficient.write(); + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficient.H b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficient.H new file mode 100644 index 0000000000000000000000000000000000000000..aaf0ca499b35f28b86e0e874d45a4099be6055a4 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficient.H @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::pressureCoefficient + +Description + Calculates pressure coefficient, c_p + + c_p = p/p_dyn,inf + + where: + + p_dyn,inf = 0.5*rho*mag(U_inf)^2 + +SourceFiles + pressureCoefficient.C + IOpressureCoefficient.H + +\*---------------------------------------------------------------------------*/ + +#ifndef pressureCoefficient_H +#define pressureCoefficient_H + +#include "volFieldsFwd.H" +#include "pointFieldFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class pressureCoefficient Declaration +\*---------------------------------------------------------------------------*/ + +class pressureCoefficient +{ + // Private data + + //- Name of this set of pressureCoefficient objects + word name_; + + const objectRegistry& obr_; + + //- on/off switch + bool active_; + + //- Name of pressure field, default is "p" + word pName_; + + //- Name of density field (optional) + word rhoName_; + + //- Reference density needed for incompressible calculations [kg/m3] + scalar rhoRef_; + + //- Free stream velocity magnitude [m/s] + scalar magUinf_; + + + // Private Member Functions + + //- Return rho if rhoName is specified otherwise rhoRef + tmp<volScalarField> rho() const; + + //- Return rhoRef if the pressure field is dynamic, i.e. p/rho + // otherwise return 1 + scalar rho(const volScalarField& p) const; + + //- Disallow default bitwise copy construct + pressureCoefficient(const pressureCoefficient&); + + //- Disallow default bitwise assignment + void operator=(const pressureCoefficient&); + + +public: + + //- Runtime type information + TypeName("pressureCoefficient"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + pressureCoefficient + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~pressureCoefficient(); + + + // Member Functions + + //- Return name of the set of pressureCoefficient + virtual const word& name() const + { + return name_; + } + + //- Read the pressureCoefficient 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 pressureCoefficient 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/pressureCoefficient/pressureCoefficientFunctionObject.C b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficientFunctionObject.C new file mode 100644 index 0000000000000000000000000000000000000000..7d75af07f0cffe76dc05263ebbf17347e9a9365f --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficientFunctionObject.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 "pressureCoefficientFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(pressureCoefficientFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + pressureCoefficientFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficientFunctionObject.H b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficientFunctionObject.H new file mode 100644 index 0000000000000000000000000000000000000000..d658646e96b22abc200bcf3ef13db1d7773d0eea --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/pressureCoefficient/pressureCoefficientFunctionObject.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::pressureCoefficientFunctionObject + +Description + FunctionObject wrapper around pressureCoefficient to allow it to be created + via the functions entry within controlDict. + +SourceFiles + pressureCoefficientFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pressureCoefficientFunctionObject_H +#define pressureCoefficientFunctionObject_H + +#include "pressureCoefficient.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject<pressureCoefficient> + pressureCoefficientFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //