ENH: CleanFunctions refinements

- include constant/faMesh cleanup (cleanFaMesh) as part of standard
  cleanCase

- simplify cleanPolyMesh function to now just warn about old
  constant/polyMesh/blockMeshDict but not try to remove anything

- cleanup cellDist.vtu (decomposePar -dry-run) as well

ENH: foamRunTutorials - fallback to Allrun-parallel, Allrun-serial

TUT: call m4 with file argument instead of redirected stdin

TUT: adjust suffixes on decomposeParDict variants
This commit is contained in:
Mark Olesen 2022-06-09 09:36:30 +02:00
parent d878ca3248
commit 7f748bd5fd
30 changed files with 151 additions and 148 deletions

View File

@ -6,7 +6,7 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase
# Restore default dictionaries
cp system/decomposeParDict-2 system/decomposeParDict
cp system/decomposeParDict.2 system/decomposeParDict
cp system/controlDict-startTime system/controlDict
# -----------------------------------------------------------------------------

View File

@ -5,12 +5,12 @@ cd "${0%/*}" || exit # Run from this directory
runApplication blockMesh
runApplication decomposePar -decomposeParDict system/decomposeParDict-2
runApplication decomposePar -decomposeParDict system/decomposeParDict.2
runParallel -s scotch -np 5 redistributePar \
-decomposeParDict system/decomposeParDict-5
runParallel -s scotch -decomposeParDict system/decomposeParDict.5 \
redistributePar
runParallel -np 5 Test-mapDistributePolyMesh \
-decomposeParDict system/decomposeParDict-5
runParallel -decomposeParDict system/decomposeParDict.5 \
Test-mapDistributePolyMesh
# -----------------------------------------------------------------------------

View File

@ -7,22 +7,10 @@
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2022 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamCleanPolyMesh
@ -76,34 +64,33 @@ do
esac
done
meshDir=polyMesh
if [ -n "$regionName" ]
then
meshDir=$regionName/polyMesh
else
meshDir=polyMesh
meshDir="$regionName/$meshDir"
fi
# If -case was specified: insist upon 'constant/polyMesh'
if [ -n "$caseDir" ]
then
if [ -d constant/$meshDir ]
if [ -d constant/"$meshDir" ]
then
# Use constant/polyMesh
meshDir=constant/$meshDir
meshDir=constant/"$meshDir"
else
echo "Error: no 'constant/$meshDir' in $caseDir" 1>&2
exit 1
fi
else
if [ -d constant/$meshDir ]
if [ -d constant/"$meshDir" ]
then
# Use constant/polyMesh
meshDir=constant/$meshDir
elif [ -d $meshDir ]
meshDir=constant/"$meshDir"
elif [ -d "$meshDir" ]
then
# Likely already in constant/ - do not adjust anything
:
elif [ "${PWD##*/}" = polyMesh -a -z "$regionName" ]
elif [ "${PWD##*/}" = polyMesh ] && [ -z "$regionName" ]
then
# Apparently already within polyMesh/
meshDir=.
@ -135,7 +122,7 @@ for i in \
surfaceIndex \
;
do
rm -rf $meshDir/$i $meshDir/$i.gz
rm -rf "$meshDir/$i" "$meshDir/$i.gz"
done
#------------------------------------------------------------------------------

View File

@ -20,7 +20,7 @@
# using Allclean, Allwclean (when present) or regular cleanCase.
#
#------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
. "${WM_PROJECT_DIR:?}"/bin/tools/CleanFunctions # Tutorial clean functions
thisScript="$0"
if [ "/${thisScript#/}" != "$thisScript" ]

View File

@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2018-2021 OpenCFD Ltd.
# Copyright (C) 2018-2022 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -24,7 +24,7 @@
# When this is detected, the case will be skipped.
#
#------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
. "${WM_PROJECT_DIR:?}"/bin/tools/RunFunctions # Tutorial run functions
# Normally use standard "make"
make="make"
@ -44,11 +44,12 @@ options:
-serial Prefer Allrun-serial if available
-parallel Prefer Allrun-parallel if available
-test Prefer Alltest script, pass -test argument to scripts
-self Avoid initial Allrun, Alltest scripts
-self Avoid initial Allrun / Alltest scripts
(prevent infinite recursion)
-help Print the usage
Recursively run Allrun/Alltest (or blockMesh + application)
Recursively run Alltest / Allrun / Allrun-parallel / Allrun-serial
(or simply blockMesh + application)
starting from the current directory or the specified -case directory.
Equivalent options:
@ -74,7 +75,7 @@ die()
#------------------------------------------------------------------------------
# Parse options
unset passArgs runTests runType skipSelf
unset passArgs runTest runType skipSelf
while [ "$#" -gt 0 ]
do
@ -95,7 +96,7 @@ do
-test)
passArgs="-test"
runTests=true
runTest=true
;;
## long-option (internal dispatch form)
@ -139,30 +140,34 @@ done
if [ -z "$skipSelf" ]
then
# Use specialized script(s)
if [ "$runTests" = true ] && [ -f Alltest ]
if [ -n "$runTest" ] && [ -f ./Alltest ]
then
./Alltest $passArgs $*
exit "$?"
elif [ -f Allrun-optional ]
elif [ -f ./Allrun-optional ]
then
echo "Skipped optional case $PWD"
exit 0
fi
# Prefer -serial or -parallel when available?
if [ -n "$runType" ]
elif [ -n "$runType" ]
then
if [ -f ./"Allrun-${runType}" ]
# Prefer -serial or -parallel when available?
allRun="Allrun-$runType"
if [ -f ./"$allRun" ]
then
./"Allrun-${runType}" $passArgs $*
./"$allRun" $passArgs $*
exit "$?"
fi
fi
if [ -f ./Allrun ]
then
./Allrun $passArgs $*
exit "$?"
fi
# Otherwise use Allrun or Allrun-parallel or Allrun-serial
for allRun in Allrun Allrun-parallel Allrun-serial
do
if [ -f ./"$allRun" ]
then
./"$allRun" $passArgs $*
exit "$?"
fi
done
fi

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2015-2021 OpenCFD Ltd.
# Copyright (C) 2015-2022 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -105,6 +105,54 @@ cleanPostProcessing()
}
cleanFaMesh()
{
if [ -e constant/faMesh ]
then
if [ -e constant/faMesh/faMeshDefinition ]
then
# Old constant/faMesh location for faMeshDefinition still in use:
# - warn but don't remove anything
echo
echo "Warning: not removing constant/faMesh/"
echo " It contains a 'faMeshDefinition' file"
echo " Relocate the file(s) to system/ to avoid this warning"
echo
else
# Can remove constant/faMesh/ entirely (no faMeshDefinition)
rm -rf constant/faMesh
fi
fi
}
cleanPolyMesh()
{
if [ -e constant/polyMesh ]
then
if [ -e constant/polyMesh/blockMeshDict ] \
|| [ -e constant/polyMesh/blockMeshDict.m4 ]
then
# Old constant/polyMesh location for blockMeshDict still in use:
# - warn but don't remove anything
echo
echo "Warning: not removing constant/polyMesh/"
echo " It contains a 'blockMeshDict' or 'blockMeshDict.m4' file"
echo " Relocate the file(s) to system/ to avoid this warning"
echo
else
# Can remove constant/polyMesh/ entirely (no blockMeshDict)
rm -rf constant/polyMesh
fi
fi
if [ -e system/blockMeshDict.m4 ]
then
rm -f system/blockMeshDict
fi
}
cleanCase()
{
cleanTimeDirectories
@ -114,6 +162,10 @@ cleanCase()
cleanOptimisation
cleanPostProcessing
cleanFaMesh
cleanPolyMesh
cleanSnappyFiles
rm -rf processor*
rm -rf TDAC
rm -rf probes*
@ -122,14 +174,14 @@ cleanCase()
rm -rf sets
rm -rf system/machines
# Possible blockMesh output
rm -f blockTopology.vtu blockFaces.vtp blockTopology.obj blockCentres.obj
# Debug output (blockMesh, decomposePar)
rm -f \
blockTopology.vtu blockFaces.vtp blockTopology.obj blockCentres.obj \
cellDist.vtu \
0/cellDist
# From mpirunDebug
rm -f gdbCommands mpirun.schema
cleanSnappyFiles
rm -f 0/cellDist
rm -f gdbCommands mpirun.schema
(
cd constant 2>/dev/null || exit 0
@ -138,33 +190,7 @@ cleanCase()
cellDecomposition cellToRegion cellLevel* pointLevel* \
tetDualMesh \
;
# Old constant/polyMesh location for blockMeshDict still in use?
# - emit a gentle warning
if [ -e polyMesh/blockMeshDict.m4 ]
then
rm -f polyMesh/blockMeshDict
echo
echo "Warning: not removing constant/polyMesh/"
echo " It contains a 'blockMeshDict.m4' file."
echo " Relocate the file to system/ to avoid this warning"
echo
elif [ -e polyMesh/blockMeshDict ]
then
echo
echo "Warning: not removing constant/polyMesh/"
echo " It contains a 'blockMeshDict' file."
echo " Relocate the file to system/ to avoid this warning"
else
# Remove polyMesh entirely if there is no blockMeshDict
rm -rf polyMesh
fi
)
if [ -e system/blockMeshDict.m4 ]
then
rm -f system/blockMeshDict
fi
}
@ -195,29 +221,6 @@ cleanUcomponents()
}
cleanFaMesh()
{
(
cd constant 2>/dev/null || exit 0
# Old constant/polyMesh location for blockMeshDict still in use?
# - emit a gentle warning
if [ -e faMesh/faMeshDefinition ]
then
rm -f faMesh/faceLabels* faMesh/faBoundary*
echo
echo "Warning: not removing the constant/faMesh/ directory"
echo " It contains a 'faMeshDefinition' file"
echo " Relocate the file to system/ to avoid this warning"
echo
else
# Remove faMesh/ entirely if there is no faMeshDefinition
rm -rf faMesh
fi
)
}
cleanApplication()
{
echo "Cleaning application $PWD"

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase0

View File

@ -1,6 +1,6 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication blockMesh

View File

@ -1,10 +1,10 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication ./Allmesh
# Run
runApplication $(getApplication)
#------------------------------------------------------------------------------

View File

@ -5,6 +5,4 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
cleanFaMesh
#------------------------------------------------------------------------------

View File

@ -5,6 +5,4 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
cleanFaMesh
#------------------------------------------------------------------------------

View File

@ -5,6 +5,4 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase
cleanFaMesh
#------------------------------------------------------------------------------

View File

@ -5,8 +5,6 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
cleanFaMesh
rm -rf history
#------------------------------------------------------------------------------

View File

@ -5,8 +5,6 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
cleanFaMesh
(cd makePerturbation && wclean)
rm -rf history

View File

@ -11,7 +11,7 @@ fi
restore0Dir
m4 < ./system/blockMeshDict.m4 > ./system/blockMeshDict
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh

View File

@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@ -16,12 +16,11 @@ FoamFile
numberOfSubdomains 2;
method simple;
method simple;
coeffs
{
n ( 2 1 1 );
n ( 2 1 1 );
}
// ************************************************************************* //

View File

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2206 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 4;
method scotch;
// ************************************************************************* //

View File

@ -5,6 +5,4 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase
cleanFaMesh
#------------------------------------------------------------------------------

View File

@ -3,7 +3,7 @@ cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
m4 < system/blockMeshDict.m4 > system/blockMeshDict
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh

View File

@ -5,8 +5,6 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase0
cleanFaMesh
(cd makeWave && wclean)
rm -rf history

View File

@ -5,6 +5,4 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase
cleanFaMesh
#------------------------------------------------------------------------------

View File

@ -5,6 +5,4 @@ cd "${0%/*}" || exit # Run from this directory
cleanCase
cleanFaMesh
#------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@ restore0Dir
runApplication blockMesh
decompDict5="-decomposeParDict system/decomposeParDict-5"
decompDict5="-decomposeParDict system/decomposeParDict.5"
# redistributePar to do decomposition
runParallel -s decompose redistributePar -decompose

View File

@ -1,8 +1,10 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/CleanFunctions # Tutorial clean functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/CleanFunctions # Tutorial clean functions
#------------------------------------------------------------------------------
cleanCase
rm *.obj
rm -f *.obj
#------------------------------------------------------------------------------

View File

@ -1,6 +1,7 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/bin/tools/RunFunctions # Tutorial run functions
cd "${0%/*}" || exit # Run from this directory
. ${WM_PROJECT_DIR:?}/bin/tools/RunFunctions # Tutorial run functions
#------------------------------------------------------------------------------
runApplication blockMesh

View File

@ -5,8 +5,8 @@ cd "${0%/*}" || exit # Run from this directory
restore0Dir
# Create the underlying block mesh
m4 system/pachuka.m4 > system/blockMeshDict
# Create the mesh
m4 system/blockMeshDict.m4 > system/blockMeshDict
runApplication blockMesh
# Create faceSet for burner inlet and faceZone for coupled wall

View File

@ -8,7 +8,7 @@
FoamFile
{
version 2.0;
format ascii;
`format' ascii;
class dictionary;
object blockMeshDict;
}
@ -16,8 +16,8 @@ FoamFile
scale 0.001;
changecom(//)changequote([,])
define(calc, [esyscmd(perl -e 'printf ($1)')])
changecom(//)changequote([,]) dnl>
define(calc, [esyscmd(perl -e 'printf ($1)')]) dnl>
define(VCOUNT, 0)
define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
@ -931,3 +931,5 @@ boundary
);
}
);
// ************************************************************************* //