diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index 9b72859c9d9dea1e138910b9c0d196e3c403c4de..f5cd4413b1a3b59bb6dc74c6fe83704ef81d9fd6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -72,7 +72,7 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField<vector>(p, iF), - rhoInlet_(0.0) + rhoInlet_(dict.lookupOrDefault<scalar>("rhoInlet", -VGREAT)) { if (dict.found("volumetricFlowRate")) { @@ -107,14 +107,9 @@ flowRateInletVelocityFvPatchVectorField vectorField("value", dict, p.size()) ); } - else if (volumetric_) - { - evaluate(Pstream::blocking); - } else { - rhoInlet_ = readScalar(dict.lookup("rhoInlet")); - updateCoeffs(rhoInlet_); + evaluate(Pstream::blocking); } } @@ -202,10 +197,30 @@ void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs() else { // mass flow-rate - const fvPatchField<scalar>& rhop = - patch().lookupPatchField<volScalarField, scalar>(rhoName_); - - operator==(n*avgU/rhop); + if + ( + patch().boundaryMesh().mesh().foundObject<volScalarField>(rhoName_) + ) + { + const fvPatchField<scalar>& rhop = + patch().lookupPatchField<volScalarField, scalar>(rhoName_); + + operator==(n*avgU/rhop); + } + else + { + // Use constant density + if (rhoInlet_ < 0) + { + FatalErrorIn + ( + "flowRateInletVelocityFvPatchVectorField::updateCoeffs()" + ) << "Did not find registered density field " << rhoName_ + << " and no constant density 'rhoInlet' specified" + << exit(FatalError); + } + operator==(n*avgU/rhoInlet_); + } } fixedValueFvPatchField<vector>::updateCoeffs(); @@ -219,7 +234,7 @@ void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const if (!volumetric_) { writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); - os.writeKeyword("rhoInlet") << rhoInlet_ << token::END_STATEMENT << nl; + writeEntryIfDifferent<scalar>(os, "rhoInlet", -VGREAT, rhoInlet_); } writeEntry("value", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H index 192e14b7d1ba5024ca91e358f51e6cb2202a3782..1a5d2f493d160bff3497b3898422c002127d84c7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.H @@ -29,7 +29,7 @@ Description magnitude as an integral over its area. Either specify 'volumetricFlowRate' or 'massFlowRate' (requires additional - 'rho' entry). + 'rho' or 'rhoInlet' entry). Example of the boundary condition specification: \verbatim @@ -44,9 +44,10 @@ Description inlet { type flowRateInletVelocity; - volumetricFlowRate 0.2; // mass flow rate [kg/s] + massFlowRate 0.2; // mass flow rate [kg/s] rho rho; // rho [m3/s or kg/s] - value uniform (0 0 0); // placeholder + rhoInlet 1.0 // uniform rho if no rho field registered + // (e.g. at startup) } \endverbatim diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.org/U b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.org/U index e3127719aab1e0a70605a10b883882ef3c43e0bd..a403d36428cca36380d7e13509eedd15ec13a23b 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.org/U +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/0.org/U @@ -33,17 +33,13 @@ boundaryField { type flowRateInletVelocity; massFlowRate constant 0.00379; - //volumetricFlowRate constant 0.00379; - rhoInlet 1.0; - value uniform (0 14.68 0); + rhoInlet 1.0; // fallback value for e.g. potentialFoam } inletSides { type flowRateInletVelocity; massFlowRate constant 0.00832; - //volumetricFlowRate constant 0.00832; - rhoInlet 1.0; - value uniform (0 17.79 0); + rhoInlet 1.0; // fallback value for e.g. potentialFoam } outlet { diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun index babec860ab7153d2f3384c00bd63f7ade233034f..4fe0655e63de7498f8f5704b3cb3a2fee2aae6dc 100755 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/Allrun @@ -14,9 +14,6 @@ runApplication potentialFoam rm -f 0/phi -# change flowRateInletVelocity to massFlowRate -runApplication changeDictionary - # run the solver runApplication `getApplication`