diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C index 07e34bdb04..7a7cabd103 100644 --- a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisRadiativeCoupledMixed/filmPyrolysisRadiativeCoupledMixedFvPatchScalarField.C @@ -108,14 +108,7 @@ filmPyrolysisRadiativeCoupledMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase - ( - patch(), - "undefined", - "undefined", - "undefined-K", - "undefined-alpha" - ), + temperatureCoupledBase(patch()), // default method (fluidThermo) filmRegionName_("surfaceFilmProperties"), pyrolysisRegionName_("pyrolysisProperties"), TnbrName_("undefined-Tnbr"), diff --git a/src/thermoTools/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C index a4ed421023..0130150a92 100644 --- a/src/thermoTools/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -58,14 +58,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase - ( - patch(), - "undefined", - "undefined", - "undefined-K", - "undefined-alpha" - ), + temperatureCoupledBase(patch()), // default method (fluidThermo) mode_(fixedHeatFlux), Q_(nullptr), q_(nullptr), diff --git a/src/thermoTools/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C index 3603707738..90899164ac 100644 --- a/src/thermoTools/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/fixedIncidentRadiation/fixedIncidentRadiationFvPatchScalarField.C @@ -45,14 +45,7 @@ fixedIncidentRadiationFvPatchScalarField ) : fixedGradientFvPatchScalarField(p, iF), - temperatureCoupledBase - ( - patch(), - "undefined", - "undefined", - "undefined-K", - "undefined-alpha" - ), + temperatureCoupledBase(patch()), // default method (fluidThermo) qrIncident_(p.size(), Zero) {} diff --git a/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C index 61a150ce10..5055a52571 100644 --- a/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/humidityTemperatureCoupledMixed/humidityTemperatureCoupledMixedFvPatchScalarField.C @@ -132,14 +132,7 @@ humidityTemperatureCoupledMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase - ( - patch(), - "fluidThermo", - "undefined", - "undefined-K", - "undefined-alpha" - ), + temperatureCoupledBase(patch(), temperatureCoupledBase::mtFluidThermo), mode_(mtConstantMass), pName_("p"), UName_("U"), diff --git a/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C index 5cd79495a3..f34d171eae 100644 --- a/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/lumpedMassWallTemperature/lumpedMassWallTemperatureFvPatchScalarField.C @@ -41,14 +41,7 @@ lumpedMassWallTemperatureFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase - ( - patch(), - "undefined", - "undefined", - "undefined-K", - "undefined-alpha" - ), + temperatureCoupledBase(patch()), // default method (fluidThermo) Cp_(0.0), mass_(0.0), curTimeIndex_(-1) diff --git a/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C b/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C index b14d96c692..d6768f7fbb 100644 --- a/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C +++ b/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.C @@ -54,18 +54,70 @@ Foam::temperatureCoupledBase::KMethodTypeNames_ Foam::temperatureCoupledBase::temperatureCoupledBase ( const fvPatch& patch, - const word& calculationType, - const word& kappaName, - const word& alphaAniName, - const word& alphaName + const KMethodType method ) : patch_(patch), - method_(KMethodTypeNames_[calculationType]), + method_(method), + kappaName_(), + alphaName_(), + alphaAniName_(), + kappaFunction1_(nullptr), + alphaFunction1_(nullptr) +{ + switch (method_) + { + case mtDirectionalSolidThermo: + case mtLookup: + case mtFunction: + { + FatalErrorInFunction + << "Cannot construct kappaMethod: " + << KMethodTypeNames_[method_] << " without a dictionary" + << abort(FatalError); + break; + } + default: + { + break; + } + } +} + + +Foam::temperatureCoupledBase::temperatureCoupledBase +( + const fvPatch& patch, + const KMethodType method, + const word& kappaName, + const word& alphaName, + const word& alphaAniName +) +: + patch_(patch), + method_(method), kappaName_(kappaName), + alphaName_(alphaName), alphaAniName_(alphaAniName), - alphaName_(alphaName) -{} + kappaFunction1_(nullptr), + alphaFunction1_(nullptr) +{ + switch (method_) + { + case mtFunction: + { + FatalErrorInFunction + << "Cannot construct kappaMethod: " + << KMethodTypeNames_[method_] << " without a dictionary" + << abort(FatalError); + break; + } + default: + { + break; + } + } +} Foam::temperatureCoupledBase::temperatureCoupledBase @@ -77,8 +129,10 @@ Foam::temperatureCoupledBase::temperatureCoupledBase patch_(patch), method_(KMethodTypeNames_.get("kappaMethod", dict)), kappaName_(dict.getOrDefault("kappa", word::null)), + alphaName_(dict.getOrDefault("alpha", word::null)), alphaAniName_(dict.getOrDefault("alphaAni", word::null)), - alphaName_(dict.getOrDefault("alpha", word::null)) + kappaFunction1_(nullptr), + alphaFunction1_(nullptr) { switch (method_) { @@ -89,7 +143,7 @@ Foam::temperatureCoupledBase::temperatureCoupledBase FatalIOErrorInFunction(dict) << "Did not find entry 'alphaAni'" " required for 'kappaMethod' " - << KMethodTypeNames_[method_] + << KMethodTypeNames_[method_] << nl << exit(FatalIOError); } @@ -104,8 +158,8 @@ Foam::temperatureCoupledBase::temperatureCoupledBase << "Did not find entry 'kappa'" " required for 'kappaMethod' " << KMethodTypeNames_[method_] << nl - << " Please set 'kappa' to the name of a volScalarField" - " or volSymmTensorField" + << "Please set 'kappa' to the name of" + " a volScalar or volSymmTensor field" << nl << exit(FatalIOError); } @@ -116,16 +170,18 @@ Foam::temperatureCoupledBase::temperatureCoupledBase { kappaFunction1_ = PatchFunction1::New ( - patch.patch(), + patch_.patch(), "kappaValue", dict ); alphaFunction1_ = PatchFunction1::New ( - patch.patch(), + patch_.patch(), "alphaValue", dict ); + + break; } default: @@ -141,13 +197,7 @@ 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())) + temperatureCoupledBase(base.patch_, base) {} @@ -160,8 +210,8 @@ Foam::temperatureCoupledBase::temperatureCoupledBase patch_(patch), method_(base.method_), kappaName_(base.kappaName_), - alphaAniName_(base.alphaAniName_), alphaName_(base.alphaName_), + alphaAniName_(base.alphaAniName_), kappaFunction1_(base.kappaFunction1_.clone(patch_.patch())), alphaFunction1_(base.alphaFunction1_.clone(patch_.patch())) {} @@ -281,6 +331,7 @@ Foam::tmp Foam::temperatureCoupledBase::kappa mesh.lookupObject(basicThermo::dictName); return thermo.kappa(patchi); + break; } @@ -306,35 +357,42 @@ Foam::tmp Foam::temperatureCoupledBase::kappa case mtLookup: { - if (mesh.foundObject(kappaName_)) { - return patch_.lookupPatchField - ( - kappaName_ - ); - } - else if (mesh.foundObject(kappaName_)) - { - const symmTensorField& KWall = - patch_.lookupPatchField - ( - kappaName_ - ); + const auto* ptr = + mesh.cfindObject(kappaName_); - const vectorField n(patch_.nf()); + if (ptr) + { + return patch_.patchField(*ptr); + } + } - return n & KWall & n; - } - else { - FatalErrorInFunction - << "Did not find field " << kappaName_ - << " on mesh " << mesh.name() << " patch " << patch_.name() - << nl - << " Please set 'kappa' to the name of a volScalarField" - << " or volSymmTensorField." - << exit(FatalError); + const auto* ptr = + mesh.cfindObject(kappaName_); + + if (ptr) + { + const symmTensorField& wallValues = + patch_.patchField(*ptr); + + const vectorField n(patch_.nf()); + + return n & wallValues & n; + } } + + + FatalErrorInFunction + << "Did not find field '" << kappaName_ + << "' on mesh " << mesh.name() + << " patch " << patch_.name() << nl + << "Please set 'kappa' to the name of" + " a volScalar or volSymmTensor field" + ", or use another method" << nl + << " " << flatOutput(KMethodTypeNames_.sortedToc()) << nl + << exit(FatalError); + break; } @@ -351,8 +409,8 @@ Foam::tmp 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" - << " or volSymmTensor field (if kappaMethod=lookup)" + << "If kappaMethod=lookup, also set 'kappa' to the name of" + " a volScalar or volSymmTensor field" << nl << exit(FatalError); break; @@ -452,39 +510,41 @@ Foam::tmp Foam::temperatureCoupledBase::alpha case mtLookup: { - if (mesh.foundObject(alphaName_)) { - return - patch_.lookupPatchField - ( - alphaName_ - ); - } - else if (mesh.foundObject(alphaName_)) - { - const symmTensorField& alphaWall = - patch_.lookupPatchField - ( - alphaName_ - ); + const auto* ptr = + mesh.cfindObject(alphaName_); - const vectorField n(patch_.nf()); + if (ptr) + { + return patch_.patchField(*ptr); + } + } - 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); + const auto* ptr = + mesh.cfindObject(alphaName_); + + if (ptr) + { + const symmTensorField& wallValues = + patch_.patchField(*ptr); + + const vectorField n(patch_.nf()); + + return n & wallValues & n; + } } + FatalErrorInFunction + << "Did not find field '" << alphaName_ + << "' on mesh " << mesh.name() + << " patch " << patch_.name() << nl + << "Please set 'alpha' to the name of" + " a volScalar or volSymmTensor field" + ", or use another method" << nl + << " " << flatOutput(KMethodTypeNames_.sortedToc()) << nl + << exit(FatalError); + break; } @@ -501,8 +561,8 @@ Foam::tmp Foam::temperatureCoupledBase::alpha << "Unimplemented method " << KMethodTypeNames_[method_] << 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)" + << "If kappaMethod=lookup, also set 'alpha' to the name of" + " a volScalar or volSymmTensor field" << nl << exit(FatalError); break; diff --git a/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H b/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H index 3e7eff8b76..b595c5dbd3 100644 --- a/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H +++ b/src/thermoTools/derivedFvPatchFields/temperatureCoupledBase/temperatureCoupledBase.H @@ -46,11 +46,11 @@ Description \table Property | Description | Required | Default kappaMethod | Thermal conductivity method | yes | - 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 | + kappa | Name of thermal conductivity field | partly | + alpha | Name of thermal diffusivity field | partly | + alphaAni | Name of non-isotropic alpha | partly | + kappaValue | Function1 supplying kappa | partly | + alphaValue | Function1 supplying alpha | partly | \endtable Usage @@ -130,12 +130,12 @@ protected: //- Name of thermal conductivity field (if looked up from database) const word kappaName_; - //- Name of the non-Isotropic alpha (default: Anialpha) - const word alphaAniName_; - //- Name of thermal diffusivity const word alphaName_; + //- Name of the non-isotropic alpha (for directional solidThermo) + const word alphaAniName_; + //- Function1 for kappa autoPtr> kappaFunction1_; @@ -147,14 +147,22 @@ public: // Constructors - //- Construct from patch and K name + //- Default construct from patch, using fluidThermo (default) + //- or specified method + explicit temperatureCoupledBase + ( + const fvPatch& patch, + const KMethodType method = KMethodType::mtFluidThermo + ); + + //- Construct from patch, method type and field names temperatureCoupledBase ( const fvPatch& patch, - const word& calculationMethod, + const KMethodType method, const word& kappaName, - const word& alphaAniName, - const word& alphaName + const word& alphaName, + const word& alphaAniName ); //- Construct from patch and dictionary @@ -171,18 +179,15 @@ public: const temperatureCoupledBase& base ); - //- Construct as copy - temperatureCoupledBase - ( - const temperatureCoupledBase& - ); + //- Copy construct + temperatureCoupledBase(const temperatureCoupledBase& base); //- Destructor virtual ~temperatureCoupledBase() = default; - // Member functions + // Member Functions //- Method to obtain K word KMethod() const @@ -191,13 +196,13 @@ public: } //- Name of thermal conductivity field - const word& kappaName() const + const word& kappaName() const noexcept { return kappaName_; } //- Name of thermal diffusivity field - const word& alphaName() const + const word& alphaName() const noexcept { return alphaName_; } diff --git a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index e59afded4d..bb6c154687 100644 --- a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -49,14 +49,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase - ( - patch(), - "undefined", - "undefined", - "undefined-K", - "undefined-alpha" - ), + temperatureCoupledBase(patch()), // default method (fluidThermo) mappedPatchFieldBase ( mappedPatchFieldBase::mapper(p, iF), diff --git a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index d82dc200c4..b6420d7a75 100644 --- a/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/thermoTools/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -51,14 +51,7 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - temperatureCoupledBase - ( - patch(), - "undefined", - "undefined", - "undefined-K", - "undefined-alpha" - ), + temperatureCoupledBase(patch()), // default method (fluidThermo) mappedPatchFieldBase ( mappedPatchFieldBase::mapper(p, iF),