freestreamVelocity/Pressure BC: stabilise in the limit of mag(Up) = 0

This commit is contained in:
Chris Greenshields
2019-02-04 20:58:06 +00:00
parent 039d77aae4
commit 0d4d30aa29
2 changed files with 46 additions and 5 deletions

View File

@ -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<scalar> magUp = mag(Up);
const Field<vector>& nf = patch().nf();
Field<scalar>& 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<scalar>::updateCoeffs();

View File

@ -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<vector>& Up = *this;
const Field<scalar> magUp = mag(Up);
valueFraction() = 0.5 - 0.5*(Up & patch().nf())/mag(Up);
const Field<vector>& nf = patch().nf();
Field<scalar>& 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<vector>::updateCoeffs();
}