From e0912a058cb68b0538ef6af6342a98ab1a331b81 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 18 May 2018 01:27:13 -0700 Subject: [PATCH 1/8] ENH: Adding pressure work terms for compressibleInterFoam Removing temporary fix from compressibleInterDyFOAM to re-calculte Uf with morphing mesh --- .../solvers/multiphase/compressibleInterFoam/TEqn.H | 11 +++++------ .../compressibleInterDyMFoam.C | 6 +----- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/applications/solvers/multiphase/compressibleInterFoam/TEqn.H b/applications/solvers/multiphase/compressibleInterFoam/TEqn.H index 26f046545e..1561ae35cc 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/TEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/TEqn.H @@ -1,16 +1,15 @@ { fvScalarMatrix TEqn ( - fvm::ddt(rho, T) + fvm::div(rhoPhi, T) - - fvm::Sp(contErr, T) + fvm::ddt(rho, T) + fvm::div(rhoPhi, T) - fvm::Sp(contErr, T) - fvm::laplacian(turbulence.alphaEff(), T) + ( - divU*p - + fvc::ddt(rho, K) + fvc::div(rhoPhi, K) + (divU*p)() - contErr/rho*p + + (fvc::ddt(rho, K) + fvc::div(rhoPhi, K))() - contErr*K ) *( - alpha1/mixture.thermo1().Cv() - + alpha2/mixture.thermo2().Cv() + alpha1()/mixture.thermo1().Cv()() + + alpha2()/mixture.thermo2().Cv()() ) == fvOptions(rho, T) diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C index 8d3d5a2702..816c495443 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -119,12 +119,8 @@ int main(int argc, char *argv[]) ghf = (g & mesh.Cf()) - ghRef; } - if ((mesh.changing() && correctPhi) || mesh.topoChanging()) + if ((mesh.changing() && correctPhi)) { - // Calculate absolute flux from the mapped surface velocity - // Note: temporary fix until mapped Uf is assessed - Uf = fvc::interpolate(U); - // Calculate absolute flux from the mapped surface velocity phi = mesh.Sf() & Uf; From f246a81f8af2a897e1fcd1db1ac5c3f772a9c4d4 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 21 Mar 2018 18:03:29 +0000 Subject: [PATCH 2/8] BUG: wideBandAbsorptionEmission: Corrected errors Resolves bug-reports https://bugs.openfoam.org/view.php?id=2881 https://bugs.openfoam.org/view.php?id=2882 Patches contributed by Kevin Nordin-Bates --- .../fvDOM/absorptionCoeffs/absorptionCoeffs.C | 6 +- .../blackBodyEmission/blackBodyEmission.C | 56 +++++-- .../blackBodyEmission/blackBodyEmission.H | 12 +- .../radiationModels/fvDOM/fvDOM/fvDOM.C | 97 +++++++++--- .../wideBandAbsorptionEmission.C | 140 ++++++++++++------ .../wideBandAbsorptionEmission.H | 41 ++--- 6 files changed, 240 insertions(+), 112 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/absorptionCoeffs/absorptionCoeffs.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/absorptionCoeffs/absorptionCoeffs.C index 1b50a08cfd..3edf6b2c7a 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/absorptionCoeffs/absorptionCoeffs.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/absorptionCoeffs/absorptionCoeffs.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,7 +26,6 @@ License #include "absorptionCoeffs.H" #include "IOstreams.H" - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // Foam::radiation::absorptionCoeffs::~absorptionCoeffs() @@ -40,7 +39,7 @@ void Foam::radiation::absorptionCoeffs::checkT(const scalar T) const if (T < Tlow_ || T > Thigh_) { WarningInFunction - << "usinf absCoeff out of temperature range:" << nl + << "using absorptionCoeffs out of temperature range:" << nl << " " << Tlow_ << " -> " << Thigh_ << "; T = " << T << nl << endl; } @@ -72,7 +71,6 @@ void Foam::radiation::absorptionCoeffs::initialise(const dictionary& dict) dict.lookup("Tlow") >> Tlow_; dict.lookup("Thigh") >> Thigh_; dict.lookup("invTemp") >> invTemp_; - dict.lookup("loTcoeffs") >> lowACoeffs_; dict.lookup("hiTcoeffs") >> highACoeffs_; } diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C index dcc1029a8a..57e4f0a16d 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -192,6 +192,44 @@ Foam::scalar Foam::radiation::blackBodyEmission::fLambdaT } +Foam::tmp +Foam::radiation::blackBodyEmission::deltaLambdaT +( + const volScalarField& T, + const Vector2D& band +) const +{ + tmp deltaLambdaT + ( + new volScalarField + ( + IOobject + ( + "deltaLambdaT", + T.mesh().time().timeName(), + T.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + T.mesh(), + dimensionedScalar("deltaLambdaT", dimless, 1.0) + ) + ); + + if (band != Vector2D::one) + { + scalarField& deltaLambdaTf = deltaLambdaT.ref(); + + forAll(T, i) + { + deltaLambdaTf[i] = fLambdaT(band[1]*T[i]) - fLambdaT(band[0]*T[i]); + } + } + + return deltaLambdaT; +} + + Foam::tmp Foam::radiation::blackBodyEmission::EbDeltaLambdaT ( @@ -215,21 +253,13 @@ Foam::radiation::blackBodyEmission::EbDeltaLambdaT ) ); - - if (band == Vector2D::one) - { - return Eb; - } - else + if (band != Vector2D::one) { scalarField& Ebif = Eb.ref(); forAll(T, i) { - const scalar T1 = fLambdaT(band[1]*T[i]); - const scalar T2 = fLambdaT(band[0]*T[i]); - - Ebif[i] *= T1 - T2; + Ebif[i] *= fLambdaT(band[1]*T[i]) - fLambdaT(band[0]*T[i]); } volScalarField::Boundary& EbBf = Eb.ref().boundaryFieldRef(); @@ -251,9 +281,9 @@ Foam::radiation::blackBodyEmission::EbDeltaLambdaT } } } - - return Eb; } + + return Eb; } diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H index c22319fc24..56fa3c441b 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/blackBodyEmission/blackBodyEmission.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,7 +27,7 @@ Class Description Class black body emission - Table of black body emissive power taken from: + Table of black body emissive power from: Modest, "Radiative Heat Transfer", pp.775-777, 1993 SourceFiles @@ -123,6 +123,13 @@ public: return (C1_/(pow5(lambda)*(exp(C2_/(lambda*T)) - 1.0))); } + //- Proportion of total energy at T from lambda1 to lambda2 + tmp deltaLambdaT + ( + const volScalarField& T, + const Vector2D& band + ) const; + //- Integral energy at T from lambda1 to lambda2 tmp EbDeltaLambdaT ( @@ -130,7 +137,6 @@ public: const Vector2D& band ) const; - // Edit // Update black body emission diff --git a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C index f6506064c1..78402206e4 100644 --- a/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,15 +54,15 @@ void Foam::radiation::fvDOM::initialise() { nRay_ = 4*nPhi_*nTheta_; IRay_.setSize(nRay_); - scalar deltaPhi = pi/(2.0*nPhi_); - scalar deltaTheta = pi/nTheta_; + const scalar deltaPhi = pi/(2.0*nPhi_); + const scalar deltaTheta = pi/nTheta_; label i = 0; for (label n = 1; n <= nTheta_; n++) { for (label m = 1; m <= 4*nPhi_; m++) { - scalar thetai = (2.0*n - 1.0)*deltaTheta/2.0; - scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + const scalar thetai = (2*n - 1)*deltaTheta/2.0; + const scalar phii = (2*m - 1)*deltaPhi/2.0; IRay_.set ( i, @@ -87,15 +87,15 @@ void Foam::radiation::fvDOM::initialise() // 2D else if (mesh_.nSolutionD() == 2) { - scalar thetai = piByTwo; - scalar deltaTheta = pi; + const scalar thetai = piByTwo; + const scalar deltaTheta = pi; nRay_ = 4*nPhi_; IRay_.setSize(nRay_); - scalar deltaPhi = pi/(2.0*nPhi_); + const scalar deltaPhi = pi/(2.0*nPhi_); label i = 0; for (label m = 1; m <= 4*nPhi_; m++) { - scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + const scalar phii = (2*m - 1)*deltaPhi/2.0; IRay_.set ( i, @@ -119,15 +119,15 @@ void Foam::radiation::fvDOM::initialise() // 1D else { - scalar thetai = piByTwo; - scalar deltaTheta = pi; + const scalar thetai = piByTwo; + const scalar deltaTheta = pi; nRay_ = 2; IRay_.setSize(nRay_); - scalar deltaPhi = pi; + const scalar deltaPhi = pi; label i = 0; for (label m = 1; m <= 2; m++) { - scalar phii = (2.0*m - 1.0)*deltaPhi/2.0; + const scalar phii = (2*m - 1)*deltaPhi/2.0; IRay_.set ( i, @@ -444,14 +444,14 @@ void Foam::radiation::fvDOM::calculate() // Set rays convergence false List rayIdConv(nRay_, false); - scalar maxResidual = 0.0; + scalar maxResidual = 0; label radIter = 0; do { Info<< "Radiation solver iter: " << radIter << endl; radIter++; - maxResidual = 0.0; + maxResidual = 0; forAll(IRay_, rayI) { if (!rayIdConv[rayI]) @@ -474,7 +474,8 @@ void Foam::radiation::fvDOM::calculate() Foam::tmp Foam::radiation::fvDOM::Rp() const { - return tmp + // Construct using contribution from first frequency band + tmp tRp ( new volScalarField ( @@ -487,21 +488,75 @@ Foam::tmp Foam::radiation::fvDOM::Rp() const IOobject::NO_WRITE, false ), - 4.0*a_*physicoChemical::sigma //absorptionEmission_->a() + ( + 4 + *physicoChemical::sigma + *(aLambda_[0] - absorptionEmission_->aDisp(0)()) + *blackBody_.deltaLambdaT(T_, absorptionEmission_->bands(0)) + ) ) ); + + volScalarField& Rp=tRp.ref(); + + // Add contributions over remaining frequency bands + for (label j=1; j < nLambda_; j++) + { + Rp += + ( + 4 + *physicoChemical::sigma + *(aLambda_[j] - absorptionEmission_->aDisp(j)()) + *blackBody_.deltaLambdaT(T_, absorptionEmission_->bands(j)) + ); + } + + return tRp; } Foam::tmp> Foam::radiation::fvDOM::Ru() const { + tmp> tRu + ( + new DimensionedField + ( + IOobject + ( + "Ru", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedScalar("zero", dimensionSet(1, -1, -3, 0, 0), 0) + ) + ); - const volScalarField::Internal& G = G_(); - const volScalarField::Internal E = absorptionEmission_->ECont()()(); - const volScalarField::Internal a = a_.internalField(); + DimensionedField& Ru=tRu.ref(); - return a*G - E; + // Sum contributions over all frequency bands + for (label j=0; j < nLambda_; j++) + { + // Compute total incident radiation within frequency band + tmp> Gj + ( + IRay_[0].ILambda(j)()*IRay_[0].omega() + ); + + for (label rayI=1; rayI < nRay_; rayI++) + { + Gj.ref() += IRay_[rayI].ILambda(j)()*IRay_[rayI].omega(); + } + + Ru += (aLambda_[j]() - absorptionEmission_->aDisp(j)()())*Gj + - absorptionEmission_->ECont(j)()(); + } + + return tRu; } diff --git a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C index f37c3fc010..cbb35e3a99 100644 --- a/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C +++ b/src/thermophysicalModels/radiation/submodels/absorptionEmissionModel/wideBandAbsorptionEmission/wideBandAbsorptionEmission.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,8 @@ License #include "wideBandAbsorptionEmission.H" #include "addToRunTimeSelectionTable.H" +#include "basicSpecieMixture.H" +#include "unitConversion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -56,12 +58,7 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission coeffsDict_((dict.optionalSubDict(typeName + "Coeffs"))), speciesNames_(0), specieIndex_(label(0)), - lookUpTable_ - ( - fileName(coeffsDict_.lookup("lookUpTableFileName")), - mesh.time().constant(), - mesh - ), + lookUpTablePtr_(), thermo_(mesh.lookupObject(basicThermo::dictName)), Yj_(nSpecies_), totalWaveLength_(0) @@ -95,7 +92,7 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission if (!speciesNames_.found(key)) { FatalErrorInFunction - << "specie: " << key << "is not in all the bands" + << "specie: " << key << " is not in all the bands" << nl << exit(FatalError); } } @@ -106,37 +103,80 @@ Foam::radiation::wideBandAbsorptionEmission::wideBandAbsorptionEmission } nBands_ = nBand; + if (coeffsDict_.found("lookUpTableFileName")) + { + const word name = coeffsDict_.lookup("lookUpTableFileName"); + if (name != "none") + { + lookUpTablePtr_.set + ( + new interpolationLookUpTable + ( + fileName(coeffsDict_.lookup("lookUpTableFileName")), + mesh.time().constant(), + mesh + ) + ); + + if (!mesh.foundObject("ft")) + { + FatalErrorInFunction + << "specie ft is not present to use with " + << "lookUpTableFileName " << nl + << exit(FatalError); + } + } + } + // Check that all the species on the dictionary are present in the - // look-up table and save the corresponding indices of the look-up table + // look-up table and save the corresponding indices of the look-up table label j = 0; forAllConstIter(HashTable