From 52ad98fa1fd61e3631a33f3e7756bffcb642ae60 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://openfoam.org> Date: Mon, 17 Jul 2017 12:18:47 +0100 Subject: [PATCH] flowRateInletVelocity extrapolated: Removed reverse flow and correct only the normal component Improved stability and convergence. --- .../flowRateInletVelocityFvPatchVectorField.C | 30 +++++++++++++------ ...flowRateOutletVelocityFvPatchVectorField.C | 6 ++-- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index 8fe4162cc7..d42e353b69 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -156,31 +156,43 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateValues { const scalar t = db().time().timeOutputValue(); - tmp<vectorField> n = patch().nf(); + const vectorField n(patch().nf()); if (extrapolateProfile_) { - vectorField newValues(this->patchInternalField()); + vectorField Up(this->patchInternalField()); - scalar flowRate = flowRate_->value(t); - scalar estimatedFlowRate = -gSum(rho*(this->patch().Sf() & newValues)); + // Patch normal extrapolated velocity + scalarField nUp(n & Up); + + // Remove the normal component of the extrapolate patch velocity + Up -= nUp*n; + + // Remove any reverse flow + nUp = min(nUp, 0.0); + + const scalar flowRate = flowRate_->value(t); + const scalar estimatedFlowRate = -gSum(rho*(this->patch().magSf()*nUp)); if (estimatedFlowRate/flowRate > 0.5) { - newValues *= (mag(flowRate)/mag(estimatedFlowRate)); + nUp *= (mag(flowRate)/mag(estimatedFlowRate)); } else { - newValues -= - ((flowRate - estimatedFlowRate)/gSum(rho*patch().magSf()))*n; + nUp -= ((flowRate - estimatedFlowRate)/gSum(rho*patch().magSf())); } - this->operator==(newValues); + // Add the corrected normal component of velocity to the patch velocity + Up += nUp*n; + + // Correct the patch velocity + this->operator==(Up); } else { const scalar avgU = -flowRate_->value(t)/gSum(rho*patch().magSf()); - operator==(n*avgU); + operator==(avgU*n); } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C index ffc0c63e46..cf331d9b7e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateOutletVelocity/flowRateOutletVelocityFvPatchVectorField.C @@ -160,10 +160,10 @@ void Foam::flowRateOutletVelocityFvPatchVectorField::updateValues Up -= nUp*n; // Remove any reverse flow - nUp = min(nUp, 0.0); + nUp = max(nUp, 0.0); const scalar flowRate = flowRate_->value(t); - const scalar estimatedFlowRate = -gSum(rho*(this->patch().magSf()*nUp)); + const scalar estimatedFlowRate = gSum(rho*(this->patch().magSf()*nUp)); if (estimatedFlowRate/flowRate > 0.5) { @@ -171,7 +171,7 @@ void Foam::flowRateOutletVelocityFvPatchVectorField::updateValues } else { - nUp -= ((flowRate - estimatedFlowRate)/gSum(rho*patch().magSf())); + nUp += ((flowRate - estimatedFlowRate)/gSum(rho*patch().magSf())); } // Add the corrected normal component of velocity to the patch velocity -- GitLab