From aca4f077ac7ee186ceafe2d36a69385da4c9d46e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 28 Sep 2020 10:35:45 +0200 Subject: [PATCH] ENH: fanPressure - use fanCurve entry if present - only use implicit legacy handling if the "fanCurve" entry is missing and the "file" entry is present. --- .../fanPressureFvPatchScalarField.C | 12 +++--- .../fanPressureFvPatchScalarField.H | 39 ++++++++++++------- .../pimpleFoam/RAS/TJunctionFan/0.orig/p | 11 ++++-- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C index c5c2fe3c09..7b94e9b886 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C @@ -54,7 +54,7 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(p, iF), - fanCurve_(), + fanCurve_(nullptr), direction_(ffdOut), rpm_(0), dm_(0), @@ -87,15 +87,15 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(p, iF, dict), - fanCurve_(), + fanCurve_(nullptr), direction_(fanFlowDirectionNames_.get("direction", dict)), rpm_(0), dm_(0), nonDimensional_(dict.getOrDefault("nonDimensional", false)) { - // Backwards compatibility - if (dict.found("file")) + if (dict.found("file") && !dict.found("fanCurve")) { + // Backwards compatibility (2006 and earlier) fanCurve_.reset ( new Function1Types::TableFile("fanCurve", dict) @@ -160,7 +160,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() const auto& phip = patch().patchField(phi); - int dir = 2*direction_ - 1; + const int dir = 2*direction_ - 1; // Average volumetric flow rate scalar volFlowRate = 0; @@ -193,7 +193,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() } // Pressure drop for this flow rate - scalar pdFan = fanCurve_->value(max(volFlowRate, 0.0)); + scalar pdFan = fanCurve_->value(max(volFlowRate, scalar(0))); if (nonDimensional_) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H index 5184876d83..8509623145 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H @@ -34,10 +34,10 @@ Description This boundary condition can be applied to assign either a pressure inlet or outlet total pressure condition for a fan. - The switch nonDimensional can be used for a non-dimensional table. It needs - inputs rpm and dm of the fan. + The switch nonDimensional can be used for a non-dimensional fan curve. + It needs inputs rpm and dm of the fan. - The nonDimensional flux for the table is calculate as : + The nonDimensional flux is calculate as : phi = 4.0*mDot/(rho*sqr(PI)*dm^3*omega) where: @@ -54,14 +54,15 @@ Description Usage \table - Property | Description | Required | Default value - file | fan curve file name | yes | - outOfBounds | out of bounds handling | yes | + Property | Description | Required | Default + fanCurve | Pressure vs flow-rate | yes | + outOfBounds | out of bounds handling | yes | direction | direction of flow through fan [in/out] | yes | - p0 | environmental total pressure | yes | - nonDimensional | uses non-dimensional table | no | false - rpm | fan rpm for non-dimensional table | no | 0.0 + p0 | environmental total pressure | yes | + nonDimensional | uses non-dimensional table | no | false + rpm | fan rpm for non-dimensional table | no | 0 dm | mean diameter for non-dimensional table | no | 0.0 + file | fan curve file name | legacy | \endtable Example of the boundary condition specification: @@ -69,26 +70,34 @@ Usage inlet { type fanPressure; - fanCurve tableFile; - file "fanCurve"; - outOfBounds clamp; direction in; + fanCurve tableFile; + fanCurveCoeffs + { + file "/fanCurve"; + outOfBounds clamp; + } p0 uniform 0; value uniform 0; } + // Legacy specification outlet { type fanPressure; - fanCurve tableFile; - file "fanCurve"; - outOfBounds clamp; direction out; + file "/fanCurve"; + outOfBounds clamp; p0 uniform 0; value uniform 0; } \endverbatim +Note + For compatibility with older versions (OpenFOAM-v2006 and earlier), + a missing \c fanCurve keyword is treated as a tableFile and makes + the \c file keyword mandatory. + See also Foam::fanFvPatchField Foam::totalPressureFvPatchScalarField diff --git a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/0.orig/p b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/0.orig/p index c5f069a787..0428a4a58b 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/0.orig/p +++ b/tutorials/incompressible/pimpleFoam/RAS/TJunctionFan/0.orig/p @@ -24,14 +24,17 @@ boundaryField inlet { type fanPressure; - outOfBounds clamp; direction in; - readerType openFoam; - file "/FluxVsdP.dat"; + fanCurve tableFile; + fanCurveCoeffs + { + file "/FluxVsdP.dat"; + // readerType openFoam; // Default + // outOfBounds clamp; // Default + } //nonDimensional true; //rpm 300; //dm 2e-2; - outOfBounds clamp; p0 uniform 30; } outlet1