diff --git a/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/Make/files b/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/Make/files index 45dac52cdb..267aae477a 100644 --- a/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/Make/files +++ b/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/Make/files @@ -31,7 +31,7 @@ wallBoilingSubModels/departureFrequencyModels/KocamustafaogullariIshiiDepartureF derivedFvPatchFields/alphatPhaseChangeWallFunctionBase/alphatPhaseChangeWallFunctionBase.C derivedFvPatchFields/alphatWallBoilingWallFunction/alphatWallBoilingWallFunctionFvPatchScalarField.C -derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.C derivedFvPatchFields/coupledMultiphaseTemperature/coupledMultiphaseTemperatureFvPatchScalarField.C +derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.C LIB = $(FOAM_LIBBIN)/libmultiphaseThermophysicalTransportModels diff --git a/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.C b/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000..a9ab0c988b --- /dev/null +++ b/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.C @@ -0,0 +1,144 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "multiphaseExternalTemperatureFvPatchScalarField.H" +#include "phaseSystem.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void Foam::multiphaseExternalTemperatureFvPatchScalarField::getKappa +( + scalarField& kappa, + scalarField& sumKappaTByDelta, + scalarField& sumKappaByDelta, + scalarField& Tref, + scalarField& Tw, + scalarField& sumq, + scalarField& qByKappa +) const +{ + // Lookup the fluid model + const phaseSystem& fluid = + db().lookupObject(phaseSystem::propertiesName); + + const phaseModel& thisPhase = fluid.phases()[internalField().group()]; + + scalarField sumKappa(size(), scalar(0)); + scalarField sumKappaT(size(), scalar(0)); + scalarField sumKappaTw(size(), scalar(0)); + + const label patchi = patch().index(); + + forAll(fluid.phases(), phasei) + { + const phaseModel& phase = fluid.phases()[phasei]; + + if (&phase != &thisPhase) + { + const scalarField& alpha = phase.boundaryField()[patchi]; + const scalarField kappaEff(phase.kappaEff(patchi)); + const scalarField alphaKappaEff(alpha*kappaEff); + + const fvPatchScalarField& T = + phase.thermo().T().boundaryField()[patchi]; + + sumKappa += alphaKappaEff; + sumKappaT += alphaKappaEff*T.patchInternalField(); + sumKappaTw += alphaKappaEff*T; + } + } + + const scalarField& alpha = thisPhase.boundaryField()[patchi]; + const scalarField kappaEff(thisPhase.kappaEff(patchi)); + const scalarField alphaKappaEff(alpha*kappaEff); + + kappa = alphaKappaEff; + qByKappa = sumq/(max(alpha, rootSmall)*kappaEff); + // sumq -= alpha*sumq; + + const scalarField& T = *this; + Tw = (sumKappaTw + alphaKappaEff*T)/(sumKappa + alphaKappaEff); + + Tref = + (sumKappaT + rootSmall*kappaEff*patchInternalField()) + /(sumKappa + rootSmall*kappaEff); + + sumKappaByDelta = sumKappa*patch().deltaCoeffs(); + sumKappaTByDelta = sumKappaT*patch().deltaCoeffs(); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::multiphaseExternalTemperatureFvPatchScalarField:: +multiphaseExternalTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + externalTemperatureFvPatchScalarField(p, iF, dict) +{} + + +Foam::multiphaseExternalTemperatureFvPatchScalarField:: +multiphaseExternalTemperatureFvPatchScalarField +( + const multiphaseExternalTemperatureFvPatchScalarField& psf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + externalTemperatureFvPatchScalarField(psf, p, iF, mapper) +{} + + +Foam::multiphaseExternalTemperatureFvPatchScalarField:: +multiphaseExternalTemperatureFvPatchScalarField +( + const multiphaseExternalTemperatureFvPatchScalarField& psf, + const DimensionedField& iF +) +: + externalTemperatureFvPatchScalarField(psf, iF) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + multiphaseExternalTemperatureFvPatchScalarField + ); +} + + +// ************************************************************************* // diff --git a/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.H b/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.H similarity index 50% rename from applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.H rename to applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.H index f62edaf6e2..d8b7d685f1 100644 --- a/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.H +++ b/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/multiphaseExternalTemperature/multiphaseExternalTemperatureFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,44 +22,26 @@ License along with OpenFOAM. If not, see . Class - Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField + Foam::multiphaseExternalTemperatureFvPatchScalarField Description - Uniform fixed heat flux boundary condition for Eulerian multi-phase cases. - Constructs a mixed constraint which portions the heat flux between the - phases in such a way as to keep the boundary temperature uniform across all - phases. The heat flux can be specified as a time-varying function, and an - under-relaxation factor can be supplied if this is necessary to maintain - stability. + Mixed boundary condition for the phase temperature of a phase in an + Euler-Euler multiphase simulation, to be used for heat-transfer with another + region in a CHT case. Optional thin wall material layer resistances can be + specified through thicknessLayers and kappaLayers entries. -Usage - \table - Property | Description | Required | Default value - q | Heat flux [w/m^2] | yes | - relax | Relaxation factor | no | 1 - \endtable - - Example of the boundary condition specification: - \verbatim - - { - type uniformFixedMultiphaseHeatFlux; - q 1000; - relax 0.3; - value $internalField; - } - \endverbatim +See also + Foam::externalTemperatureFvPatchScalarField SourceFiles - uniformFixedMultiphaseHeatFluxFvPatchScalarField.C + multiphaseExternalTemperatureFvPatchScalarField.C \*---------------------------------------------------------------------------*/ -#ifndef uniformFixedMultiphaseHeatFluxFvPatchScalarField_H -#define uniformFixedMultiphaseHeatFluxFvPatchScalarField_H +#ifndef multiphaseExternalTemperatureFvPatchScalarField_H +#define multiphaseExternalTemperatureFvPatchScalarField_H -#include "mixedFvPatchFields.H" -#include "Function1.H" +#include "externalTemperatureFvPatchScalarField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -67,32 +49,42 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class uniformFixedMultiphaseHeatFluxFvPatchScalarField Declaration + Class multiphaseExternalTemperatureFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ -class uniformFixedMultiphaseHeatFluxFvPatchScalarField +class multiphaseExternalTemperatureFvPatchScalarField : - public mixedFvPatchScalarField + public externalTemperatureFvPatchScalarField { - // Private Data - //- Heat flux [W/m^2] - autoPtr> q_; +protected: - //- Relaxation factor - scalar relax_; + //- Get the patch kappa, sum kappa*Tc/delta, kappa/delta and + // reference temperature for all phases except the phase being solved + // and also the current phase-average wall T and phase heat-flux + // obtained by partitioning the sum heat-flux provided + virtual void getKappa + ( + scalarField& kappa, + scalarField& sumKappaTByDelta, + scalarField& sumKappaByDelta, + scalarField& Tref, + scalarField& Tw, + scalarField& sumq, + scalarField& qByKappa + ) const; public: //- Runtime type information - TypeName("uniformFixedMultiphaseHeatFlux"); + TypeName("multiphaseExternalTemperature"); // Constructors //- Construct from patch, internal field and dictionary - uniformFixedMultiphaseHeatFluxFvPatchScalarField + multiphaseExternalTemperatureFvPatchScalarField ( const fvPatch&, const DimensionedField&, @@ -100,26 +92,26 @@ public: ); //- Construct by mapping given - // uniformFixedMultiphaseHeatFluxFvPatchScalarField + // multiphaseExternalTemperatureFvPatchScalarField // onto a new patch - uniformFixedMultiphaseHeatFluxFvPatchScalarField + multiphaseExternalTemperatureFvPatchScalarField ( - const uniformFixedMultiphaseHeatFluxFvPatchScalarField&, + const multiphaseExternalTemperatureFvPatchScalarField&, const fvPatch&, const DimensionedField&, const fvPatchFieldMapper& ); //- Disallow copy without setting internal field reference - uniformFixedMultiphaseHeatFluxFvPatchScalarField + multiphaseExternalTemperatureFvPatchScalarField ( - const uniformFixedMultiphaseHeatFluxFvPatchScalarField& + const multiphaseExternalTemperatureFvPatchScalarField& ) = delete; //- Copy constructor setting internal field reference - uniformFixedMultiphaseHeatFluxFvPatchScalarField + multiphaseExternalTemperatureFvPatchScalarField ( - const uniformFixedMultiphaseHeatFluxFvPatchScalarField&, + const multiphaseExternalTemperatureFvPatchScalarField&, const DimensionedField& ); @@ -131,32 +123,9 @@ public: { return tmp ( - new uniformFixedMultiphaseHeatFluxFvPatchScalarField(*this, iF) + new multiphaseExternalTemperatureFvPatchScalarField(*this, iF) ); } - - - // Member Functions - - // Access - - //- Allow manipulation of the boundary values - virtual bool fixesValue() const - { - return false; - } - - - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - - // I-O - - //- Write - virtual void write(Ostream&) const; }; diff --git a/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.C b/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.C deleted file mode 100644 index 9c9a06bb53..0000000000 --- a/applications/modules/multiphaseEuler/multiphaseThermophysicalTransportModels/derivedFvPatchFields/uniformFixedMultiphaseHeatFlux/uniformFixedMultiphaseHeatFluxFvPatchScalarField.C +++ /dev/null @@ -1,185 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "uniformFixedMultiphaseHeatFluxFvPatchScalarField.H" -#include "fvPatchFieldMapper.H" -#include "phaseSystem.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField:: -uniformFixedMultiphaseHeatFluxFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - mixedFvPatchScalarField(p, iF, dict, false), - q_(Function1::New("q", dict)), - relax_(dict.lookupOrDefault("relax", 1)) -{ - fvPatchScalarField::operator=(scalarField("value", dict, p.size())); - - valueFraction() = 1; - refValue() = patchInternalField(); - refGrad() = Zero; -} - - -Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField:: -uniformFixedMultiphaseHeatFluxFvPatchScalarField -( - const uniformFixedMultiphaseHeatFluxFvPatchScalarField& psf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - mixedFvPatchScalarField(psf, p, iF, mapper), - q_(psf.q_, false), - relax_(psf.relax_) -{} - - -Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField:: -uniformFixedMultiphaseHeatFluxFvPatchScalarField -( - const uniformFixedMultiphaseHeatFluxFvPatchScalarField& psf, - const DimensionedField& iF -) -: - mixedFvPatchScalarField(psf, iF), - q_(psf.q_, false), - relax_(psf.relax_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField::updateCoeffs() -{ - if (updated()) - { - return; - } - - const label patchi = patch().index(); - - const scalar q = q_->value(db().time().userTimeValue()); - - const phaseSystem& fluid = - db().lookupObject(phaseSystem::propertiesName); - - const phaseModel& thisPhase = fluid.phases()[internalField().group()]; - - // Sums of alpha*kappaEff - scalarField sumNotThisAlphaKappaEff(patch().size(), 0); - scalarField sumNotThisAlphaKappaEffT(patch().size(), 0); - scalarField sumNotThisAlphaKappaEffTw(patch().size(), 0); - - // Contributions from phases other than this one - forAll(fluid.phases(), phasei) - { - const phaseModel& phase = fluid.phases()[phasei]; - - if (&phase != &thisPhase) - { - const scalarField& alpha = phase.boundaryField()[patchi]; - const scalarField kappaEff(phase.kappaEff(patchi)); - const scalarField alphaKappaEff(alpha*kappaEff); - const fvPatchScalarField& T = - phase.thermo().T().boundaryField()[patchi]; - - sumNotThisAlphaKappaEff += alphaKappaEff; - sumNotThisAlphaKappaEffT += alphaKappaEff*T.patchInternalField(); - sumNotThisAlphaKappaEffTw += alphaKappaEff*T; - } - } - - // Contribution from this phase, and stabilisation - const scalarField& alpha = thisPhase.boundaryField()[patchi]; - const scalarField kappaEff(thisPhase.kappaEff(patchi)); - const scalarField alphaKappaEff(alpha*kappaEff); - const fvPatchScalarField& T = *this; - - // Calculate the phase average wall temperature - const scalarField Tw = - (sumNotThisAlphaKappaEffTw + alphaKappaEff*T) - /(sumNotThisAlphaKappaEff + alphaKappaEff); - - valueFraction() = - sumNotThisAlphaKappaEff/(sumNotThisAlphaKappaEff + alphaKappaEff); - - // Stabilisation for refValue - sumNotThisAlphaKappaEff = max(sumNotThisAlphaKappaEff, rootSmall*kappaEff); - sumNotThisAlphaKappaEffT = - max - ( - sumNotThisAlphaKappaEffT, - rootSmall*kappaEff*T.patchInternalField() - ); - refValue() = sumNotThisAlphaKappaEffT/sumNotThisAlphaKappaEff; - - refGrad() = q/(max(alpha, rootSmall)*kappaEff); - - // Modify mixed parameters for under-relaxation - if (relax_ != 1) - { - const scalarField f(valueFraction()); - valueFraction() = 1 - relax_*(1 - f); - refValue() = (f*relax_*refValue() + (1 - relax_)*Tw)/valueFraction(); - //refGrad() = refGrad(); // No change - } - - mixedFvPatchScalarField::updateCoeffs(); -} - - -void Foam::uniformFixedMultiphaseHeatFluxFvPatchScalarField::write -( - Ostream& os -) const -{ - mixedFvPatchScalarField::write(os); - writeEntry(os, q_()); - writeEntry(os, "relax", relax_); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - makePatchTypeField - ( - fvPatchScalarField, - uniformFixedMultiphaseHeatFluxFvPatchScalarField - ); -} - - -// ************************************************************************* // diff --git a/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.C b/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.C index 2bac3aa600..f938be895a 100644 --- a/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.C +++ b/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.C @@ -31,6 +31,38 @@ License using Foam::constant::physicoChemical::sigma; +// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // + +void Foam::externalTemperatureFvPatchScalarField::getKappa +( + scalarField& kappa, + scalarField& sumKappaTByDelta, + scalarField& sumKappaByDelta, + scalarField& Tref, + scalarField& Tw, + scalarField& sumq, + scalarField& qByKappa +) const +{ + const thermophysicalTransportModel& ttm = + patch().boundaryMesh().mesh() + .lookupType(); + + kappa = ttm.kappaEff(patch().index()); + + tmp qCorr(ttm.qCorr(patch().index())); + + if (qCorr.valid()) + { + sumq += qCorr; + } + + qByKappa = sumq/kappa; + + Tw = *this; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::externalTemperatureFvPatchScalarField:: @@ -43,11 +75,21 @@ externalTemperatureFvPatchScalarField : mixedFvPatchScalarField(p, iF, dict, false), haveQ_(dict.found("Q")), - Q_(haveQ_ ? dict.lookup("Q") : NaN), + Q_ + ( + haveQ_ + ? Function1::New("Q", dict) + : autoPtr>() + ), haveq_(dict.found("q")), - q_(haveq_ ? scalarField("q", dict, p.size()) : scalarField()), + q_ + ( + haveq_ + ? Function1::New("q", dict) + : autoPtr>() + ), haveh_(dict.found("h")), - h_(haveh_ ? scalarField("h", dict, p.size()) : scalarField()), + h_(haveh_ ? Function1::New("h", dict).ptr() : nullptr), Ta_(haveh_ ? Function1::New("Ta", dict).ptr() : nullptr), emissivity_(dict.lookupOrDefault("emissivity", 0)), thicknessLayers_ @@ -58,9 +100,9 @@ externalTemperatureFvPatchScalarField ( dict.lookupOrDefault("kappaLayers", scalarList()) ), - relaxation_(dict.lookupOrDefault("relaxation", 1)), + relax_(dict.lookupOrDefault("relaxation", 1)), qrName_(dict.lookupOrDefault("qr", word::null)), - qrRelaxation_(dict.lookupOrDefault("qrRelaxation", 1)), + qrRelax_(dict.lookupOrDefault("qrRelaxation", 1)), qrPrevious_ ( qrName_ != word::null @@ -116,18 +158,18 @@ externalTemperatureFvPatchScalarField : mixedFvPatchScalarField(ptf, p, iF, mapper), haveQ_(ptf.haveQ_), - Q_(ptf.Q_), + Q_(ptf.Q_, false), haveq_(ptf.haveq_), - q_(haveq_ ? mapper(ptf.q_)() : scalarField()), + q_(ptf.q_, false), haveh_(ptf.haveh_), - h_(haveh_ ? mapper(ptf.h_)() : scalarField()), + h_(ptf.h_, false), Ta_(ptf.Ta_, false), emissivity_(ptf.emissivity_), thicknessLayers_(ptf.thicknessLayers_), kappaLayers_(ptf.kappaLayers_), - relaxation_(ptf.relaxation_), + relax_(ptf.relax_), qrName_(ptf.qrName_), - qrRelaxation_(ptf.qrRelaxation_), + qrRelax_(ptf.qrRelax_), qrPrevious_ ( qrName_ != word::null @@ -146,18 +188,18 @@ externalTemperatureFvPatchScalarField : mixedFvPatchScalarField(tppsf, iF), haveQ_(tppsf.haveQ_), - Q_(tppsf.Q_), + Q_(tppsf.Q_, false), haveq_(tppsf.haveq_), - q_(tppsf.q_), + q_(tppsf.q_, false), haveh_(tppsf.haveh_), - h_(tppsf.h_), + h_(tppsf.h_, false), Ta_(tppsf.Ta_, false), emissivity_(tppsf.emissivity_), thicknessLayers_(tppsf.thicknessLayers_), kappaLayers_(tppsf.kappaLayers_), - relaxation_(tppsf.relaxation_), + relax_(tppsf.relax_), qrName_(tppsf.qrName_), - qrRelaxation_(tppsf.qrRelaxation_), + qrRelax_(tppsf.qrRelax_), qrPrevious_(tppsf.qrPrevious_) {} @@ -175,16 +217,6 @@ void Foam::externalTemperatureFvPatchScalarField::map const externalTemperatureFvPatchScalarField& tiptf = refCast(ptf); - if (haveq_) - { - mapper(q_, tiptf.q_); - } - - if (haveh_) - { - mapper(h_, tiptf.h_); - } - if (qrName_ != word::null) { mapper(qrPrevious_, tiptf.qrPrevious_); @@ -202,16 +234,6 @@ void Foam::externalTemperatureFvPatchScalarField::reset const externalTemperatureFvPatchScalarField& tiptf = refCast(ptf); - if (haveq_) - { - q_.reset(tiptf.q_); - } - - if (haveh_) - { - h_.reset(tiptf.h_); - } - if (qrName_ != word::null) { qrPrevious_.reset(tiptf.qrPrevious_); @@ -226,54 +248,47 @@ void Foam::externalTemperatureFvPatchScalarField::updateCoeffs() return; } - const scalarField& Tp(*this); - - // Store current valueFraction and refValue for relaxation - const scalarField valueFraction0(valueFraction()); - const scalarField refValue0(refValue()); - // Get the radiative heat flux and relax - scalarField qr(Tp.size(), 0); + scalarField qr(size(), 0); if (qrName_ != word::null) { qr = - qrRelaxation_ + qrRelax_ *patch().lookupPatchField(qrName_) - + (1 - qrRelaxation_)*qrPrevious_; + + (1 - qrRelax_)*qrPrevious_; qrPrevious_ = qr; } // Compute the total non-convective heat flux - scalarField qTot(qr); + scalarField sumq(qr); if (haveQ_) { - qTot += Q_/gSum(patch().magSf()); + sumq += Q_->value(db().time().userTimeValue())/gSum(patch().magSf()); } if (haveq_) { - qTot += q_; + sumq += q_->value(db().time().userTimeValue()); } - const thermophysicalTransportModel& ttm = - patch().boundaryMesh().mesh() - .lookupType(); + scalarField kappa(size(), 0); + scalarField sumKappaTByDelta(size(), 0); + scalarField sumKappaByDelta(size(), 0); + scalarField Tref(*this); + scalarField Tw(*this); + scalarField qByKappa(size(), 0); + getKappa + ( + kappa, + sumKappaTByDelta, + sumKappaByDelta, + Tref, + Tw, + sumq, + qByKappa + ); - const scalarField kappa(ttm.kappaEff(patch().index())); - tmp qCorr(ttm.qCorr(patch().index())); - - if (qCorr.valid()) - { - qTot += qCorr; - } - - // Evaluate - if (!haveh_) - { - refGrad() = qTot/kappa; - refValue() = Tp; - valueFraction() = 0; - } - else + // Add optional external convective heat transfer contribution + if (haveh_) { scalar totalSolidRes = 0; if (thicknessLayers_.size()) @@ -288,6 +303,7 @@ void Foam::externalTemperatureFvPatchScalarField::updateCoeffs() } } + const scalar h = h_->value(this->db().time().userTimeValue()); const scalar Ta = Ta_->value(this->db().time().userTimeValue()); const scalarField hp @@ -298,44 +314,38 @@ void Foam::externalTemperatureFvPatchScalarField::updateCoeffs() /( (emissivity_ > 0) ? ( - h_ + h + emissivity_*sigma.value() - *((pow3(Ta) + pow3(Tp)) + Ta*Tp*(Ta + Tp)) + *((pow3(Ta) + pow3(Tw)) + Ta*Tw*(Ta + Tw)) )() - : h_ + : scalarField(size(), h) ) + totalSolidRes ) ); - const scalarField hpTa(hp*Ta); + sumKappaByDelta += hp; + sumKappaTByDelta += hp*Ta; - const scalarField kappaDeltaCoeffs - ( - kappa*patch().deltaCoeffs() - ); - - refGrad() = 0; - forAll(Tp, i) - { - if (qTot[i] < 0) - { - const scalar hpmqTot = hp[i] - qTot[i]/Tp[i]; - refValue()[i] = hpTa[i]/hpmqTot; - valueFraction()[i] = hpmqTot/(hpmqTot + kappaDeltaCoeffs[i]); - } - else - { - refValue()[i] = (hpTa[i] + qTot[i])/hp[i]; - valueFraction()[i] = hp[i]/(hp[i] + kappaDeltaCoeffs[i]); - } - } + refValue() = sumKappaTByDelta/sumKappaByDelta; + } + else + { + refValue() = Tref; } - // Relax valueFraction() = - relaxation_*valueFraction() + (1 - relaxation_)*valueFraction0; - refValue() = - relaxation_*refValue() + (1 - relaxation_)*refValue0; + sumKappaByDelta/(kappa*patch().deltaCoeffs() + sumKappaByDelta); + + refGrad() = qByKappa; + + // Modify mixed parameters for under-relaxation + if (relax_ != 1) + { + const scalarField f(valueFraction()); + valueFraction() = 1 - relax_*(1 - f); + refValue() = (f*relax_*refValue() + (1 - relax_)*Tw)/valueFraction(); + // refGrad() = No change + } mixedFvPatchScalarField::updateCoeffs(); @@ -365,17 +375,17 @@ void Foam::externalTemperatureFvPatchScalarField::write if (haveQ_) { - writeEntry(os, "Q", Q_); + writeEntry(os, Q_()); } if (haveq_) { - writeEntry(os, "q", q_); + writeEntry(os, q_()); } if (haveh_) { - writeEntry(os, "h", h_); + writeEntry(os, h_()); writeEntry(os, Ta_()); writeEntryIfDifferent(os, "emissivity", scalar(0), emissivity_); writeEntryIfDifferent @@ -394,12 +404,12 @@ void Foam::externalTemperatureFvPatchScalarField::write ); } - writeEntryIfDifferent(os, "relaxation", scalar(1), relaxation_); + writeEntryIfDifferent(os, "relaxation", scalar(1), relax_); if (qrName_ != word::null) { writeEntry(os, "qr", qrName_); - writeEntry(os, "qrRelaxation", qrRelaxation_); + writeEntry(os, "qrRelaxation", qrRelax_); writeEntry(os, "qrPrevious", qrPrevious_); } diff --git a/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.H b/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.H index 77f0838f7e..dfff8b806f 100644 --- a/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.H +++ b/src/ThermophysicalTransportModels/coupledThermophysicalTransportModels/externalTemperature/externalTemperatureFvPatchScalarField.H @@ -28,37 +28,35 @@ Description This boundary condition applies a heat flux condition to temperature on an external wall. Heat flux can be specified in the following ways: - - fixed power: supply Q - - fixed heat flux: supply q - - fixed heat transfer coefficient: supply h and Ta + - Fixed power: requires \c Q + - Fixed heat flux: requires \c q + - Fixed heat transfer coefficient: requires \c h and \c Ta where: \vartable - Q | Power [W] - q | Heat flux [W/m^2] - h | Heat transfer coefficient [W/m^2/K] - Ta | Ambient temperature [K] + Q | Power Function1 of time [W] + q | Heat flux Function1 of time [W/m^2] + h | Heat transfer coefficient Function1 of time [W/m^2/K] + Ta | Ambient temperature Function1 of time [K] \endvartable - If more than one parameter is given then the heat fluxes are summed. + Only one of \c Q or \c q may be specified, if \c h and \c Ta are also + specified the corresponding heat-flux is added. - If a heat transfer coefficient is given optional thin thermal layer - resistances can be specified through thicknessLayers and kappaLayers - entries. + If the heat transfer coefficient \c h is specified an optional thin thermal + layer resistances can also be specified through thicknessLayers and + kappaLayers entries. The patch thermal conductivity \c kappa is obtained from the region thermophysicalTransportModel so that this boundary condition can be applied directly to either fluid or solid regions. - The ambient temperature Ta is specified as a Foam::Function1 of time but - uniform is space. - Usage \table Property | Description | Required | Default value - Q | Power [W] | no | 0 - q | Heat flux [W/m^2] | no | 0 - h | Heat transfer coefficient [W/m^2/K] | no | 0 + Q | Power [W] | no | + q | Heat flux [W/m^2] | no | + h | Heat transfer coefficient [W/m^2/K] | no | Ta | Ambient temperature [K] | if h is given | thicknessLayers | Layer thicknesses [m] | no | kappaLayers | Layer thermal conductivities [W/m/K] | no | @@ -84,8 +82,8 @@ Usage \endverbatim See also - Foam::patchKappa Foam::mixedFvPatchScalarField + Foam::Function1 SourceFiles externalTemperatureFvPatchScalarField.C @@ -119,7 +117,7 @@ class externalTemperatureFvPatchScalarField bool haveQ_; //- Heat power [W] - scalar Q_; + autoPtr> Q_; // Heat flux @@ -128,7 +126,7 @@ class externalTemperatureFvPatchScalarField bool haveq_; //- Heat flux [W/m^2] - scalarField q_; + autoPtr> q_; // Heat transfer coefficient @@ -137,7 +135,7 @@ class externalTemperatureFvPatchScalarField bool haveh_; //- Heat transfer coefficient [W/m^2K] - scalarField h_; + autoPtr> h_; //- Ambient temperature [K] autoPtr> Ta_; @@ -152,8 +150,8 @@ class externalTemperatureFvPatchScalarField scalarList kappaLayers_; - //- Relaxation for the wall temperature (thermal inertia) - scalar relaxation_; + //- Relaxation factor for the wall temperature (thermal inertia) + scalar relax_; // Radiation @@ -161,13 +159,30 @@ class externalTemperatureFvPatchScalarField //- Name of the radiative heat flux const word qrName_; - //- Relaxation for qr - scalar qrRelaxation_; + //- Relaxation factor for qr + scalar qrRelax_; //- Cache qr for relaxation scalarField qrPrevious_; +protected: + + //- Get the patch kappa, kappa*Tc/delta, kappa/delta, + // reference T, current wall T and also the + // heat-flux/delta obtained from the sum heat-flux provided + virtual void getKappa + ( + scalarField& kappa, + scalarField& sumKappaTByDelta, + scalarField& sumKappaByDelta, + scalarField& Tref, + scalarField& Tw, + scalarField& sumq, + scalarField& qByKappa + ) const; + + public: //- Runtime type information diff --git a/tutorials/multiphaseEuler/wallBoilingIATE/0/T.gas b/tutorials/multiphaseEuler/wallBoilingIATE/0/T.gas index ce14b165f4..d6b3226b00 100644 --- a/tutorials/multiphaseEuler/wallBoilingIATE/0/T.gas +++ b/tutorials/multiphaseEuler/wallBoilingIATE/0/T.gas @@ -34,8 +34,8 @@ boundaryField } wall { - type uniformFixedMultiphaseHeatFlux; - q + type multiphaseExternalTemperature; + q0 { type scale; value 73890; @@ -46,7 +46,7 @@ boundaryField duration 0.01; } } - relax 0.3; + relaxation 0.3; value $internalField; } front diff --git a/tutorials/multiphaseEuler/wallBoilingIATE/0/T.liquid b/tutorials/multiphaseEuler/wallBoilingIATE/0/T.liquid index 8fd3dfaae5..a2fd326d39 100644 --- a/tutorials/multiphaseEuler/wallBoilingIATE/0/T.liquid +++ b/tutorials/multiphaseEuler/wallBoilingIATE/0/T.liquid @@ -34,7 +34,7 @@ boundaryField } wall { - type uniformFixedMultiphaseHeatFlux; + type multiphaseExternalTemperature; q { type scale; @@ -46,7 +46,7 @@ boundaryField duration 0.01; } } - relax 0.3; + relaxation 0.3; value $internalField; } front diff --git a/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.gas b/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.gas index ce14b165f4..7c616d0bf9 100644 --- a/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.gas +++ b/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.gas @@ -34,7 +34,7 @@ boundaryField } wall { - type uniformFixedMultiphaseHeatFlux; + type multiphaseExternalTemperature; q { type scale; @@ -46,7 +46,7 @@ boundaryField duration 0.01; } } - relax 0.3; + relaxation 0.3; value $internalField; } front diff --git a/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.liquid b/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.liquid index 8fd3dfaae5..a2fd326d39 100644 --- a/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.liquid +++ b/tutorials/multiphaseEuler/wallBoilingPolydisperse/0/T.liquid @@ -34,7 +34,7 @@ boundaryField } wall { - type uniformFixedMultiphaseHeatFlux; + type multiphaseExternalTemperature; q { type scale; @@ -46,7 +46,7 @@ boundaryField duration 0.01; } } - relax 0.3; + relaxation 0.3; value $internalField; } front diff --git a/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas b/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas index ce14b165f4..7c616d0bf9 100644 --- a/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas +++ b/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas @@ -34,7 +34,7 @@ boundaryField } wall { - type uniformFixedMultiphaseHeatFlux; + type multiphaseExternalTemperature; q { type scale; @@ -46,7 +46,7 @@ boundaryField duration 0.01; } } - relax 0.3; + relaxation 0.3; value $internalField; } front diff --git a/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas2 b/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas2 index a3e4b002bb..48880fe9cf 100644 --- a/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas2 +++ b/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.gas2 @@ -34,7 +34,7 @@ boundaryField } wall { - type uniformFixedMultiphaseHeatFlux; + type multiphaseExternalTemperature; q { type scale; @@ -46,7 +46,7 @@ boundaryField duration 0.01; } } - relax 0.3; + relaxation 0.3; value $internalField; } front diff --git a/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.liquid b/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.liquid index 8fd3dfaae5..a2fd326d39 100644 --- a/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.liquid +++ b/tutorials/multiphaseEuler/wallBoilingPolydisperseTwoGroups/0/T.liquid @@ -34,7 +34,7 @@ boundaryField } wall { - type uniformFixedMultiphaseHeatFlux; + type multiphaseExternalTemperature; q { type scale; @@ -46,7 +46,7 @@ boundaryField duration 0.01; } } - relax 0.3; + relaxation 0.3; value $internalField; } front