mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: flowRateInletVelocity: require volumeFlowRate or massFlowRate keyword
This commit is contained in:
@ -40,8 +40,9 @@ flowRateInletVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF),
|
||||
flowRate_(),
|
||||
phiName_("phi"),
|
||||
rhoName_("rho")
|
||||
volumetric_(false),
|
||||
rhoName_("rho"),
|
||||
rhoInlet_(0.0)
|
||||
{}
|
||||
|
||||
|
||||
@ -56,8 +57,9 @@ flowRateInletVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
|
||||
flowRate_(ptf.flowRate_().clone().ptr()),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_)
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
{}
|
||||
|
||||
|
||||
@ -69,11 +71,52 @@ flowRateInletVelocityFvPatchVectorField
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF, dict),
|
||||
flowRate_(DataEntry<scalar>::New("flowRate", dict)),
|
||||
phiName_(dict.lookupOrDefault<word>("phi", "phi")),
|
||||
rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
|
||||
{}
|
||||
fixedValueFvPatchField<vector>(p, iF),
|
||||
rhoInlet_(0.0)
|
||||
{
|
||||
if (dict.found("volumetricFlowRate"))
|
||||
{
|
||||
volumetric_ = true;
|
||||
flowRate_ = DataEntry<scalar>::New("volumetricFlowRate", dict);
|
||||
rhoName_ = "rho";
|
||||
}
|
||||
else if (dict.found("massFlowRate"))
|
||||
{
|
||||
volumetric_ = false;
|
||||
flowRate_ = DataEntry<scalar>::New("massFlowRate", dict);
|
||||
rhoName_ = word(dict.lookupOrDefault<word>("rho", "rho"));
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"flowRateInletVelocityFvPatchVectorField::"
|
||||
"flowRateInletVelocityFvPatchVectorField"
|
||||
"(const fvPatch&, const DimensionedField<vector, volMesh>&,"
|
||||
" const dictionary&)",
|
||||
dict
|
||||
) << "Please supply either 'volumetricFlowRate' or"
|
||||
<< " 'massFlowRate' and 'rho'" << exit(FatalIOError);
|
||||
}
|
||||
|
||||
// Value field require if mass based
|
||||
if (dict.found("value"))
|
||||
{
|
||||
fvPatchField<vector>::operator=
|
||||
(
|
||||
vectorField("value", dict, p.size())
|
||||
);
|
||||
}
|
||||
else if (volumetric_)
|
||||
{
|
||||
evaluate(Pstream::blocking);
|
||||
}
|
||||
else
|
||||
{
|
||||
rhoInlet_ = readScalar(dict.lookup("rhoInlet"));
|
||||
updateCoeffs(rhoInlet_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::flowRateInletVelocityFvPatchVectorField::
|
||||
@ -84,8 +127,9 @@ flowRateInletVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf),
|
||||
flowRate_(ptf.flowRate_().clone().ptr()),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_)
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
{}
|
||||
|
||||
|
||||
@ -98,13 +142,44 @@ flowRateInletVelocityFvPatchVectorField
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf, iF),
|
||||
flowRate_(ptf.flowRate_().clone().ptr()),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_)
|
||||
volumetric_(ptf.volumetric_),
|
||||
rhoName_(ptf.rhoName_),
|
||||
rhoInlet_(ptf.rhoInlet_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs
|
||||
(
|
||||
const scalar uniformRho
|
||||
)
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
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
|
||||
operator==(n*avgU);
|
||||
}
|
||||
else
|
||||
{
|
||||
// mass flow-rate
|
||||
operator==(n*avgU/uniformRho);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
@ -119,40 +194,18 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
|
||||
tmp<vectorField> n = patch().nf();
|
||||
|
||||
const surfaceScalarField& phi =
|
||||
db().lookupObject<surfaceScalarField>(phiName_);
|
||||
|
||||
if (phi.dimensions() == dimVelocity*dimArea)
|
||||
if (volumetric_ || rhoName_ == "none")
|
||||
{
|
||||
// volumetric flow-rate
|
||||
// volumetric flow-rate or density not given
|
||||
operator==(n*avgU);
|
||||
}
|
||||
else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
|
||||
{
|
||||
if (rhoName_ == "none")
|
||||
{
|
||||
// volumetric flow-rate if density not given
|
||||
operator==(n*avgU);
|
||||
}
|
||||
else
|
||||
{
|
||||
// mass flow-rate
|
||||
const fvPatchField<scalar>& rhop =
|
||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
||||
|
||||
operator==(n*avgU/rhop);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
|
||||
) << "dimensions of " << phiName_ << " are incorrect" << nl
|
||||
<< " on patch " << this->patch().name()
|
||||
<< " of field " << this->dimensionedInternalField().name()
|
||||
<< " in file " << this->dimensionedInternalField().objectPath()
|
||||
<< nl << exit(FatalError);
|
||||
// mass flow-rate
|
||||
const fvPatchField<scalar>& rhop =
|
||||
patch().lookupPatchField<volScalarField, scalar>(rhoName_);
|
||||
|
||||
operator==(n*avgU/rhop);
|
||||
}
|
||||
|
||||
fixedValueFvPatchField<vector>::updateCoeffs();
|
||||
@ -163,8 +216,11 @@ void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<vector>::write(os);
|
||||
flowRate_->writeData(os);
|
||||
writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
|
||||
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
|
||||
if (!volumetric_)
|
||||
{
|
||||
writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
|
||||
os.writeKeyword("rhoInlet") << rhoInlet_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
@ -28,21 +28,25 @@ Description
|
||||
Describes a volumetric/mass flow normal vector boundary condition by its
|
||||
magnitude as an integral over its area.
|
||||
|
||||
The basis of the patch (volumetric or mass) is determined by the
|
||||
dimensions of the flux, phi.
|
||||
|
||||
If the flux is mass-based
|
||||
- the current density is used to correct the velocity
|
||||
- volumetric flow rate can be applied by setting the 'rho' entry to 'none'
|
||||
Either specify 'volumetricFlowRate' or 'massFlowRate' (requires additional
|
||||
'rho' entry).
|
||||
|
||||
Example of the boundary condition specification:
|
||||
\verbatim
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s]
|
||||
rho rho; // none | rho [m3/s or kg/s]
|
||||
value uniform (0 0 0); // placeholder
|
||||
type flowRateInletVelocity;
|
||||
volumetricFlowRate 0.2; // Volumetric [m3/s]
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\verbatim
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
volumetricFlowRate 0.2; // mass flow rate [kg/s]
|
||||
rho rho; // rho [m3/s or kg/s]
|
||||
value uniform (0 0 0); // placeholder
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
@ -79,12 +83,15 @@ class flowRateInletVelocityFvPatchVectorField
|
||||
//- Inlet integral flow rate
|
||||
autoPtr<DataEntry<scalar> > flowRate_;
|
||||
|
||||
//- Name of the flux transporting the field
|
||||
word phiName_;
|
||||
//- Is volumetric?
|
||||
bool volumetric_;
|
||||
|
||||
//- Name of the density field used to normalize the mass flux
|
||||
word rhoName_;
|
||||
|
||||
//- Rho initialisation value (for start; if value not supplied)
|
||||
scalar rhoInlet_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -157,6 +164,10 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Update the coefficients associated with the patch field given
|
||||
// uniform density field
|
||||
void updateCoeffs(const scalar uniformRho);
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ boundaryField
|
||||
burner
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.001294; //60kW C3H8
|
||||
massFlowRate constant 0.001294; //60kW C3H8
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ boundaryField
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.1;
|
||||
massFlowRate constant 0.1;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
outlet
|
||||
|
||||
@ -43,8 +43,8 @@ boundaryField
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.1;
|
||||
value uniform (0 0 0);
|
||||
massFlowRate constant 0.1;
|
||||
rhoInlet 1; // estimate for initial rho
|
||||
}
|
||||
outlet
|
||||
{
|
||||
|
||||
@ -43,7 +43,7 @@ boundaryField
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.1;
|
||||
massFlowRate constant 0.1;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
outlet
|
||||
|
||||
@ -43,7 +43,7 @@ boundaryField
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.1;
|
||||
massFlowRate constant 0.1;
|
||||
value uniform (0 0 0);
|
||||
}
|
||||
outlet
|
||||
|
||||
@ -28,8 +28,8 @@ boundaryField
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.5;
|
||||
value uniform (0 0 0);
|
||||
massFlowRate constant 0.5;
|
||||
rhoInlet 0.5; // Guess for rho
|
||||
}
|
||||
outlet
|
||||
{
|
||||
|
||||
@ -43,8 +43,7 @@ boundaryField
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.1;
|
||||
value uniform (0 0 0);
|
||||
volumetricFlowRate constant 0.1;
|
||||
}
|
||||
outlet
|
||||
{
|
||||
|
||||
@ -32,13 +32,13 @@ boundaryField
|
||||
inletCentral
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00379;
|
||||
massFlowRate constant 0.00379;
|
||||
value uniform (0 14.68 0);
|
||||
}
|
||||
inletSides
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00832;
|
||||
massFlowRate constant 0.00832;
|
||||
value uniform (0 17.79 0);
|
||||
}
|
||||
outlet
|
||||
|
||||
@ -32,13 +32,13 @@ boundaryField
|
||||
inletCentral
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00379;
|
||||
massFlowRate constant 0.00379;
|
||||
value uniform (0 14.68 0);
|
||||
}
|
||||
inletSides
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00832;
|
||||
massFlowRate constant 0.00832;
|
||||
value uniform (0 17.79 0);
|
||||
}
|
||||
outlet
|
||||
|
||||
@ -32,13 +32,13 @@ boundaryField
|
||||
inletCentral
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00379;
|
||||
massFlowRate constant 0.00379;
|
||||
value uniform (0 14.68 0);
|
||||
}
|
||||
inletSides
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00832;
|
||||
massFlowRate constant 0.00832;
|
||||
value uniform (0 17.79 0);
|
||||
}
|
||||
outlet
|
||||
|
||||
@ -32,13 +32,13 @@ boundaryField
|
||||
inletCentral
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00379;
|
||||
massFlowRate constant 0.00379;
|
||||
value uniform (0 14.68 0);
|
||||
}
|
||||
inletSides
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 0.00832;
|
||||
massFlowRate constant 0.00832;
|
||||
value uniform (0 17.79 0);
|
||||
}
|
||||
outlet
|
||||
|
||||
@ -23,8 +23,7 @@ boundaryField
|
||||
inlet
|
||||
{
|
||||
type flowRateInletVelocity;
|
||||
flowRate constant 50;
|
||||
value uniform (0 0 0);
|
||||
volumetricFlowRate constant 50;
|
||||
}
|
||||
|
||||
walls
|
||||
|
||||
Reference in New Issue
Block a user