From b6c07ab65a395a6f877e3239f775137f83438bb6 Mon Sep 17 00:00:00 2001 From: Elwardi Date: Mon, 8 Apr 2024 15:35:40 +0200 Subject: [PATCH 1/8] build: restrict switching branches to master and v2212 in Allwmake --- Allwmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Allwmake b/Allwmake index a75a1d4..4877a89 100755 --- a/Allwmake +++ b/Allwmake @@ -5,6 +5,9 @@ cd "${0%/*}" || exit # Run from this directory #------------------------------------------------------------------------------ foamv=${WM_PROJECT_VERSION} +curr_branch=$(git branch --show-current) +if [[ $curr_branch == "master" || $curr_branch == "v2212" ]]; then +# Switch branches if necessary if [[ $foamv =~ ^v([0-9]{4})$ ]]; then ver=${BASH_REMATCH[1]} if [ "${ver}" -eq "2106" ]; then @@ -22,6 +25,7 @@ else echo "${WM_PROJECT}-${foamv} is not supported, this toolkit only works with OpenCFD's releases of OpenFOAM." exit 1 fi +fi #------------------------------------------------------------------------------ From d95b26f109df173fa886d1c32e09d05588a0640a Mon Sep 17 00:00:00 2001 From: Elwardi Date: Fri, 26 Apr 2024 14:08:17 +0200 Subject: [PATCH 2/8] feat: add sample sampling to damBreak2D case for debugging --- tutorials/damBreak2D/Allrun | 3 +- tutorials/damBreak2D/system/controlDict | 5 +- tutorials/damBreak2D/system/sampling | 94 ++++++++++++++++--------- 3 files changed, 67 insertions(+), 35 deletions(-) diff --git a/tutorials/damBreak2D/Allrun b/tutorials/damBreak2D/Allrun index 4ddb69a..c9fe940 100755 --- a/tutorials/damBreak2D/Allrun +++ b/tutorials/damBreak2D/Allrun @@ -3,6 +3,7 @@ cd "${0%/*}" || exit # Run from this directory . ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions #------------------------------------------------------------------------------ +set -e restore0Dir runApplication blockMesh @@ -21,6 +22,6 @@ for i in $(seq 1 $maxRef); do done cp -rT 0/polyMesh constant/polyMesh runApplication decomposePar -constant -#mpirun -np 8 --output-filename log interFoam -parallel +mpirun -np 4 --output-filename log interFoam -parallel #------------------------------------------------------------------------------ diff --git a/tutorials/damBreak2D/system/controlDict b/tutorials/damBreak2D/system/controlDict index 8325d4d..fab83d5 100644 --- a/tutorials/damBreak2D/system/controlDict +++ b/tutorials/damBreak2D/system/controlDict @@ -60,6 +60,9 @@ maxAlphaCo 1; maxDeltaT 1; -//#sinclude "sampling" +functions +{ + #include "sampling" +} // ************************************************************************* // diff --git a/tutorials/damBreak2D/system/sampling b/tutorials/damBreak2D/system/sampling index f1d86f9..e23ae96 100644 --- a/tutorials/damBreak2D/system/sampling +++ b/tutorials/damBreak2D/system/sampling @@ -1,7 +1,7 @@ /*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2012 | +| \\ / O peration | Version: v2112 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ @@ -14,41 +14,69 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -functions +__surfaceFieldValue { - sampleSets + type surfaceFieldValue; + libs (fieldFunctionObjects); + log on; + enabled true; + writeControl timeStep; + writeInterval 1; + writeFields false; + surfaceFormat vtk; +} + + +// * * * * * * * * * * * * * * * * Sampling * * * * * * * * * * * * * * * * // + +// Sample volume fields to surfaces and hold on registry. +sampled +{ + type surfaces; + libs (sampling); + log true; + + executeControl timeStep; + executeInterval 1; + writeControl none; + sampleOnExecute true; + surfaceFormat none; + fields ( p U ); + surfaces + { + walls + { + type patch; + patches ( ".*Wall" ); + // triangulate false; + } + } +} + + +// * * * * * * * * * * * * * * * Calculations * * * * * * * * * * * * * * * // + +nonWeightedAreaAverage +{ + ${__surfaceFieldValue} + enabled true; + + regionType sampledSurface; + name sampledTriSurf; + sampledSurfaceDict { - type sets; - libs (sampling); - - writeControl timeStep; - writeInterval 1; - - setFormat vtk; - interpolationScheme cellPointFace; - fields ( alpha.water ); - - sets - ( - gauge_1 - { - type face; - axis y; - start (0.02 0.20 0.005); - end (0.02 0.25 0.005); - nPoints 100; - } - - gauge_2 - { - type face; - axis y; - start (0.2 0.03 0.005); - end (0.2 0.55 0.005); - nPoints 100; - } - ); + type patch; + patches ( ".*Wall" ); + interpolate true; } + + operation areaAverage; + fields ( p U ); } +// * * * * * * * * * * * * * * * * * Cleanup * * * * * * * * * * * * * * * * // + +#remove "__.*" + + // ************************************************************************* // From 5d18b230842df823084097810d22eef7e26e3b83 Mon Sep 17 00:00:00 2001 From: Elwardi Date: Mon, 1 Jan 2024 22:45:13 +0100 Subject: [PATCH 3/8] docs: update README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 994d1b2..d35b85d 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ This repository extracts library parts from [blastFoam](https://github.com/synth To get started, you can visit the one and only [wiki page](https://github.com/STFS-TUDa/blastAMR/wiki). +> [!NOTE] +> If you're using OpenFOAM v2206 or newer, please switch to the `v2212` branch. The `master` branch is for OpenFOAM v2112 +> and earlier versions for now. See #6. + ## Objectives - Have a reasonable Load-balanced AMR for 2D/3D OpenFOAM meshes in the **ESI fork**. From b66b0f870f952f19cf1bd3f937417f91b2b74441 Mon Sep 17 00:00:00 2001 From: Elwardi Date: Mon, 1 Jan 2024 23:40:52 +0100 Subject: [PATCH 4/8] feat: add gradientRange class --- src/errorEstimators/gradientRange/gradientRange.C | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/errorEstimators/gradientRange/gradientRange.C b/src/errorEstimators/gradientRange/gradientRange.C index c968c50..71059d2 100644 --- a/src/errorEstimators/gradientRange/gradientRange.C +++ b/src/errorEstimators/gradientRange/gradientRange.C @@ -92,19 +92,21 @@ void gradientEstimator::update(const bool scale) } error_ = 0.0; - const auto& vf = mesh_.lookupObject(gradField_); + const auto& T = mesh_.lookupObject(gradField_); const scalar refineThreshold(dict().lookupOrDefault("refineThreshold", 0.5)); const scalar unrefineThreshold(dict().lookupOrDefault("unrefineThreshold", 0.4)); Info << "refineThreshold = " << refineThreshold << endl; Info << "unrefineThreshold = " << unrefineThreshold << endl; - error_ == mag(fvc::grad(vf)) / dimensionedScalar(vf.dimensions()/dimLength,1.0); + // @todo: Use cached gradient if possible in gradient-based error indicators + // @body: Explore the possibility of using cached field gradients instead of new computations + error_ == mag(fvc::grad(T)) / dimensionedScalar(T.dimensions()/dimLength,1.0); - scalar maxGrad = gMax(error_); - scalar minGrad = gMin(error_); + scalar maxGradT = gMax(error_); + scalar minGradT = gMin(error_); - lowerRefine_ = minGrad + refineThreshold*(maxGrad-minGrad); + lowerRefine_ = minGradT + refineThreshold*(maxGradT-minGradT); upperRefine_ = GREAT; - lowerUnrefine_ = minGrad + unrefineThreshold*(maxGrad-minGrad); + lowerUnrefine_ = minGradT + unrefineThreshold*(maxGradT-minGradT); upperUnrefine_ = GREAT; if (scale) normalize(error_); } @@ -115,4 +117,3 @@ void gradientEstimator::update(const bool scale) } // End namespace Foam // ************************************************************************* // - From 50b74092efa1baba6060ea40ac567a1544ecb307 Mon Sep 17 00:00:00 2001 From: Elwardi Date: Wed, 3 Jan 2024 03:54:45 +0100 Subject: [PATCH 5/8] fix: closes #9, fvc::grad takes care of gradient cache checks --- src/errorEstimators/gradientRange/gradientRange.C | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/errorEstimators/gradientRange/gradientRange.C b/src/errorEstimators/gradientRange/gradientRange.C index 71059d2..98b0c07 100644 --- a/src/errorEstimators/gradientRange/gradientRange.C +++ b/src/errorEstimators/gradientRange/gradientRange.C @@ -92,21 +92,19 @@ void gradientEstimator::update(const bool scale) } error_ = 0.0; - const auto& T = mesh_.lookupObject(gradField_); + const auto& vf = mesh_.lookupObject(gradField_); const scalar refineThreshold(dict().lookupOrDefault("refineThreshold", 0.5)); const scalar unrefineThreshold(dict().lookupOrDefault("unrefineThreshold", 0.4)); Info << "refineThreshold = " << refineThreshold << endl; Info << "unrefineThreshold = " << unrefineThreshold << endl; - // @todo: Use cached gradient if possible in gradient-based error indicators - // @body: Explore the possibility of using cached field gradients instead of new computations - error_ == mag(fvc::grad(T)) / dimensionedScalar(T.dimensions()/dimLength,1.0); + error_ == mag(fvc::grad(vf)) / dimensionedScalar(vf.dimensions()/dimLength,1.0); - scalar maxGradT = gMax(error_); - scalar minGradT = gMin(error_); + scalar maxGrad = gMax(error_); + scalar minGrad = gMin(error_); - lowerRefine_ = minGradT + refineThreshold*(maxGradT-minGradT); + lowerRefine_ = minGrad + refineThreshold*(maxGrad-minGrad); upperRefine_ = GREAT; - lowerUnrefine_ = minGradT + unrefineThreshold*(maxGradT-minGradT); + lowerUnrefine_ = minGrad + unrefineThreshold*(maxGrad-minGrad); upperUnrefine_ = GREAT; if (scale) normalize(error_); } From ebfa5d0ce64247f33919a779b40e395ee24e7dbb Mon Sep 17 00:00:00 2001 From: Elwardi Date: Mon, 4 Mar 2024 10:19:19 +0100 Subject: [PATCH 6/8] docs: make note about auto-sensing of openfoam versions --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index d35b85d..994d1b2 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,6 @@ This repository extracts library parts from [blastFoam](https://github.com/synth To get started, you can visit the one and only [wiki page](https://github.com/STFS-TUDa/blastAMR/wiki). -> [!NOTE] -> If you're using OpenFOAM v2206 or newer, please switch to the `v2212` branch. The `master` branch is for OpenFOAM v2112 -> and earlier versions for now. See #6. - ## Objectives - Have a reasonable Load-balanced AMR for 2D/3D OpenFOAM meshes in the **ESI fork**. From 46aac75bbb772ff46ded02cbb05b8807ca1dbd1b Mon Sep 17 00:00:00 2001 From: Elwardi Date: Mon, 4 Mar 2024 10:29:17 +0100 Subject: [PATCH 7/8] build: update Allwmake --- Allwmake | 1 - 1 file changed, 1 deletion(-) diff --git a/Allwmake b/Allwmake index 4877a89..7f4d532 100755 --- a/Allwmake +++ b/Allwmake @@ -25,7 +25,6 @@ else echo "${WM_PROJECT}-${foamv} is not supported, this toolkit only works with OpenCFD's releases of OpenFOAM." exit 1 fi -fi #------------------------------------------------------------------------------ From 4686f71ad35b1531de59204ef2fe22f687e2266d Mon Sep 17 00:00:00 2001 From: Elwardi Date: Mon, 8 Apr 2024 15:35:40 +0200 Subject: [PATCH 8/8] build: restrict switching branches to master and v2212 in Allwmake --- Allwmake | 1 + 1 file changed, 1 insertion(+) diff --git a/Allwmake b/Allwmake index 7f4d532..4877a89 100755 --- a/Allwmake +++ b/Allwmake @@ -25,6 +25,7 @@ else echo "${WM_PROJECT}-${foamv} is not supported, this toolkit only works with OpenCFD's releases of OpenFOAM." exit 1 fi +fi #------------------------------------------------------------------------------