diff --git a/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C index 1592f3f38289f2819f8c58fadb15795dd1c0301a..7a9c170d7a3123ca17baab91476c75cbf2b9f600 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -92,46 +93,50 @@ movingWallVelocityFvPatchVectorField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::movingWallVelocityFvPatchVectorField::updateCoeffs() +Foam::tmp<Foam::vectorField> +Foam::movingWallVelocityFvPatchVectorField::Uwall() const { - if (updated()) - { - return; - } - const fvMesh& mesh = internalField().mesh(); + const fvPatch& p = patch(); + const polyPatch& pp = p.patch(); + const pointField& oldPoints = mesh.oldPoints(); - if (mesh.moving()) + vectorField oldFc(pp.size()); + + forAll(oldFc, i) { - const fvPatch& p = patch(); - const polyPatch& pp = p.patch(); - const pointField& oldPoints = mesh.oldPoints(); + oldFc[i] = pp[i].centre(oldPoints); + } + + const scalar deltaT = mesh.time().deltaTValue(); - vectorField oldFc(pp.size()); + const vectorField Up((pp.faceCentres() - oldFc)/deltaT); - forAll(oldFc, i) - { - oldFc[i] = pp[i].centre(oldPoints); - } + const auto& U = static_cast<const volVectorField&>(internalField()); - const scalar deltaT = mesh.time().deltaTValue(); + tmp<scalarField> phip = + p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U)); - const vectorField Up((pp.faceCentres() - oldFc)/deltaT); + const vectorField n(p.nf()); + const scalarField& magSf = p.magSf(); + tmp<scalarField> Un = phip/(magSf + VSMALL); - const volVectorField& U = - static_cast<const volVectorField&>(internalField()); + return (Up + n*(Un - (n & Up))); +} - scalarField phip - ( - p.patchField<surfaceScalarField, scalar>(fvc::meshPhi(U)) - ); - const vectorField n(p.nf()); - const scalarField& magSf = p.magSf(); - tmp<scalarField> Un = phip/(magSf + VSMALL); +void Foam::movingWallVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + const fvMesh& mesh = internalField().mesh(); - vectorField::operator=(Up + n*(Un - (n & Up))); + if (mesh.moving()) + { + vectorField::operator=(Uwall()()); } fixedValueFvPatchVectorField::updateCoeffs(); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.H index bd272e93176d02215bebbf3fccf562e6c1b4f9de..9b5b05cd7ec3d74e68863b3d8bec9ac96cb5facd 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/movingWallVelocity/movingWallVelocityFvPatchVectorField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -71,7 +71,6 @@ class movingWallVelocityFvPatchVectorField : public fixedValueFvPatchVectorField { - public: //- Runtime type information @@ -140,7 +139,10 @@ public: } - // Member functions + // Member Functions + + //- Return wall velocity field + tmp<vectorField> Uwall() const; //- Update the coefficients associated with the patch field virtual void updateCoeffs();