From 52edc09e2bd94ba77fce0ec90f7392f3d2ef1bfb Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Fri, 19 Dec 2014 12:07:53 +0100 Subject: [PATCH 1/4] ENH: Provide Qr field for coupling and post-pro --- .../radiationModel/fvDOM/fvDOM/fvDOM.C | 121 ++++-------------- .../radiationModel/fvDOM/fvDOM/fvDOM.H | 58 ++++----- .../radiationModel/fvDOM/fvDOM/fvDOMI.H | 25 ++-- 3 files changed, 59 insertions(+), 145 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C index 880383e38..322faef1d 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -67,6 +67,19 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) mesh(), dimensionedScalar("G", dimMass/pow3(dimTime), 0.0) ), + Qr_ + ( + IOobject + ( + "Qr", + mesh_.time().timeName(), + T.db(), + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0) + ), a_ ( IOobject @@ -260,8 +273,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) forAll(IRay_, rayId) { const surfaceScalarField Ji(IRay_[rayId].dAve() & mesh().Sf()); - volScalarField& iRayLambdaI = - IRay_[rayId].ILambda(lambdaI); + volScalarField& iRayLambdaI = IRay_[rayId].ILambda(lambdaI); fvRayDiv_[lambdaI].set ( @@ -297,102 +309,6 @@ Foam::radiation::fvDOM::~fvDOM() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::tmp -Foam::radiation::fvDOM::Qin() const -{ - tmp tQin - ( - new volScalarField::GeometricBoundaryField - ( - mesh().boundary(), - mesh().V(), // Dummy internal field, - calculatedFvPatchScalarField::typeName - ) - ); - volScalarField::GeometricBoundaryField& sumQin = tQin(); - - sumQin = 0; - - forAll(Qin_, lambdaI) - { - sumQin += Qin(lambdaI); - } - - return tQin; -} - - -Foam::tmp -Foam::radiation::fvDOM::Qem() const -{ - tmp tsumQem - ( - new volScalarField::GeometricBoundaryField - ( - mesh().boundary(), - mesh().V(), // Dummy internal field, - calculatedFvPatchScalarField::typeName - ) - ); - volScalarField::GeometricBoundaryField& sumQem = tsumQem(); - - sumQem = 0; - - forAll(Qem_, lambdaI) - { - sumQem += Qem(lambdaI); - } - - return tsumQem; -} - -Foam::tmp -Foam::radiation::fvDOM::Qr() const -{ - tmp tQr - ( - new volScalarField::GeometricBoundaryField - ( - mesh().boundary(), - mesh().V(), // Dummy internal field, - calculatedFvPatchScalarField::typeName - ) - ); - volScalarField::GeometricBoundaryField& Qr = tQr(); - - Qr = 0; - - forAll(Qem_, lambdaI) - { - Qr += Qin(lambdaI); - Qr -= Qem(lambdaI); - } - - return tQr; -} - - -Foam::tmp -Foam::radiation::fvDOM::Qr(scalar lambdaI) const -{ - tmp tQr - ( - new volScalarField::GeometricBoundaryField - ( - mesh().boundary(), - mesh().V(), // Dummy internal field, - calculatedFvPatchScalarField::typeName - ) - ); - volScalarField::GeometricBoundaryField& Qr = tQr(); - - Qr = 0; - Qr += Qin(lambdaI); - Qr -= Qem(lambdaI); - - return tQr; -} - bool Foam::radiation::fvDOM::read() { @@ -562,12 +478,21 @@ void Foam::radiation::fvDOM::updateBlackBodyEmission() void Foam::radiation::fvDOM::updateG() { G_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0); + Qr_ = dimensionedScalar("zero",dimMass/pow3(dimTime), 0.0); forAll(IRay_, rayI) { IRay_[rayI].addIntensity(); G_ += IRay_[rayI].I()*IRay_[rayI].omega(); } + + forAll(Qr_.boundaryField(), patchI) + { + forAll(aLambda_, lambdaI) + { + Qr_.boundaryField()[patchI] += Qin_[lambdaI][patchI] - Qem_[lambdaI][patchI]; + } + } } diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H index f77b413a9..9e018325d 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H @@ -80,6 +80,9 @@ class fvDOM //- Incident radiation [W/m2] volScalarField G_; + //- Total radiative heat flux [W/m2] + volScalarField Qr_; + //- Total absorption coefficient [1/m] volScalarField a_; @@ -156,41 +159,31 @@ public: // Member functions - //- Total incident radiative heat flux field - tmp Qin() const; + // Edit - //- Total emitted radiative heat flux field - tmp Qem() const; + //- Solve radiation equation(s) + void calculate(); - //- Total radiative heat flux as difference of Qem and Qin - tmp Qr() const; + //- Read radiation properties dictionary + bool read(); - //- Band-wise radiative heat flux as difference of Qem and Qin - tmp Qr(scalar lambda) const; + //- Update G and calculate total heat flux on boundary + void updateG(); - //- Solve radiation equation(s) - void calculate(); + //- Set the rayId and lambdaId from by decomposing an intensity + // field name + void setRayIdLambdaId + ( + const word& name, + label& rayId, + label& lambdaId + ) const; - //- Read radiation properties dictionary - bool read(); + //- Source term component (for power of T^4) + virtual tmp Rp() const; - //- Update G and calculate total heat flux on boundary - void updateG(); - - //- Set the rayId and lambdaId from by decomposing an intensity - // field name - void setRayIdLambdaId - ( - const word& name, - label& rayId, - label& lambdaId - ) const; - - //- Source term component (for power of T^4) - virtual tmp Rp() const; - - //- Source term component (constant) - virtual tmp > Ru() const; + //- Source term component (constant) + virtual tmp > Ru() const; // Access @@ -226,16 +219,19 @@ public: //- Const access to incident radiation field inline const volScalarField& G() const; + //- Const access to total radiative heat flux field + inline const volScalarField& Qr() const; + //- Const access to band wise emitted radiative heat flux field inline const volScalarField::GeometricBoundaryField& Qem ( - scalar lambda + const label lambda ) const; //- Const access to band wise incident radiative heat flux field inline const volScalarField::GeometricBoundaryField& Qin ( - scalar lambda + const label lambda ) const; //- Const access to black body diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H index abf70e5ea..04f65dee7 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOMI.H @@ -29,6 +29,7 @@ Foam::radiation::fvDOM::IRay(const label rayI) const return IRay_[rayI]; } + inline const Foam::volScalarField& Foam::radiation::fvDOM::IRayLambda ( @@ -85,34 +86,26 @@ inline const Foam::volScalarField& Foam::radiation::fvDOM::G() const } +inline const Foam::volScalarField& Foam::radiation::fvDOM::Qr() const +{ + return Qr_; +} + + inline const Foam::volScalarField::GeometricBoundaryField& -Foam::radiation::fvDOM::Qin(scalar lambdaI) const +Foam::radiation::fvDOM::Qin(const label lambdaI) const { return Qin_[lambdaI]; } -/* -inline Foam::volScalarField::GeometricBoundaryField& -Foam::radiation::fvDOM::Qin(scalar lambdaI) -{ - return Qin_[lambdaI]; -} -*/ inline const Foam::volScalarField::GeometricBoundaryField& -Foam::radiation::fvDOM::Qem(scalar lambdaI) const +Foam::radiation::fvDOM::Qem(const label lambdaI) const { return Qem_[lambdaI]; } -/* -inline Foam::volScalarField::GeometricBoundaryField& -Foam::radiation::fvDOM::Qem(scalar lambdaI) -{ - return Qem_[lambdaI]; -} -*/ inline const Foam::radiation::blackBodyEmission& Foam::radiation::fvDOM::blackBody() const { From 5a00d439f67a4ad0ce391ce6490e059ac8a1ef78 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Fri, 19 Dec 2014 12:55:23 +0100 Subject: [PATCH 2/4] Re-instate Qin() and Qem() --- .../radiationModel/fvDOM/fvDOM/fvDOM.C | 49 +++++++++++++++++++ .../radiationModel/fvDOM/fvDOM/fvDOM.H | 6 +++ 2 files changed, 55 insertions(+) diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C index 322faef1d..fc7a0d79c 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -309,6 +309,55 @@ Foam::radiation::fvDOM::~fvDOM() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::tmp +Foam::radiation::fvDOM::Qin() const +{ + tmp tQin + ( + new volScalarField::GeometricBoundaryField + ( + mesh().boundary(), + mesh().V(), // Dummy internal field, + calculatedFvPatchScalarField::typeName + ) + ); + volScalarField::GeometricBoundaryField& sumQin = tQin(); + + sumQin = 0; + + forAll(Qin_, lambdaI) + { + sumQin += Qin(lambdaI); + } + + return tQin; +} + + +Foam::tmp +Foam::radiation::fvDOM::Qem() const +{ + tmp tsumQem + ( + new volScalarField::GeometricBoundaryField + ( + mesh().boundary(), + mesh().V(), // Dummy internal field, + calculatedFvPatchScalarField::typeName + ) + ); + volScalarField::GeometricBoundaryField& sumQem = tsumQem(); + + sumQem = 0; + + forAll(Qem_, lambdaI) + { + sumQem += Qem(lambdaI); + } + + return tsumQem; +} + bool Foam::radiation::fvDOM::read() { diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H index 9e018325d..8a5cb6047 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.H @@ -234,6 +234,12 @@ public: const label lambda ) const; + //- Total incident radiative heat flux field + tmp Qin() const; + + //- Total emitted radiative heat flux field + tmp Qem() const; + //- Const access to black body inline const blackBodyEmission& blackBody() const; From a3794911c57672a28e912addb44db7fcc5962537 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Fri, 19 Dec 2014 14:19:35 +0100 Subject: [PATCH 3/4] BACKPORT: radiationModel constructors --- .../radiation/radiationModel/P1/P1.C | 86 +++++++- .../radiation/radiationModel/P1/P1.H | 2 + .../radiationModel/fvDOM/fvDOM/fvDOM.C | 196 ++++++++++++------ .../radiationModel/fvDOM/fvDOM/fvDOM.H | 6 + .../radiationModel/noRadiation/noRadiation.C | 18 +- .../radiationModel/noRadiation/noRadiation.H | 3 + .../radiationModel/newRadiationModel.C | 47 ++++- .../radiationModel/radiationModel.C | 63 +++++- .../radiationModel/radiationModel.H | 69 +++++- 9 files changed, 390 insertions(+), 100 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModel/P1/P1.C b/src/thermophysicalModels/radiation/radiationModel/P1/P1.C index 1afa7a6f0..2cc76c07b 100644 --- a/src/thermophysicalModels/radiation/radiationModel/P1/P1.C +++ b/src/thermophysicalModels/radiation/radiationModel/P1/P1.C @@ -39,13 +39,7 @@ namespace Foam namespace radiation { defineTypeNameAndDebug(P1, 0); - - addToRunTimeSelectionTable - ( - radiationModel, - P1, - dictionary - ); + addToRadiationRunTimeSelectionTables(P1); } } @@ -122,6 +116,76 @@ Foam::radiation::P1::P1(const volScalarField& T) {} +Foam::radiation::P1::P1(const dictionary& dict, const volScalarField& T) +: + radiationModel(typeName, dict, T), + G_ + ( + IOobject + ( + "G", + mesh_.time().timeName(), + T.db(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ), + Qr_ + ( + IOobject + ( + "Qr", + mesh_.time().timeName(), + T.db(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0) + ), + a_ + ( + IOobject + ( + "a", + mesh_.time().timeName(), + T.db(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensionedScalar("a", dimless/dimLength, 0.0) + ), + e_ + ( + IOobject + ( + "e", + mesh_.time().timeName(), + T.db(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("a", dimless/dimLength, 0.0) + ), + E_ + ( + IOobject + ( + "E", + mesh_.time().timeName(), + T.db(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("E", dimMass/dimLength/pow3(dimTime), 0.0) + ) +{} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::radiation::P1::~P1() @@ -150,7 +214,9 @@ void Foam::radiation::P1::calculate() a_ = absorptionEmission_->a(); e_ = absorptionEmission_->e(); E_ = absorptionEmission_->E(); - const volScalarField sigmaEff = scatter_->sigmaEff(); + const volScalarField sigmaEff(scatter_->sigmaEff()); + + const dimensionedScalar a0 ("a0", a_.dimensions(), ROOTVSMALL); // Construct diffusion const volScalarField gamma @@ -163,7 +229,7 @@ void Foam::radiation::P1::calculate() IOobject::NO_READ, IOobject::NO_WRITE ), - 1.0/(3.0*a_ + sigmaEff) + 1.0/(3.0*a_ + sigmaEff + a0) ); // Solve G transport equation @@ -210,10 +276,8 @@ Foam::radiation::P1::Ru() const { const DimensionedField& G = G_.dimensionedInternalField(); - const DimensionedField E = absorptionEmission_->ECont()().dimensionedInternalField(); - const DimensionedField a = absorptionEmission_->aCont()().dimensionedInternalField(); diff --git a/src/thermophysicalModels/radiation/radiationModel/P1/P1.H b/src/thermophysicalModels/radiation/radiationModel/P1/P1.H index 5eeffb6ec..73321e92c 100644 --- a/src/thermophysicalModels/radiation/radiationModel/P1/P1.H +++ b/src/thermophysicalModels/radiation/radiationModel/P1/P1.H @@ -96,6 +96,8 @@ public: //- Construct from components P1(const volScalarField& T); + //- Construct from components + P1(const dictionary& dict, const volScalarField& T); // Destructor virtual ~P1(); diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C index fc7a0d79c..047e6d67f 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -38,75 +38,14 @@ namespace Foam namespace radiation { defineTypeNameAndDebug(fvDOM, 0); - - addToRunTimeSelectionTable - ( - radiationModel, - fvDOM, - dictionary - ); + addToRadiationRunTimeSelectionTables(fvDOM); } } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -Foam::radiation::fvDOM::fvDOM(const volScalarField& T) -: - radiationModel(typeName, T), - G_ - ( - IOobject - ( - "G", - mesh().time().timeName(), - T.db(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh(), - dimensionedScalar("G", dimMass/pow3(dimTime), 0.0) - ), - Qr_ - ( - IOobject - ( - "Qr", - mesh_.time().timeName(), - T.db(), - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - mesh_, - dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0) - ), - a_ - ( - IOobject - ( - "a", - mesh().time().timeName(), - T.db(), - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh(), - dimensionedScalar("a", dimless/dimLength, 0.0) - ), - nTheta_(readLabel(coeffs_.lookup("nTheta"))), - nPhi_(readLabel(coeffs_.lookup("nPhi"))), - nRay_(0), - nLambda_(absorptionEmission_->nBands()), - aLambda_(nLambda_), - blackBody_(nLambda_, T), - IRay_(0), - Qem_(nLambda_), - Qin_(nLambda_), - convergence_(coeffs_.lookupOrDefault("convergence", 0.0)), - maxIter_(coeffs_.lookupOrDefault