diff --git a/etc/caseDicts/postProcessing/fields/reconstruct b/etc/caseDicts/postProcessing/fields/reconstruct new file mode 100644 index 0000000000..5444db82eb --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/reconstruct @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Calculates the reconstruction of a field; e.g., to construct a cell-centred + velocity, U, from the face-centred flux, phi. + +\*---------------------------------------------------------------------------*/ + +type reconstruct; +libs ("libfieldFunctionObjects.so"); + +field ; + +executeControl writeTime; +writeControl writeTime; + +// ************************************************************************* // diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files index 0b9a05330a..7ad6621038 100644 --- a/src/functionObjects/field/Make/files +++ b/src/functionObjects/field/Make/files @@ -47,6 +47,7 @@ pressure/pressure.C MachNo/MachNo.C shearStress/shearStress.C totalEnthalpy/totalEnthalpy.C +reconstruct/reconstruct.C turbulenceFields/turbulenceFields.C yPlus/yPlus.C diff --git a/src/functionObjects/field/reconstruct/reconstruct.C b/src/functionObjects/field/reconstruct/reconstruct.C new file mode 100644 index 0000000000..4664f9386a --- /dev/null +++ b/src/functionObjects/field/reconstruct/reconstruct.C @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 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 "reconstruct.H" +#include "fvcReconstruct.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(reconstruct, 0); + addToRunTimeSelectionTable(functionObject, reconstruct, dictionary); +} +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +bool Foam::functionObjects::reconstruct::calcReconstruction() +{ + typedef GeometricField SurfaceFieldType; + + if (foundObject(fieldName_)) + { + return store + ( + resultName_, + fvc::reconstruct(lookupObject(fieldName_)), + mesh_.changing() && mesh_.solution().cache(resultName_) + ); + } + else + { + return false; + } +} + + +bool Foam::functionObjects::reconstruct::calc() +{ + bool processed = false; + + processed = processed || calcReconstruction(); + processed = processed || calcReconstruction(); + + if (!processed) + { + cannotFindObject(fieldName_); + } + + return processed; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::reconstruct::reconstruct +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fieldExpression(name, runTime, dict, typeName) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::reconstruct::~reconstruct() +{} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/reconstruct/reconstruct.H b/src/functionObjects/field/reconstruct/reconstruct.H new file mode 100644 index 0000000000..7e06504a4e --- /dev/null +++ b/src/functionObjects/field/reconstruct/reconstruct.H @@ -0,0 +1,102 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2022 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::functionObjects::reconstruct + +Description + Calculates the reconstruction of a field; e.g., to construct a cell-centred + velocity, U, from the face-centred flux, phi. The operation is limited to + scalar and vector surface fields, and the output is a volume vector or + tensor field. + +See also + Foam::functionObjects::fvMeshFunctionObject + +SourceFiles + reconstruct.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_reconstruct_H +#define functionObjects_reconstruct_H + +#include "fieldExpression.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class reconstruct Declaration +\*---------------------------------------------------------------------------*/ + +class reconstruct +: + public fieldExpression +{ + // Private Member Functions + + //- Calculate the magnitude of the field and register the result + template + inline bool calcReconstruction(); + + //- Calculate the reconstruction field and return true if successful + virtual bool calc(); + + +public: + + //- Runtime type information + TypeName("reconstruct"); + + + // Constructors + + //- Construct from Time and dictionary + reconstruct + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + //- Destructor + virtual ~reconstruct(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/test/postProcessing/channel/system/controlDict b/test/postProcessing/channel/system/controlDict index fb086a1192..b414570c13 100644 --- a/test/postProcessing/channel/system/controlDict +++ b/test/postProcessing/channel/system/controlDict @@ -118,6 +118,8 @@ fieldsFunctions #includeFunc randomise(U, magPerturbation=0.1) + #includeFunc reconstruct(phi) + #includeFunc scale(age, scale=0.1) #includeFunc shearStress