Revert pressureInletOutletVelocity BCs

due to convergence problems with the new version for runs at high Courant number
This commit is contained in:
Henry
2014-03-12 12:27:19 +00:00
committed by Andrew Heather
parent c67779b221
commit 0a7259cc46
5 changed files with 76 additions and 162 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,10 +25,10 @@ License
#include "pressureInletOutletVelocityFvPatchVectorField.H" #include "pressureInletOutletVelocityFvPatchVectorField.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pressureInletOutletVelocityFvPatchVectorField:: Foam::pressureInletOutletVelocityFvPatchVectorField::
@ -38,14 +38,12 @@ pressureInletOutletVelocityFvPatchVectorField
const DimensionedField<vector, volMesh>& iF const DimensionedField<vector, volMesh>& iF
) )
: :
mixedFvPatchVectorField(p, iF), directionMixedFvPatchVectorField(p, iF),
phiName_("phi"), phiName_("phi")
rhoName_("rho"),
applyTangentialVelocity_(false)
{ {
refValue() = *this; refValue() = vector::zero;
refGrad() = vector::zero; refGrad() = vector::zero;
valueFraction() = 0.0; valueFraction() = symmTensor::zero;
} }
@ -58,12 +56,10 @@ pressureInletOutletVelocityFvPatchVectorField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
mixedFvPatchVectorField(ptf, p, iF, mapper), directionMixedFvPatchVectorField(ptf, p, iF, mapper),
phiName_(ptf.phiName_), phiName_(ptf.phiName_)
rhoName_(ptf.rhoName_),
applyTangentialVelocity_(ptf.applyTangentialVelocity_)
{ {
if (applyTangentialVelocity_) if (ptf.tangentialVelocity_.size())
{ {
tangentialVelocity_ = mapper(ptf.tangentialVelocity_); tangentialVelocity_ = mapper(ptf.tangentialVelocity_);
} }
@ -78,26 +74,25 @@ pressureInletOutletVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchVectorField(p, iF), directionMixedFvPatchVectorField(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi")), phiName_(dict.lookupOrDefault<word>("phi", "phi"))
rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
applyTangentialVelocity_(false)
{ {
fvPatchVectorField::operator=(vectorField("value", dict, p.size())); fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
if (dict.found("tangentialVelocity")) if (dict.found("tangentialVelocity"))
{ {
applyTangentialVelocity_ = true;
setTangentialVelocity setTangentialVelocity
( (
vectorField("tangentialVelocity", dict, p.size()) vectorField("tangentialVelocity", dict, p.size())
); );
} }
else
{
refValue() = vector::zero;
}
refValue() = *this;
refGrad() = vector::zero; refGrad() = vector::zero;
valueFraction() = 0.0; valueFraction() = symmTensor::zero;
} }
@ -107,11 +102,9 @@ pressureInletOutletVelocityFvPatchVectorField
const pressureInletOutletVelocityFvPatchVectorField& pivpvf const pressureInletOutletVelocityFvPatchVectorField& pivpvf
) )
: :
mixedFvPatchVectorField(pivpvf), directionMixedFvPatchVectorField(pivpvf),
phiName_(pivpvf.phiName_), phiName_(pivpvf.phiName_),
rhoName_(pivpvf.rhoName_), tangentialVelocity_(pivpvf.tangentialVelocity_)
tangentialVelocity_(pivpvf.tangentialVelocity_),
applyTangentialVelocity_(pivpvf.applyTangentialVelocity_)
{} {}
@ -122,11 +115,9 @@ pressureInletOutletVelocityFvPatchVectorField
const DimensionedField<vector, volMesh>& iF const DimensionedField<vector, volMesh>& iF
) )
: :
mixedFvPatchVectorField(pivpvf, iF), directionMixedFvPatchVectorField(pivpvf, iF),
phiName_(pivpvf.phiName_), phiName_(pivpvf.phiName_),
rhoName_(pivpvf.rhoName_), tangentialVelocity_(pivpvf.tangentialVelocity_)
tangentialVelocity_(pivpvf.tangentialVelocity_),
applyTangentialVelocity_(pivpvf.applyTangentialVelocity_)
{} {}
@ -135,10 +126,9 @@ pressureInletOutletVelocityFvPatchVectorField
void Foam::pressureInletOutletVelocityFvPatchVectorField:: void Foam::pressureInletOutletVelocityFvPatchVectorField::
setTangentialVelocity(const vectorField& tangentialVelocity) setTangentialVelocity(const vectorField& tangentialVelocity)
{ {
applyTangentialVelocity_ = true;
tangentialVelocity_ = tangentialVelocity; tangentialVelocity_ = tangentialVelocity;
vectorField n(patch().nf()); const vectorField n(patch().nf());
tangentialVelocity_ -= n*(n & tangentialVelocity_); refValue() = tangentialVelocity_ - n*(n & tangentialVelocity_);
} }
@ -147,8 +137,8 @@ void Foam::pressureInletOutletVelocityFvPatchVectorField::autoMap
const fvPatchFieldMapper& m const fvPatchFieldMapper& m
) )
{ {
mixedFvPatchVectorField::autoMap(m); directionMixedFvPatchVectorField::autoMap(m);
if (applyTangentialVelocity_) if (tangentialVelocity_.size())
{ {
tangentialVelocity_.autoMap(m); tangentialVelocity_.autoMap(m);
} }
@ -161,9 +151,9 @@ void Foam::pressureInletOutletVelocityFvPatchVectorField::rmap
const labelList& addr const labelList& addr
) )
{ {
mixedFvPatchVectorField::rmap(ptf, addr); directionMixedFvPatchVectorField::rmap(ptf, addr);
if (applyTangentialVelocity_) if (tangentialVelocity_.size())
{ {
const pressureInletOutletVelocityFvPatchVectorField& tiptf = const pressureInletOutletVelocityFvPatchVectorField& tiptf =
refCast<const pressureInletOutletVelocityFvPatchVectorField>(ptf); refCast<const pressureInletOutletVelocityFvPatchVectorField>(ptf);
@ -180,67 +170,25 @@ void Foam::pressureInletOutletVelocityFvPatchVectorField::updateCoeffs()
return; return;
} }
const surfaceScalarField& phi =
db().lookupObject<surfaceScalarField>(phiName_);
const fvsPatchField<scalar>& phip = const fvsPatchField<scalar>& phip =
patch().patchField<surfaceScalarField, scalar>(phi); patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
vectorField n(patch().nf()); valueFraction() = neg(phip)*(I - sqr(patch().nf()));
const Field<scalar>& magSf = patch().magSf();
if (phi.dimensions() == dimVelocity*dimArea) directionMixedFvPatchVectorField::updateCoeffs();
{ directionMixedFvPatchVectorField::evaluate();
refValue() = n*phip/magSf;
}
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{
const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
refValue() = n*phip/(rhop*magSf);
}
else
{
FatalErrorIn
(
"pressureInletOutletVelocityFvPatchVectorField::"
"updateCoeffs()"
) << "dimensions of phi are not correct" << nl
<< " on patch " << this->patch().name()
<< " of field " << this->dimensionedInternalField().name()
<< " in file " << this->dimensionedInternalField().objectPath()
<< exit(FatalError);
}
if (applyTangentialVelocity_)
{
// Adjust the tangential velocity to conserve kinetic energy
// of the entrained fluid
// scalarField magSqrUt(magSqr(tangentialVelocity_));
// scalarField scale
// (
// sqrt(max(magSqrUt - magSqr(refValue()), scalar(0))/magSqrUt)
// );
// refValue() += scale*tangentialVelocity_;
refValue() += tangentialVelocity_;
}
valueFraction() = 1.0 - pos(phip);
mixedFvPatchVectorField::updateCoeffs();
} }
void Foam::pressureInletOutletVelocityFvPatchVectorField::write void Foam::pressureInletOutletVelocityFvPatchVectorField::write
( (
Ostream& os Ostream& os
) const )
const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); if (tangentialVelocity_.size())
if (applyTangentialVelocity_)
{ {
tangentialVelocity_.writeEntry("tangentialVelocity", os); tangentialVelocity_.writeEntry("tangentialVelocity", os);
} }
@ -255,7 +203,9 @@ void Foam::pressureInletOutletVelocityFvPatchVectorField::operator=
const fvPatchField<vector>& pvf const fvPatchField<vector>& pvf
) )
{ {
fvPatchField<vector>::operator=(pvf); tmp<vectorField> normalValue = transform(valueFraction(), refValue());
tmp<vectorField> transformGradValue = transform(I - valueFraction(), pvf);
fvPatchField<vector>::operator=(normalValue + transformGradValue);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -25,21 +25,21 @@ Class
Foam::pressureInletOutletVelocityFvPatchVectorField Foam::pressureInletOutletVelocityFvPatchVectorField
Group Group
grpInletBoundaryConditions grpOutletBoundaryConditions grpInletletBoundaryConditions grpOutletBoundaryConditions
Description Description
This velocity inlet/outlet boundary condition is applied to pressure This velocity inlet/outlet boundary condition is applied to pressure
boundaries where the pressure is specified. A zero-gradient condition is boundaries where the pressure is specified. A zero-gradient condition is
applied for outflow (as defined by the flux); for inflow, the velocity is applied for outflow (as defined by the flux); for inflow, the velocity is
obtained from the patch-face normal component of the internal-cell value and obtained from the patch-face normal component of the internal-cell value.
the tangential patch velocity can be optionally specified.
The tangential patch velocity can be optionally specified.
\heading Patch usage \heading Patch usage
\table \table
Property | Description | Required | Default value Property | Description | Required | Default value
phi | flux field name | no | phi phi | flux field name | no | phi
rho | density field name | no | rho
tangentialVelocity | tangential velocity field | no | tangentialVelocity | tangential velocity field | no |
\endtable \endtable
@ -49,7 +49,6 @@ Description
{ {
type pressureInletOutletVelocity; type pressureInletOutletVelocity;
phi phi; phi phi;
rho rho;
tangentialVelocity uniform (0 0 0); tangentialVelocity uniform (0 0 0);
value uniform 0; value uniform 0;
} }
@ -70,7 +69,7 @@ SourceFiles
#define pressureInletOutletVelocityFvPatchVectorField_H #define pressureInletOutletVelocityFvPatchVectorField_H
#include "fvPatchFields.H" #include "fvPatchFields.H"
#include "mixedFvPatchFields.H" #include "directionMixedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -83,24 +82,16 @@ namespace Foam
class pressureInletOutletVelocityFvPatchVectorField class pressureInletOutletVelocityFvPatchVectorField
: :
public mixedFvPatchVectorField public directionMixedFvPatchVectorField
{ {
// Private data // Private data
//- Flux field name //- Flux field name
word phiName_; word phiName_;
//- Density field name
word rhoName_;
protected:
//- Optional tangential velocity component //- Optional tangential velocity component
vectorField tangentialVelocity_; vectorField tangentialVelocity_;
bool applyTangentialVelocity_;
public: public:
@ -117,17 +108,6 @@ public:
const DimensionedField<vector, volMesh>& const DimensionedField<vector, volMesh>&
); );
//- Construct by mapping given
// pressureInletOutletVelocityFvPatchVectorField
// onto a new patch
pressureInletOutletVelocityFvPatchVectorField
(
const pressureInletOutletVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct from patch, internal field and dictionary //- Construct from patch, internal field and dictionary
pressureInletOutletVelocityFvPatchVectorField pressureInletOutletVelocityFvPatchVectorField
( (
@ -136,6 +116,16 @@ public:
const dictionary& const dictionary&
); );
//- Construct by mapping given
// pressureInletOutletVelocityFvPatchVectorField onto a new patch
pressureInletOutletVelocityFvPatchVectorField
(
const pressureInletOutletVelocityFvPatchVectorField&,
const fvPatch&,
const DimensionedField<vector, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy //- Construct as copy
pressureInletOutletVelocityFvPatchVectorField pressureInletOutletVelocityFvPatchVectorField
( (
@ -147,10 +137,7 @@ public:
{ {
return tmp<fvPatchVectorField> return tmp<fvPatchVectorField>
( (
new pressureInletOutletVelocityFvPatchVectorField new pressureInletOutletVelocityFvPatchVectorField(*this)
(
*this
)
); );
} }
@ -169,11 +156,7 @@ public:
{ {
return tmp<fvPatchVectorField> return tmp<fvPatchVectorField>
( (
new pressureInletOutletVelocityFvPatchVectorField new pressureInletOutletVelocityFvPatchVectorField(*this, iF)
(
*this,
iF
)
); );
} }
@ -194,18 +177,6 @@ public:
return phiName_; return phiName_;
} }
//- Return the name of rho
const word& rhoName() const
{
return rhoName_;
}
//- Return reference to the name of rho to allow adjustment
word& rhoName()
{
return rhoName_;
}
//- Return the tangential velocity //- Return the tangential velocity
const vectorField& tangentialVelocity() const const vectorField& tangentialVelocity() const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -33,17 +33,17 @@ License
void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField:: void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
calcTangentialVelocity() calcTangentialVelocity()
{ {
applyTangentialVelocity_ = true;
const scalar t = this->db().time().timeOutputValue(); const scalar t = this->db().time().timeOutputValue();
vector om = omega_->value(t); vector om = omega_->value(t);
vector axisHat = om/mag(om); vector axisHat = om/mag(om);
tangentialVelocity_ = const vectorField tangentialVelocity
(-om) ^ (patch().Cf() - axisHat*(axisHat & patch().Cf())); (
(-om) ^ (patch().Cf() - axisHat*(axisHat & patch().Cf()))
);
const vectorField n(patch().nf()); const vectorField n(patch().nf());
tangentialVelocity_ -= n*(n & tangentialVelocity_); refValue() = tangentialVelocity - n*(n & tangentialVelocity);
} }
@ -72,7 +72,9 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
: :
pressureInletOutletVelocityFvPatchVectorField(ptf, p, iF, mapper), pressureInletOutletVelocityFvPatchVectorField(ptf, p, iF, mapper),
omega_(ptf.omega_().clone().ptr()) omega_(ptf.omega_().clone().ptr())
{} {
calcTangentialVelocity();
}
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField:: Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
@ -85,7 +87,9 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
: :
pressureInletOutletVelocityFvPatchVectorField(p, iF, dict), pressureInletOutletVelocityFvPatchVectorField(p, iF, dict),
omega_(DataEntry<vector>::New("omega", dict)) omega_(DataEntry<vector>::New("omega", dict))
{} {
calcTangentialVelocity();
}
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField:: Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
@ -96,7 +100,9 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
: :
pressureInletOutletVelocityFvPatchVectorField(rppvf), pressureInletOutletVelocityFvPatchVectorField(rppvf),
omega_(rppvf.omega_().clone().ptr()) omega_(rppvf.omega_().clone().ptr())
{} {
calcTangentialVelocity();
}
Foam::rotatingPressureInletOutletVelocityFvPatchVectorField:: Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::
@ -108,24 +114,13 @@ rotatingPressureInletOutletVelocityFvPatchVectorField
: :
pressureInletOutletVelocityFvPatchVectorField(rppvf, iF), pressureInletOutletVelocityFvPatchVectorField(rppvf, iF),
omega_(rppvf.omega_().clone().ptr()) omega_(rppvf.omega_().clone().ptr())
{} {
calcTangentialVelocity();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::updateCoeffs()
{
if (updated())
{
return;
}
calcTangentialVelocity();
pressureInletOutletVelocityFvPatchVectorField::updateCoeffs();
}
void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::write void Foam::rotatingPressureInletOutletVelocityFvPatchVectorField::write
( (
Ostream& os Ostream& os

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -177,9 +177,6 @@ public:
// Member functions // Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write //- Write
virtual void write(Ostream&) const; virtual void write(Ostream&) const;
}; };

View File

@ -44,6 +44,7 @@ boundaryField
atmosphere atmosphere
{ {
type pressureInletOutletVelocity; type pressureInletOutletVelocity;
tangentialVelocity $internalField;
value uniform (0 0 0); value uniform (0 0 0);
} }