From 6532f27547e4ad342cbbd5b237bcd778c11aa097 Mon Sep 17 00:00:00 2001 From: sergio <sergio> Date: Tue, 1 Oct 2019 19:16:43 +0200 Subject: [PATCH] ENH: add support for alpha field in temperatureCoupledBase --- ...allHeatFluxTemperatureFvPatchScalarField.C | 11 +- ...fixedIncidentRadiationFvPatchScalarField.C | 11 +- ...pedMassWallTemperatureFvPatchScalarField.C | 11 +- .../temperatureCoupledBase.C | 230 ++++++++++++++---- .../temperatureCoupledBase.H | 37 ++- ...tureCoupledBaffleMixedFvPatchScalarField.C | 11 +- ...eratureRadCoupledMixedFvPatchScalarField.C | 11 +- ...sRadiativeCoupledMixedFvPatchScalarField.C | 10 +- ...emperatureCoupledMixedFvPatchScalarField.C | 11 +- 9 files changed, 277 insertions(+), 66 deletions(-) diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C index c7890aa5b02..403428b7970 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -57,7 +57,14 @@ externalWallHeatFluxTemperatureFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), + temperatureCoupledBase + ( + patch(), + "undefined", + "undefined", + "undefined-K", + "undefined-alpha" + ), mode_(fixedHeatFlux), Q_(0), q_(), diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C index f352349d310..187dbbe4497 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,14 @@ fixedIncidentRadiationFvPatchScalarField ) : fixedGradientFvPatchScalarField(p, iF), - temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), + temperatureCoupledBase + ( + patch(), + "undefined", + "undefined", + "undefined-K", + "undefined-alpha" + ), qrIncident_(p.size(), Zero) {} diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C index 9a9da7fa01a..64c5d88fa33 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,7 +39,14 @@ lumpedMassWallTemperatureFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), + temperatureCoupledBase + ( + patch(), + "undefined", + "undefined", + "undefined-K", + "undefined-alpha" + ), Cp_(0.0), mass_(0.0), curTimeIndex_(-1) diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C index ea4621d2559..4a43fc748e3 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -53,13 +53,15 @@ Foam::temperatureCoupledBase::temperatureCoupledBase const fvPatch& patch, const word& calculationType, const word& kappaName, - const word& alphaAniName + const word& alphaAniName, + const word& alphaName ) : patch_(patch), method_(KMethodTypeNames_[calculationType]), kappaName_(kappaName), - alphaAniName_(alphaAniName) + alphaAniName_(alphaAniName), + alphaName_(alphaName) {} @@ -72,7 +74,8 @@ Foam::temperatureCoupledBase::temperatureCoupledBase patch_(patch), method_(KMethodTypeNames_.get("kappaMethod", dict)), kappaName_(dict.lookupOrDefault<word>("kappa", "none")), - alphaAniName_(dict.lookupOrDefault<word>("alphaAni","none")) + alphaAniName_(dict.lookupOrDefault<word>("alphaAni","none")), + alphaName_(dict.lookupOrDefault<word>("alpha","none")) { switch (method_) { @@ -123,15 +126,11 @@ Foam::temperatureCoupledBase::temperatureCoupledBase patch_(patch), method_(base.method_), kappaName_(base.kappaName_), - alphaAniName_(base.alphaAniName_) + alphaAniName_(base.alphaAniName_), + alphaName_(base.alphaName_) {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::temperatureCoupledBase::~temperatureCoupledBase() -{} - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa @@ -148,48 +147,54 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa { typedef compressible::turbulenceModel turbulenceModel; - const word turbName(turbulenceModel::propertiesName); - - if - ( - mesh.foundObject<turbulenceModel>(turbName) - ) { - const turbulenceModel& turbModel = - mesh.lookupObject<turbulenceModel>(turbName); + const auto* ptr = + mesh.cfindObject<turbulenceModel> + ( + turbulenceModel::propertiesName + ); - return turbModel.kappaEff(patchi); + if (ptr) + { + return ptr->kappaEff(patchi); + } } - else if (mesh.foundObject<fluidThermo>(basicThermo::dictName)) - { - const fluidThermo& thermo = - mesh.lookupObject<fluidThermo>(basicThermo::dictName); - return thermo.kappa(patchi); - } - else if (mesh.foundObject<basicThermo>(basicThermo::dictName)) { - const basicThermo& thermo = - mesh.lookupObject<basicThermo>(basicThermo::dictName); + const auto* ptr = + mesh.cfindObject<fluidThermo>(basicThermo::dictName); - return thermo.kappa(patchi); + if (ptr) + { + return ptr->kappa(patchi); + } } - else if (mesh.foundObject<basicThermo>("phaseProperties")) + { - const basicThermo& thermo = - mesh.lookupObject<basicThermo>("phaseProperties"); + const auto* ptr = + mesh.cfindObject<basicThermo>(basicThermo::dictName); - return thermo.kappa(patchi); + if (ptr) + { + return ptr->kappa(patchi); + } } - else + { - FatalErrorInFunction - << "kappaMethod defined to employ " - << KMethodTypeNames_[method_] - << " method, but thermo package not available" - << exit(FatalError); + const auto* ptr = + mesh.cfindObject<basicThermo>("phaseProperties"); + + if (ptr) + { + return ptr->kappa(patchi); + } } + FatalErrorInFunction + << "Using kappaMethod " << KMethodTypeNames_[method_] + << ", but thermo package not available\n" + << exit(FatalError); + break; } @@ -253,8 +258,148 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa << " or volSymmTensorField." << exit(FatalError); } + break; + } + default: + { + FatalErrorInFunction + << "Unimplemented method " << KMethodTypeNames_[method_] << nl + << "Please set 'kappaMethod' to one of " + << flatOutput(KMethodTypeNames_.sortedToc()) << nl + << "and 'kappa' to the name of the volScalar" + << " or volSymmTensor field (if kappaMethod=lookup)" + << exit(FatalError); + break; + } + } + + return scalarField(); +} + + +Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::alpha +( + const scalarField& Tp +) const +{ + const fvMesh& mesh = patch_.boundaryMesh().mesh(); + const label patchi = patch_.index(); + + switch (method_) + { + case mtFluidThermo: + { + typedef compressible::turbulenceModel turbulenceModel; + + { + const auto* ptr = + mesh.cfindObject<turbulenceModel> + ( + turbulenceModel::propertiesName + ); + + if (ptr) + { + return ptr->alphaEff(patchi); + } + } + + { + const auto* ptr = + mesh.cfindObject<fluidThermo>(basicThermo::dictName); + + if (ptr) + { + return ptr->alpha(patchi); + } + } + + { + const auto* ptr = + mesh.cfindObject<basicThermo>(basicThermo::dictName); + + if (ptr) + { + return ptr->alpha(patchi); + } + } + + { + const auto* ptr = + mesh.cfindObject<basicThermo>("phaseProperties"); + + if (ptr) + { + return ptr->alpha(patchi); + } + } + + FatalErrorInFunction + << "Using kappaMethod " << KMethodTypeNames_[method_] + << ", but thermo package not available\n" + << exit(FatalError); + + break; + } + + case mtSolidThermo: + { + const solidThermo& thermo = + mesh.lookupObject<solidThermo>(basicThermo::dictName); + + return thermo.alpha(patchi); + break; + } + + case mtDirectionalSolidThermo: + { + const symmTensorField& alphaAni = + patch_.lookupPatchField<volSymmTensorField, scalar> + ( + alphaAniName_ + ); + + const vectorField n(patch_.nf()); + + return n & alphaAni & n; + } + + case mtLookup: + { + if (mesh.foundObject<volScalarField>(alphaName_)) + { + return + patch_.lookupPatchField<volScalarField, scalar> + ( + alphaName_ + ); + } + else if (mesh.foundObject<volSymmTensorField>(alphaName_)) + { + const symmTensorField& alphaWall = + patch_.lookupPatchField<volSymmTensorField, scalar> + ( + alphaName_ + ); + + const vectorField n(patch_.nf()); + + return n & alphaWall & n; + } + else + { + FatalErrorInFunction + << "Did not find field " << alphaName_ + << " on mesh " << mesh.name() << " patch " << patch_.name() + << nl + << "Please set 'kappaMethod' to one of " + << flatOutput(KMethodTypeNames_.sortedToc()) << nl + << "and 'alpha' to the name of the volScalar" + << " or volSymmTensor field (if kappaMethod=lookup)" + << exit(FatalError); + } break; } @@ -265,13 +410,15 @@ Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::kappa << "Unimplemented method " << KMethodTypeNames_[method_] << nl << "Please set 'kappaMethod' to one of " << flatOutput(KMethodTypeNames_.sortedToc()) << nl - << "and 'kappa' to the name of the volScalar" + << "and 'alpha' to the name of the volScalar" << " or volSymmTensor field (if kappaMethod=lookup)" << exit(FatalError); + + break; } } - return scalarField(0); + return scalarField(); } @@ -280,6 +427,7 @@ void Foam::temperatureCoupledBase::write(Ostream& os) const os.writeEntry("kappaMethod", KMethodTypeNames_[method_]); os.writeEntry("kappa", kappaName_); os.writeEntry("alphaAni", alphaAniName_); + os.writeEntry("alpha", alphaName_); } diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H index 4e7ff6af235..c7d6b6e20d4 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -42,10 +42,11 @@ Description \par Keywords provided by this class: \table - Property | Description | Required | Default value - kappaMethod | Thermal conductivity method | yes | - kappa | Name of thermal conductivity field | no | none - alphaAni | Name of the non-isotropic alpha | no | Anialpha + 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 \endtable Usage @@ -85,7 +86,7 @@ class temperatureCoupledBase { public: - // Public enumerations + // Public Enumerations //- Type of supplied Kappa enum KMethodType @@ -99,7 +100,7 @@ public: protected: - // Protected data + // Protected Data static const Enum<KMethodType> KMethodTypeNames_; @@ -115,6 +116,9 @@ protected: //- Name of the non-Isotropic alpha (default: Anialpha) const word alphaAniName_; + //- Name of thermal diffusivity + const word alphaName_; + public: @@ -126,7 +130,8 @@ public: const fvPatch& patch, const word& calculationMethod, const word& kappaName, - const word& alphaAniName + const word& alphaAniName, + const word& alphaName ); //- Construct from patch and dictionary @@ -136,7 +141,7 @@ public: const dictionary& dict ); - //- Construct from patch and temperatureCoupledBase + //- Construct from patch and temperatureCoupledBase temperatureCoupledBase ( const fvPatch& patch, @@ -145,7 +150,8 @@ public: //- Destructor - virtual ~temperatureCoupledBase(); + virtual ~temperatureCoupledBase() = default; + // Member functions @@ -161,11 +167,20 @@ public: return kappaName_; } + //- Name of thermal diffusivity field + const word& alphaName() const + { + return alphaName_; + } + //- Given patch temperature calculate corresponding K field virtual tmp<scalarField> kappa(const scalarField& Tp) const; + //- Given patch temperature calculate corresponding alphaEff field + virtual tmp<scalarField> alpha(const scalarField& Tp) const; + //- Write - void write(Ostream&) const; + void write(Ostream& os) const; }; diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index 3a9f6c3cbda..6db4fa007af 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2016 OpenFOAM Foundation @@ -48,7 +48,14 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), + temperatureCoupledBase + ( + patch(), + "undefined", + "undefined", + "undefined-K", + "undefined-alpha" + ), TnbrName_("undefined-Tnbr"), thicknessLayers_(0), kappaLayers_(0), diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index b0baf118d58..489f3ab7a09 100644 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- | Copyright (C) 2011-2017 OpenFOAM Foundation @@ -49,7 +49,14 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), + temperatureCoupledBase + ( + patch(), + "undefined", + "undefined", + "undefined-K", + "undefined-alpha" + ), TnbrName_("undefined-Tnbr"), qrNbrName_("undefined-qrNbr"), qrName_("undefined-qr"), diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C index b06050e379e..2d528e397f8 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C @@ -88,7 +88,6 @@ pyrModel() const modelNames.append(iter()->regionMesh().name()); } - FatalErrorInFunction << "Unable to locate pyrolysis region " << pyrolysisRegionName_ << ". Available regions include: " << modelNames @@ -108,7 +107,14 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), + temperatureCoupledBase + ( + patch(), + "undefined", + "undefined", + "undefined-K", + "undefined-alpha" + ), filmRegionName_("surfaceFilmProperties"), pyrolysisRegionName_("pyrolysisProperties"), TnbrName_("undefined-Tnbr"), diff --git a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C index e790ccfa3da..e67e0ee4b83 100644 --- a/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/thermophysicalPropertiesFvPatchFields/liquidProperties/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2015-2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -128,7 +128,14 @@ humidityTemperatureCoupledMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase(patch(), "fluidThermo", "undefined", "undefined-K"), + temperatureCoupledBase + ( + patch(), + "fluidThermo", + "undefined", + "undefined-K", + "undefined-alpha" + ), mode_(mtConstantMass), pName_("p"), UName_("U"), -- GitLab