From d1b651533f9295aa4ac1656d87a5a5e45b79f37c Mon Sep 17 00:00:00 2001 From: sergio Date: Thu, 1 Jun 2017 12:39:28 -0700 Subject: [PATCH] Modification on rhoPimpleFoam pEq's for handling rho thermo and incompressible EoS. Adding rho limiters if p is limited. This is important when LTS stepping or large Co number is used. Updating rhoBuoyantPimpleFoam to handle closed domain for rho thermo and incompressible Eos. Consolidating chtMultiRegionSimpleFoam and chtMultiRegionFoam pEqs to use the same formulation as rhoBuoyantPimpleFoam and rhoBuoyantSimpleFoam --- .../compressible/rhoPimpleFoam/createFields.H | 23 ++++++++ .../solvers/compressible/rhoPimpleFoam/pEqn.H | 11 +++- .../compressible/rhoPimpleFoam/pcEqn.H | 12 +++- .../heatTransfer/buoyantPimpleFoam/pEqn.H | 46 +++++++++++++-- .../buoyantSimpleFoam/createFields.H | 23 ++++++++ .../heatTransfer/buoyantSimpleFoam/pEqn.H | 17 +++--- .../chtMultiRegionSimpleFoam/fluid/pEqn.H | 20 ++++++- .../fluid/createFluidFields.H | 19 +++++++ .../chtMultiRegionFoam/fluid/pEqn.H | 57 ++++++++++++++----- .../fluid/setRegionFluidFields.H | 3 + .../basic/fluidThermo/fluidThermo.H | 7 ++- .../basic/psiThermo/psiThermo.C | 8 ++- .../basic/psiThermo/psiThermo.H | 7 ++- .../basic/rhoThermo/rhoThermo.C | 10 +++- .../basic/rhoThermo/rhoThermo.H | 8 ++- 15 files changed, 229 insertions(+), 42 deletions(-) diff --git a/applications/solvers/compressible/rhoPimpleFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/createFields.H index 3ec620dc22..8079428225 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/createFields.H +++ b/applications/solvers/compressible/rhoPimpleFoam/createFields.H @@ -73,3 +73,26 @@ Info<< "Creating field kinetic energy K\n" << endl; volScalarField K("K", 0.5*magSqr(U)); #include "createMRF.H" + + +dimensionedScalar rhoMax +( + dimensionedScalar::lookupOrDefault + ( + "rhoMax", + pimple.dict(), + dimDensity, + GREAT + ) +); + +dimensionedScalar rhoMin +( + dimensionedScalar::lookupOrDefault + ( + "rhoMin", + pimple.dict(), + dimDensity, + 0 + ) +); diff --git a/applications/solvers/compressible/rhoPimpleFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/pEqn.H index 83eeb8fc68..3a0ca9d042 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/pEqn.H @@ -84,9 +84,6 @@ else } } -// Thermodynamic density update -thermo.correctRho(psi*p - psip0); - #include "rhoEqn.H" #include "compressibleContinuityErrs.H" @@ -101,12 +98,20 @@ K = 0.5*magSqr(U); if (pressureControl.limit(p)) { p.correctBoundaryConditions(); + thermo.correctRho(psi*p - psip0, rhoMin, rhoMax); rho = thermo.rho(); } else if (pimple.SIMPLErho()) { + thermo.correctRho(psi*p - psip0, rhoMin, rhoMax); rho = thermo.rho(); } +else +{ + thermo.correctRho(psi*p - psip0, rhoMin, rhoMax) ; +} + +Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl; if (thermo.dpdt()) { diff --git a/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H b/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H index e9b849bc05..546dfaf251 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/pcEqn.H @@ -95,9 +95,6 @@ else } } -// Thermodynamic density update -thermo.correctRho(psi*p - psip0); - #include "rhoEqn.H" #include "compressibleContinuityErrs.H" @@ -112,12 +109,21 @@ K = 0.5*magSqr(U); if (pressureControl.limit(p)) { p.correctBoundaryConditions(); + thermo.correctRho(psi*p - psip0, rhoMin, rhoMax); rho = thermo.rho(); } + else if (pimple.SIMPLErho()) { + thermo.correctRho(psi*p - psip0, rhoMin, rhoMax); rho = thermo.rho(); } +else +{ + thermo.correctRho(psi*p - psip0, rhoMin, rhoMax); +} + +Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl; if (thermo.dpdt()) { diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H index c097118753..0f53379eef 100644 --- a/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H @@ -1,3 +1,7 @@ + +dimensionedScalar compressibility = fvc::domainIntegrate(psi); +bool compressible = (compressibility.value() > SMALL); + rho = thermo.rho(); // Thermodynamic density needs to be updated by psi*d(p) after the @@ -41,6 +45,12 @@ while (pimple.correctNonOrthogonal()) - fvm::laplacian(rhorAUf, p_rgh) ); + p_rghEqn.setReference + ( + pRefCell, + compressible ? getRefCellValue(p_rgh, pRefCell) : pRefValue + ); + p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter()))); if (pimple.finalNonOrthogonalIter()) @@ -63,12 +73,40 @@ while (pimple.correctNonOrthogonal()) p = p_rgh + rho*gh; // Thermodynamic density update -thermo.correctRho(psi*p - psip0); +//thermo.correctRho(psi*p - psip0); + +#include "rhoEqn.H" +#include "compressibleContinuityErrs.H" + +if (p_rgh.needReference()) +{ + if (!compressible) + { + p += dimensionedScalar + ( + "p", + p.dimensions(), + pRefValue - getRefCellValue(p, pRefCell) + ); + } + else + { + p += (initialMass - fvc::domainIntegrate(psi*p)) + /compressibility; + thermo.correctRho(psi*p - psip0); + rho = thermo.rho(); + + } + p_rgh = p - rho*gh; +} +else +{ + thermo.correctRho(psi*p - psip0); +} + +rho = thermo.rho(); if (thermo.dpdt()) { dpdt = fvc::ddt(p); } - -#include "rhoEqn.H" -#include "compressibleContinuityErrs.H" diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H index b9f275407f..64bc8558c8 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H @@ -88,3 +88,26 @@ dimensionedScalar totalVolume = sum(mesh.V()); #include "createMRF.H" #include "createRadiationModel.H" + +dimensionedScalar rhoMax +( + dimensionedScalar::lookupOrDefault + ( + "rhoMax", + simple.dict(), + dimDensity, + GREAT + ) +); + +dimensionedScalar rhoMin +( + dimensionedScalar::lookupOrDefault + ( + "rhoMin", + simple.dict(), + dimDensity, + 0 + ) +); + diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H index 647cf954bb..aa3ad0f163 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H @@ -1,7 +1,4 @@ { - rho = thermo.rho(); - rho.relax(); - volScalarField rAU("rAU", 1.0/UEqn.A()); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); volVectorField HbyA(constrainHbyA(rAU*UEqn.H(), U, p_rgh)); @@ -24,6 +21,8 @@ // Update the pressure BCs to ensure flux consistency constrainPressure(p_rgh, rho, U, phiHbyA, rhorAUf, MRF); + dimensionedScalar compressibility = fvc::domainIntegrate(psi); + bool compressible = (compressibility.value() > SMALL); while (simple.correctNonOrthogonal()) { @@ -32,7 +31,12 @@ fvm::laplacian(rhorAUf, p_rgh) == fvc::div(phiHbyA) ); - p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); + p_rghEqn.setReference + ( + pRefCell, + compressible ? getRefCellValue(p_rgh, pRefCell) : pRefValue + ); + p_rghEqn.solve(); if (simple.finalNonOrthogonalIter()) @@ -51,12 +55,9 @@ } } - #include "continuityErrs.H" - p = p_rgh + rho*gh; - dimensionedScalar compressibility = fvc::domainIntegrate(psi); - bool compressible = (compressibility.value() > SMALL); + #include "continuityErrs.H" // For closed-volume cases adjust the pressure level // to obey overall mass continuity diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H index 7fe544d6a5..5b8286ca4b 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H @@ -1,8 +1,10 @@ { + /* rho = thermo.rho(); rho = max(rho, rhoMin[i]); rho = min(rho, rhoMax[i]); rho.relax(); + */ volScalarField rAU("rAU", 1.0/UEqn.A()); surfaceScalarField rhorAUf("rhorAUf", fvc::interpolate(rho*rAU)); @@ -67,10 +69,22 @@ // For closed-volume cases adjust the pressure level // to obey overall mass continuity - if (closedVolume && compressible) + if (closedVolume) { - p += (initialMass - fvc::domainIntegrate(thermo.rho())) - /compressibility; + if (!compressible) + { + p += dimensionedScalar + ( + "p", + p.dimensions(), + pRefValue - getRefCellValue(p, pRefCell) + ); + } + else + { + p += (initialMass - fvc::domainIntegrate(psi*p)) + /compressibility; + } p_rgh = p - rho*gh; } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index be3ec79a2c..87e372fcae 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -19,6 +19,9 @@ List frozenFlowFluid(fluidRegions.size(), false); PtrList MRFfluid(fluidRegions.size()); PtrList fluidFvOptions(fluidRegions.size()); +List