diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H index 24cfbf4f685a291b1a836fc0dfd931f9bfc526d1..d4878d063dab6ee8ed4243c61d529832d3dd9c6a 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H @@ -15,12 +15,10 @@ ( UEqn == - -fvc::reconstruct + fvc::reconstruct ( - ( - fvc::snGrad(pd) - + ghf*fvc::snGrad(rho) - ) * mesh.magSf() + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() ) ); } diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H b/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H index 103b3ea3bb531684ed48fc5fe74ac8ec588f4d99..f199713cf877086d8202d88a0b66d5e763d728d6 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H @@ -59,27 +59,6 @@ fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) ); - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("ghf", g & mesh.Cf()); - - dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef")); - - Info<< "Creating field pd\n" << endl; - volScalarField pd - ( - IOobject - ( - "pd", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - p = pd + rho*gh + pRef; thermo->correct(); dimensionedScalar initialMass = fvc::domainIntegrate(rho); diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H index 53f6688a6a8438f11c91816941e5d78b5bd47c14..7e48167d67a938b8fb52993be324d2cc01185f72 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H @@ -1,5 +1,5 @@ { - bool closedVolume = pd.needReference(); + bool closedVolume = p.needReference(); rho = thermo->rho(); @@ -17,38 +17,35 @@ ) ); - phi = phiU - ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf(); + phi = phiU + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::ddt(psi, pd) - + fvc::ddt(psi)*pRef - + fvc::ddt(psi, rho)*gh + fvm::ddt(psi, p) + fvc::div(phi) - - fvm::laplacian(rhorUAf, pd) + - fvm::laplacian(rhorUAf, p) ); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) { - pdEqn.solve(mesh.solver(pd.name() + "Final")); + pEqn.solve(mesh.solver(p.name() + "Final")); } else { - pdEqn.solve(mesh.solver(pd.name())); + pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { - phi += pdEqn.flux(); + phi += pEqn.flux(); } } U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf); U.correctBoundaryConditions(); - p == pd + rho*gh + pRef; DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); #include "rhoEqn.H" @@ -62,6 +59,4 @@ /fvc::domainIntegrate(thermo->psi()); rho = thermo->rho(); } - - pd == p - (rho*gh + pRef); } diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H index 71a57cd2a930c3affd56ba48b809e455d2a93e6c..aa476b4dc808f46619dd5c94fd9d8defaa10c55d 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H @@ -13,14 +13,11 @@ ( UEqn() == - -fvc::reconstruct + fvc::reconstruct ( - ( - fvc::snGrad(pd) - + ghf*fvc::snGrad(rho) - ) * mesh.magSf() + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() ) ).initialResidual(); maxResidual = max(eqnResidual, maxResidual); - diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C index d91b6398f27144233a20adab7983689e3d000c24..b2a8c5c374211719be84f7e03b6340f55a29e2e9 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C @@ -39,15 +39,14 @@ Description int main(int argc, char *argv[]) { + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "createFields.H" + #include "initContinuityErrs.H" -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" -# include "readEnvironmentalProperties.H" -# include "createFields.H" -# include "initContinuityErrs.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; @@ -55,17 +54,17 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" -# include "initConvergenceCheck.H" + #include "readSIMPLEControls.H" + #include "initConvergenceCheck.H" - pd.storePrevIter(); + p.storePrevIter(); rho.storePrevIter(); // Pressure-velocity SIMPLE corrector { -# include "UEqn.H" -# include "hEqn.H" -# include "pEqn.H" + #include "UEqn.H" + #include "hEqn.H" + #include "pEqn.H" } turbulence->correct(); @@ -76,7 +75,7 @@ int main(int argc, char *argv[]) << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; -# include "convergenceCheck.H" + #include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H index 879ee722b98ec4c6ab21ca66518c22fc31a9105c..0d9d9d5ec7fc667216c1af6937a24f50d7905986 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H @@ -51,38 +51,16 @@ ) ); - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("ghf", g & mesh.Cf()); - - dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef")); - - Info<< "Creating field pd\n" << endl; - volScalarField pd - ( - IOobject - ( - "pd", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - p = pd + rho*gh + pRef; thermo->correct(); - - label pdRefCell = 0; - scalar pdRefValue = 0.0; + label pRefCell = 0; + scalar pRefValue = 0.0; setRefCell ( - pd, + p, mesh.solutionDict().subDict("SIMPLE"), - pdRefCell, - pdRefValue + pRefCell, + pRefValue ); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H index 8d97ad9048a5a6e145d9fa0184629534df3a61e3..d592bc3c43eb47f568b79f123f27dd95654fe6ff 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H @@ -1,4 +1,6 @@ { + rho = thermo->rho(); + volScalarField rUA = 1.0/UEqn().A(); surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA)); @@ -7,60 +9,57 @@ phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf()); bool closedVolume = adjustPhi(phi, U, p); - surfaceScalarField buoyancyPhi = ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf(); - phi -= buoyancyPhi; + surfaceScalarField buoyancyPhi = + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); + phi += buoyancyPhi; for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::laplacian(rhorUAf, pd) == fvc::div(phi) + fvm::laplacian(rhorUAf, p) == fvc::div(phi) ); - pdEqn.setReference(pdRefCell, pdRefValue); + pEqn.setReference(pRefCell, p[pRefCell]); // retain the residual from the first iteration if (nonOrth == 0) { - eqnResidual = pdEqn.solve().initialResidual(); + eqnResidual = pEqn.solve().initialResidual(); maxResidual = max(eqnResidual, maxResidual); } else { - pdEqn.solve(); + pEqn.solve(); } if (nonOrth == nNonOrthCorr) { + // For closed-volume cases adjust the pressure and density levels + // to obey overall mass continuity + if (closedVolume) + { + p += (initialMass - fvc::domainIntegrate(thermo->psi()*p)) + /fvc::domainIntegrate(thermo->psi()); + } + // Calculate the conservative fluxes - phi -= pdEqn.flux(); + phi -= pEqn.flux(); // Explicitly relax pressure for momentum corrector - pd.relax(); + p.relax(); // Correct the momentum source with the pressure gradient flux // calculated from the relaxed pressure - U -= rUA*fvc::reconstruct((buoyancyPhi + pdEqn.flux())/rhorUAf); + U += rUA*fvc::reconstruct((buoyancyPhi - pEqn.flux())/rhorUAf); U.correctBoundaryConditions(); } } #include "continuityErrs.H" - p == pd + rho*gh + pRef; - - // For closed-volume cases adjust the pressure and density levels - // to obey overall mass continuity - if (closedVolume) - { - p += (initialMass - fvc::domainIntegrate(thermo->psi()*p)) - /fvc::domainIntegrate(thermo->psi()); - } - rho = thermo->rho(); rho.relax(); Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl; - - pd == p - (rho*gh + pRef); } diff --git a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/alphat b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/alphat new file mode 100644 index 0000000000000000000000000000000000000000..5b9884a613ee886a95cb72e4cd55c77c0657e501 --- /dev/null +++ b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/alphat @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object alphat; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + floor + { + type compressible::alphatWallFunction; + value uniform 0; + } + ceiling + { + type compressible::alphatWallFunction; + value uniform 0; + } + fixedWalls + { + type compressible::alphatWallFunction; + value uniform 0; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/pd b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/mut similarity index 73% rename from tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/pd rename to tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/mut index 3a679ba63a51f43776afa9f72c8fe4e69e328aac..7c893682965996d4b4b48036a27527eeab2ebdf6 100644 --- a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/pd +++ b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/mut @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | -| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile @@ -10,11 +10,12 @@ FoamFile version 2.0; format ascii; class volScalarField; - object pd; + location "0"; + object mut; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -dimensions [1 -1 -2 0 0 0 0]; +dimensions [1 -1 -1 0 0 0 0]; internalField uniform 0; @@ -22,21 +23,20 @@ boundaryField { floor { - type fixedFluxBuoyantPressure; + type mutWallFunction; value uniform 0; } - ceiling { - type fixedFluxBuoyantPressure; + type mutWallFunction; value uniform 0; } - fixedWalls { - type fixedFluxBuoyantPressure; + type mutWallFunction; value uniform 0; } } + // ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/p b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/p index 10cf8ccf8e1db93392b06f55e43b51c5006cde71..188522464acb9b347136541e983dc3d02d2b0d32 100644 --- a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/p +++ b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/0/p @@ -16,26 +16,26 @@ FoamFile dimensions [1 -1 -2 0 0 0 0]; -internalField uniform 100000; +internalField uniform 1e5; boundaryField { floor { - type calculated; - value uniform 100000; + type fixedFluxBuoyantPressure; + value uniform 1e5; } ceiling { - type calculated; - value uniform 100000; + type fixedFluxBuoyantPressure; + value uniform 1e5; } fixedWalls { - type calculated; - value uniform 100000; + type fixedFluxBuoyantPressure; + value uniform 1e5; } } diff --git a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSchemes index 583bf08e11cb06903ecea9b68ba94a197d2ebed3..35b5a3de97726aa485d4a2b0953e416448dbb7b3 100644 --- a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSchemes @@ -42,7 +42,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear corrected; - laplacian((rho*(1|A(U))),pd) Gauss linear corrected; + laplacian((rho*(1|A(U))),p) Gauss linear corrected; laplacian(alphaEff,h) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; @@ -62,7 +62,7 @@ snGradSchemes fluxRequired { default no; - pd ; + p ; } diff --git a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSolution b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSolution index c7dcb8279da2f8d7c4afc7063a37071da1f38f73..ffe5b53f56aa268749c19d3ceede84925d35c365 100644 --- a/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSolution +++ b/tutorials/heatTransfer/buoyantPisoFoam/hotRoom/system/fvSolution @@ -25,7 +25,7 @@ solvers relTol 0; } - pd + p { solver PCG; preconditioner DIC; @@ -33,7 +33,7 @@ solvers relTol 0.1; } - pdFinal + pFinal { solver PCG; preconditioner DIC; diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/pd b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/mut similarity index 73% rename from tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/pd rename to tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/mut index 3a679ba63a51f43776afa9f72c8fe4e69e328aac..7c893682965996d4b4b48036a27527eeab2ebdf6 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/pd +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/mut @@ -1,8 +1,8 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.5 | -| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile @@ -10,11 +10,12 @@ FoamFile version 2.0; format ascii; class volScalarField; - object pd; + location "0"; + object mut; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -dimensions [1 -1 -2 0 0 0 0]; +dimensions [1 -1 -1 0 0 0 0]; internalField uniform 0; @@ -22,21 +23,20 @@ boundaryField { floor { - type fixedFluxBuoyantPressure; + type mutWallFunction; value uniform 0; } - ceiling { - type fixedFluxBuoyantPressure; + type mutWallFunction; value uniform 0; } - fixedWalls { - type fixedFluxBuoyantPressure; + type mutWallFunction; value uniform 0; } } + // ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p index 10cf8ccf8e1db93392b06f55e43b51c5006cde71..188522464acb9b347136541e983dc3d02d2b0d32 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p @@ -16,26 +16,26 @@ FoamFile dimensions [1 -1 -2 0 0 0 0]; -internalField uniform 100000; +internalField uniform 1e5; boundaryField { floor { - type calculated; - value uniform 100000; + type fixedFluxBuoyantPressure; + value uniform 1e5; } ceiling { - type calculated; - value uniform 100000; + type fixedFluxBuoyantPressure; + value uniform 1e5; } fixedWalls { - type calculated; - value uniform 100000; + type fixedFluxBuoyantPressure; + value uniform 1e5; } } diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes index 9dbebd21cbc1a0cd01091dde9e0cbcd63a459855..cb548b9d9fa88a28a17aefd4f99b9edeee80ea47 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear corrected; - laplacian((rho*(1|A(U))),pd) Gauss linear corrected; + laplacian((rho*(1|A(U))),p) Gauss linear corrected; laplacian(alphaEff,h) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; @@ -61,7 +61,7 @@ snGradSchemes fluxRequired { default no; - pd ; + p ; } diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSolution b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSolution index dfbfd6a27f1d095120342e7f47910f85b53f92c8..9ff08c3657a4d84256fde4866772cbca40ae5dcf 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSolution +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSolution @@ -17,7 +17,7 @@ FoamFile solvers { - pd + p { solver PCG; preconditioner DIC; @@ -69,16 +69,16 @@ solvers SIMPLE { nNonOrthogonalCorrectors 0; - pdRefCell 0; - pdRefValue 0; + pRefCell 0; + pRefValue 1e5; } relaxationFactors { rho 1; - pd 0.3; + p 0.3; U 0.7; - h 0.7; + h 0.1; k 0.7; epsilon 0.7; R 0.7;