diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index bbd50fa4dee61bf21fdd116f4a26ee4dc1d59818..9b72859c9d9dea1e138910b9c0d196e3c403c4de 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<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,14 +142,18 @@ 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() +void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs +( + const scalar uniformRho +) { if (updated()) { @@ -119,40 +167,45 @@ 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 operator==(n*avgU); } - else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + else { - 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); - } + // mass flow-rate + operator==(n*avgU/uniformRho); + } +} + + +void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() +{ + 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 or density not given + operator==(n*avgU); } 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); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H index a4b48c762985683f97f69192740423473d0ac503..192e14b7d1ba5024ca91e358f51e6cb2202a3782 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<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(); diff --git a/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/U b/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/U index 69ad6faa274315f25b2e1da51f4011e96a8cfc75..f5e2ba0301de694602c496a6070faad3b4426951 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 84b8f75f3cfe486af95eb409be5724fed1af8f31..713bdebe4a1ae6141aed1c1b8764f065fc4f5663 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 84b8f75f3cfe486af95eb409be5724fed1af8f31..1105ba84b0d3d45703447c25e8255a293531b6c5 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 c9822054aff3223147af983d91e4ef4d4c646e44..e9b532f37361e311feb19f07d7173d8ed7d6b847 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 b66f23d6cb6b26067ac01026aa738c1153365861..20e25d12a8c318b8b0532714ad2919ed4068fe7c 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 d5bd0a74cf75eac8797c6d9337e2ea656734ba4d..22ce6f4d0338b88579c590cae4228da54ad8822a 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 b66f23d6cb6b26067ac01026aa738c1153365861..ad11b09e1e850ffc6943363fb5dfe9128be79ec2 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 352d6b50277375ebbd80840c8e5422c6f53647df..7f8c434997d68a5388638800a7005537a215005e 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 352d6b50277375ebbd80840c8e5422c6f53647df..7f8c434997d68a5388638800a7005537a215005e 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 352d6b50277375ebbd80840c8e5422c6f53647df..7f8c434997d68a5388638800a7005537a215005e 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 352d6b50277375ebbd80840c8e5422c6f53647df..7f8c434997d68a5388638800a7005537a215005e 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 526fadc34444c886d69c5e2bf11feaa56f9ff8bf..5a7c8f1661d1b4454e1ffd90c1e6b89ea41f6e94 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