diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H index a8b7765415..5668a645e9 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H @@ -1,10 +1,7 @@ // Initialise solid field pointer lists -PtrList coordinates(solidRegions.size()); PtrList thermos(solidRegions.size()); PtrList radiations(solidRegions.size()); PtrList solidHeatSources(solidRegions.size()); -PtrList betavSolid(solidRegions.size()); -PtrList aniAlphas(solidRegions.size()); // Populate solid field pointer lists forAll(solidRegions, i) @@ -24,84 +21,4 @@ forAll(solidRegions, i) i, new fv::options(solidRegions[i]) ); - - if (!thermos[i].isotropic()) - { - Info<< " Adding coordinateSystems\n" << endl; - coordinates.set - ( - i, - coordinateSystem::New(solidRegions[i], thermos[i].properties()) - ); - - tmp tkappaByCv = - thermos[i].Kappa()/thermos[i].Cv(); - - aniAlphas.set - ( - i, - new volSymmTensorField - ( - IOobject - ( - "Anialpha", - runTime.timeName(), - solidRegions[i], - IOobject::NO_READ, - IOobject::NO_WRITE - ), - solidRegions[i], - dimensionedSymmTensor - ( - "zero", - tkappaByCv().dimensions(), - Zero - ), - zeroGradientFvPatchSymmTensorField::typeName - ) - ); - - aniAlphas[i].primitiveFieldRef() = - coordinates[i].R().transformVector(tkappaByCv()); - aniAlphas[i].correctBoundaryConditions(); - - } - - IOobject betavSolidIO - ( - "betavSolid", - runTime.timeName(), - solidRegions[i], - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ); - - if (betavSolidIO.typeHeaderOk(true)) - { - betavSolid.set - ( - i, - new volScalarField(betavSolidIO, solidRegions[i]) - ); - } - else - { - betavSolid.set - ( - i, - new volScalarField - ( - IOobject - ( - "betavSolid", - runTime.timeName(), - solidRegions[i], - IOobject::NO_READ, - IOobject::NO_WRITE - ), - solidRegions[i], - dimensionedScalar(dimless, scalar(1)) - ) - ); - } } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H index c3890fa3e8..17611d9e00 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H @@ -3,31 +3,8 @@ solidThermo& thermo = thermos[i]; tmp trho = thermo.rho(); const volScalarField& rho = trho(); -tmp tCv = thermo.Cv(); -const volScalarField& Cv = tCv(); - -tmp taniAlpha; -if (!thermo.isotropic()) -{ - volSymmTensorField& aniAlpha = aniAlphas[i]; - tmp tkappaByCv = thermo.Kappa()/Cv; - const coordinateSystem& coodSys = coordinates[i]; - - aniAlpha.primitiveFieldRef() = - coodSys.R().transformVector(tkappaByCv()); - aniAlpha.correctBoundaryConditions(); - - taniAlpha = tmp - ( - new volSymmTensorField(aniAlpha) - ); -} - - volScalarField& e = thermo.he(); -const volScalarField& betav = betavSolid[i]; - const fv::options& fvOptions = solidHeatSources[i]; solidNoLoopControl& pimple = pimples.solid(i); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H index b0dcb6b36a..498ef9f973 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H @@ -3,12 +3,8 @@ { fvScalarMatrix eEqn ( - fvm::ddt(betav*rho, e) - - ( - thermo.isotropic() - ? fvm::laplacian(betav*thermo.alpha(), e, "laplacian(alpha,e)") - : fvm::laplacian(betav*taniAlpha(), e, "laplacian(alpha,e)") - ) + fvm::ddt(rho, e) + + thermo.divq(e) == fvOptions(rho, e) ); diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C index 317e87b770..89b0c0b492 100644 --- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C +++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.C @@ -104,6 +104,52 @@ Foam::functionObjects::wallHeatFlux::calcWallHeatFlux(const volVectorField& q) } +Foam::tmp +Foam::functionObjects::wallHeatFlux::calcWallHeatFlux +( + const surfaceScalarField& q +) +{ + tmp twallHeatFlux + ( + volScalarField::New + ( + type(), + mesh_, + dimensionedScalar(dimMass/pow3(dimTime), 0) + ) + ); + + volScalarField::Boundary& wallHeatFluxBf = + twallHeatFlux.ref().boundaryFieldRef(); + + const surfaceScalarField::Boundary& qBf = q.boundaryField(); + + forAllConstIter(labelHashSet, patchSet_, iter) + { + const label patchi = iter.key(); + + wallHeatFluxBf[patchi] = -qBf[patchi]; + } + + if (foundObject("qr")) + { + const volScalarField& qr = lookupObject("qr"); + + const volScalarField::Boundary& radHeatFluxBf = qr.boundaryField(); + + forAllConstIter(labelHashSet, patchSet_, iter) + { + const label patchi = iter.key(); + + wallHeatFluxBf[patchi] -= radHeatFluxBf[patchi]; + } + } + + return twallHeatFlux; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::functionObjects::wallHeatFlux::wallHeatFlux @@ -206,22 +252,14 @@ bool Foam::functionObjects::wallHeatFlux::execute() thermophysicalTransportModel::typeName ); - return store - ( - name, - calcWallHeatFlux(ttm.q()) - ); + return store(name, calcWallHeatFlux(ttm.q())); } else if (foundObject(solidThermo::dictName)) { const solidThermo& thermo = lookupObject(solidThermo::dictName); - return store - ( - name, - calcWallHeatFlux(-thermo.alpha()*fvc::grad(thermo.he())) - ); + return store(name, calcWallHeatFlux(thermo.q())); } else { diff --git a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H index 192455a889..aaaaca21d4 100644 --- a/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H +++ b/src/functionObjects/field/wallHeatFlux/wallHeatFlux.H @@ -75,6 +75,7 @@ SourceFiles #include "writeLocalObjects.H" #include "HashSet.H" #include "volFieldsFwd.H" +#include "surfaceFieldsFwd.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -110,6 +111,9 @@ protected: //- Calculate the heat-flux tmp calcWallHeatFlux(const volVectorField& q); + //- Calculate the heat-flux + tmp calcWallHeatFlux(const surfaceScalarField& q); + public: diff --git a/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C b/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C index b8427411e3..33e0edbae1 100644 --- a/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C +++ b/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.C @@ -24,7 +24,10 @@ License \*---------------------------------------------------------------------------*/ #include "heSolidThermo.H" -#include "volFields.H" +#include "fvmLaplacian.H" +#include "fvcLaplacian.H" +#include "coordinateSystem.H" +#include "zeroGradientFvPatchFields.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -267,4 +270,81 @@ Foam::heSolidThermo::Kappa } +template +Foam::tmp +Foam::heSolidThermo::KappaLocal() const +{ + const fvMesh& mesh = this->T_.mesh(); + + tmp tKappaLocal; + + if (!isotropic()) + { + coordinateSystem coordinates + ( + coordinateSystem::New(mesh, this->properties()) + ); + + const tmp tKappa(Kappa()); + + tKappaLocal = + ( + volSymmTensorField::New + ( + "KappaLocal", + mesh, + dimensionedSymmTensor(tKappa().dimensions(), Zero), + zeroGradientFvPatchSymmTensorField::typeName + ) + ); + volSymmTensorField& KappaLocal = tKappaLocal.ref(); + + KappaLocal.primitiveFieldRef() = + coordinates.R().transformVector(tKappa()); + KappaLocal.correctBoundaryConditions(); + } + + return tKappaLocal; +} + + +template +Foam::tmp +Foam::heSolidThermo::q() const +{ + return + - ( + isotropic() + ? fvm::laplacian(this->kappa(), this->T_)().flux() + : fvm::laplacian(KappaLocal(), this->T_)().flux() + ); +} + + +template +Foam::tmp +Foam::heSolidThermo::divq +( + volScalarField& e +) const +{ + return + - ( + isotropic() + ? fvc::laplacian(this->kappa(), this->T_) + + correction(fvm::laplacian(this->alpha(), e)) + : fvc::laplacian(KappaLocal(), this->T_) + + correction + ( + fvm::laplacian + ( + KappaLocal()/this->Cv(), + e, + "laplacian(" + this->alpha().name() + ",e)" + ) + ) + ); +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.H b/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.H index 92aa0cf01b..30497d4022 100644 --- a/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.H +++ b/src/thermophysicalModels/solidThermo/solidThermo/heSolidThermo.H @@ -56,6 +56,9 @@ class heSolidThermo //- Calculate the thermo variables void calculate(); + //- Return the anisotropic Kappa in the local coordinate system + tmp KappaLocal() const; + public: @@ -96,23 +99,23 @@ public: //- Update properties virtual void correct(); + //- Return true if thermal conductivity is isotropic + virtual bool isotropic() const + { + return MixtureType::thermoType::isotropic; + } - // Derived thermal properties + //- Anisotropic thermal conductivity [W/m/K] + virtual tmp Kappa() const; - //- Anisotropic thermal conductivity [W/m/K] - virtual tmp Kappa() const; + //- Anisotropic thermal conductivity [W/m/K] + virtual tmp Kappa(const label patchi) const; - //- Return true if thermal conductivity is isotropic - virtual bool isotropic() const - { - return MixtureType::thermoType::isotropic; - } + //- Return the heat flux + virtual tmp q() const; - - // Per patch calculation - - //- Anisotropic thermal conductivity [W/m/K] - virtual tmp Kappa(const label patchi) const; + //- Return the source term for the energy equation + virtual tmp divq(volScalarField& he) const; // Member Operators diff --git a/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.H b/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.H index d55261824f..4f9c73ff29 100644 --- a/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.H +++ b/src/thermophysicalModels/solidThermo/solidThermo/solidThermo.H @@ -40,6 +40,7 @@ SourceFiles #include "basicThermo.H" #include "uniformGeometricFields.H" +#include "fvScalarMatrix.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -114,25 +115,29 @@ public: // Member Functions - // Fields derived from thermodynamic state variables + //- Density [kg/m^3] + virtual tmp rho() const = 0; - //- Density [kg/m^3] - virtual tmp rho() const = 0; + //- Density for patch [kg/m^3] + virtual tmp rho(const label patchi) const = 0; - //- Density for patch [kg/m^3] - virtual tmp rho(const label patchi) const = 0; + //- Return non-const access to the local density field [kg/m^3] + virtual volScalarField& rho() = 0; - //- Return non-const access to the local density field [kg/m^3] - virtual volScalarField& rho() = 0; + //- Return true if thermal conductivity is isotropic + virtual bool isotropic() const = 0; - //- Anisotropic thermal conductivity [W/m/K] - virtual tmp Kappa() const = 0; + //- Anisotropic thermal conductivity [W/m/K] + virtual tmp Kappa() const = 0; - //- Anisotropic thermal conductivity for patch [W/m/K] - virtual tmp Kappa(const label patchi) const = 0; + //- Anisotropic thermal conductivity for patch [W/m/K] + virtual tmp Kappa(const label patchi) const = 0; - //- Return true if thermal conductivity is isotropic - virtual bool isotropic() const = 0; + //- Return the heat flux + virtual tmp q() const = 0; + + //- Return the source term for the energy equation + virtual tmp divq(volScalarField& he) const = 0; }; @@ -184,25 +189,29 @@ public: // Member Functions - // Fields derived from thermodynamic state variables + //- Density [kg/m^3] + virtual tmp rho() const; - //- Density [kg/m^3] - virtual tmp rho() const; + //- Density for patch [kg/m^3] + virtual tmp rho(const label patchi) const; - //- Density for patch [kg/m^3] - virtual tmp rho(const label patchi) const; + //- Return non-const access to the local density field [kg/m^3] + virtual volScalarField& rho(); - //- Return non-const access to the local density field [kg/m^3] - virtual volScalarField& rho(); + //- Return true if thermal conductivity is isotropic + virtual bool isotropic() const = 0; - //- Anisotropic thermal conductivity [W/m/K] - virtual tmp Kappa() const = 0; + //- Anisotropic thermal conductivity [W/m/K] + virtual tmp Kappa() const = 0; - //- Anisotropic thermal conductivity for patch [W/m/K] - virtual tmp Kappa(const label patchi) const = 0; + //- Anisotropic thermal conductivity for patch [W/m/K] + virtual tmp Kappa(const label patchi) const = 0; - //- Return true if thermal conductivity is isotropic - virtual bool isotropic() const = 0; + //- Return the heat flux + virtual tmp q() const = 0; + + //- Return the source term for the energy equation + virtual tmp divq(volScalarField& he) const = 0; }; @@ -243,6 +252,7 @@ public: {} }; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvOptions b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvOptions index 1dc13d3ae5..5513818b02 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionFoam/heatExchanger/constant/air/fvOptions @@ -24,7 +24,7 @@ airToporous master false; nbrModel porousToair; - fields (h); + fields (e); semiImplicit no; } diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/heater/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/heater/fvSchemes index fe16f26922..3b264bb650 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/heater/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/heater/fvSchemes @@ -32,8 +32,7 @@ divSchemes laplacianSchemes { - default none; - laplacian(alpha,e) Gauss linear corrected; + default Gauss linear corrected; } interpolationSchemes diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/metal/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/metal/fvSchemes index 5364564a75..4ebd206954 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/metal/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/heatedDuct/system/metal/fvSchemes @@ -32,8 +32,7 @@ divSchemes laplacianSchemes { - default none; - laplacian(alpha,e) Gauss linear corrected; + default Gauss linear corrected; } interpolationSchemes diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/system/solid/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/system/solid/fvSchemes index 1ab9ea6d39..8bc4f23ffc 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/system/solid/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/reverseBurner/system/solid/fvSchemes @@ -31,8 +31,7 @@ divSchemes laplacianSchemes { - default none; - laplacian(alpha,e) Gauss linear corrected; + default Gauss linear corrected; } interpolationSchemes