From 1af512ae5199ccbf3bd3b7499dd9fb0ebdee96d7 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 5 Dec 2017 11:43:09 +0000 Subject: [PATCH] ENH: Added divergence scheme test case --- .../schemes/divergenceExample/0/T | 51 +++++++++++ .../schemes/divergenceExample/0/U | 51 +++++++++++ .../schemes/divergenceExample/Allrun | 21 +++++ .../schemes/divergenceExample/README | 17 ++++ .../constant/transportProperties | 21 +++++ .../divergenceExample/system/blockMeshDict | 89 +++++++++++++++++++ .../divergenceExample/system/controlDict | 74 +++++++++++++++ .../divergenceExample/system/fvSchemes | 50 +++++++++++ .../system/fvSchemes.template | 50 +++++++++++ .../divergenceExample/system/fvSolution | 37 ++++++++ .../divergenceExample/system/schemesToTest | 14 +++ 11 files changed, 475 insertions(+) create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/0/T create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/0/U create mode 100755 tutorials/verificationAndValidation/schemes/divergenceExample/Allrun create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/README create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution create mode 100644 tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/0/T b/tutorials/verificationAndValidation/schemes/divergenceExample/0/T new file mode 100644 index 0000000000..a467b9caf2 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/0/T @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 1e-8; + +boundaryField +{ + top + { + type zeroGradient; + } + + bottom + { + type fixedValue; + value uniform 0; + } + + left + { + type fixedValue; + value uniform 1; + } + + right + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/0/U b/tutorials/verificationAndValidation/schemes/divergenceExample/0/U new file mode 100644 index 0000000000..354c78f6d5 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/0/U @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (1 1 0); + +boundaryField +{ + top + { + type zeroGradient; + } + + bottom + { + type fixedValue; + value $internalField; + } + + left + { + type fixedValue; + value $internalField; + } + + right + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/Allrun b/tutorials/verificationAndValidation/schemes/divergenceExample/Allrun new file mode 100755 index 0000000000..46e746c9c9 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/Allrun @@ -0,0 +1,21 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication blockMesh + +cat system/schemesToTest | while read scheme +do + echo "Updating fvSchmes to use $scheme" + sed "s/DIVSCHEME/$scheme/g" system/fvSchemes.template > system/fvSchemes + + # Create a sanitised name for the scheme - remove 'special' characters + schemeTag=$(sed -e 's# #_#g#' -e 's#(##g' -e 's#)##g' -e 's#\.##g' <<< "$scheme") + + runApplication -s ${schemeTag} scalarTransportFoam + + # Save the line plot + mv postProcessing/sample1/100/line1_T.xy line1_T_${schemeTag}.xy +done diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/README b/tutorials/verificationAndValidation/schemes/divergenceExample/README new file mode 100644 index 0000000000..6b586a8f8e --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/README @@ -0,0 +1,17 @@ +Divergence scheme test +====================== + +Various divergence schemes are examined on a 2-D structured mesh, where a +passive scalar is convected at 45deg to the mesh co-ordinate system using a +uniform flow velocity. Executing: + +./Allrun + +will update the system/fvSchemes file to use each scheme listed in the file +system/schemesToTest and perform the test using the scalarTransportFoam solver. +A test file for each run is generated that can be used to compare the predicted +scalar profile against the exact solution. + +For more information, see: + +https://www.openfoam.com/documentation/cpp-guide/html/guide-schemes-divergence-example.html diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties b/tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties new file mode 100644 index 0000000000..1d7dd0c063 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +DT DT [0 2 -1 0 0] 0; + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict b/tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict new file mode 100644 index 0000000000..0a2bf84381 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/blockMeshDict @@ -0,0 +1,89 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (0 0 0) + (1 0 0) + (1 1 0) + (0 1 0) + (0 0 0.1) + (1 0 0.1) + (1 1 0.1) + (0 1 0.1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (50 50 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + top + { + type patch; + faces + ( + (3 7 6 2) + ); + } + bottom + { + type patch; + faces + ( + (1 5 4 0) + ); + } + left + { + type patch; + faces + ( + (0 4 7 3) + ); + } + right + { + type patch; + faces + ( + (2 6 5 1) + ); + } + frontAndBack + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict b/tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict new file mode 100644 index 0000000000..57f4d3a02d --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/controlDict @@ -0,0 +1,74 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application scalarTransportFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 100; + +deltaT 0.005; + +writeControl timeStep; + +writeInterval 100; + +purgeWrite 1; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + sample1 + { + type sets; + functionObjectLibs ("libsampling.so"); + outputControl onEnd; + setFormat raw; + sets + ( + line1 + { + type uniform; + axis distance; + + // Slightly perturbed so as not to align with face or edge + start (0 1 0.00501); + end (1 0 0.00501); + nPoints 200; + } + ); + interpolationScheme cellPoint; + fields (T); + } +} + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes new file mode 100644 index 0000000000..2187810b69 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,T) Gauss limitedLinear 0.2; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template new file mode 100644 index 0000000000..be5ae28968 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSchemes.template @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,T) Gauss DIVSCHEME; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution new file mode 100644 index 0000000000..5a89311545 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/fvSolution @@ -0,0 +1,37 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { +// solver smoothSolver; +// smoother symGaussSeidel; + solver PBiCG; + preconditioner DILU; + tolerance 1e-10; + relTol 0; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // diff --git a/tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest b/tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest new file mode 100644 index 0000000000..be48003bf6 --- /dev/null +++ b/tutorials/verificationAndValidation/schemes/divergenceExample/system/schemesToTest @@ -0,0 +1,14 @@ +limitedLinear 0.2 +limitedLinear 1.0 +linear +linearUpwind grad(U) +LUST +midPoint +Minmod +MUSCL +QUICK +SFCD +SuperBee +UMIST +upwind +vanLeer