diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C index 2211770a15f80200e9782dd76dfab6969899b676..825a229c9a52613af31a046270d6d57ffeb9204d 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -261,6 +261,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::autoMap ) { mixedFvPatchScalarField::autoMap(mapper); + temperatureCoupledBase::autoMap(mapper); if (q_) { @@ -289,6 +290,9 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::rmap const auto& rhs = refCast<const externalWallHeatFluxTemperatureFvPatchScalarField>(ptf); + temperatureCoupledBase::rmap(rhs, addr); + + if (q_) { q_->rmap(rhs.q_(), addr); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C index abee359f96f5557d5903acd52c982ee3cf393755..3603707738c6cdabcd69f7353c00e620068f0a76 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2019,2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -131,6 +131,7 @@ void Foam::radiation::fixedIncidentRadiationFvPatchScalarField::autoMap ) { fixedGradientFvPatchScalarField::autoMap(m); + temperatureCoupledBase::autoMap(m); qrIncident_.autoMap(m); } @@ -149,6 +150,7 @@ void Foam::radiation::fixedIncidentRadiationFvPatchScalarField::rmap psf ); + temperatureCoupledBase::rmap(thftpsf, addr); qrIncident_.rmap(thftpsf.qrIncident_, addr); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C index e58856a10a1f46d1324159d2a999cb3b2e1ccc7e..5cd79495a347bd258911c7679ff0cbbee0211b7e 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C @@ -129,6 +129,34 @@ lumpedMassWallTemperatureFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::lumpedMassWallTemperatureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& mapper +) +{ + mixedFvPatchScalarField::autoMap(mapper); + temperatureCoupledBase::autoMap(mapper); +} + + +void Foam::lumpedMassWallTemperatureFvPatchScalarField::rmap +( + const fvPatchField<scalar>& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); + + const lumpedMassWallTemperatureFvPatchScalarField& tiptf = + refCast + < + const lumpedMassWallTemperatureFvPatchScalarField + >(ptf); + + temperatureCoupledBase::rmap(tiptf, addr); +} + + void Foam::lumpedMassWallTemperatureFvPatchScalarField::updateCoeffs() { if (updated() || (curTimeIndex_ == this->db().time().timeIndex())) diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.H index 842581a1db58147b2a19e7b2c63280dfcdae8c24..c657b4cc72a366559ee242ad77945f0471bb276f 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.H @@ -166,6 +166,22 @@ public: // Member functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchField<scalar>&, + const labelList& + ); + + // Evaluation functions //- Update the coefficients associated with the patch field diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C index 5c89fed301a749e49ce825592e7ce83de42e78af..f2b3bcd255cf12761e07d468a80729ac18a0b1b1 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,8 @@ Foam::temperatureCoupledBase::KMethodTypeNames_ { KMethodType::mtFluidThermo, "fluidThermo" }, { KMethodType::mtSolidThermo, "solidThermo" }, { KMethodType::mtDirectionalSolidThermo, "directionalSolidThermo" }, - { KMethodType::mtLookup, "lookup" } + { KMethodType::mtLookup, "lookup" }, + { KMethodType::mtFunction, "function" } }; @@ -74,9 +75,9 @@ Foam::temperatureCoupledBase::temperatureCoupledBase : patch_(patch), method_(KMethodTypeNames_.get("kappaMethod", dict)), - kappaName_(dict.getOrDefault<word>("kappa", "none")), - alphaAniName_(dict.getOrDefault<word>("alphaAni", "none")), - alphaName_(dict.getOrDefault<word>("alpha", "none")) + kappaName_(dict.getOrDefault<word>("kappa", word::null)), + alphaAniName_(dict.getOrDefault<word>("alphaAni", word::null)), + alphaName_(dict.getOrDefault<word>("alpha", word::null)) { switch (method_) { @@ -110,6 +111,22 @@ Foam::temperatureCoupledBase::temperatureCoupledBase break; } + case mtFunction: + { + kappaFunction1_ = PatchFunction1<scalar>::New + ( + patch.patch(), + "kappaValue", + dict + ); + alphaFunction1_ = PatchFunction1<scalar>::New + ( + patch.patch(), + "alphaValue", + dict + ); + } + default: { break; @@ -118,6 +135,21 @@ Foam::temperatureCoupledBase::temperatureCoupledBase } +Foam::temperatureCoupledBase::temperatureCoupledBase +( + const temperatureCoupledBase& base +) +: + patch_(base.patch_), + method_(base.method_), + kappaName_(base.kappaName_), + alphaAniName_(base.alphaAniName_), + alphaName_(base.alphaName_), + kappaFunction1_(base.kappaFunction1_.clone(patch_.patch())), + alphaFunction1_(base.alphaFunction1_.clone(patch_.patch())) +{} + + Foam::temperatureCoupledBase::temperatureCoupledBase ( const fvPatch& patch, @@ -128,12 +160,47 @@ Foam::temperatureCoupledBase::temperatureCoupledBase method_(base.method_), kappaName_(base.kappaName_), alphaAniName_(base.alphaAniName_), - alphaName_(base.alphaName_) + alphaName_(base.alphaName_), + kappaFunction1_(base.kappaFunction1_.clone(patch_.patch())), + alphaFunction1_(base.alphaFunction1_.clone(patch_.patch())) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::temperatureCoupledBase::autoMap +( + const FieldMapper& mapper +) +{ + if (kappaFunction1_) + { + kappaFunction1_().autoMap(mapper); + } + if (alphaFunction1_) + { + alphaFunction1_().autoMap(mapper); + } +} + + +void Foam::temperatureCoupledBase::rmap +( + const temperatureCoupledBase& ptf, + const labelList& addr +) +{ + if (kappaFunction1_) + { + kappaFunction1_().rmap(ptf.kappaFunction1_(), addr); + } + if (alphaFunction1_) + { + alphaFunction1_().rmap(ptf.alphaFunction1_(), addr); + } +} + + Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa ( const scalarField& Tp @@ -262,6 +329,13 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa break; } + case KMethodType::mtFunction: + { + const auto& tm = patch_.patch().boundaryMesh().mesh().time(); + return kappaFunction1_->value(tm.timeOutputValue()); + break; + } + default: { FatalErrorInFunction @@ -405,6 +479,13 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::alpha break; } + case KMethodType::mtFunction: + { + const auto& tm = patch_.patch().boundaryMesh().mesh().time(); + return alphaFunction1_->value(tm.timeOutputValue()); + break; + } + default: { FatalErrorInFunction @@ -426,9 +507,26 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::alpha void Foam::temperatureCoupledBase::write(Ostream& os) const { os.writeEntry("kappaMethod", KMethodTypeNames_[method_]); - os.writeEntry("kappa", kappaName_); - os.writeEntry("alphaAni", alphaAniName_); - os.writeEntry("alpha", alphaName_); + if (!kappaName_.empty()) + { + os.writeEntry("kappa", kappaName_); + } + if (!alphaAniName_.empty()) + { + os.writeEntry("alphaAni", alphaAniName_); + } + if (!alphaName_.empty()) + { + os.writeEntry("alpha", alphaName_); + } + if (kappaFunction1_) + { + kappaFunction1_->writeData(os); + } + if (alphaFunction1_) + { + alphaFunction1_->writeData(os); + } } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H index 9a697cd89cbbd823f27b3f684998bccf53fb8ab2..65a759f78227089e9b59a21682a624c6f8c08f6c 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019,2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,15 +39,18 @@ Description - 'directionalSolidThermo': uses look up for volSymmTensorField for transformed kappa vector. Field name definable in 'alphaAni', named 'Anialpha' in solid solver by default + - 'function' : kappa, alpha directly specified as Function1 - 'phaseSystem' : used for multiphase thermos \par Keywords provided by this class: \table Property | Description | Required | Default kappaMethod | Thermal conductivity method | yes | - kappa | Name of thermal conductivity field | no | none - alpha | Name of thermal diffusivity field | no | none - alphaAni | Name of non-isotropic alpha | no | none + kappa | Name of thermal conductivity field | no | + alpha | Name of thermal diffusivity field | no | + alphaAni | Name of non-isotropic alpha | no | + kappaValue | Function1 supplying kappa | no | + alphaValue | Function1 supplying alpha | no | \endtable Usage @@ -56,12 +59,22 @@ Usage { ... kappaMethod directionalSolidThermo; - kappa none; alphaAni Anialpha; ... } \endverbatim + \verbatim + specifiedWall + { + ... + kappaMethod function; + kappaFunction constant 1.0; + alphaFunction constant 100.0; + ... + } + \endverbatim + SourceFiles temperatureCoupledBase.C @@ -73,6 +86,7 @@ SourceFiles #include "scalarField.H" #include "Enum.H" #include "fvPatch.H" +#include "PatchFunction1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,7 +109,8 @@ public: mtFluidThermo, mtSolidThermo, mtDirectionalSolidThermo, - mtLookup + mtLookup, + mtFunction }; @@ -120,6 +135,12 @@ protected: //- Name of thermal diffusivity const word alphaName_; + //- Function1 for kappa + autoPtr<PatchFunction1<scalar>> kappaFunction1_; + + //- Function1 for alpha + autoPtr<PatchFunction1<scalar>> alphaFunction1_; + public: @@ -149,6 +170,12 @@ public: const temperatureCoupledBase& base ); + //- Construct as copy + temperatureCoupledBase + ( + const temperatureCoupledBase& + ); + //- Destructor virtual ~temperatureCoupledBase() = default; @@ -174,6 +201,19 @@ public: return alphaName_; } + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const FieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const temperatureCoupledBase&, + const labelList& + ); + //- Given patch temperature calculate corresponding K field virtual tmp<scalarField> kappa(const scalarField& Tp) const; diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index 74da1678870d9fce4305a3a3e35a226d60014fe6..e59afded4dbd5dc228585ac9132fa2c5d32d3348 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -62,9 +62,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField mappedPatchFieldBase<scalar>::mapper(p, iF), *this ), - TnbrName_("undefined-Tnbr"), - thicknessLayers_(0), - kappaLayers_(0) + TnbrName_("undefined-Tnbr") { this->refValue() = 0.0; this->refGrad() = 0.0; @@ -91,7 +89,9 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField ), TnbrName_(ptf.TnbrName_), thicknessLayers_(ptf.thicknessLayers_), - kappaLayers_(ptf.kappaLayers_) + thicknessLayer_(ptf.thicknessLayer_.clone(p.patch())), + kappaLayers_(ptf.kappaLayers_), + kappaLayer_(ptf.kappaLayer_.clone(p.patch())) {} @@ -111,9 +111,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField *this, dict ), - TnbrName_(dict.get<word>("Tnbr")), - thicknessLayers_(0), - kappaLayers_(0) + TnbrName_(dict.get<word>("Tnbr")) { if (!isA<mappedPatchBase>(this->patch().patch())) { @@ -132,10 +130,25 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField << "the assemble coupled option for energy. " << endl; + // Read list of layers if (dict.readIfPresent("thicknessLayers", thicknessLayers_)) { dict.readEntry("kappaLayers", kappaLayers_); } + // Read single additional PatchFunction1 + thicknessLayer_ = PatchFunction1<scalar>::NewIfPresent + ( + p.patch(), + "thicknessLayer", + dict + ); + kappaLayer_ = PatchFunction1<scalar>::NewIfPresent + ( + p.patch(), + "kappaLayer", + dict + ); + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); @@ -187,7 +200,9 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField ), TnbrName_(wtcsf.TnbrName_), thicknessLayers_(wtcsf.thicknessLayers_), - kappaLayers_(wtcsf.kappaLayers_) + thicknessLayer_(wtcsf.thicknessLayer_.clone(patch().patch())), + kappaLayers_(wtcsf.kappaLayers_), + kappaLayer_(wtcsf.kappaLayer_.clone(patch().patch())) {} @@ -207,12 +222,96 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField ), TnbrName_(wtcsf.TnbrName_), thicknessLayers_(wtcsf.thicknessLayers_), - kappaLayers_(wtcsf.kappaLayers_) + thicknessLayer_(wtcsf.thicknessLayer_.clone(patch().patch())), + kappaLayers_(wtcsf.kappaLayers_), + kappaLayer_(wtcsf.kappaLayer_.clone(patch().patch())) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& mapper +) +{ + mixedFvPatchScalarField::autoMap(mapper); + temperatureCoupledBase::autoMap(mapper); + //mappedPatchFieldBase<scalar>::autoMap(mapper); + if (thicknessLayer_) + { + thicknessLayer_().autoMap(mapper); + kappaLayer_().autoMap(mapper); + } +} + + +void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::rmap +( + const fvPatchField<scalar>& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); + + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField& tiptf = + refCast + < + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField + >(ptf); + + temperatureCoupledBase::rmap(tiptf, addr); + //mappedPatchFieldBase<scalar>::rmap(ptf, addr); + if (thicknessLayer_) + { + thicknessLayer_().rmap(tiptf.thicknessLayer_(), addr); + kappaLayer_().rmap(tiptf.kappaLayer_(), addr); + } +} + + +tmp<Foam::scalarField> +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::kappa +( + const scalarField& Tp +) const +{ + // Get kappa from relevant thermo + tmp<scalarField> tk(temperatureCoupledBase::kappa(Tp)); + + // Optionally modify with explicit resistance + if (thicknessLayer_ || thicknessLayers_.size()) + { + scalarField KDelta(tk*patch().deltaCoeffs()); + + // Harmonic averaging of kappa*deltaCoeffs + { + KDelta = 1.0/KDelta; + if (thicknessLayer_) + { + const scalar t = db().time().timeOutputValue(); + KDelta += + thicknessLayer_().value(t) + /kappaLayer_().value(t); + } + if (thicknessLayers_.size()) + { + forAll(thicknessLayers_, iLayer) + { + KDelta += thicknessLayers_[iLayer]/kappaLayers_[iLayer]; + } + } + KDelta = 1.0/KDelta; + } + + // Update kappa from KDelta + tk = KDelta/patch().deltaCoeffs(); + } + + return tk; +} + + void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs() { if (updated()) @@ -233,17 +332,9 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs() this->internalField() ); - const tmp<scalarField> myKDelta = kappa(*this)*patch().deltaCoeffs(); - - if (thicknessLayers_.size() > 0) - { - myKDelta.ref() = 1.0/myKDelta.ref(); - forAll(thicknessLayers_, iLayer) - { - myKDelta.ref() += thicknessLayers_[iLayer]/kappaLayers_[iLayer]; - } - myKDelta.ref() = 1.0/myKDelta.ref(); - } + const scalarField& Tp = *this; + const scalarField kappaTp(kappa(Tp)); + const tmp<scalarField> myKDelta = kappaTp*patch().deltaCoeffs(); scalarField nbrIntFld; @@ -306,7 +397,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs() if (debug) { - scalar Q = gSum(kappa(*this)*patch().magSf()*snGrad()); + scalar Q = gSum(kappaTp*patch().magSf()*snGrad()); Info<< patch().boundaryMesh().mesh().name() << ':' << patch().name() << ':' @@ -381,6 +472,11 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write { mixedFvPatchScalarField::write(os); os.writeEntry("Tnbr", TnbrName_); + if (thicknessLayer_) + { + thicknessLayer_().writeData(os); + kappaLayer_().writeData(os); + } if (thicknessLayers_.size()) { thicknessLayers_.writeEntry("thicknessLayers", os); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H index efcd53dd30bdaa6a7c0cfa0a915811967fb7c218..7de8e9d7a3747577e1034bb0a134c96eb480be30 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H @@ -50,6 +50,8 @@ Usage Tnbr | name of the field | no | T thicknessLayers | list of thicknesses per layer [m] | no | kappaLayers | list of thermal conductivities per layer [W/m/K] | no | + thicknessLayer | single thickness of layer [m] | no | + kappaLayer | corresponding thermal conductivity [W/m/K] | no | kappaMethod | inherited from temperatureCoupledBase | inherited | kappa | inherited from temperatureCoupledBase | inherited | \endtable @@ -110,9 +112,11 @@ class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField //- Thickness of layers scalarList thicknessLayers_; + autoPtr<PatchFunction1<scalar>> thicknessLayer_; //- Conductivity of layers scalarList kappaLayers_; + autoPtr<PatchFunction1<scalar>> kappaLayer_; // Private member functions @@ -204,6 +208,27 @@ public: // Member Functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchField<scalar>&, + const labelList& + ); + + + //- Given patch temperature calculate corresponding K field. Override + //- temperatureCoupledBase::kappa to includes effect of any + //- explicit kappaThickness + virtual tmp<scalarField> kappa(const scalarField& Tp) const; + //- Update the coefficients associated with the patch field virtual void updateCoeffs(); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index 6eb362268b3b1b0e9e7c72e8c70166085392aa10..3a33f5478a23408e2f6039746d032e60816e65c9 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -67,8 +67,6 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField TnbrName_("undefined-Tnbr"), qrNbrName_("undefined-qrNbr"), qrName_("undefined-qr"), - thicknessLayers_(0), - kappaLayers_(0), thermalInertia_(false) { this->refValue() = 0.0; @@ -99,7 +97,9 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField qrNbrName_(psf.qrNbrName_), qrName_(psf.qrName_), thicknessLayers_(psf.thicknessLayers_), + thicknessLayer_(psf.thicknessLayer_.clone(p.patch())), kappaLayers_(psf.kappaLayers_), + kappaLayer_(psf.kappaLayer_.clone(p.patch())), thermalInertia_(psf.thermalInertia_) {} @@ -123,8 +123,6 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField TnbrName_(dict.getOrDefault<word>("Tnbr", "T")), qrNbrName_(dict.getOrDefault<word>("qrNbr", "none")), qrName_(dict.getOrDefault<word>("qr", "none")), - thicknessLayers_(0), - kappaLayers_(0), thermalInertia_(dict.getOrDefault<Switch>("thermalInertia", false)) { if (!isA<mappedPatchBase>(this->patch().patch())) @@ -137,10 +135,65 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField << exit(FatalError); } + //const auto* eptr = dict.findEntry("thicknessLayers"); + //if (eptr) + //{ + // // Detect either a list (parsed as a scalarList) or + // // a single entry (parsed as a PatchFunction1) or + // + // if + // ( + // eptr->isStream() + // && eptr->stream().peek().isPunctuation(token::BEGIN_LIST) + // ) + // { + // // Backwards compatibility + // thicknessLayers_ = dict.get<scalarList>("thicknessLayers"); + // kappaLayers_ = dict.get<scalarList>("kappaLayers"); + // + // if (thicknessLayers_.size() != kappaLayers_.size()) + // { + // FatalIOErrorInFunction(dict) << "Inconstent sizes :" + // << "thicknessLayers:" << thicknessLayers_ + // << "kappaLayers:" << kappaLayers_ + // << exit(FatalIOError); + // } + // } + // else + // { + // thicknessLayer_ = PatchFunction1<scalar>::New + // ( + // p.patch(), + // "thicknessLayers", + // dict + // ); + // kappaLayer_ = PatchFunction1<scalar>::New + // ( + // p.patch(), + // "kappaLayers", + // dict + // ); + // } + //} + + // Read list of layers if (dict.readIfPresent("thicknessLayers", thicknessLayers_)) { dict.readEntry("kappaLayers", kappaLayers_); } + // Read single additional PatchFunction1 + thicknessLayer_ = PatchFunction1<scalar>::NewIfPresent + ( + p.patch(), + "thicknessLayer", + dict + ); + kappaLayer_ = PatchFunction1<scalar>::NewIfPresent + ( + p.patch(), + "kappaLayer", + dict + ); fvPatchScalarField::operator=(scalarField("value", dict, p.size())); @@ -194,7 +247,9 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField qrNbrName_(psf.qrNbrName_), qrName_(psf.qrName_), thicknessLayers_(psf.thicknessLayers_), + thicknessLayer_(psf.thicknessLayer_.clone(patch().patch())), kappaLayers_(psf.kappaLayers_), + kappaLayer_(psf.kappaLayer_.clone(patch().patch())), thermalInertia_(psf.thermalInertia_) {} @@ -217,13 +272,97 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField qrNbrName_(psf.qrNbrName_), qrName_(psf.qrName_), thicknessLayers_(psf.thicknessLayers_), + thicknessLayer_(psf.thicknessLayer_.clone(patch().patch())), kappaLayers_(psf.kappaLayers_), + kappaLayer_(psf.kappaLayer_.clone(patch().patch())), thermalInertia_(psf.thermalInertia_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void turbulentTemperatureRadCoupledMixedFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& mapper +) +{ + mixedFvPatchScalarField::autoMap(mapper); + temperatureCoupledBase::autoMap(mapper); + //mappedPatchFieldBase<scalar>::autoMap(mapper); + if (thicknessLayer_) + { + thicknessLayer_().autoMap(mapper); + kappaLayer_().autoMap(mapper); + } +} + + +void turbulentTemperatureRadCoupledMixedFvPatchScalarField::rmap +( + const fvPatchField<scalar>& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); + + const turbulentTemperatureRadCoupledMixedFvPatchScalarField& tiptf = + refCast + < + const turbulentTemperatureRadCoupledMixedFvPatchScalarField + >(ptf); + + temperatureCoupledBase::rmap(tiptf, addr); + //mappedPatchFieldBase<scalar>::rmap(ptf, addr); + if (thicknessLayer_) + { + thicknessLayer_().rmap(tiptf.thicknessLayer_(), addr); + kappaLayer_().rmap(tiptf.kappaLayer_(), addr); + } +} + + +tmp<Foam::scalarField> +turbulentTemperatureRadCoupledMixedFvPatchScalarField::kappa +( + const scalarField& Tp +) const +{ + // Get kappa from relevant thermo + tmp<scalarField> tk(temperatureCoupledBase::kappa(Tp)); + + // Optionally modify with explicit resistance + if (thicknessLayer_ || thicknessLayers_.size()) + { + scalarField KDelta(tk*patch().deltaCoeffs()); + + // Harmonic averaging of kappa*deltaCoeffs + { + KDelta = 1.0/KDelta; + if (thicknessLayer_) + { + const scalar t = db().time().timeOutputValue(); + KDelta += + thicknessLayer_().value(t) + /kappaLayer_().value(t); + } + if (thicknessLayers_.size()) + { + forAll(thicknessLayers_, iLayer) + { + KDelta += thicknessLayers_[iLayer]/kappaLayers_[iLayer]; + } + } + KDelta = 1.0/KDelta; + } + + // Update kappa from KDelta + tk = KDelta/patch().deltaCoeffs(); + } + + return tk; +} + + void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() { if (updated()) @@ -250,17 +389,8 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() const scalarField Tc(patchInternalField()); const scalarField& Tp = *this; - scalarField KDelta(kappa(Tp)*patch().deltaCoeffs()); - - if (thicknessLayers_.size() > 0) - { - KDelta = 1.0/KDelta; - forAll(thicknessLayers_, iLayer) - { - KDelta += thicknessLayers_[iLayer]/kappaLayers_[iLayer]; - } - KDelta = 1.0/KDelta; - } + const scalarField kappaTp(kappa(Tp)); + const scalarField KDelta(kappaTp*patch().deltaCoeffs()); scalarField TcNbr; @@ -400,13 +530,13 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() valueFraction() = alpha/(alpha + KDelta); scalarField c(KDeltaNbr*TcNbr + (mCpDt + mCpDtNbr)*TpOld); refValue() = c/alpha; - refGrad() = (qr + qrNbr)/kappa(Tp); + refGrad() = (qr + qrNbr)/kappaTp; } else { valueFraction() = KDeltaNbr/(KDeltaNbr + KDelta); refValue() = TcNbr; - refGrad() = (qr + qrNbr)/kappa(Tp); + refGrad() = (qr + qrNbr)/kappaTp; } source() = Zero; @@ -426,7 +556,7 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs() if (debug) { - scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad()); + scalar Q = gSum(kappaTp*patch().magSf()*snGrad()); Info<< patch().boundaryMesh().mesh().name() << ':' << patch().name() << ':' @@ -604,6 +734,11 @@ void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write os.writeEntry("qr", qrName_); os.writeEntry("thermalInertia", thermalInertia_); + if (thicknessLayer_) + { + thicknessLayer_().writeData(os); + kappaLayer_().writeData(os); + } if (thicknessLayers_.size()) { thicknessLayers_.writeEntry("thicknessLayers", os); diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H index 16a350763a2d4a669f4f24fdff145b2bef60e493..0dbabd4d7bea8ab99f86ee06176cd2a562ee0002 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H @@ -45,6 +45,8 @@ Usage qr | name of the radiative flux in this region | no | none thicknessLayers | list of thicknesses per layer [m] | no | kappaLayers | list of thermal conductivites per layer [W/m/K] | no | + thicknessLayer | single thickness of layer [m] | no | + kappaLayer | corresponding thermal conductivity [W/m/K] | no | kappaMethod | inherited from temperatureCoupledBase | inherited | kappa | inherited from temperatureCoupledBase | inherited | thermalInertia | Add thermal inertia to wall node | no | false @@ -114,11 +116,13 @@ class turbulentTemperatureRadCoupledMixedFvPatchScalarField //- Name of the radiative heat flux in local region const word qrName_; - //- Thickness of layers + //- Thickness of layers (either scalarList or a single PatchFunction1) scalarList thicknessLayers_; + autoPtr<PatchFunction1<scalar>> thicknessLayer_; //- Conductivity of layers scalarList kappaLayers_; + autoPtr<PatchFunction1<scalar>> kappaLayer_; //- Thermal inertia term Switch thermalInertia_; @@ -224,6 +228,27 @@ public: // Member Functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchField<scalar>&, + const labelList& + ); + + + //- Given patch temperature calculate corresponding K field. Override + //- temperatureCoupledBase::kappa to includes effect of any + //- explicit kappaThickness + virtual tmp<scalarField> kappa(const scalarField& Tp) const; + //- Update the coefficients associated with the patch field virtual void updateCoeffs(); diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C index 7b0d624c06422fff6fc6c049aa9c31f2f2e87f43..07e34bdb04b268103017e652c1e968ff5244f9e6 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C @@ -225,6 +225,34 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& mapper +) +{ + mixedFvPatchScalarField::autoMap(mapper); + temperatureCoupledBase::autoMap(mapper); +} + + +void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::rmap +( + const fvPatchField<scalar>& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); + + const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField& tiptf = + refCast + < + const filmPyrolysisRadiativeCoupledMixedFvPatchScalarField + >(ptf); + + temperatureCoupledBase::rmap(tiptf, addr); +} + + void filmPyrolysisRadiativeCoupledMixedFvPatchScalarField::updateCoeffs() { if (updated()) diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H index d7e04532e04f2f4ef4060cc388637330f0196ab8..66e0625638bf9ea6096720f12b1a50cce1337876 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.H @@ -216,6 +216,22 @@ public: // Member functions + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchField<scalar>&, + const labelList& + ); + + //- Get corresponding K field tmp<scalarField> K() const; diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C index e79c81d5b14ecb1b065430349091d5918b0f8273..507acfeac8961f13db27d6446bea14ba984c2bdc 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C @@ -139,26 +139,6 @@ thermalBaffleFvPatchScalarField::thermalBaffleFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void thermalBaffleFvPatchScalarField::autoMap -( - const fvPatchFieldMapper& m -) -{ - mixedFvPatchScalarField::autoMap(m); -} - - -void thermalBaffleFvPatchScalarField::rmap -( - const fvPatchScalarField& ptf, - const labelList& addr -) -{ - mixedFvPatchScalarField::rmap(ptf, addr); -} - - void thermalBaffleFvPatchScalarField::createPatchMesh() { const fvMesh& thisMesh = patch().boundaryMesh().mesh(); diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H index 3637a77d883cae23729fb885c4bab4894e201ab5..15d7134717a9139e7c9025f89b03a2f144482fac 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H @@ -325,23 +325,6 @@ public: // Member functions - - // Mapping functions - - //- Map (and resize as needed) from self given a mapping object - virtual void autoMap - ( - const fvPatchFieldMapper& - ); - - //- Reverse map the given fvPatchField onto this fvPatchField - virtual void rmap - ( - const fvPatchScalarField&, - const labelList& - ); - - //- Update the coefficients associated with the patch field virtual void updateCoeffs(); diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C index 36e562882c5226193434f5fb5aefbd0f84814532..8f6719195afe0b8596e4b7670eddbcb4c970f48e 100644 --- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C @@ -383,6 +383,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::autoMap ) { mixedFvPatchScalarField::autoMap(m); + temperatureCoupledBase::autoMap(m); if (fluid_) { @@ -411,6 +412,7 @@ void Foam::humidityTemperatureCoupledMixedFvPatchScalarField::rmap ptf ); + temperatureCoupledBase::rmap(tiptf, addr); if (fluid_) { mass_.rmap(tiptf.mass_, addr);