From dff4c3da05e04f548a2746a1fdbd961511537e66 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 29 Nov 2022 09:18:57 +0000 Subject: [PATCH 1/2] ENH: limitHeight: new faOption to limit film height --- src/faOptions/Make/files | 1 + .../corrections/limitHeight/limitHeight.C | 152 +++++++++++++++++ .../corrections/limitHeight/limitHeight.H | 153 ++++++++++++++++++ 3 files changed, 306 insertions(+) create mode 100644 src/faOptions/corrections/limitHeight/limitHeight.C create mode 100644 src/faOptions/corrections/limitHeight/limitHeight.H diff --git a/src/faOptions/Make/files b/src/faOptions/Make/files index af26eff51b..43e1de42e4 100644 --- a/src/faOptions/Make/files +++ b/src/faOptions/Make/files @@ -17,5 +17,6 @@ $(derivedSources)/externalFileSource/externalFileSource.C corrections=corrections $(corrections)/limitVelocity/limitVelocity.C +$(corrections)/limitHeight/limitHeight.C LIB = $(FOAM_LIBBIN)/libfaOptions diff --git a/src/faOptions/corrections/limitHeight/limitHeight.C b/src/faOptions/corrections/limitHeight/limitHeight.C new file mode 100644 index 0000000000..89e1787c16 --- /dev/null +++ b/src/faOptions/corrections/limitHeight/limitHeight.C @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 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 . + +\*---------------------------------------------------------------------------*/ + +#include "limitHeight.H" +#include "areaFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fa +{ + defineTypeNameAndDebug(limitHeight, 0); + addToRunTimeSelectionTable + ( + option, + limitHeight, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fa::limitHeight::limitHeight +( + const word& name, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + faceSetOption(name, modelType, dict, mesh), + hName_("h"), + max_(0) // overwritten later +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::fa::limitHeight::read(const dictionary& dict) +{ + if (!faceSetOption::read(dict)) + { + return false; + } + + coeffs_.readIfPresent("h", hName_); + coeffs_.readEntry("max", max_); + + fieldNames_.resize(1, hName_); + + applied_.resize(1, false); + + return true; +} + + +void Foam::fa::limitHeight::correct(areaScalarField& h) +{ + // Count nTotFaces ourselves + // (maybe only applying on a subset) + label nFacesAbove = 0; + const label nTotFaces = returnReduce(faces_.size(), sumOp