From 423fa5ba5519c2192ff6a1784b2a4d9b7ee2e918 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Mon, 6 Mar 2023 21:19:20 +0000 Subject: [PATCH] filmSurfaceVelocityFvPatchVectorField: New film surface boundary condition Class Foam::filmSurfaceVelocityFvPatchVectorField Description Film surface velocity boundary condition Evaluates the surface velocity from the shear imposed by the neighbouring fluid velocity using a simple drag model based on the difference between the fluid and film velocities multiplied by the coefficient \c Cs. This simple model is used in preference to the standard viscous shear stress model in order to provide some means to include the drag enhancing effect of surface ripples, rivulets etc. in the film surface. Usage \table Property | Description | Required | Default value Cs | Fluid-film drag coefficient | yes | \endtable Example of the boundary condition specification: \verbatim { type filmSurfaceVelocity; Cs 0.005; } \endverbatim --- .../solvers/modules/isothermalFilm/Make/files | 1 + .../filmSurfaceVelocityFvPatchVectorField.C | 182 ++++++++++++++++++ .../filmSurfaceVelocityFvPatchVectorField.H | 165 ++++++++++++++++ .../fixedShearStressFvPatchVectorField.C | 4 +- 4 files changed, 350 insertions(+), 2 deletions(-) create mode 100644 applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.C create mode 100644 applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.H diff --git a/applications/solvers/modules/isothermalFilm/Make/files b/applications/solvers/modules/isothermalFilm/Make/files index a0ae4a33dd..1e08d75d2f 100644 --- a/applications/solvers/modules/isothermalFilm/Make/files +++ b/applications/solvers/modules/isothermalFilm/Make/files @@ -19,6 +19,7 @@ patches/mappedFilmSurface/mappedFilmSurfaceFvPatch/mappedFilmSurfaceFvPatch.C derivedFvPatchFields/alphaOne/alphaOneFvPatchScalarField.C derivedFvPatchFields/filmContactAngle/filmContactAngleFvPatchScalarField.C derivedFvPatchFields/mappedFilmPressure/mappedFilmPressureFvPatchScalarField.C +derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.C filmGaussGrad/filmGaussGrads.C diff --git a/applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.C b/applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.C new file mode 100644 index 0000000000..20512e2dd2 --- /dev/null +++ b/applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.C @@ -0,0 +1,182 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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 "filmSurfaceVelocityFvPatchVectorField.H" +#include "momentumTransportModel.H" +#include "mappedPatchBase.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::filmSurfaceVelocityFvPatchVectorField:: +filmSurfaceVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchField(p, iF), + Cs_(0) +{ + refValue() = Zero; + refGrad() = Zero; + valueFraction() = 0; +} + + +Foam::filmSurfaceVelocityFvPatchVectorField:: +filmSurfaceVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchField(p, iF, dict, false), + Cs_(dict.lookup("Cs")) +{ + refValue() = Zero; + refGrad() = Zero; + valueFraction() = 0; + + if (dict.found("value")) + { + fvPatchVectorField::operator= + ( + vectorField("value", dict, p.size()) + ); + } + else + { + // If the value entry is not present initialise to zero-gradient + fvPatchVectorField::operator=(patchInternalField()); + } +} + + +Foam::filmSurfaceVelocityFvPatchVectorField:: +filmSurfaceVelocityFvPatchVectorField +( + const filmSurfaceVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField(ptf, p, iF, mapper), + Cs_(ptf.Cs_) +{} + + +Foam::filmSurfaceVelocityFvPatchVectorField:: +filmSurfaceVelocityFvPatchVectorField +( + const filmSurfaceVelocityFvPatchVectorField& ptf, + const DimensionedField& iF +) +: + mixedFvPatchField(ptf, iF), + Cs_(ptf.Cs_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::filmSurfaceVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Since we're inside initEvaluate/evaluate there might be processor + // comms underway. Change the tag we use. + const int oldTag = UPstream::msgType(); + UPstream::msgType() = oldTag + 1; + + // Get the coupling information from the mappedPatchBase + const mappedPatchBase& mpp = mappedPatchBase::getMap(patch().patch()); + const label patchiNbr = mpp.nbrPolyPatch().index(); + const fvPatch& patchNbr = + refCast(mpp.nbrMesh()).boundary()[patchiNbr]; + + const vectorField UpNbr = + patchNbr.lookupPatchField("U") + .patchInternalField(); + + // Set the reference value to the neighbouring fluid internal velocity + refValue() = mpp.distribute(UpNbr); + + // Remove the normal component of the surface vel + const vectorField n(patch().nf()); + refValue() -= n*(n & refValue()); + + // Lookup the momentum transport model + const momentumTransportModel& transportModel = + db().lookupType(); + + // Get the patch laminar viscosity + const tmp nuEff(transportModel.nuEff(patch().index())); + + // Calculate the drag coefficient from the drag constant + // and the magnitude of the velocity difference + const scalarField Ds(Cs_*mag(refValue() - *this)); + + // Calculate the value-fraction from the balance between the + // external fluid drag and internal film stress + valueFraction() = Ds/(Ds + patch().deltaCoeffs()*nuEff); + + mixedFvPatchField::updateCoeffs(); + + // Restore tag + UPstream::msgType() = oldTag; +} + + +void Foam::filmSurfaceVelocityFvPatchVectorField::write +( + Ostream& os +) const +{ + fvPatchField::write(os); + + writeEntry(os, "Cs", Cs_); + writeEntry(os, "value", *this); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + filmSurfaceVelocityFvPatchVectorField + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.H b/applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.H new file mode 100644 index 0000000000..1f4e93a6be --- /dev/null +++ b/applications/solvers/modules/isothermalFilm/derivedFvPatchFields/filmSurfaceVelocity/filmSurfaceVelocityFvPatchVectorField.H @@ -0,0 +1,165 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 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::filmSurfaceVelocityFvPatchVectorField + +Description + Film surface velocity boundary condition + + Evaluates the surface velocity from the shear imposed by the neighbouring + fluid velocity using a simple drag model based on the difference between the + fluid and film velocities multiplied by the coefficient \c Cs. This simple + model is used in preference to the standard viscous shear stress model in + order to provide some means to include the drag enhancing effect + of surface ripples, rivulets etc. in the film surface. + +Usage + \table + Property | Description | Required | Default value + Cs | Fluid-film drag coefficient | yes | + \endtable + + Example of the boundary condition specification: + \verbatim + + { + type filmSurfaceVelocity; + Cs 0.005; + } + \endverbatim + +See also + Foam::mixedFvPatchField + +SourceFiles + filmSurfaceVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef filmSurfaceVelocityFvPatchVectorField_H +#define filmSurfaceVelocityFvPatchVectorField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class filmSurfaceVelocityFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class filmSurfaceVelocityFvPatchVectorField +: + public mixedFvPatchVectorField +{ + // Private Data + + //- Fluid-film drag-coefficient + scalar Cs_; + + +public: + + //- Runtime type information + TypeName("filmSurfaceVelocity"); + + + // Constructors + + //- Construct from patch and internal field + filmSurfaceVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + filmSurfaceVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // filmSurfaceVelocityFvPatchVectorField + // onto a new patch + filmSurfaceVelocityFvPatchVectorField + ( + const filmSurfaceVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Disallow copy without setting internal field reference + filmSurfaceVelocityFvPatchVectorField + ( + const filmSurfaceVelocityFvPatchVectorField& + ) = delete; + + //- Copy constructor setting internal field reference + filmSurfaceVelocityFvPatchVectorField + ( + const filmSurfaceVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new filmSurfaceVelocityFvPatchVectorField + ( + *this, + iF + ) + ); + } + + + // Member Functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C b/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C index 6c526be65e..c4a02db0d2 100644 --- a/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C +++ b/src/MomentumTransportModels/momentumTransportModels/derivedFvPatchFields/fixedShearStress/fixedShearStressFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,7 +93,7 @@ void Foam::fixedShearStressFvPatchVectorField::updateCoeffs() const momentumTransportModel& turbModel = db().lookupType(internalField().group()); - scalarField nuEff(turbModel.nuEff(patch().index())); + const scalarField nuEff(turbModel.nuEff(patch().index())); const vectorField Uc(patchInternalField());