From 80c1a65bc8eb5bc751b77400529ea76b41062af0 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Tue, 2 Nov 2021 10:26:20 +0000 Subject: [PATCH] movingWallSlipVelocity: Added boundary condition This boundary condition specifies a slip velocity on moving walls. It works similarly to movingWallVelocity, except that the tangential velocity is not constrained. It can be specified as follows: { type movingWallSlipVelocity; value uniform (0 0 0); // Initial value } --- src/finiteVolume/Make/files | 1 + ...movingWallSlipVelocityFvPatchVectorField.C | 149 ++++++++++++++++++ ...movingWallSlipVelocityFvPatchVectorField.H | 142 +++++++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.H diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 9e7842e50c..a8f7c573a7 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -178,6 +178,7 @@ $(derivedFvPatchFields)/mappedVelocityFluxFixedValue/mappedVelocityFluxFixedValu $(derivedFvPatchFields)/matchedFlowRateOutletVelocity/matchedFlowRateOutletVelocityFvPatchVectorField.C $(derivedFvPatchFields)/noSlip/noSlipFvPatchVectorField.C $(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.C $(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C $(derivedFvPatchFields)/outletMappedUniformInlet/outletMappedUniformInletFvPatchFields.C $(derivedFvPatchFields)/fixedMeanOutletInlet/fixedMeanOutletInletFvPatchFields.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.C new file mode 100644 index 0000000000..a93e94d42c --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.C @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2021 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 "movingWallSlipVelocityFvPatchVectorField.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "fvcMeshPhi.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::movingWallSlipVelocityFvPatchVectorField:: +movingWallSlipVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + directionMixedFvPatchVectorField(p, iF) +{ + refValue() = Zero; + refGrad() = Zero; + valueFraction() = Zero; +} + + +Foam::movingWallSlipVelocityFvPatchVectorField:: +movingWallSlipVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + directionMixedFvPatchVectorField(p, iF) +{ + fvPatchVectorField::operator=(vectorField("value", dict, p.size())); + + const vectorField n(p.nf()); + + refValue() = sqr(n) & *this; + refGrad() = Zero; + valueFraction() = sqr(n); +} + + +Foam::movingWallSlipVelocityFvPatchVectorField:: +movingWallSlipVelocityFvPatchVectorField +( + const movingWallSlipVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + directionMixedFvPatchVectorField(ptf, p, iF, mapper) +{} + + +Foam::movingWallSlipVelocityFvPatchVectorField:: +movingWallSlipVelocityFvPatchVectorField +( + const movingWallSlipVelocityFvPatchVectorField& mwvpvf, + const DimensionedField& iF +) +: + directionMixedFvPatchVectorField(mwvpvf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::movingWallSlipVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvMesh& mesh = internalField().mesh(); + + if (mesh.moving()) + { + const fvPatch& p = patch(); + + const volVectorField& U = + static_cast(internalField()); + + scalarField phip + ( + p.patchField(fvc::meshPhi(U)) + ); + + const vectorField n(p.nf()); + const scalarField& magSf = p.magSf(); + + tmp Un = phip/(magSf + vSmall); + + refValue() = n*Un; + refGrad() = Zero; + valueFraction() = sqr(n); + } + + directionMixedFvPatchVectorField::updateCoeffs(); + directionMixedFvPatchVectorField::evaluate(); +} + + +void Foam::movingWallSlipVelocityFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + writeEntry(os, "value", *this); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + movingWallSlipVelocityFvPatchVectorField + ); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.H new file mode 100644 index 0000000000..59477e4c38 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/derived/movingWallSlipVelocity/movingWallSlipVelocityFvPatchVectorField.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2021 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::movingWallSlipVelocityFvPatchVectorField + +Description + This boundary condition provides a slip velocity condition for cases with + moving walls. + +Usage + Example of the boundary condition specification: + \verbatim + + { + type movingWallSlipVelocity; + value uniform (0 0 0); // Initial value + } + \endverbatim + +SourceFiles + movingWallSlipVelocityFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef movingWallSlipVelocityFvPatchVectorField_H +#define movingWallSlipVelocityFvPatchVectorField_H + +#include "directionMixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class movingWallSlipVelocityFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class movingWallSlipVelocityFvPatchVectorField +: + public directionMixedFvPatchVectorField +{ + +public: + + //- Runtime type information + TypeName("movingWallSlipVelocity"); + + + // Constructors + + //- Construct from patch and internal field + movingWallSlipVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + movingWallSlipVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given movingWallSlipVelocityFvPatchVectorField + // onto a new patch + movingWallSlipVelocityFvPatchVectorField + ( + const movingWallSlipVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Disallow copy without setting internal field reference + movingWallSlipVelocityFvPatchVectorField + ( + const movingWallSlipVelocityFvPatchVectorField& + ) = delete; + + //- Copy constructor setting internal field reference + movingWallSlipVelocityFvPatchVectorField + ( + const movingWallSlipVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new movingWallSlipVelocityFvPatchVectorField(*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 + +// ************************************************************************* //