functionObjects: New function to reconstruct cell velocity from face flux
This is a simple function that provides a convenient way for a user to
call fvc::reconstruct for the purposes of post-processing flux fields;
e.g., to construct a cell velocity from a face flux.
It can be used to generate output during a run by adding the following
settings to a case's controlDict:
functions
{
#includeFunc reconstruct(phi)
}
Or it can be executed as a postProcessing step by calling:
postProcess -func "reconstruct(phi)"
This commit is contained in:
22
etc/caseDicts/postProcessing/fields/reconstruct
Normal file
22
etc/caseDicts/postProcessing/fields/reconstruct
Normal file
@ -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 <fieldName>;
|
||||
|
||||
executeControl writeTime;
|
||||
writeControl writeTime;
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
100
src/functionObjects/field/reconstruct/reconstruct.C
Normal file
100
src/functionObjects/field/reconstruct/reconstruct.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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<class Type>
|
||||
bool Foam::functionObjects::reconstruct::calcReconstruction()
|
||||
{
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||
|
||||
if (foundObject<SurfaceFieldType>(fieldName_))
|
||||
{
|
||||
return store
|
||||
(
|
||||
resultName_,
|
||||
fvc::reconstruct(lookupObject<SurfaceFieldType>(fieldName_)),
|
||||
mesh_.changing() && mesh_.solution().cache(resultName_)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::reconstruct::calc()
|
||||
{
|
||||
bool processed = false;
|
||||
|
||||
processed = processed || calcReconstruction<scalar>();
|
||||
processed = processed || calcReconstruction<vector>();
|
||||
|
||||
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()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
102
src/functionObjects/field/reconstruct/reconstruct.H
Normal file
102
src/functionObjects/field/reconstruct/reconstruct.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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<class Type>
|
||||
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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -118,6 +118,8 @@ fieldsFunctions
|
||||
|
||||
#includeFunc randomise(U, magPerturbation=0.1)
|
||||
|
||||
#includeFunc reconstruct(phi)
|
||||
|
||||
#includeFunc scale(age, scale=0.1)
|
||||
|
||||
#includeFunc shearStress
|
||||
|
||||
Reference in New Issue
Block a user