diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C index 59e729de7a03e4542990294daed30ee686fe216c..c5c2fe3c09b286ad607e7ea9946a85e9994c1ca2 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.C @@ -30,6 +30,7 @@ License #include "addToRunTimeSelectionTable.H" #include "volFields.H" #include "surfaceFields.H" +#include "TableFile.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -86,12 +87,28 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(p, iF, dict), - fanCurve_(dict), + fanCurve_(), direction_(fanFlowDirectionNames_.get("direction", dict)), rpm_(0), dm_(0), nonDimensional_(dict.getOrDefault("nonDimensional", false)) { + // Backwards compatibility + if (dict.found("file")) + { + fanCurve_.reset + ( + new Function1Types::TableFile<scalar>("fanCurve", dict) + ); + } + else + { + fanCurve_.reset + ( + Function1<scalar>::New("fanCurve", dict) + ); + } + if (nonDimensional_) { dict.readEntry("rpm", rpm_); @@ -102,30 +119,30 @@ Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField ( - const fanPressureFvPatchScalarField& pfopsf + const fanPressureFvPatchScalarField& fppsf ) : - totalPressureFvPatchScalarField(pfopsf), - fanCurve_(pfopsf.fanCurve_), - direction_(pfopsf.direction_), - rpm_(pfopsf.rpm_), - dm_(pfopsf.dm_), - nonDimensional_(pfopsf.nonDimensional_) + totalPressureFvPatchScalarField(fppsf), + fanCurve_(fppsf.fanCurve_.clone()), + direction_(fppsf.direction_), + rpm_(fppsf.rpm_), + dm_(fppsf.dm_), + nonDimensional_(fppsf.nonDimensional_) {} Foam::fanPressureFvPatchScalarField::fanPressureFvPatchScalarField ( - const fanPressureFvPatchScalarField& pfopsf, + const fanPressureFvPatchScalarField& fppsf, const DimensionedField<scalar, volMesh>& iF ) : - totalPressureFvPatchScalarField(pfopsf, iF), - fanCurve_(pfopsf.fanCurve_), - direction_(pfopsf.direction_), - rpm_(pfopsf.rpm_), - dm_(pfopsf.dm_), - nonDimensional_(pfopsf.nonDimensional_) + totalPressureFvPatchScalarField(fppsf, iF), + fanCurve_(fppsf.fanCurve_.clone()), + direction_(fppsf.direction_), + rpm_(fppsf.rpm_), + dm_(fppsf.dm_), + nonDimensional_(fppsf.nonDimensional_) {} @@ -139,11 +156,9 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() } // Retrieve flux field - const surfaceScalarField& phi = - db().lookupObject<surfaceScalarField>(phiName()); + const auto& phi = db().lookupObject<surfaceScalarField>(phiName()); - const fvsPatchField<scalar>& phip = - patch().patchField<surfaceScalarField, scalar>(phi); + const auto& phip = patch().patchField<surfaceScalarField, scalar>(phi); int dir = 2*direction_ - 1; @@ -178,7 +193,7 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() } // Pressure drop for this flow rate - scalar pdFan = fanCurve_(max(volFlowRate, 0.0)); + scalar pdFan = fanCurve_->value(max(volFlowRate, 0.0)); if (nonDimensional_) { @@ -197,8 +212,9 @@ void Foam::fanPressureFvPatchScalarField::updateCoeffs() void Foam::fanPressureFvPatchScalarField::write(Ostream& os) const { totalPressureFvPatchScalarField::write(os); - fanCurve_.write(os); + fanCurve_->writeData(os); os.writeEntry("direction", fanFlowDirectionNames_[direction_]); + if (nonDimensional_) { os.writeEntry("nonDimensional", "true"); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H index f1ccf048586e8ac2742ea48cb895566584bdad85..5184876d8386b81dac41c43cb9ecf38a39f55d5d 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fanPressure/fanPressureFvPatchScalarField.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd + Copyright (C) 2017-2020 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -69,6 +69,7 @@ Usage inlet { type fanPressure; + fanCurve tableFile; file "fanCurve"; outOfBounds clamp; direction in; @@ -79,6 +80,7 @@ Usage outlet { type fanPressure; + fanCurve tableFile; file "fanCurve"; outOfBounds clamp; direction out; @@ -90,7 +92,7 @@ Usage See also Foam::fanFvPatchField Foam::totalPressureFvPatchScalarField - Foam::interpolationTable + Foam::Function1 SourceFiles fanPressureFvPatchScalarField.C @@ -101,7 +103,7 @@ SourceFiles #define fanPressureFvPatchScalarField_H #include "totalPressureFvPatchScalarField.H" -#include "interpolationTable.H" +#include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -134,8 +136,8 @@ private: // Private Data - //- Tabulated fan curve - interpolationTable<scalar> fanCurve_; + //- Run-time selectable fan curve + autoPtr<Function1<scalar>> fanCurve_; //- Direction of flow through the fan relative to patch fanFlowDirection direction_;