diff --git a/src/postProcessing/functionObjects/utilities/Make/files b/src/postProcessing/functionObjects/utilities/Make/files index 4f132af3fa..01b4d0c4c9 100644 --- a/src/postProcessing/functionObjects/utilities/Make/files +++ b/src/postProcessing/functionObjects/utilities/Make/files @@ -9,6 +9,9 @@ Lambda2/Lambda2FunctionObject.C Peclet/Peclet.C Peclet/PecletFunctionObject.C +Q/Q.C +Q/QFunctionObject.C + DESModelRegions/DESModelRegions.C DESModelRegions/DESModelRegionsFunctionObject.C diff --git a/src/postProcessing/functionObjects/utilities/Q/IOQ.H b/src/postProcessing/functionObjects/utilities/Q/IOQ.H new file mode 100644 index 0000000000..f4739a0876 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/Q/IOQ.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::IOQ + +Description + Instance of the generic IOOutputFilter for Q. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOQ_H +#define IOQ_H + +#include "Q.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter IOQ; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Q/Q.C b/src/postProcessing/functionObjects/utilities/Q/Q.C new file mode 100644 index 0000000000..3cfb670b6b --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/Q/Q.C @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "Q.H" +#include "volFields.H" +#include "dictionary.H" +#include "fvcGrad.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::Q, 0); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::Q::Q +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + obr_(obr), + active_(true), + UName_("U") +{ + // Check if the available mesh is an fvMesh, otherwise deactivate + if (!isA(obr_)) + { + active_ = false; + WarningIn + ( + "Q::Q" + "(" + "const word&, " + "const objectRegistry&, " + "const dictionary&, " + "const bool" + ")" + ) << "No fvMesh available, deactivating." << nl + << endl; + } + + read(dict); + + if (active_) + { + const fvMesh& mesh = refCast(obr_); + + volScalarField* QPtr + ( + new volScalarField + ( + IOobject + ( + type(), + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("0", dimless, 0.0) + ) + ); + + mesh.objectRegistry::store(QPtr); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::Q::~Q() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::Q::read(const dictionary& dict) +{ + if (active_) + { + UName_ = dict.lookupOrDefault("UName", "U"); + } +} + + +void Foam::Q::execute() +{ + // Do nothing - only valid on write +} + + +void Foam::Q::end() +{ + // Do nothing - only valid on write +} + + +void Foam::Q::write() +{ + if (active_) + { + const fvMesh& mesh = refCast(obr_); + + const volVectorField& U = + mesh.lookupObject(UName_); + + const volTensorField gradU(fvc::grad(U)); + + volScalarField& Q = + const_cast + ( + mesh.lookupObject(type()) + ); + + Q = 0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU)))); + + Q.correctBoundaryConditions(); + + Q.write(); + + Info<< type() << " output:" << nl + << " writing " << Q.name() << " field" << nl << endl; + } +} + + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Q/Q.H b/src/postProcessing/functionObjects/utilities/Q/Q.H new file mode 100644 index 0000000000..c42099dac7 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/Q/Q.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::Q + +Group + grpUtilitiesFunctionObjects + +Description + This function object calculates and outputs the second invariant of the + velocity gradient tensor [1/s^2]. + + \f[ + Q = 0.5(sqr(tr(\nabla U)) - tr(((\nabla U) \cdot (\nabla U)))) + \f] + +SourceFiles + Q.C + IOQ.H + +\*---------------------------------------------------------------------------*/ + +#ifndef Q_H +#define Q_H + +#include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" +#include "pointFieldFwd.H" +#include "OFstream.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class Q Declaration +\*---------------------------------------------------------------------------*/ + +class Q +{ + // Private data + + //- Name of this set of Q objects + word name_; + + //- Reference to the database + const objectRegistry& obr_; + + //- On/off switch + bool active_; + + //- Name of velocity field, default is "U" + word UName_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + Q(const Q&); + + //- Disallow default bitwise assignment + void operator=(const Q&); + + +public: + + //- Runtime type information + TypeName("Q"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + Q + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~Q(); + + + // Member Functions + + //- Return name of the set of Q + virtual const word& name() const + { + return name_; + } + + //- Read the Q 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 Q 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/Q/QFunctionObject.C b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.C new file mode 100644 index 0000000000..0fa525f0b6 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.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 "QFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(QFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + QFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H new file mode 100644 index 0000000000..4c96aac505 --- /dev/null +++ b/src/postProcessing/functionObjects/utilities/Q/QFunctionObject.H @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::QFunctionObject + +Description + FunctionObject wrapper around Q to allow it to be created + via the functions entry within controlDict. + +SourceFiles + QFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef QFunctionObject_H +#define QFunctionObject_H + +#include "Q.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject QFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //