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:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "one.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -42,7 +43,8 @@ flowRateInletVelocityFvPatchVectorField
|
||||
flowRate_(),
|
||||
volumetric_(false),
|
||||
rhoName_("rho"),
|
||||
rhoInlet_(0.0)
|
||||
rhoInlet_(0.0),
|
||||
extrapolateProfile_(false)
|
||||
{}
|
||||
|
||||
|
||||
@ -59,7 +61,8 @@ flowRateInletVelocityFvPatchVectorField
|
||||
flowRate_(ptf.flowRate_, false),
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
rhoInlet_(ptf.rhoInlet_),
|
||||
extrapolateProfile_(ptf.extrapolateProfile_)
|
||||
{}
|
||||
|
||||
|
||||
@ -72,7 +75,11 @@ flowRateInletVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
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"))
|
||||
{
|
||||
@ -120,7 +127,8 @@ flowRateInletVelocityFvPatchVectorField
|
||||
flowRate_(ptf.flowRate_, false),
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
rhoInlet_(ptf.rhoInlet_),
|
||||
extrapolateProfile_(ptf.extrapolateProfile_)
|
||||
{}
|
||||
|
||||
|
||||
@ -135,12 +143,50 @@ flowRateInletVelocityFvPatchVectorField
|
||||
flowRate_(ptf.flowRate_, false),
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
rhoInlet_(ptf.rhoInlet_),
|
||||
extrapolateProfile_(ptf.extrapolateProfile_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * 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()
|
||||
{
|
||||
if (updated())
|
||||
@ -148,27 +194,19 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
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")
|
||||
{
|
||||
// volumetric flow-rate or density not given
|
||||
operator==(n*avgU);
|
||||
updateValues(one());
|
||||
}
|
||||
else
|
||||
{
|
||||
// mass flow-rate
|
||||
// Mass flow-rate
|
||||
if (db().foundObject<volScalarField>(rhoName_))
|
||||
{
|
||||
const fvPatchField<scalar>& rhop =
|
||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
||||
|
||||
operator==(n*avgU/rhop);
|
||||
updateValues(rhop);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -180,7 +218,8 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
<< " and no constant density 'rhoInlet' specified"
|
||||
<< exit(FatalError);
|
||||
}
|
||||
operator==(n*avgU/rhoInlet_);
|
||||
|
||||
updateValues(rhoInlet_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,7 @@ Description
|
||||
massFlowRate | mass flow rate [kg/s] | no |
|
||||
volumetricFlowRate | volumetric flow rate [m3/s]| no |
|
||||
rhoInlet | inlet density | no |
|
||||
extrapolateProfile | Extrapolate velocity profile | no | false
|
||||
\endtable
|
||||
|
||||
Example of the boundary condition specification for a volumetric flow rate:
|
||||
@ -57,7 +58,8 @@ Description
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
volumetricFlowRate 0.2;
|
||||
value uniform (0 0 0); // placeholder
|
||||
extrapolateProfile yes;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
@ -67,8 +69,10 @@ Description
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
massFlowRate 0.2;
|
||||
extrapolateProfile yes;
|
||||
rho rho;
|
||||
rhoInlet 1.0;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
@ -78,9 +82,9 @@ Description
|
||||
Note
|
||||
- \c rhoInlet is required for the case of a mass flow rate, where the
|
||||
density field is not available at start-up
|
||||
- the value is positive into the domain (as an inlet)
|
||||
- may not work correctly for transonic inlets
|
||||
- strange behaviour with potentialFoam since the U equation is not solved
|
||||
- The value is positive into the domain (as an inlet)
|
||||
- May not work correctly for transonic inlets
|
||||
- Strange behaviour with potentialFoam since the U equation is not solved
|
||||
|
||||
SeeAlso
|
||||
Foam::DataEntry
|
||||
@ -101,6 +105,7 @@ SourceFiles
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class flowRateInletVelocityFvPatchVectorField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -123,6 +128,16 @@ class flowRateInletVelocityFvPatchVectorField
|
||||
//- Rho initialisation value (for start; if value not supplied)
|
||||
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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user