diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index bbd50fa4de..9b72859c9d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -40,8 +40,9 @@ flowRateInletVelocityFvPatchVectorField : fixedValueFvPatchField(p, iF), flowRate_(), - phiName_("phi"), - rhoName_("rho") + volumetric_(false), + rhoName_("rho"), + rhoInlet_(0.0) {} @@ -56,8 +57,9 @@ flowRateInletVelocityFvPatchVectorField : fixedValueFvPatchField(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(p, iF, dict), - flowRate_(DataEntry::New("flowRate", dict)), - phiName_(dict.lookupOrDefault("phi", "phi")), - rhoName_(dict.lookupOrDefault("rho", "rho")) -{} + fixedValueFvPatchField(p, iF), + rhoInlet_(0.0) +{ + if (dict.found("volumetricFlowRate")) + { + volumetric_ = true; + flowRate_ = DataEntry::New("volumetricFlowRate", dict); + rhoName_ = "rho"; + } + else if (dict.found("massFlowRate")) + { + volumetric_ = false; + flowRate_ = DataEntry::New("massFlowRate", dict); + rhoName_ = word(dict.lookupOrDefault("rho", "rho")); + } + else + { + FatalIOErrorIn + ( + "flowRateInletVelocityFvPatchVectorField::" + "flowRateInletVelocityFvPatchVectorField" + "(const fvPatch&, const DimensionedField&," + " const dictionary&)", + dict + ) << "Please supply either 'volumetricFlowRate' or" + << " 'massFlowRate' and 'rho'" << exit(FatalIOError); + } + + // Value field require if mass based + if (dict.found("value")) + { + fvPatchField::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(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(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 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 n = patch().nf(); - const surfaceScalarField& phi = - db().lookupObject(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& rhop = - patch().lookupPatchField(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& rhop = + patch().lookupPatchField(rhoName_); + + operator==(n*avgU/rhop); } fixedValueFvPatchField::updateCoeffs(); @@ -163,8 +216,11 @@ void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchField::write(os); flowRate_->writeData(os); - writeEntryIfDifferent(os, "phi", "phi", phiName_); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); + if (!volumetric_) + { + writeEntryIfDifferent(os, "rho", "rho", rhoName_); + os.writeKeyword("rhoInlet") << rhoInlet_ << token::END_STATEMENT << nl; + } writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H index a4b48c7629..192e14b7d1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H @@ -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 > 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(); diff --git a/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/U b/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/U index 69ad6faa27..f5e2ba0301 100644 --- a/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/U +++ b/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/U @@ -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); } diff --git a/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/0/U b/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/0/U index 84b8f75f3c..713bdebe4a 100644 --- a/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/0/U +++ b/tutorials/compressible/rhoPimpleFoam/ras/angledDuct/0/U @@ -43,7 +43,7 @@ boundaryField inlet { type flowRateInletVelocity; - flowRate constant 0.1; + massFlowRate constant 0.1; value uniform (0 0 0); } outlet diff --git a/tutorials/compressible/rhoPimplecFoam/angledDuct/0/U b/tutorials/compressible/rhoPimplecFoam/angledDuct/0/U index 84b8f75f3c..1105ba84b0 100644 --- a/tutorials/compressible/rhoPimplecFoam/angledDuct/0/U +++ b/tutorials/compressible/rhoPimplecFoam/angledDuct/0/U @@ -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 { diff --git a/tutorials/compressible/rhoPorousMRFLTSPimpleFoam/angledDuct/0/U b/tutorials/compressible/rhoPorousMRFLTSPimpleFoam/angledDuct/0/U index c9822054af..e9b532f373 100644 --- a/tutorials/compressible/rhoPorousMRFLTSPimpleFoam/angledDuct/0/U +++ b/tutorials/compressible/rhoPorousMRFLTSPimpleFoam/angledDuct/0/U @@ -43,7 +43,7 @@ boundaryField inlet { type flowRateInletVelocity; - flowRate constant 0.1; + massFlowRate constant 0.1; value uniform (0 0 0); } outlet diff --git a/tutorials/compressible/rhoPorousMRFSimpleFoam/angledDuctImplicit/0/U b/tutorials/compressible/rhoPorousMRFSimpleFoam/angledDuctImplicit/0/U index b66f23d6cb..20e25d12a8 100644 --- a/tutorials/compressible/rhoPorousMRFSimpleFoam/angledDuctImplicit/0/U +++ b/tutorials/compressible/rhoPorousMRFSimpleFoam/angledDuctImplicit/0/U @@ -43,7 +43,7 @@ boundaryField inlet { type flowRateInletVelocity; - flowRate constant 0.1; + massFlowRate constant 0.1; value uniform (0 0 0); } outlet diff --git a/tutorials/compressible/rhoSimplecFoam/squareBend/0/U b/tutorials/compressible/rhoSimplecFoam/squareBend/0/U index d5bd0a74cf..22ce6f4d03 100644 --- a/tutorials/compressible/rhoSimplecFoam/squareBend/0/U +++ b/tutorials/compressible/rhoSimplecFoam/squareBend/0/U @@ -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 { diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/U b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/U index b66f23d6cb..ad11b09e1e 100644 --- a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/U +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/U @@ -43,8 +43,7 @@ boundaryField inlet { type flowRateInletVelocity; - flowRate constant 0.1; - value uniform (0 0 0); + volumetricFlowRate constant 0.1; } outlet { diff --git a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0.org/U b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0.org/U index 352d6b5027..7f8c434997 100644 --- a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0.org/U +++ b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0.org/U @@ -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 diff --git a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0/U b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0/U index 352d6b5027..7f8c434997 100644 --- a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0/U +++ b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/0/U @@ -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 diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0.org/U b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0.org/U index 352d6b5027..7f8c434997 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0.org/U +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0.org/U @@ -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 diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U index 352d6b5027..7f8c434997 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/0/U @@ -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 diff --git a/tutorials/multiphase/interFoam/ras/waterChannel/0/U b/tutorials/multiphase/interFoam/ras/waterChannel/0/U index 526fadc344..5a7c8f1661 100644 --- a/tutorials/multiphase/interFoam/ras/waterChannel/0/U +++ b/tutorials/multiphase/interFoam/ras/waterChannel/0/U @@ -23,8 +23,7 @@ boundaryField inlet { type flowRateInletVelocity; - flowRate constant 50; - value uniform (0 0 0); + volumetricFlowRate constant 50; } walls