freestreamPressureFvPatchScalarField: Added support for supersonic freestream

Set the new optional switch "supersonic" to true if the freestream flow is
supersonic.
This commit is contained in:
Henry Weller
2018-05-22 20:00:30 +01:00
parent b9af7f6018
commit 26ec6f8ceb
2 changed files with 35 additions and 15 deletions

View File

@ -37,7 +37,8 @@ freestreamPressureFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
UName_("U") UName_("U"),
supersonic_(false)
{} {}
@ -50,7 +51,11 @@ freestreamPressureFvPatchScalarField
) )
: :
mixedFvPatchScalarField(p, iF), mixedFvPatchScalarField(p, iF),
UName_(dict.lookupOrDefault<word>("U", "U")) UName_(dict.lookupOrDefault<word>("U", "U")),
supersonic_
(
dict.lookupOrDefault<Switch>("supersonic", false)
)
{ {
freestreamValue() = scalarField("freestreamValue", dict, p.size()); freestreamValue() = scalarField("freestreamValue", dict, p.size());
@ -74,37 +79,40 @@ freestreamPressureFvPatchScalarField
Foam::freestreamPressureFvPatchScalarField:: Foam::freestreamPressureFvPatchScalarField::
freestreamPressureFvPatchScalarField freestreamPressureFvPatchScalarField
( (
const freestreamPressureFvPatchScalarField& ptf, const freestreamPressureFvPatchScalarField& psf,
const fvPatch& p, const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF, const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
mixedFvPatchScalarField(ptf, p, iF, mapper), mixedFvPatchScalarField(psf, p, iF, mapper),
UName_(ptf.UName_) UName_(psf.UName_),
supersonic_(psf.supersonic_)
{} {}
Foam::freestreamPressureFvPatchScalarField:: Foam::freestreamPressureFvPatchScalarField::
freestreamPressureFvPatchScalarField freestreamPressureFvPatchScalarField
( (
const freestreamPressureFvPatchScalarField& wbppsf const freestreamPressureFvPatchScalarField& psf
) )
: :
mixedFvPatchScalarField(wbppsf), mixedFvPatchScalarField(psf),
UName_(wbppsf.UName_) UName_(psf.UName_),
supersonic_(psf.supersonic_)
{} {}
Foam::freestreamPressureFvPatchScalarField:: Foam::freestreamPressureFvPatchScalarField::
freestreamPressureFvPatchScalarField freestreamPressureFvPatchScalarField
( (
const freestreamPressureFvPatchScalarField& wbppsf, const freestreamPressureFvPatchScalarField& psf,
const DimensionedField<scalar, volMesh>& iF const DimensionedField<scalar, volMesh>& iF
) )
: :
mixedFvPatchScalarField(wbppsf, iF), mixedFvPatchScalarField(psf, iF),
UName_(wbppsf.UName_) UName_(psf.UName_),
supersonic_(psf.supersonic_)
{} {}
@ -123,7 +131,14 @@ void Foam::freestreamPressureFvPatchScalarField::updateCoeffs()
UName_ UName_
); );
if (supersonic_)
{
valueFraction() = 0.5 - 0.5*(Up & patch().nf())/mag(Up);
}
else
{
valueFraction() = 0.5 + 0.5*(Up & patch().nf())/mag(Up); valueFraction() = 0.5 + 0.5*(Up & patch().nf())/mag(Up);
}
mixedFvPatchField<scalar>::updateCoeffs(); mixedFvPatchField<scalar>::updateCoeffs();
} }
@ -134,6 +149,7 @@ void Foam::freestreamPressureFvPatchScalarField::write(Ostream& os) const
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
writeEntryIfDifferent<word>(os, "U", "U", UName_); writeEntryIfDifferent<word>(os, "U", "U", UName_);
freestreamValue().writeEntry("freestreamValue", os); freestreamValue().writeEntry("freestreamValue", os);
os.writeKeyword("supersonic") << supersonic_ << token::END_STATEMENT << nl;
writeEntry("value", os); writeEntry("value", os);
} }

View File

@ -39,6 +39,7 @@ Usage
Property | Description | Required | Default value Property | Description | Required | Default value
U | velocity field name | no | U U | velocity field name | no | U
freestreamValue | freestream pressure | yes | freestreamValue | freestream pressure | yes |
supersonic | Switch for supersonic flow | no | false
\endtable \endtable
Example of the boundary condition specification: Example of the boundary condition specification:
@ -86,6 +87,9 @@ class freestreamPressureFvPatchScalarField
//- Name of the velocity field //- Name of the velocity field
word UName_; word UName_;
//- Set true for supersonic freestream
Switch supersonic_;
public: public: