From 12b68e115120a612313e1a2032e2996014a8fea8 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 25 Sep 2020 16:05:51 +0200 Subject: [PATCH] ENH: replace finiteArea timeVaryingUniformFixedValue with Function1 version - timeVaryingUniformFixedValue -> uniformFixedValue - allows a variety of functions (eg, coded, expressions, tables, ...) - more similarity to finiteVolume patch type STYLE: remove unused timeVarying... from etc/controlDict --- etc/controlDict | 3 - src/finiteArea/Make/files | 2 +- .../uniformFixedValueFaPatchField.C} | 55 +++++---- .../uniformFixedValueFaPatchField.H} | 104 ++++++++---------- .../uniformFixedValueFaPatchFields.C} | 6 +- .../uniformFixedValueFaPatchFields.H} | 10 +- .../uniformFixedValueFaPatchFieldsFwd.H} | 10 +- .../finiteArea/liquidFilmFoam/cylinder/0/h | 4 +- 8 files changed, 86 insertions(+), 108 deletions(-) rename src/finiteArea/fields/faPatchFields/derived/{timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.C => uniformFixedValue/uniformFixedValueFaPatchField.C} (65%) rename src/finiteArea/fields/faPatchFields/derived/{timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H => uniformFixedValue/uniformFixedValueFaPatchField.H} (59%) rename src/finiteArea/fields/faPatchFields/derived/{timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C => uniformFixedValue/uniformFixedValueFaPatchFields.C} (92%) rename src/finiteArea/fields/faPatchFields/derived/{timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.H => uniformFixedValue/uniformFixedValueFaPatchFields.H} (86%) rename src/finiteArea/fields/faPatchFields/derived/{timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFieldsFwd.H => uniformFixedValue/uniformFixedValueFaPatchFieldsFwd.H} (86%) diff --git a/etc/controlDict b/etc/controlDict index a150545e48..dbd6782f87 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -903,10 +903,7 @@ DebugSwitches thermophysicalFunction 0; time 0; timeVaryingAlphaContactAngle 0; - timeVaryingFlowRateInletVelocity 0; timeVaryingMappedFixedValue 0; - timeVaryingTotalPressure 0; - timeVaryingUniformFixedValue 0; timer 0; topoAction 0; topoCellLooper 0; diff --git a/src/finiteArea/Make/files b/src/finiteArea/Make/files index 44a1db2be5..631570b62c 100644 --- a/src/finiteArea/Make/files +++ b/src/finiteArea/Make/files @@ -48,7 +48,7 @@ $(derivedFaPatchFields)/fixedValueOutflow/fixedValueOutflowFaPatchFields.C $(derivedFaPatchFields)/inletOutlet/inletOutletFaPatchFields.C $(derivedFaPatchFields)/slip/slipFaPatchFields.C $(derivedFaPatchFields)/edgeNormalFixedValue/edgeNormalFixedValueFaPatchVectorField.C -$(derivedFaPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C +$(derivedFaPatchFields)/uniformFixedValue/uniformFixedValueFaPatchFields.C faePatchFields = fields/faePatchFields $(faePatchFields)/faePatchField/faePatchFields.C diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.C b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.C similarity index 65% rename from src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.C rename to src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.C index 1bba29333b..4de3a60c88 100644 --- a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.C +++ b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,27 +25,24 @@ License \*---------------------------------------------------------------------------*/ -#include "timeVaryingUniformFixedValueFaPatchField.H" -#include "Time.H" +#include "uniformFixedValueFaPatchField.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::timeVaryingUniformFixedValueFaPatchField:: -timeVaryingUniformFixedValueFaPatchField +Foam::uniformFixedValueFaPatchField::uniformFixedValueFaPatchField ( const faPatch& p, const DimensionedField& iF ) : fixedValueFaPatchField(p, iF), - timeSeries_() + uniformValue_(nullptr) {} template -Foam::timeVaryingUniformFixedValueFaPatchField:: -timeVaryingUniformFixedValueFaPatchField +Foam::uniformFixedValueFaPatchField::uniformFixedValueFaPatchField ( const faPatch& p, const DimensionedField& iF, @@ -53,85 +50,83 @@ timeVaryingUniformFixedValueFaPatchField ) : fixedValueFaPatchField(p, iF), - timeSeries_(dict) + uniformValue_(Function1::New("uniformValue", dict)) { if (dict.found("value")) { - faPatchField::operator==(Field("value", dict, p.size())); + faPatchField::operator== + ( + Field("value", dict, p.size()) + ); } else { - updateCoeffs(); + this->evaluate(); } } template -Foam::timeVaryingUniformFixedValueFaPatchField:: -timeVaryingUniformFixedValueFaPatchField +Foam::uniformFixedValueFaPatchField::uniformFixedValueFaPatchField ( - const timeVaryingUniformFixedValueFaPatchField& ptf, + const uniformFixedValueFaPatchField& ptf, const faPatch& p, const DimensionedField& iF, const faPatchFieldMapper& mapper ) : fixedValueFaPatchField(ptf, p, iF, mapper), - timeSeries_(ptf.timeSeries_) + uniformValue_(ptf.uniformValue_.clone()) {} template -Foam::timeVaryingUniformFixedValueFaPatchField:: -timeVaryingUniformFixedValueFaPatchField +Foam::uniformFixedValueFaPatchField::uniformFixedValueFaPatchField ( - const timeVaryingUniformFixedValueFaPatchField& ptf + const uniformFixedValueFaPatchField& ptf ) : fixedValueFaPatchField(ptf), - timeSeries_(ptf.timeSeries_) + uniformValue_(ptf.uniformValue_.clone()) {} template -Foam::timeVaryingUniformFixedValueFaPatchField:: -timeVaryingUniformFixedValueFaPatchField +Foam::uniformFixedValueFaPatchField::uniformFixedValueFaPatchField ( - const timeVaryingUniformFixedValueFaPatchField& ptf, + const uniformFixedValueFaPatchField& ptf, const DimensionedField& iF ) : fixedValueFaPatchField(ptf, iF), - timeSeries_(ptf.timeSeries_) + uniformValue_(ptf.uniformValue_.clone()) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -void Foam::timeVaryingUniformFixedValueFaPatchField::updateCoeffs() +void Foam::uniformFixedValueFaPatchField::updateCoeffs() { if (this->updated()) { return; } - faPatchField::operator== - ( - timeSeries_(this->db().time().timeOutputValue()) - ); + const scalar t = this->db().time().timeOutputValue(); + faPatchField::operator==(uniformValue_->value(t)); fixedValueFaPatchField::updateCoeffs(); } template -void Foam::timeVaryingUniformFixedValueFaPatchField::write +void Foam::uniformFixedValueFaPatchField::write ( Ostream& os ) const { faPatchField::write(os); - timeSeries_.write(os); + uniformValue_->writeData(os); this->writeEntry("value", os); } diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H similarity index 59% rename from src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H rename to src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H index 96c06675dd..cf75c75e16 100644 --- a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchField.H +++ b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchField.H @@ -5,8 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,43 +24,42 @@ License along with OpenFOAM. If not, see . Class - Foam::timeVaryingUniformFixedValueFaPatchField + Foam::uniformFixedValueFaPatchField Description - A time-varying form of a uniform fixed value finite area - boundary condition. + This finiteArea boundary condition + provides a uniform fixed value condition, which can also be time-varying. + +Usage + \table + Property | Description | Required | Default + uniformValue | uniform value | yes | + \endtable Example of the boundary condition specification: \verbatim - inlet + { - type timeVaryingUniformFixedValue; - fileName "/time-series"; - outOfBounds clamp; // (error|warn|clamp|repeat) + type uniformFixedValue; + uniformValue constant 0.2; } \endverbatim -Author - Zeljko Tukovic, FMENA - Hrvoje Jasak, Wikki Ltd. - -Note - This class is derived directly from a fixedValue patch rather than from - a uniformFixedValue patch. - -See Also - Foam::interpolationTable and Foam::fixedValueFaPatchField +See also + Foam::Function1Types + Foam::fixedValueFvPatchField + Foam::uniformFixedValueFvPatchField.C SourceFiles - timeVaryingUniformFixedValueFaPatchField.C + uniformFixedValueFaPatchField.C \*---------------------------------------------------------------------------*/ -#ifndef timeVaryingUniformFixedValueFaPatchField_H -#define timeVaryingUniformFixedValueFaPatchField_H +#ifndef uniformFixedValueFaPatchField_H +#define uniformFixedValueFaPatchField_H #include "fixedValueFaPatchField.H" -#include "interpolationTable.H" +#include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -69,56 +67,56 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class timeVaryingUniformFixedValueFaPatch Declaration + Class uniformFixedValueFaPatch Declaration \*---------------------------------------------------------------------------*/ template -class timeVaryingUniformFixedValueFaPatchField +class uniformFixedValueFaPatchField : public fixedValueFaPatchField { - // Private data + // Private Data - //- The time series being used, including the bounding treatment - interpolationTable timeSeries_; + //- Value + autoPtr> uniformValue_; public: //- Runtime type information - TypeName("timeVaryingUniformFixedValue"); + TypeName("uniformFixedValue"); // Constructors //- Construct from patch and internal field - timeVaryingUniformFixedValueFaPatchField + uniformFixedValueFaPatchField ( const faPatch&, const DimensionedField& ); //- Construct from patch, internal field and dictionary - timeVaryingUniformFixedValueFaPatchField + uniformFixedValueFaPatchField ( const faPatch&, const DimensionedField&, const dictionary& ); - //- Construct by mapping given patch field onto a new patch - timeVaryingUniformFixedValueFaPatchField + //- Construct by mapping onto a new patch + uniformFixedValueFaPatchField ( - const timeVaryingUniformFixedValueFaPatchField&, + const uniformFixedValueFaPatchField&, const faPatch&, const DimensionedField&, const faPatchFieldMapper& ); - //- Construct as copy - timeVaryingUniformFixedValueFaPatchField + //- Copy construct + uniformFixedValueFaPatchField ( - const timeVaryingUniformFixedValueFaPatchField& + const uniformFixedValueFaPatchField& ); //- Construct and return a clone @@ -126,14 +124,14 @@ public: { return tmp> ( - new timeVaryingUniformFixedValueFaPatchField(*this) + new uniformFixedValueFaPatchField(*this) ); } //- Construct as copy setting internal field reference - timeVaryingUniformFixedValueFaPatchField + uniformFixedValueFaPatchField ( - const timeVaryingUniformFixedValueFaPatchField&, + const uniformFixedValueFaPatchField&, const DimensionedField& ); @@ -145,34 +143,22 @@ public: { return tmp> ( - new timeVaryingUniformFixedValueFaPatchField(*this, iF) + new uniformFixedValueFaPatchField(*this, iF) ); } //- Destructor - virtual ~timeVaryingUniformFixedValueFaPatchField() = default; + virtual ~uniformFixedValueFaPatchField() = default; - // Member functions - - // Access - - //- Return the time series used - const interpolationTable& timeSeries() const - { - return timeSeries_; - } - - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); + // Member Functions + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); //- Write - virtual void write(Ostream&) const; + virtual void write(Ostream& os) const; }; @@ -183,7 +169,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository - #include "timeVaryingUniformFixedValueFaPatchField.C" + #include "uniformFixedValueFaPatchField.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.C similarity index 92% rename from src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C rename to src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.C index d32c7ea768..0647d784cc 100644 --- a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.C +++ b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,7 @@ License \*---------------------------------------------------------------------------*/ -#include "timeVaryingUniformFixedValueFaPatchFields.H" +#include "uniformFixedValueFaPatchFields.H" #include "addToRunTimeSelectionTable.H" #include "areaFields.H" @@ -36,7 +36,7 @@ namespace Foam // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -makeFaPatchFields(timeVaryingUniformFixedValue); +makeFaPatchFields(uniformFixedValue); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.H b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.H similarity index 86% rename from src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.H rename to src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.H index 5ddf8b47fb..17b020ae6d 100644 --- a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFields.H +++ b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFields.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,10 +25,10 @@ License \*---------------------------------------------------------------------------*/ -#ifndef timeVaryingUniformFixedValueFaPatchFields_H -#define timeVaryingUniformFixedValueFaPatchFields_H +#ifndef uniformFixedValueFaPatchFields_H +#define uniformFixedValueFaPatchFields_H -#include "timeVaryingUniformFixedValueFaPatchField.H" +#include "uniformFixedValueFaPatchField.H" #include "fieldTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -38,7 +38,7 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makeFaPatchTypeFieldTypedefs(timeVaryingUniformFixedValue) +makeFaPatchTypeFieldTypedefs(uniformFixedValue) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFieldsFwd.H b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFieldsFwd.H similarity index 86% rename from src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFieldsFwd.H rename to src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFieldsFwd.H index 717de5df54..9facb8dce2 100644 --- a/src/finiteArea/fields/faPatchFields/derived/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFaPatchFieldsFwd.H +++ b/src/finiteArea/fields/faPatchFields/derived/uniformFixedValue/uniformFixedValueFaPatchFieldsFwd.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2017 Wikki Ltd + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,8 +25,8 @@ License \*---------------------------------------------------------------------------*/ -#ifndef timeVaryingUniformFixedValueFaPatchFieldsFwd_H -#define timeVaryingUniformFixedValueFaPatchFieldsFwd_H +#ifndef uniformFixedValueFaPatchFieldsFwd_H +#define uniformFixedValueFaPatchFieldsFwd_H #include "faPatchField.H" #include "fieldTypes.H" @@ -38,9 +38,9 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template class timeVaryingUniformFixedValueFaPatchField; +template class uniformFixedValueFaPatchField; -makeFaPatchTypeFieldTypedefs(timeVaryingUniformFixedValue); +makeFaPatchTypeFieldTypedefs(uniformFixedValue); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/finiteArea/liquidFilmFoam/cylinder/0/h b/tutorials/finiteArea/liquidFilmFoam/cylinder/0/h index 1f6f476d8a..35980be347 100644 --- a/tutorials/finiteArea/liquidFilmFoam/cylinder/0/h +++ b/tutorials/finiteArea/liquidFilmFoam/cylinder/0/h @@ -23,8 +23,8 @@ boundaryField { inlet { - type fixedValue; - value uniform 0.000141; + type uniformFixedValue; + uniformValue 0.000141; } outlet