From 6a0df8a47088591f93f946972554d8793af65c74 Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Tue, 24 Nov 2015 16:35:11 +0000 Subject: [PATCH] fvPatchFields: Rationalized the construction of DataEntry values --- ...lindricalInletVelocityFvPatchVectorField.C | 20 ++--- .../fixedFluxPressureFvPatchScalarField.C | 50 ++++++------- .../flowRateInletVelocityFvPatchVectorField.C | 6 +- .../oscillatingFixedValueFvPatchField.C | 14 ++-- ...ureInletOutletVelocityFvPatchVectorField.C | 8 +- .../rotatingTotalPressureFvPatchScalarField.C | 8 +- .../rotatingWallVelocityFvPatchVectorField.C | 8 +- ...lFlowRateInletVelocityFvPatchVectorField.C | 12 +-- .../timeVaryingMappedFixedValueFvPatchField.C | 73 ++++++++----------- .../uniformFixedGradientFvPatchField.C | 52 ++++--------- .../uniformFixedGradientFvPatchField.H | 10 +-- .../uniformFixedValueFvPatchField.C | 42 ++++------- .../uniformFixedValueFvPatchField.H | 10 +-- .../uniformInletOutletFvPatchField.C | 56 +++++++------- .../uniformInletOutletFvPatchField.H | 3 +- .../uniformJump/uniformJumpFvPatchField.C | 8 +- .../uniformJumpAMIFvPatchField.C | 8 +- .../uniformTotalPressureFvPatchScalarField.C | 27 +++---- 18 files changed, 171 insertions(+), 244 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C index 238bb5d21dd..3bdfa9e6e96 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -60,9 +60,9 @@ cylindricalInletVelocityFvPatchVectorField fixedValueFvPatchField<vector>(ptf, p, iF, mapper), centre_(ptf.centre_), axis_(ptf.axis_), - axialVelocity_(ptf.axialVelocity_().clone().ptr()), - radialVelocity_(ptf.radialVelocity_().clone().ptr()), - rpm_(ptf.rpm_().clone().ptr()) + axialVelocity_(ptf.axialVelocity_, false), + radialVelocity_(ptf.radialVelocity_, false), + rpm_(ptf.rpm_, false) {} @@ -92,9 +92,9 @@ cylindricalInletVelocityFvPatchVectorField fixedValueFvPatchField<vector>(ptf), centre_(ptf.centre_), axis_(ptf.axis_), - axialVelocity_(ptf.axialVelocity_().clone().ptr()), - radialVelocity_(ptf.radialVelocity_().clone().ptr()), - rpm_(ptf.rpm_().clone().ptr()) + axialVelocity_(ptf.axialVelocity_, false), + radialVelocity_(ptf.radialVelocity_, false), + rpm_(ptf.rpm_, false) {} @@ -108,9 +108,9 @@ cylindricalInletVelocityFvPatchVectorField fixedValueFvPatchField<vector>(ptf, iF), centre_(ptf.centre_), axis_(ptf.axis_), - axialVelocity_(ptf.axialVelocity_().clone().ptr()), - radialVelocity_(ptf.radialVelocity_().clone().ptr()), - rpm_(ptf.rpm_().clone().ptr()) + axialVelocity_(ptf.axialVelocity_, false), + radialVelocity_(ptf.radialVelocity_, false), + rpm_(ptf.rpm_, false) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index 936e702aa32..e3a9409b25e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -44,57 +44,57 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ( - const fixedFluxPressureFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, - const fvPatchFieldMapper& mapper + const dictionary& dict ) : fixedGradientFvPatchScalarField(p, iF), curTimeIndex_(-1) { - patchType() = ptf.patchType(); - - // Map gradient. Set unmapped values and overwrite with mapped ptf - gradient() = 0.0; - gradient().map(ptf.gradient(), mapper); - - // Evaluate the value field from the gradient if the internal field is valid - if (notNull(iF) && iF.size()) + if (dict.found("value") && dict.found("gradient")) { - scalarField::operator= + fvPatchField<scalar>::operator= ( - //patchInternalField() + gradient()/patch().deltaCoeffs() - // ***HGW Hack to avoid the construction of mesh.deltaCoeffs - // which fails for AMI patches for some mapping operations - patchInternalField() + gradient()*(patch().nf() & patch().delta()) + scalarField("value", dict, p.size()) ); + gradient() = scalarField("gradient", dict, p.size()); + } + else + { + fvPatchField<scalar>::operator=(patchInternalField()); + gradient() = 0.0; } } Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ( + const fixedFluxPressureFvPatchScalarField& ptf, const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, - const dictionary& dict + const fvPatchFieldMapper& mapper ) : fixedGradientFvPatchScalarField(p, iF), curTimeIndex_(-1) { - if (dict.found("value") && dict.found("gradient")) + patchType() = ptf.patchType(); + + // Map gradient. Set unmapped values and overwrite with mapped ptf + gradient() = 0.0; + gradient().map(ptf.gradient(), mapper); + + // Evaluate the value field from the gradient if the internal field is valid + if (notNull(iF) && iF.size()) { - fvPatchField<scalar>::operator= + scalarField::operator= ( - scalarField("value", dict, p.size()) + //patchInternalField() + gradient()/patch().deltaCoeffs() + // ***HGW Hack to avoid the construction of mesh.deltaCoeffs + // which fails for AMI patches for some mapping operations + patchInternalField() + gradient()*(patch().nf() & patch().delta()) ); - gradient() = scalarField("gradient", dict, p.size()); - } - else - { - fvPatchField<scalar>::operator=(patchInternalField()); - gradient() = 0.0; } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C index 0838108985c..7dc2d9497ba 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C @@ -56,7 +56,7 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField<vector>(ptf, p, iF, mapper), - flowRate_(ptf.flowRate_().clone().ptr()), + flowRate_(ptf.flowRate_, false), volumetric_(ptf.volumetric_), rhoName_(ptf.rhoName_), rhoInlet_(ptf.rhoInlet_) @@ -117,7 +117,7 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField<vector>(ptf), - flowRate_(ptf.flowRate_().clone().ptr()), + flowRate_(ptf.flowRate_, false), volumetric_(ptf.volumetric_), rhoName_(ptf.rhoName_), rhoInlet_(ptf.rhoInlet_) @@ -132,7 +132,7 @@ flowRateInletVelocityFvPatchVectorField ) : fixedValueFvPatchField<vector>(ptf, iF), - flowRate_(ptf.flowRate_().clone().ptr()), + flowRate_(ptf.flowRate_, false), volumetric_(ptf.volumetric_), rhoName_(ptf.rhoName_), rhoInlet_(ptf.rhoInlet_) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/oscillatingFixedValue/oscillatingFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/oscillatingFixedValue/oscillatingFixedValueFvPatchField.C index 42d52401d87..715586a3691 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/oscillatingFixedValue/oscillatingFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/oscillatingFixedValue/oscillatingFixedValueFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,8 +74,8 @@ oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField fixedValueFvPatchField<Type>(ptf, p, iF, mapper), refValue_(ptf.refValue_, mapper), offset_(ptf.offset_), - amplitude_(ptf.amplitude_().clone().ptr()), - frequency_(ptf.frequency_().clone().ptr()), + amplitude_(ptf.amplitude_, false), + frequency_(ptf.frequency_, false), curTimeIndex_(-1) {} @@ -122,8 +122,8 @@ oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField fixedValueFvPatchField<Type>(ptf), refValue_(ptf.refValue_), offset_(ptf.offset_), - amplitude_(ptf.amplitude_().clone().ptr()), - frequency_(ptf.frequency_().clone().ptr()), + amplitude_(ptf.amplitude_, false), + frequency_(ptf.frequency_, false), curTimeIndex_(-1) {} @@ -138,8 +138,8 @@ oscillatingFixedValueFvPatchField<Type>::oscillatingFixedValueFvPatchField fixedValueFvPatchField<Type>(ptf, iF), refValue_(ptf.refValue_), offset_(ptf.offset_), - amplitude_(ptf.amplitude_().clone().ptr()), - frequency_(ptf.frequency_().clone().ptr()), + amplitude_(ptf.amplitude_, false), + frequency_(ptf.frequency_, false), curTimeIndex_(-1) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C index 22b36b08447..3a49f4a6800 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -71,7 +71,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField ) : pressureInletOutletVelocityFvPatchVectorField(ptf, p, iF, mapper), - omega_(ptf.omega_().clone().ptr()) + omega_(ptf.omega_, false) { calcTangentialVelocity(); } @@ -99,7 +99,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField ) : pressureInletOutletVelocityFvPatchVectorField(rppvf), - omega_(rppvf.omega_().clone().ptr()) + omega_(rppvf.omega_, false) { calcTangentialVelocity(); } @@ -113,7 +113,7 @@ rotatingPressureInletOutletVelocityFvPatchVectorField ) : pressureInletOutletVelocityFvPatchVectorField(rppvf, iF), - omega_(rppvf.omega_().clone().ptr()) + omega_(rppvf.omega_, false) { calcTangentialVelocity(); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C index 87a99128610..83647fb7820 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.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-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -53,7 +53,7 @@ rotatingTotalPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(ptf, p, iF, mapper), - omega_(ptf.omega_().clone().ptr()) + omega_(ptf.omega_, false) {} @@ -77,7 +77,7 @@ rotatingTotalPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(rtppsf), - omega_(rtppsf.omega_().clone().ptr()) + omega_(rtppsf.omega_, false) {} @@ -89,7 +89,7 @@ rotatingTotalPressureFvPatchScalarField ) : totalPressureFvPatchScalarField(rtppsf, iF), - omega_(rtppsf.omega_().clone().ptr()) + omega_(rtppsf.omega_, false) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C index daa6a83903c..82f5d2e28bb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,7 +56,7 @@ rotatingWallVelocityFvPatchVectorField fixedValueFvPatchField<vector>(ptf, p, iF, mapper), origin_(ptf.origin_), axis_(ptf.axis_), - omega_(ptf.omega_().clone().ptr()) + omega_(ptf.omega_, false) {} @@ -97,7 +97,7 @@ rotatingWallVelocityFvPatchVectorField fixedValueFvPatchField<vector>(rwvpvf), origin_(rwvpvf.origin_), axis_(rwvpvf.axis_), - omega_(rwvpvf.omega_().clone().ptr()) + omega_(rwvpvf.omega_, false) {} @@ -111,7 +111,7 @@ rotatingWallVelocityFvPatchVectorField fixedValueFvPatchField<vector>(rwvpvf, iF), origin_(rwvpvf.origin_), axis_(rwvpvf.axis_), - omega_(rwvpvf.omega_().clone().ptr()) + omega_(rwvpvf.omega_, false) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C index e86d92d5dba..a871e91de07 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C @@ -59,8 +59,8 @@ swirlFlowRateInletVelocityFvPatchVectorField fixedValueFvPatchField<vector>(ptf, p, iF, mapper), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), - flowRate_(ptf.flowRate_().clone().ptr()), - rpm_(ptf.rpm_().clone().ptr()) + flowRate_(ptf.flowRate_, false), + rpm_(ptf.rpm_, false) {} @@ -89,8 +89,8 @@ swirlFlowRateInletVelocityFvPatchVectorField fixedValueFvPatchField<vector>(ptf), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), - flowRate_(ptf.flowRate_().clone().ptr()), - rpm_(ptf.rpm_().clone().ptr()) + flowRate_(ptf.flowRate_, false), + rpm_(ptf.rpm_, false) {} @@ -104,8 +104,8 @@ swirlFlowRateInletVelocityFvPatchVectorField fixedValueFvPatchField<vector>(ptf, iF), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), - flowRate_(ptf.flowRate_().clone().ptr()), - rpm_(ptf.rpm_().clone().ptr()) + flowRate_(ptf.flowRate_, false), + rpm_(ptf.rpm_, false) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index f52abedfdd0..3e2f43965ba 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -58,38 +58,6 @@ timeVaryingMappedFixedValueFvPatchField {} -template<class Type> -timeVaryingMappedFixedValueFvPatchField<Type>:: -timeVaryingMappedFixedValueFvPatchField -( - const timeVaryingMappedFixedValueFvPatchField<Type>& ptf, - const fvPatch& p, - const DimensionedField<Type, volMesh>& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchField<Type>(ptf, p, iF, mapper), - fieldTableName_(ptf.fieldTableName_), - setAverage_(ptf.setAverage_), - perturb_(ptf.perturb_), - mapMethod_(ptf.mapMethod_), - mapperPtr_(NULL), - sampleTimes_(0), - startSampleTime_(-1), - startSampledValues_(0), - startAverage_(pTraits<Type>::zero), - endSampleTime_(-1), - endSampledValues_(0), - endAverage_(pTraits<Type>::zero), - offset_ - ( - ptf.offset_.valid() - ? ptf.offset_().clone().ptr() - : NULL - ) -{} - - template<class Type> timeVaryingMappedFixedValueFvPatchField<Type>:: timeVaryingMappedFixedValueFvPatchField @@ -152,6 +120,33 @@ timeVaryingMappedFixedValueFvPatchField } +template<class Type> +timeVaryingMappedFixedValueFvPatchField<Type>:: +timeVaryingMappedFixedValueFvPatchField +( + const timeVaryingMappedFixedValueFvPatchField<Type>& ptf, + const fvPatch& p, + const DimensionedField<Type, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField<Type>(ptf, p, iF, mapper), + fieldTableName_(ptf.fieldTableName_), + setAverage_(ptf.setAverage_), + perturb_(ptf.perturb_), + mapMethod_(ptf.mapMethod_), + mapperPtr_(NULL), + sampleTimes_(0), + startSampleTime_(-1), + startSampledValues_(0), + startAverage_(pTraits<Type>::zero), + endSampleTime_(-1), + endSampledValues_(0), + endAverage_(pTraits<Type>::zero), + offset_(ptf.offset_, false) +{} + + template<class Type> timeVaryingMappedFixedValueFvPatchField<Type>:: timeVaryingMappedFixedValueFvPatchField @@ -172,12 +167,7 @@ timeVaryingMappedFixedValueFvPatchField endSampleTime_(ptf.endSampleTime_), endSampledValues_(ptf.endSampledValues_), endAverage_(ptf.endAverage_), - offset_ - ( - ptf.offset_.valid() - ? ptf.offset_().clone().ptr() - : NULL - ) + offset_(ptf.offset_, false) {} @@ -202,12 +192,7 @@ timeVaryingMappedFixedValueFvPatchField endSampleTime_(ptf.endSampleTime_), endSampledValues_(ptf.endSampledValues_), endAverage_(ptf.endAverage_), - offset_ - ( - ptf.offset_.valid() - ? ptf.offset_().clone().ptr() - : NULL - ) + offset_(ptf.offset_, false) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C index 0a5a113d907..aa7c057a7a0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.C @@ -55,44 +55,30 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField template<class Type> Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField ( - const uniformFixedGradientFvPatchField<Type>& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const fvPatchFieldMapper& mapper + const dictionary& dict ) : - fixedGradientFvPatchField<Type>(ptf, p, iF, mapper), - uniformGradient_(ptf.uniformGradient_().clone().ptr()) + fixedGradientFvPatchField<Type>(p, iF), + uniformGradient_(DataEntry<Type>::New("uniformGradient", dict)) { - // For safety re-evaluate - const scalar t = this->db().time().timeOutputValue(); - this->gradient() = uniformGradient_->value(t); + this->evaluate(); } template<class Type> Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField ( + const uniformFixedGradientFvPatchField<Type>& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const dictionary& dict + const fvPatchFieldMapper& mapper ) : - fixedGradientFvPatchField<Type>(p, iF), - uniformGradient_(DataEntry<Type>::New("uniformGradient", dict)) -{ - if (dict.found("gradient")) - { - this->gradient() = Field<Type>("gradient", dict, p.size()); - } - else - { - const scalar t = this->db().time().timeOutputValue(); - this->gradient() = uniformGradient_->value(t); - } - - fixedGradientFvPatchField<Type>::evaluate(); -} + fixedGradientFvPatchField<Type>(ptf, p, iF, mapper), + uniformGradient_(ptf.uniformGradient_, false) +{} template<class Type> @@ -102,12 +88,7 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField ) : fixedGradientFvPatchField<Type>(ptf), - uniformGradient_ - ( - ptf.uniformGradient_.valid() - ? ptf.uniformGradient_().clone().ptr() - : NULL - ) + uniformGradient_(ptf.uniformGradient_, false) {} @@ -119,19 +100,12 @@ Foam::uniformFixedGradientFvPatchField<Type>::uniformFixedGradientFvPatchField ) : fixedGradientFvPatchField<Type>(ptf, iF), - uniformGradient_ - ( - ptf.uniformGradient_.valid() - ? ptf.uniformGradient_().clone().ptr() - : NULL - ) + uniformGradient_(ptf.uniformGradient_, false) { - // For safety re-evaluate - const scalar t = this->db().time().timeOutputValue(); - + // Evaluate the profile if defined if (ptf.uniformGradient_.valid()) { - this->gradient() = uniformGradient_->value(t); + this->evaluate(); } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.H index 5659297fecc..2ad895b362c 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedGradient/uniformFixedGradientFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -164,12 +164,8 @@ public: // Member functions - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); //- Write virtual void write(Ostream&) const; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C index e5870388908..8d52b8700d7 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C @@ -55,34 +55,32 @@ Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField template<class Type> Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField ( - const uniformFixedValueFvPatchField<Type>& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const fvPatchFieldMapper& mapper + const dictionary& dict ) : - fixedValueFvPatchField<Type>(p, iF), // bypass mapper - uniformValue_(ptf.uniformValue_().clone().ptr()) + fixedValueFvPatchField<Type>(p, iF), + uniformValue_(DataEntry<Type>::New("uniformValue", dict)) { - // Evaluate since value not mapped - const scalar t = this->db().time().timeOutputValue(); - fvPatchField<Type>::operator==(uniformValue_->value(t)); + this->evaluate(); } template<class Type> Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField ( + const uniformFixedValueFvPatchField<Type>& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const dictionary& dict + const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchField<Type>(p, iF), - uniformValue_(DataEntry<Type>::New("uniformValue", dict)) + fixedValueFvPatchField<Type>(p, iF), // Don't map + uniformValue_(ptf.uniformValue_, false) { - const scalar t = this->db().time().timeOutputValue(); - fvPatchField<Type>::operator==(uniformValue_->value(t)); + // Evaluate since value not mapped + this->evaluate(); } @@ -93,12 +91,7 @@ Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField ) : fixedValueFvPatchField<Type>(ptf), - uniformValue_ - ( - ptf.uniformValue_.valid() - ? ptf.uniformValue_().clone().ptr() - : NULL - ) + uniformValue_(ptf.uniformValue_, false) {} @@ -110,19 +103,12 @@ Foam::uniformFixedValueFvPatchField<Type>::uniformFixedValueFvPatchField ) : fixedValueFvPatchField<Type>(ptf, iF), - uniformValue_ - ( - ptf.uniformValue_.valid() - ? ptf.uniformValue_().clone().ptr() - : NULL - ) + uniformValue_(ptf.uniformValue_, false) { - // For safety re-evaluate - const scalar t = this->db().time().timeOutputValue(); - + // Evaluate the profile if defined if (ptf.uniformValue_.valid()) { - fvPatchField<Type>::operator==(uniformValue_->value(t)); + this->evaluate(); } } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.H index 072d02f1b6d..6d77aa88571 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-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -163,12 +163,8 @@ public: // Member functions - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); //- Write virtual void write(Ostream&) const; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C index 3c4da515c41..54217a529af 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,63 +46,61 @@ Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField template<class Type> Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField ( - const uniformInletOutletFvPatchField<Type>& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const fvPatchFieldMapper& mapper + const dictionary& dict ) : mixedFvPatchField<Type>(p, iF), - phiName_(ptf.phiName_), - uniformInletValue_(ptf.uniformInletValue_, false) + phiName_(dict.lookupOrDefault<word>("phi", "phi")), + uniformInletValue_(DataEntry<Type>::New("uniformInletValue", dict)) { - this->patchType() = ptf.patchType(); - - // For safety re-evaluate const scalar t = this->db().time().timeOutputValue(); this->refValue() = uniformInletValue_->value(t); - this->refGrad() = pTraits<Type>::zero; - this->valueFraction() = 0.0; - // Map value (unmapped get refValue) - if (notNull(iF) && iF.size()) + if (dict.found("value")) + { + fvPatchField<Type>::operator= + ( + Field<Type>("value", dict, p.size()) + ); + } + else { fvPatchField<Type>::operator=(this->refValue()); } - this->map(ptf, mapper); + this->refGrad() = pTraits<Type>::zero; + this->valueFraction() = 0.0; } template<class Type> Foam::uniformInletOutletFvPatchField<Type>::uniformInletOutletFvPatchField ( + const uniformInletOutletFvPatchField<Type>& ptf, const fvPatch& p, const DimensionedField<Type, volMesh>& iF, - const dictionary& dict + const fvPatchFieldMapper& mapper ) : - mixedFvPatchField<Type>(p, iF), - phiName_(dict.lookupOrDefault<word>("phi", "phi")), - uniformInletValue_(DataEntry<Type>::New("uniformInletValue", dict)) + mixedFvPatchField<Type>(p, iF), // Don't map + phiName_(ptf.phiName_), + uniformInletValue_(ptf.uniformInletValue_, false) { + this->patchType() = ptf.patchType(); + + // Evaluate refValue since not mapped const scalar t = this->db().time().timeOutputValue(); this->refValue() = uniformInletValue_->value(t); - if (dict.found("value")) - { - fvPatchField<Type>::operator= - ( - Field<Type>("value", dict, p.size()) - ); - } - else - { - fvPatchField<Type>::operator=(this->refValue()); - } - this->refGrad() = pTraits<Type>::zero; this->valueFraction() = 0.0; + + // Initialize the patch value to the refValue + fvPatchField<Type>::operator=(this->refValue()); + + this->map(ptf, mapper); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.H index cc9e2d0a9df..2ab8c72ee86 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformInletOutlet/uniformInletOutletFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -193,7 +193,6 @@ public: // Member operators virtual void operator=(const fvPatchField<Type>& pvf); - }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C index 250442dad05..046d9bbeb83 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,7 @@ Foam::uniformJumpFvPatchField<Type>::uniformJumpFvPatchField ) : fixedJumpFvPatchField<Type>(ptf, p, iF, mapper), - jumpTable_(ptf.jumpTable_().clone().ptr()) + jumpTable_(ptf.jumpTable_, false) {} @@ -90,7 +90,7 @@ Foam::uniformJumpFvPatchField<Type>::uniformJumpFvPatchField ) : fixedJumpFvPatchField<Type>(ptf), - jumpTable_(ptf.jumpTable_().clone().ptr()) + jumpTable_(ptf.jumpTable_, false) {} @@ -102,7 +102,7 @@ Foam::uniformJumpFvPatchField<Type>::uniformJumpFvPatchField ) : fixedJumpFvPatchField<Type>(ptf, iF), - jumpTable_(ptf.jumpTable_().clone().ptr()) + jumpTable_(ptf.jumpTable_, false) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C index 0670119ab0c..7b2d55e1eb3 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,7 @@ Foam::uniformJumpAMIFvPatchField<Type>::uniformJumpAMIFvPatchField ) : fixedJumpAMIFvPatchField<Type>(ptf, p, iF, mapper), - jumpTable_(ptf.jumpTable_().clone().ptr()) + jumpTable_(ptf.jumpTable_, false) {} @@ -87,7 +87,7 @@ Foam::uniformJumpAMIFvPatchField<Type>::uniformJumpAMIFvPatchField ) : fixedJumpAMIFvPatchField<Type>(ptf), - jumpTable_(ptf.jumpTable_().clone().ptr()) + jumpTable_(ptf.jumpTable_, false) {} @@ -99,7 +99,7 @@ Foam::uniformJumpAMIFvPatchField<Type>::uniformJumpAMIFvPatchField ) : fixedJumpAMIFvPatchField<Type>(ptf, iF), - jumpTable_(ptf.jumpTable_().clone().ptr()) + jumpTable_(ptf.jumpTable_, false) {} diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C index 5cfd99db24a..52ecf6fe4f1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformTotalPressure/uniformTotalPressureFvPatchScalarField.C @@ -73,8 +73,8 @@ uniformTotalPressureFvPatchScalarField } else { - scalar p0 = pressure_->value(this->db().time().timeOutputValue()); - fvPatchField<scalar>::operator=(p0); + const scalar t = this->db().time().timeOutputValue(); + fvPatchScalarField::operator==(pressure_->value(t)); } } @@ -88,15 +88,18 @@ uniformTotalPressureFvPatchScalarField const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchScalarField(p, iF), // bypass mapper + fixedValueFvPatchScalarField(p, iF), // Don't map UName_(ptf.UName_), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), - pressure_(ptf.pressure_().clone().ptr()) + pressure_(ptf.pressure_, false) { - // Evaluate since value not mapped + patchType() = ptf.patchType(); + + // Set the patch pressure to the current total pressure + // This is not ideal but avoids problems with the creation of patch faces const scalar t = this->db().time().timeOutputValue(); fvPatchScalarField::operator==(pressure_->value(t)); } @@ -114,12 +117,7 @@ uniformTotalPressureFvPatchScalarField rhoName_(ptf.rhoName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), - pressure_ - ( - ptf.pressure_.valid() - ? ptf.pressure_().clone().ptr() - : NULL - ) + pressure_(ptf.pressure_, false) {} @@ -136,12 +134,7 @@ uniformTotalPressureFvPatchScalarField rhoName_(ptf.rhoName_), psiName_(ptf.psiName_), gamma_(ptf.gamma_), - pressure_ - ( - ptf.pressure_.valid() - ? ptf.pressure_().clone().ptr() - : NULL - ) + pressure_(ptf.pressure_, false) {} -- GitLab