From 60775d7673a31e2625180f6262054bd661b6d997 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 1 Nov 2022 18:13:06 +0500 Subject: [PATCH] FSF solver test --- applications/solvers/interFSFFoam/UEqn.H | 2 +- applications/solvers/interFSFFoam/pEqn.H | 6 +-- applications/solvers/interFSFFoam/pcEqn.H | 53 ++++++++++--------- tests/dropletRelaxation2D/calculate.sh | 6 +-- .../src/constant/phaseProperties | 2 +- .../src/constant/physicalProperties.phase2 | 4 +- .../src/system/blockMeshDict | 8 +-- .../dropletRelaxation2D/src/system/fvSchemes | 2 +- .../dropletRelaxation2D/src/system/fvSolution | 12 ++--- .../src/system/setFieldsDict | 2 +- 10 files changed, 49 insertions(+), 48 deletions(-) diff --git a/applications/solvers/interFSFFoam/UEqn.H b/applications/solvers/interFSFFoam/UEqn.H index a55507a..73c525b 100644 --- a/applications/solvers/interFSFFoam/UEqn.H +++ b/applications/solvers/interFSFFoam/UEqn.H @@ -25,7 +25,7 @@ ( - ghf*fvc::snGrad(rho) - fvc::snGrad(p_rgh) -// + fvc::snGrad(pc) + + fvc::snGrad(pc) ) * mesh.magSf() + phic ) diff --git a/applications/solvers/interFSFFoam/pEqn.H b/applications/solvers/interFSFFoam/pEqn.H index 1709a4a..041172b 100644 --- a/applications/solvers/interFSFFoam/pEqn.H +++ b/applications/solvers/interFSFFoam/pEqn.H @@ -28,7 +28,7 @@ surfaceScalarField phig ( phic*rAUf -// + fvc::snGrad(pc)*rAUf*mesh.magSf() + + fvc::snGrad(pc)*rAUf*mesh.magSf() - ghf*fvc::snGrad(rho)*rAUf*mesh.magSf() ); @@ -76,7 +76,7 @@ // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); - p == p_rgh + rho*gh; + p == p_rgh + rho*gh - pc; if (p_rgh.needReference()) { @@ -87,7 +87,7 @@ pressureReference.refValue() - getRefCellValue(p, pressureReference.refCell()) ); - p_rgh = p - rho*gh; + p_rgh = p - rho*gh + pc; } if (!correctPhi) diff --git a/applications/solvers/interFSFFoam/pcEqn.H b/applications/solvers/interFSFFoam/pcEqn.H index abde7d5..f11b9e0 100644 --- a/applications/solvers/interFSFFoam/pcEqn.H +++ b/applications/solvers/interFSFFoam/pcEqn.H @@ -1,7 +1,7 @@ -// fcf.storePrevIter(); +fcf.storePrevIter(); fcfFilt.storePrevIter(); -// const scalar cPhicFilterCoeff(alphaControls.lookupOrDefault("cPhicFilterCoeff", 0.1)); +const scalar cPhicFilterCoeff(alphaControls.lookupOrDefault("cPhicFilterCoeff", 0.1)); const scalar cPhicThresholdCoeff(alphaControls.lookupOrDefault("cPhicThresholdCoeff", 0.01)); // label pcRefCell = 0; @@ -21,18 +21,19 @@ fcf = *fvc::interpolate(w2*kappa) /fvc::interpolate(w2)*deltaf; +fcf.relax(); + fc = fvc::reconstruct(fcf*mesh.magSf()); // fcfFilt = -// deltaf/(mag(deltaf) + mixture.deltaN()) +// mag(deltaf)/(mag(deltaf) + mixture.deltaN()) // *( // fcfFilt.oldTime() -// + cPhicFilterCoeff*((gradPcf - (gradPcf & nHatfv)*nHatfv) & mesh.Sf()/mesh.magSf()) +// + cPhicFilterCoeff*(fvc::interpolate(gradPc - (gradPc & nHatv)*nHatv) & (mesh.Sf()/mesh.magSf())) // ); fcfFilt = - mag(deltaf)/(mag(deltaf) + mixture.deltaN()) - *fvc::interpolate(gradPc - (gradPc & nHatv)*nHatv) & (mesh.Sf()/mesh.magSf()); + cPhicFilterCoeff*fvc::interpolate(gradPc - (gradPc & nHatv)*nHatv) & (mesh.Sf()/mesh.magSf()); fcfFilt.relax(); @@ -47,7 +48,7 @@ while (pimple.correctNonOrthogonal()) fvScalarMatrix pcEqn ( fvm::laplacian(pc) - == fvc::div((fcf - fcfFilt)*mesh.magSf()) + == fvc::div((fcf)*mesh.magSf()) ); pcEqn.setReference @@ -68,34 +69,34 @@ while (pimple.correctNonOrthogonal()) // 1.0 // ); // phic = pcEqn.flux(); -// phic = (fcf - fvc::snGrad(pc))*mesh.magSf(); + phic = (fcf - fvc::snGrad(pc))*mesh.magSf(); // phicFilt = // pos(phic)*mag(phic) // - (1.0 - pos(phic))*mag(phic); - phic = mag(deltaf)/(mag(deltaf) + mixture.deltaN())*fvc::snGrad(pc)*mesh.magSf(); +// phic = mag(deltaf)/(mag(deltaf) + mixture.deltaN())*fvc::snGrad(pc)*mesh.magSf(); // phic = fvc::snGrad(pc)*mesh.magSf(); - const dimensionedScalar phicAvg + const dimensionedScalar fcfAvg ( - dimensionSet(dimForce/dimLength), + dimensionSet(dimForce/dimVolume), // average(mag(fcf))/(average(pos(mag(fcf))) + SMALL) -// average(mag(fcf)) - cPhicThresholdCoeff*gSum(mag(fcf.field()*mesh.magSf())) - /gSum(SMALL + pos(mag(fcf.field()) - SMALL)) + average(mag(fcf.field())) +// cPhicThresholdCoeff*gSum(mag(fcf.field()*mesh.magSf())) +// /gSum(SMALL + pos(mag(fcf.field()) - SMALL)) ); - Info<< "phicAvg = " << phicAvg.value() << nl; - -// phic -= -// max -// ( -// min -// ( -// phic, -// phicAvg -// ), -// - phicAvg -// ); + Info<< "fcfAvg = " << fcfAvg.value() << nl; + + phic -= + max + ( + min + ( + phic, + cPhicThresholdCoeff*fcfAvg*mesh.magSf() + ), + - cPhicThresholdCoeff*fcfAvg*mesh.magSf() + ); // phic -= cPhicThresholdCoeff*phicFilt; } diff --git a/tests/dropletRelaxation2D/calculate.sh b/tests/dropletRelaxation2D/calculate.sh index eb89acf..9cb92c2 100755 --- a/tests/dropletRelaxation2D/calculate.sh +++ b/tests/dropletRelaxation2D/calculate.sh @@ -5,7 +5,7 @@ #Variables section caseName=case1 -scaleSize=$(echo "0.0001" | bc -l) +scaleSize=$(echo "0.000001" | bc -l) cd ${caseName} @@ -27,9 +27,9 @@ runApplication transformPoints "scale=(${scaleSize} ${scaleSize} ${scaleSize})" rm log.transformPoints runParallel transformPoints "scale=(${scaleSize} ${scaleSize} ${scaleSize})" -foamDictionary -entry endTime -set $(echo "0.05" | bc -l) system/controlDict +foamDictionary -entry endTime -set $(echo "0.005" | bc -l) system/controlDict foamDictionary -entry deltaT -set $(echo "0.000001" | bc -l) system/controlDict -foamDictionary -entry writeInterval -set $(echo "0.0001" | bc -l) system/controlDict +foamDictionary -entry writeInterval -set $(echo "0.00001" | bc -l) system/controlDict foamDictionary -entry adjustTimeStep -set "yes" system/controlDict foamDictionary -entry maxCo -set $(echo "0.1" | bc -l) system/controlDict foamDictionary -entry maxAlphaCo -set $(echo "0.1" | bc -l) system/controlDict diff --git a/tests/dropletRelaxation2D/src/constant/phaseProperties b/tests/dropletRelaxation2D/src/constant/phaseProperties index 52b5a84..6d2b68b 100644 --- a/tests/dropletRelaxation2D/src/constant/phaseProperties +++ b/tests/dropletRelaxation2D/src/constant/phaseProperties @@ -18,7 +18,7 @@ phases (phase1 phase2); pMin 1000; -sigma 0.07; +sigma 0.02; // sigma // { diff --git a/tests/dropletRelaxation2D/src/constant/physicalProperties.phase2 b/tests/dropletRelaxation2D/src/constant/physicalProperties.phase2 index 353e8f4..e7c5acd 100644 --- a/tests/dropletRelaxation2D/src/constant/physicalProperties.phase2 +++ b/tests/dropletRelaxation2D/src/constant/physicalProperties.phase2 @@ -16,9 +16,9 @@ FoamFile viscosityModel constant; -nu 1e-06; +nu 2e-06; -rho 1000; +rho 800; // thermoType // { diff --git a/tests/dropletRelaxation2D/src/system/blockMeshDict b/tests/dropletRelaxation2D/src/system/blockMeshDict index 66adab5..61763cf 100644 --- a/tests/dropletRelaxation2D/src/system/blockMeshDict +++ b/tests/dropletRelaxation2D/src/system/blockMeshDict @@ -16,12 +16,12 @@ FoamFile convertToMeters 1; -boxWidth 10.0; -boxHeight 10.0; +boxWidth 60.0; +boxHeight 60.0; boxDepth 1.0; -Nx 80; -Ny 80; +Nx 60; +Ny 60; Nz 1; box0Nx $Nx; diff --git a/tests/dropletRelaxation2D/src/system/fvSchemes b/tests/dropletRelaxation2D/src/system/fvSchemes index e9f518f..9693649 100644 --- a/tests/dropletRelaxation2D/src/system/fvSchemes +++ b/tests/dropletRelaxation2D/src/system/fvSchemes @@ -28,7 +28,7 @@ divSchemes { // div(rhoPhi,U) Gauss linearUpwind grad(U); div(rhoPhi,U) Gauss vanLeerV; - div(phi,alpha) Gauss interfaceCompression vanLeer 1; + div(phi,alpha) Gauss interfaceCompression vanLeer 0; // div(phi,alpha) Gauss PLICU interfaceCompression vanLeer 1; // div(phi,alpha) Gauss MPLIC; // div(phi,alpha) Gauss MPLICU; diff --git a/tests/dropletRelaxation2D/src/system/fvSolution b/tests/dropletRelaxation2D/src/system/fvSolution index 7fedd17..0f48f38 100644 --- a/tests/dropletRelaxation2D/src/system/fvSolution +++ b/tests/dropletRelaxation2D/src/system/fvSolution @@ -30,12 +30,12 @@ solvers tolerance 1e-12; relTol 0; - nAlphaSmoothers 3; + nAlphaSmoothers 7; cSmCoeff 0.5; - cShCoeff 0.98; + cShCoeff 0.1; nKappaSmoothers 2; -// cPhicFilterCoeff 0.1; - cPhicThresholdCoeff 0.01; + cPhicFilterCoeff 0.9; + cPhicThresholdCoeff 0.05; } ".*(rho|rhoFinal)" @@ -157,8 +157,8 @@ relaxationFactors // p_rghFinal 1; // phic 0.7; // phicFinal 1; -// fcf 0.7; -// fcfFinal 1; + fcf 0.7; + fcfFinal 1; fcfFilt 0.7; fcfFiltFinal 1; } diff --git a/tests/dropletRelaxation2D/src/system/setFieldsDict b/tests/dropletRelaxation2D/src/system/setFieldsDict index c69e179..ada356b 100644 --- a/tests/dropletRelaxation2D/src/system/setFieldsDict +++ b/tests/dropletRelaxation2D/src/system/setFieldsDict @@ -24,7 +24,7 @@ regions ( boxToCell { - box (-2 -2 -2) (2 2 2); + box (-15 -15 -15) (15 15 15); fieldValues ( volScalarFieldValue alpha.phase1 0