diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C index 1c9fe68db..ccb1ea4c9 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamPressure/freestreamPressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -131,13 +131,39 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs() UName_ ); + const Field magUp = mag(Up); + + const Field& nf = patch().nf(); + + Field& vf = valueFraction(); + if (supersonic_) { - valueFraction() = 0.5 - 0.5*(Up & patch().nf())/mag(Up); + forAll(vf, i) + { + if (magUp[i] > vSmall) + { + vf[i] = 0.5 - 0.5*(Up[i] & nf[i])/magUp[i]; + } + else + { + vf[i] = 0.5; + } + } } else { - valueFraction() = 0.5 + 0.5*(Up & patch().nf())/mag(Up); + forAll(vf, i) + { + if (magUp[i] > vSmall) + { + vf[i] = 0.5 + 0.5*(Up[i] & nf[i])/magUp[i]; + } + else + { + vf[i] = 0.5; + } + } } mixedFvPatchField::updateCoeffs(); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/freestreamVelocity/freestreamVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/freestreamVelocity/freestreamVelocityFvPatchVectorField.C index 878eb722a..74f4917a5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/freestreamVelocity/freestreamVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/freestreamVelocity/freestreamVelocityFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -107,8 +107,23 @@ void Foam::freestreamVelocityFvPatchVectorField::updateCoeffs() } const Field& Up = *this; + const Field magUp = mag(Up); - valueFraction() = 0.5 - 0.5*(Up & patch().nf())/mag(Up); + const Field& nf = patch().nf(); + + Field& vf = valueFraction(); + + forAll(vf, i) + { + if (magUp[i] > vSmall) + { + vf[i] = 0.5 - 0.5*(Up[i] & nf[i])/magUp[i]; + } + else + { + vf[i] = 0.5; + } + } mixedFvPatchField::updateCoeffs(); }