diff --git a/applications/solvers/basic/potentialFoam/potentialFoam.C b/applications/solvers/basic/potentialFoam/potentialFoam.C index 37e613b7e2b57a83803b07dbe1f3be74153e326d..db5c3612946968906d089250453dcbbbdfa18816 100644 --- a/applications/solvers/basic/potentialFoam/potentialFoam.C +++ b/applications/solvers/basic/potentialFoam/potentialFoam.C @@ -35,8 +35,8 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "fvIOoptionList.H" #include "pisoControl.H" +#include "fvIOoptionList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,6 +61,12 @@ int main(int argc, char *argv[]) "Write the velocity potential field" ); + argList::addBoolOption + ( + "writep", + "Calculate and write the pressure field" + ); + #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" @@ -125,6 +131,53 @@ int main(int argc, char *argv[]) Phi.write(); } + // Calculate the pressure field + if (args.optionFound("writep")) + { + Info<< nl << "Calculating approximate pressure field" << endl; + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell + ( + p, + potentialFlow.dict(), + pRefCell, + pRefValue + ); + + // Calculate the flow-direction filter tensor + volScalarField magSqrU(magSqr(U)); + volSymmTensorField F(sqr(U)/(magSqrU + SMALL*average(magSqrU))); + + // Calculate the divergence of the flow-direction filtered div(U*U) + // Filtering with the flow-direction generates a more reasonable + // pressure distribution in regions of high velocity gradient in the + // direction of the flow + volScalarField divDivUU + ( + fvc::div + ( + F & fvc::div(phi, U), + "div(div(phi,U))" + ) + ); + + // Solve a Poisson equation for the approximate pressure + while (potentialFlow.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvm::laplacian(p) + divDivUU + ); + + pEqn.setReference(pRefCell, pRefValue); + pEqn.solve(); + } + + p.write(); + } + runTime.functionObjects().end(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" diff --git a/tutorials/basic/potentialFoam/cylinder/Allrun b/tutorials/basic/potentialFoam/cylinder/Allrun index 74a2fc93fb5c534cce3635408579acc8830712a3..ea05ecadcb4eed1ff0b8cd9f8ebc7eab78209a83 100755 --- a/tutorials/basic/potentialFoam/cylinder/Allrun +++ b/tutorials/basic/potentialFoam/cylinder/Allrun @@ -8,7 +8,7 @@ application=`getApplication` cp -r 0.org 0 > /dev/null 2>&1 runApplication blockMesh -runApplication $application +runApplication $application -writePhi -writep runApplication streamFunction # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/basic/potentialFoam/cylinder/system/fvSchemes b/tutorials/basic/potentialFoam/cylinder/system/fvSchemes index b3b176d949a83c4486c52bd54c0781b403504c3a..e71ede26d8d4b68bc33113c5bfb0008c88ccc260 100644 --- a/tutorials/basic/potentialFoam/cylinder/system/fvSchemes +++ b/tutorials/basic/potentialFoam/cylinder/system/fvSchemes @@ -28,6 +28,8 @@ gradSchemes divSchemes { default none; + div(phi,U) bounded Gauss linear; + div(div(phi,U)) Gauss linear; } laplacianSchemes diff --git a/tutorials/basic/potentialFoam/cylinder/system/fvSolution b/tutorials/basic/potentialFoam/cylinder/system/fvSolution index 9e1ab1b2b403b7c51b3416da3e814d7dc8b55dac..41a58da20eac24c8e5bd380b52fec3d5d08bf7cb 100644 --- a/tutorials/basic/potentialFoam/cylinder/system/fvSolution +++ b/tutorials/basic/potentialFoam/cylinder/system/fvSolution @@ -19,10 +19,20 @@ solvers { Phi { - solver PCG; - preconditioner DIC; + solver GAMG; + smoother DIC; + cacheAgglomeration on; + agglomerator faceAreaPair; + nCellsInCoarsestLevel 10; + mergeLevels 1; + tolerance 1e-06; - relTol 0; + relTol 0.01; + } + + p + { + $Phi; } } diff --git a/tutorials/basic/potentialFoam/pitzDaily/Allrun b/tutorials/basic/potentialFoam/pitzDaily/Allrun index 74a2fc93fb5c534cce3635408579acc8830712a3..ea05ecadcb4eed1ff0b8cd9f8ebc7eab78209a83 100755 --- a/tutorials/basic/potentialFoam/pitzDaily/Allrun +++ b/tutorials/basic/potentialFoam/pitzDaily/Allrun @@ -8,7 +8,7 @@ application=`getApplication` cp -r 0.org 0 > /dev/null 2>&1 runApplication blockMesh -runApplication $application +runApplication $application -writePhi -writep runApplication streamFunction # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/basic/potentialFoam/pitzDaily/system/fvSchemes b/tutorials/basic/potentialFoam/pitzDaily/system/fvSchemes index b2334a206c9c7c0e385ee73e73fa1b619362d78d..998719caeaa3caa1304ff77f0d25819f8152a815 100644 --- a/tutorials/basic/potentialFoam/pitzDaily/system/fvSchemes +++ b/tutorials/basic/potentialFoam/pitzDaily/system/fvSchemes @@ -28,6 +28,8 @@ gradSchemes divSchemes { default none; + div(phi,U) bounded Gauss linear; + div(div(phi,U)) Gauss linear; } laplacianSchemes diff --git a/tutorials/basic/potentialFoam/pitzDaily/system/fvSolution b/tutorials/basic/potentialFoam/pitzDaily/system/fvSolution index 3565bddf3718b5e45146bf27370edffbe42a1832..4682f4cc8683a12f017575d0cdfc23c92cea2cba 100644 --- a/tutorials/basic/potentialFoam/pitzDaily/system/fvSolution +++ b/tutorials/basic/potentialFoam/pitzDaily/system/fvSolution @@ -19,17 +19,26 @@ solvers { Phi { - solver PCG; - preconditioner DIC; + solver GAMG; + smoother DIC; + cacheAgglomeration on; + agglomerator faceAreaPair; + nCellsInCoarsestLevel 10; + mergeLevels 1; + tolerance 1e-06; - relTol 0; + relTol 0.01; + } + + p + { + $Phi; } } potentialFlow { - nNonOrthogonalCorrectors 0; + nNonOrthogonalCorrectors 2; } - // ************************************************************************* //