From 20b28e38f9b132c1b2adb23797885353f2511dbe Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 29 Jun 2012 15:38:58 +0100 Subject: [PATCH] ENH: uniformFixedValue: point variants --- .../uniformFixedValuePointPatchField.C | 60 +++++++++++++++---- .../uniformFixedValuePointPatchField.H | 31 +++++++--- .../uniformFixedValueFvPatchField.C | 50 +++++++++------- .../uniformFixedValueFvPatchField.H | 19 +++--- 4 files changed, 107 insertions(+), 53 deletions(-) diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C index 07a90f6ee8..0b626d888c 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,7 +41,7 @@ uniformFixedValuePointPatchField ) : fixedValuePointPatchField(p, iF), - uniformValue_(pTraits::zero) + uniformValue_() {} @@ -54,10 +54,21 @@ uniformFixedValuePointPatchField const dictionary& dict ) : - fixedValuePointPatchField(p, iF, dict), - uniformValue_(pTraits(dict.lookup("uniformValue"))) + fixedValuePointPatchField(p, iF, dict, false), + uniformValue_(DataEntry::New("uniformValue", dict)) { - Field::operator=(uniformValue_); + if (dict.found("value")) + { + fixedValuePointPatchField::operator== + ( + Field("value", dict, p.size()) + ); + } + else + { + const scalar t = this->db().time().timeOutputValue(); + fixedValuePointPatchField::operator=(uniformValue_->value(t)); + } } @@ -72,8 +83,12 @@ uniformFixedValuePointPatchField ) : fixedValuePointPatchField(ptf, p, iF, mapper), - uniformValue_(ptf.uniformValue_) -{} + uniformValue_(ptf.uniformValue_().clone().ptr()) +{ + // For safety re-evaluate + const scalar t = this->db().time().timeOutputValue(); + fixedValuePointPatchField::operator=(uniformValue_->value(t)); +} template @@ -84,7 +99,7 @@ uniformFixedValuePointPatchField ) : fixedValuePointPatchField(ptf), - uniformValue_(ptf.uniformValue_) + uniformValue_(ptf.uniformValue_().clone().ptr()) {} @@ -97,19 +112,38 @@ uniformFixedValuePointPatchField ) : fixedValuePointPatchField(ptf, iF), - uniformValue_(ptf.uniformValue_) -{} + uniformValue_(ptf.uniformValue_().clone().ptr()) +{ + // For safety re-evaluate + const scalar t = this->db().time().timeOutputValue(); + fixedValuePointPatchField::operator==(uniformValue_->value(t)); +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +void uniformFixedValuePointPatchField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + const scalar t = this->db().time().timeOutputValue(); + fixedValuePointPatchField::operator==(uniformValue_->value(t)); + + fixedValuePointPatchField::updateCoeffs(); +} + + template void uniformFixedValuePointPatchField:: write(Ostream& os) const { - pointPatchField::write(os); - os.writeKeyword("uniformValue") - << uniformValue_ << token::END_STATEMENT << nl; + // Note: write value + fixedValuePointPatchField::write(os); + uniformValue_->writeData(os); } diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.H b/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.H index f3a2b4f17b..120f1ffe16 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.H +++ b/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,20 @@ Class Foam::uniformFixedValuePointPatchField Description - Foam::uniformFixedValuePointPatchField + Enables the specification of a uniform fixed value boundary condition. + + Example of the boundary condition specification: + \verbatim + inlet + { + type uniformFixedValue; + uniformValue constant 0.2; + } + \endverbatim + + The uniformValue entry is a DataEntry type, able to describe time + varying functions. The example above gives the usage for supplying a + constant value. SourceFiles uniformFixedValuePointPatchField.C @@ -36,6 +49,7 @@ SourceFiles #define uniformFixedValuePointPatchField_H #include "fixedValuePointPatchField.H" +#include "DataEntry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,7 +67,7 @@ class uniformFixedValuePointPatchField { // Private data - Type uniformValue_; + autoPtr > uniformValue_; public: @@ -136,16 +150,15 @@ public: // Access //- Return the fluctuation scale - const Type& uniformValue() const + const DataEntry& uniformValue() const { return uniformValue_; } - //- Return reference to the fluctuation scale to allow adjustment - Type& uniformValue() - { - return uniformValue_; - } + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); //- Write diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C index c3d5dcfc77..21f03aea9f 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,18 +44,32 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField {} +template +uniformFixedValueFvPatchField::uniformFixedValueFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const Field& fld +) +: + fixedValueFvPatchField(p, iF, fld), + uniformValue_() +{} + + template uniformFixedValueFvPatchField::uniformFixedValueFvPatchField ( const uniformFixedValueFvPatchField& ptf, const fvPatch& p, const DimensionedField& iF, - const fvPatchFieldMapper& + const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField(p, iF), + fixedValueFvPatchField(ptf, p, iF, mapper), uniformValue_(ptf.uniformValue_().clone().ptr()) { + // For safety re-evaluate const scalar t = this->db().time().timeOutputValue(); fvPatchField::operator==(uniformValue_->value(t)); } @@ -72,8 +86,15 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField fixedValueFvPatchField(p, iF), uniformValue_(DataEntry::New("uniformValue", dict)) { - const scalar t = this->db().time().timeOutputValue(); - fvPatchField::operator==(uniformValue_->value(t)); + if (dict.found("value")) + { + fvPatchField::operator==(Field("value", dict, p.size())); + } + else + { + const scalar t = this->db().time().timeOutputValue(); + fvPatchField::operator==(uniformValue_->value(t)); + } } @@ -85,10 +106,7 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField : fixedValueFvPatchField(ptf), uniformValue_(ptf.uniformValue_().clone().ptr()) -{ - const scalar t = this->db().time().timeOutputValue(); - fvPatchField::operator==(uniformValue_->value(t)); -} +{} template @@ -101,6 +119,7 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField fixedValueFvPatchField(ptf, iF), uniformValue_(ptf.uniformValue_().clone().ptr()) { + // For safety re-evaluate const scalar t = this->db().time().timeOutputValue(); fvPatchField::operator==(uniformValue_->value(t)); } @@ -108,18 +127,6 @@ uniformFixedValueFvPatchField::uniformFixedValueFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -void uniformFixedValueFvPatchField::autoMap -( - const fvPatchFieldMapper& m -) -{ - this->setSize(m.size()); - const scalar t = this->db().time().timeOutputValue(); - fvPatchField::operator==(uniformValue_->value(t)); -} - - template void uniformFixedValueFvPatchField::updateCoeffs() { @@ -138,6 +145,7 @@ void uniformFixedValueFvPatchField::updateCoeffs() template void uniformFixedValueFvPatchField::write(Ostream& os) const { + // Note: do not write value fvPatchField::write(os); uniformValue_->writeData(os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H index 1643f65af8..cd6445babf 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,6 @@ SourceFiles #ifndef uniformFixedValueFvPatchField_H #define uniformFixedValueFvPatchField_H -#include "Random.H" #include "fixedValueFvPatchFields.H" #include "DataEntry.H" @@ -87,6 +86,14 @@ public: const DimensionedField& ); + //- Construct from patch and internal field and patch field + uniformFixedValueFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const Field& fld + ); + //- Construct from patch, internal field and dictionary uniformFixedValueFvPatchField ( @@ -142,14 +149,6 @@ public: // Member functions - // Mapping functions - - //- Map (and resize as needed) from self given a mapping object - virtual void autoMap - ( - const fvPatchFieldMapper& - ); - // Evaluation functions