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