ENH: Added new filmFlux function object

Calculates the mass flux for surface film models.

Example usage:

    filmFlux
    {
        type            filmFlux;
        writeControl    writeTime;
        result          myPhi; // optional
    }
This commit is contained in:
Andrew Heather
2020-12-21 18:06:57 +00:00
parent bf3e9b442d
commit 48f8811896
4 changed files with 359 additions and 0 deletions

View File

@ -77,5 +77,8 @@ $(PATCHFIELDS)/filmHeightInletVelocity/filmHeightInletVelocityFvPatchVectorField
$(PATCHFIELDS)/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C $(PATCHFIELDS)/inclinedFilmNusseltHeight/inclinedFilmNusseltHeightFvPatchScalarField.C
$(PATCHFIELDS)/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C $(PATCHFIELDS)/inclinedFilmNusseltInletVelocity/inclinedFilmNusseltInletVelocityFvPatchVectorField.C
/* Function objects */
FUNCTIONOBJECTS=functionObjects
$(FUNCTIONOBJECTS)/filmFlux/filmFlux.C
LIB = $(FOAM_LIBBIN)/libsurfaceFilmModels LIB = $(FOAM_LIBBIN)/libsurfaceFilmModels

View File

@ -0,0 +1,156 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "filmFlux.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "surfaceInterpolate.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(filmFlux, 0);
addToRunTimeSelectionTable(functionObject, filmFlux, dictionary);
}
}
const Foam::functionObjects::filmFlux::filmType&
Foam::functionObjects::filmFlux::filmModel()
{
return time_.objectRegistry::lookupObject<filmType>(filmName_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::filmFlux::filmFlux
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
stateFunctionObject(name, runTime),
filmName_("surfaceFilmProperties"),
resultName_(scopedName("filmFlux"))
{
read(dict);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::filmFlux::read(const dictionary& dict)
{
if (stateFunctionObject::read(dict))
{
dict.readIfPresent<word>("film", filmName_);
dict.readIfPresent<word>("result", resultName_);
return true;
}
return false;
}
bool Foam::functionObjects::filmFlux::execute()
{
const auto& model = filmModel();
const fvMesh& filmMesh = model.regionMesh();
auto* resultPtr = filmMesh.getObjectPtr<surfaceScalarField>(resultName_);
if (!resultPtr)
{
resultPtr = new surfaceScalarField
(
IOobject
(
resultName_,
time_.timeName(),
filmMesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
filmMesh,
dimensionedScalar(dimMass/dimTime, Zero)
);
filmMesh.objectRegistry::store(resultPtr);
}
auto& result = *resultPtr;
const surfaceScalarField& phi = model.phi();
const volScalarField& magSf = model.magSf();
const volScalarField::Internal& vol = filmMesh.V();
volScalarField height
(
IOobject
(
"height",
time_.timeName(),
filmMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
filmMesh,
dimensionedScalar(dimLength, Zero),
zeroGradientFvPatchScalarField::typeName
);
auto& heightc = height.ref();
heightc = max(dimensionedScalar("eps", dimLength, ROOTVSMALL), vol/magSf());
height.correctBoundaryConditions();
result = phi/fvc::interpolate(height);
return true;
}
bool Foam::functionObjects::filmFlux::write()
{
const auto& filmMesh = filmModel().regionMesh();
filmMesh.lookupObject<surfaceScalarField>(resultName_).write();
return true;
}
// ************************************************************************* //

View File

@ -0,0 +1,170 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
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::filmFlux
Group
grpFieldFunctionObjects
Description
Calculates the mass flux for surface film models.
Operands:
\table
Operand | Type | Location
input | dictionary | constant/\<surfaceFilmProperties\>
output file | - | -
output field | surfaceScalarField <!--
--> | \<time\>/\<filmRegion\>/\<outField\>
\endtable
Usage
Minimal example by using \c system/controlDict.functions:
\verbatim
filmFlux1
{
// Mandatory entries (unmodifiable)
type filmFlux;
// Optional entries (runtime modifiable)
film <surfaceFilmPropertiesDictionary>;
result <resultName>;
// Optional (inherited) entries
...
}
\endverbatim
where the entries mean:
\table
Property | Description | Type | Reqd | Dflt
type | Type name: filmFlux | word | yes | -
film | Name of surface film properties dictionary <!--
--> | dict | no | surfaceFilmProperties
result | Name of result field | word | no | filmFlux
\endtable
The inherited entries are elaborated in:
- \link stateFunctionObject.H \endlink
Usage by the \c postProcess utility is not available.
See also
- Foam::functionObjects::stateFunctionObject
SourceFiles
flux.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_filmFlux_H
#define functionObjects_filmFlux_H
#include "stateFunctionObject.H"
#include "kinematicSingleLayer.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class filmFlux Declaration
\*---------------------------------------------------------------------------*/
class filmFlux
:
public stateFunctionObject
{
// Private Data
typedef regionModels::surfaceFilmModels::kinematicSingleLayer filmType;
//- Film model name
word filmName_;
//- Name of derived flux field
word resultName_;
// Private Member Functions
//- Helper function to set the pointer to the film model
const filmType& filmModel();
public:
//- Runtime type information
TypeName("filmFlux");
// Constructors
//- Construct from Time and dictionary
filmFlux
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- No copy construct
filmFlux(const filmFlux&) = delete;
//- No copy assignment
void operator=(const filmFlux&) = delete;
//- Destructor
virtual ~filmFlux() = default;
// Member Functions
//- Read the field data
virtual bool read(const dictionary&);
//- Execute
virtual bool execute();
//- Write the field
virtual bool write();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -63,6 +63,36 @@ functions
internalField yes; internalField yes;
patches (); patches ();
} }
filmFlux
{
type filmFlux;
writeControl writeTime;
result myPhi; // optional
}
filmPatchFluxIn
{
type surfaceFieldValue;
libs (fieldFunctionObjects);
region wallFilmRegion;
fields (myPhi);
operation sum;
regionType patch;
name inlet;
writeFields no;
}
filmPatchFluxOut
{
type surfaceFieldValue;
libs (fieldFunctionObjects);
region wallFilmRegion;
fields (myPhi);
operation sum;
regionType patch;
name outlet;
writeFields no;
}
} }
// ************************************************************************* // // ************************************************************************* //