flowRateInletVelocity: Added option to extrapolate the velocity profile to the inlet

e.g.

    inlet
    {
        type                flowRateInletVelocity;
        massFlowRate        0.2;
        extrapolateProfile  yes;
        rho                 rho;
        rhoInlet            1.0;
        value               uniform (0 0 0);
    }
This commit is contained in:
Henry Weller
2016-02-07 22:55:52 +00:00
parent 14df9bde95
commit 9fc0201568
2 changed files with 77 additions and 23 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) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,6 +28,7 @@ License
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "one.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -42,7 +43,8 @@ flowRateInletVelocityFvPatchVectorField
flowRate_(), flowRate_(),
volumetric_(false), volumetric_(false),
rhoName_("rho"), rhoName_("rho"),
rhoInlet_(0.0) rhoInlet_(0.0),
extrapolateProfile_(false)
{} {}
@ -59,7 +61,8 @@ flowRateInletVelocityFvPatchVectorField
flowRate_(ptf.flowRate_, false), flowRate_(ptf.flowRate_, false),
volumetric_(ptf.volumetric_), volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_) rhoInlet_(ptf.rhoInlet_),
extrapolateProfile_(ptf.extrapolateProfile_)
{} {}
@ -72,7 +75,11 @@ flowRateInletVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchField<vector>(p, iF), fixedValueFvPatchField<vector>(p, iF),
rhoInlet_(dict.lookupOrDefault<scalar>("rhoInlet", -VGREAT)) rhoInlet_(dict.lookupOrDefault<scalar>("rhoInlet", -VGREAT)),
extrapolateProfile_
(
dict.lookupOrDefault<Switch>("extrapolateProfile", false)
)
{ {
if (dict.found("volumetricFlowRate")) if (dict.found("volumetricFlowRate"))
{ {
@ -120,7 +127,8 @@ flowRateInletVelocityFvPatchVectorField
flowRate_(ptf.flowRate_, false), flowRate_(ptf.flowRate_, false),
volumetric_(ptf.volumetric_), volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_) rhoInlet_(ptf.rhoInlet_),
extrapolateProfile_(ptf.extrapolateProfile_)
{} {}
@ -135,12 +143,50 @@ flowRateInletVelocityFvPatchVectorField
flowRate_(ptf.flowRate_, false), flowRate_(ptf.flowRate_, false),
volumetric_(ptf.volumetric_), volumetric_(ptf.volumetric_),
rhoName_(ptf.rhoName_), rhoName_(ptf.rhoName_),
rhoInlet_(ptf.rhoInlet_) rhoInlet_(ptf.rhoInlet_),
extrapolateProfile_(ptf.extrapolateProfile_)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class RhoType>
void Foam::flowRateInletVelocityFvPatchVectorField::updateValues
(
const RhoType& rho
)
{
const scalar t = db().time().timeOutputValue();
tmp<vectorField> n = patch().nf();
if (extrapolateProfile_)
{
vectorField newValues(this->patchInternalField());
scalar flowRate = flowRate_->value(t);
scalar estimatedFlowRate = -gSum(rho*(this->patch().Sf() & newValues));
if (estimatedFlowRate/flowRate > 0.5)
{
newValues *= (mag(flowRate)/mag(estimatedFlowRate));
}
else
{
newValues -=
((flowRate - estimatedFlowRate)/gSum(rho*patch().magSf()))*n;
}
this->operator==(newValues);
}
else
{
const scalar avgU = -flowRate_->value(t)/gSum(rho*patch().magSf());
operator==(n*avgU);
}
}
void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
{ {
if (updated()) if (updated())
@ -148,27 +194,19 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
return; return;
} }
const scalar t = db().time().timeOutputValue();
// a simpler way of doing this would be nice
const scalar avgU = -flowRate_->value(t)/gSum(patch().magSf());
tmp<vectorField> n = patch().nf();
if (volumetric_ || rhoName_ == "none") if (volumetric_ || rhoName_ == "none")
{ {
// volumetric flow-rate or density not given updateValues(one());
operator==(n*avgU);
} }
else else
{ {
// mass flow-rate // Mass flow-rate
if (db().foundObject<volScalarField>(rhoName_)) if (db().foundObject<volScalarField>(rhoName_))
{ {
const fvPatchField<scalar>& rhop = const fvPatchField<scalar>& rhop =
patch().lookupPatchField<volScalarField, scalar>(rhoName_); patch().lookupPatchField<volScalarField, scalar>(rhoName_);
operator==(n*avgU/rhop); updateValues(rhop);
} }
else else
{ {
@ -180,7 +218,8 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
<< " and no constant density 'rhoInlet' specified" << " and no constant density 'rhoInlet' specified"
<< exit(FatalError); << exit(FatalError);
} }
operator==(n*avgU/rhoInlet_);
updateValues(rhoInlet_);
} }
} }

View File

@ -49,6 +49,7 @@ Description
massFlowRate | mass flow rate [kg/s] | no | massFlowRate | mass flow rate [kg/s] | no |
volumetricFlowRate | volumetric flow rate [m3/s]| no | volumetricFlowRate | volumetric flow rate [m3/s]| no |
rhoInlet | inlet density | no | rhoInlet | inlet density | no |
extrapolateProfile | Extrapolate velocity profile | no | false
\endtable \endtable
Example of the boundary condition specification for a volumetric flow rate: Example of the boundary condition specification for a volumetric flow rate:
@ -57,7 +58,8 @@ Description
{ {
type flowRateInletVelocity; type flowRateInletVelocity;
volumetricFlowRate 0.2; volumetricFlowRate 0.2;
value uniform (0 0 0); // placeholder extrapolateProfile yes;
value uniform (0 0 0);
} }
\endverbatim \endverbatim
@ -67,8 +69,10 @@ Description
{ {
type flowRateInletVelocity; type flowRateInletVelocity;
massFlowRate 0.2; massFlowRate 0.2;
extrapolateProfile yes;
rho rho; rho rho;
rhoInlet 1.0; rhoInlet 1.0;
value uniform (0 0 0);
} }
\endverbatim \endverbatim
@ -78,9 +82,9 @@ Description
Note Note
- \c rhoInlet is required for the case of a mass flow rate, where the - \c rhoInlet is required for the case of a mass flow rate, where the
density field is not available at start-up density field is not available at start-up
- the value is positive into the domain (as an inlet) - The value is positive into the domain (as an inlet)
- may not work correctly for transonic inlets - May not work correctly for transonic inlets
- strange behaviour with potentialFoam since the U equation is not solved - Strange behaviour with potentialFoam since the U equation is not solved
SeeAlso SeeAlso
Foam::DataEntry Foam::DataEntry
@ -101,6 +105,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class flowRateInletVelocityFvPatchVectorField Declaration Class flowRateInletVelocityFvPatchVectorField Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -123,6 +128,16 @@ class flowRateInletVelocityFvPatchVectorField
//- Rho initialisation value (for start; if value not supplied) //- Rho initialisation value (for start; if value not supplied)
scalar rhoInlet_; scalar rhoInlet_;
//- Set true to extrapolate the velocity profile from the interior
Switch extrapolateProfile_;
// Private member functions
//- Update the patch values given the appropriate density type and value
template<class RhoType>
void updateValues(const RhoType& rho);
public: public: