mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: added clean up function remove0DirFields (RunFunctions)
- less typing than before and avoids relying on bash-specific behaviour (fixes #3448) ENH: add -region support for cleanFaMesh and cleanPolyMesh CONFIG: add bash completion help for -area-region ENH: general improvements for regionProperties - robustness and failsafe for foamListRegions, regionProperties - additional global model switches for regionModels
This commit is contained in:
committed by
Andrew Heather
parent
ccb57c0499
commit
c7b5f1e3eb
@ -30,7 +30,8 @@ Group
|
||||
grpPostProcessingUtilities
|
||||
|
||||
Description
|
||||
List regions from constant/regionProperties.
|
||||
List volume regions from constant/regionProperties
|
||||
or area regions from constant/finite-area/regionProperties
|
||||
|
||||
Usage
|
||||
\b foamListRegions [OPTION]
|
||||
@ -72,6 +73,12 @@ int main(int argc, char *argv[])
|
||||
"List constant/finite-area/regionProperties (if available)"
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"optional",
|
||||
"A missing regionProperties is not treated as an error"
|
||||
);
|
||||
|
||||
argList::addDryRunOption
|
||||
(
|
||||
"Make reading optional and add verbosity"
|
||||
@ -92,14 +99,20 @@ int main(int argc, char *argv[])
|
||||
++optVerbose;
|
||||
}
|
||||
|
||||
// File is optional, not an error
|
||||
const bool isOptional = args.found("optional");
|
||||
|
||||
// Use finite-area regions
|
||||
const bool doFiniteArea = args.found("finite-area");
|
||||
|
||||
// The number of optional region filters to apply
|
||||
const label nFilters = (args.size()-1);
|
||||
|
||||
IOobjectOption::readOption readOpt(IOobjectOption::MUST_READ);
|
||||
|
||||
if (dryRun || doFiniteArea)
|
||||
if (dryRun || isOptional || doFiniteArea)
|
||||
{
|
||||
// Always treat finite-area regionProperties as optional
|
||||
// The finite-area regionProperties are also considered optional
|
||||
readOpt = IOobjectOption::READ_IF_PRESENT;
|
||||
}
|
||||
|
||||
@ -116,58 +129,70 @@ int main(int argc, char *argv[])
|
||||
if (doFiniteArea)
|
||||
{
|
||||
regionProps = regionProperties(runTime, faMeshPrefix, readOpt);
|
||||
|
||||
if (regionProps.empty())
|
||||
{
|
||||
InfoErr<< "No finite-area region types" << nl;
|
||||
}
|
||||
else if (optVerbose)
|
||||
{
|
||||
InfoErr
|
||||
<< "Have " << regionProps.size()
|
||||
<< " finite-area region types, "
|
||||
<< regionProps.count() << " regions" << nl << nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
regionProps = regionProperties(runTime, readOpt);
|
||||
}
|
||||
|
||||
// Some reporting...
|
||||
if (regionProps.empty())
|
||||
{
|
||||
// Probably only occurs with -dry-run option
|
||||
if (doFiniteArea)
|
||||
{
|
||||
InfoErr<< "No finite-area region types" << nl;
|
||||
}
|
||||
else if (isOptional)
|
||||
{
|
||||
InfoErr<< "No region types" << nl;
|
||||
}
|
||||
}
|
||||
else if (optVerbose)
|
||||
{
|
||||
InfoErr << "Have " << regionProps.size();
|
||||
|
||||
if (doFiniteArea)
|
||||
{
|
||||
InfoErr<< " finite-area";
|
||||
}
|
||||
InfoErr
|
||||
<< "Have " << regionProps.size() << " region types, "
|
||||
<< " region types, "
|
||||
<< regionProps.count() << " regions" << nl << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We now handle checking args and general sanity etc.
|
||||
wordList regionTypes;
|
||||
|
||||
if (args.size() > 1)
|
||||
DynamicList<word> regionTypes;
|
||||
|
||||
if (isOptional && regionProps.empty())
|
||||
{
|
||||
regionTypes.resize(args.size()-1);
|
||||
// Nothing to do...
|
||||
}
|
||||
else if (nFilters > 0)
|
||||
{
|
||||
// Apply region filters
|
||||
|
||||
// No duplicates
|
||||
regionTypes.reserve_exact
|
||||
(
|
||||
Foam::min(nFilters, regionProps.size())
|
||||
);
|
||||
|
||||
// No duplicates, and no duplicate warnings
|
||||
wordHashSet uniq;
|
||||
|
||||
label nTypes = 0;
|
||||
for (label argi = 1; argi < args.size(); ++argi)
|
||||
{
|
||||
regionTypes[nTypes] = args[argi];
|
||||
|
||||
const word& regType = regionTypes[nTypes];
|
||||
word regType(args[argi]);
|
||||
|
||||
if (uniq.insert(regType))
|
||||
{
|
||||
if (regionProps.contains(regType))
|
||||
{
|
||||
++nTypes;
|
||||
if (!regionTypes.contains(regType))
|
||||
{
|
||||
regionTypes.push_back(std::move(regType));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -175,24 +200,24 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
regionTypes.resize(nTypes);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Take all regions
|
||||
regionTypes = regionProps.sortedToc();
|
||||
}
|
||||
|
||||
|
||||
for (const word& regionType : regionTypes)
|
||||
{
|
||||
const wordList& regionNames = regionProps[regionType];
|
||||
|
||||
for (const word& regionName : regionNames)
|
||||
if (const auto iter = regionProps.cfind(regionType); iter.good())
|
||||
{
|
||||
for (const word& regionName : iter.val())
|
||||
{
|
||||
Info<< regionName << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
138
bin/foamCleanFaMesh
Executable file
138
bin/foamCleanFaMesh
Executable file
@ -0,0 +1,138 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011 OpenFOAM Foundation
|
||||
# Copyright (C) 2025 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# Script
|
||||
# foamCleanFaMesh
|
||||
#
|
||||
# Description
|
||||
# Remove the contents of the constant/finite-area/faMesh directory
|
||||
# as per the Foam::faMesh::removeFiles() method.
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat <<USAGE
|
||||
|
||||
Usage: ${0##*/} [OPTION]
|
||||
options:
|
||||
-case <dir> case directory, default is the cwd
|
||||
-area-region <name> area-mesh region
|
||||
-dry-run | -n report actions but do not remove
|
||||
-help print the usage
|
||||
|
||||
Remove the contents of the constant/finite-area/faMesh directory as per the
|
||||
Foam::faMesh::removeFiles() method.
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Parse options
|
||||
unset caseDir areaRegion optDryRun
|
||||
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help*)
|
||||
usage
|
||||
;;
|
||||
-dry-run | -n)
|
||||
optDryRun="(dry-run) "
|
||||
;;
|
||||
|
||||
-case=*)
|
||||
caseDir="${1#*=}"
|
||||
;;
|
||||
|
||||
-case)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
||||
caseDir=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
-area-region)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
areaRegion=$2
|
||||
shift
|
||||
;;
|
||||
|
||||
(*)
|
||||
usage "unknown option/argument: '$*'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Remove files (mesh etc)
|
||||
# also remove .gz versions of the same files
|
||||
|
||||
removeFiles()
|
||||
{
|
||||
local directory="$1"
|
||||
|
||||
for i in \
|
||||
faceLabels \
|
||||
faBoundary \
|
||||
;
|
||||
do
|
||||
if [ -n "$optDryRun" ]
|
||||
then
|
||||
echo "${optDryRun} rm -rf $directory/{$i,$i.gz}"
|
||||
else
|
||||
rm -rf -- "$directory/$i" "$directory/$i.gz"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
meshDir="constant/finite-area/${areaRegion}${areaRegion:+/}faMesh"
|
||||
|
||||
if [ -d "$meshDir" ]
|
||||
then
|
||||
# [OK] has constant/finite-areaRegion/<region>/faMesh
|
||||
:
|
||||
|
||||
elif [ -n "$caseDir" ]
|
||||
then
|
||||
# Specified -case, so no extra magic...
|
||||
echo "Error: no <$meshDir> in $caseDir" 1>&2
|
||||
exit 1
|
||||
|
||||
else
|
||||
# Try some other combinations
|
||||
other="${meshDir#constant/}"
|
||||
|
||||
if [ -d "$other" ]
|
||||
then
|
||||
# Probably already within constant/
|
||||
meshDir="$other}"
|
||||
elif [ "${PWD##*/}" = faMesh ] && [ -z "$areaRegion" ]
|
||||
then
|
||||
# Apparently already within faMesh/
|
||||
meshDir=.
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo "Cleaning ${caseDir:-.}/$meshDir" 1>&2
|
||||
|
||||
removeFiles "$meshDir"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
@ -7,7 +7,7 @@
|
||||
# \\/ M anipulation |
|
||||
#-------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2022 OpenCFD Ltd.
|
||||
# Copyright (C) 2022,2025 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -27,8 +27,9 @@ usage() {
|
||||
|
||||
Usage: ${0##*/} [OPTION]
|
||||
options:
|
||||
-case <dir> specify alternative case directory, default is the cwd
|
||||
-region <name> specify alternative mesh region
|
||||
-case <dir> case directory, default is the cwd
|
||||
-region <name> mesh region
|
||||
-dry-run | -n report actions but do not remove
|
||||
-help print the usage
|
||||
|
||||
Remove the contents of the constant/polyMesh directory as per the
|
||||
@ -38,58 +39,101 @@ USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
unset caseDir regionName
|
||||
#------------------------------------------------------------------------------
|
||||
# Parse options
|
||||
unset caseDir regionName optDryRun
|
||||
|
||||
# Parse a single option
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help*)
|
||||
usage
|
||||
;;
|
||||
-dry-run | -n)
|
||||
optDryRun="(dry-run) "
|
||||
;;
|
||||
|
||||
-case=*)
|
||||
caseDir="${1#*=}"
|
||||
;;
|
||||
|
||||
-case)
|
||||
caseDir="$2"
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
|
||||
caseDir=$2
|
||||
shift 2
|
||||
shift
|
||||
;;
|
||||
|
||||
-region)
|
||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
||||
regionName=$2
|
||||
shift 2
|
||||
regionName="$2"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
|
||||
(*)
|
||||
usage "unknown option/argument: '$*'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
meshDir=polyMesh
|
||||
if [ -n "$regionName" ]
|
||||
then
|
||||
meshDir="$regionName/$meshDir"
|
||||
fi
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# If -case was specified: insist upon 'constant/polyMesh'
|
||||
if [ -n "$caseDir" ]
|
||||
then
|
||||
if [ -d constant/"$meshDir" ]
|
||||
# Remove files (mesh itself, modifiers, snappyHexMesh ones) and subdirectories
|
||||
# also remove .gz versions of the same files
|
||||
|
||||
removeFiles()
|
||||
{
|
||||
local directory="$1"
|
||||
|
||||
for i in \
|
||||
points faces \
|
||||
owner neighbour \
|
||||
boundary \
|
||||
cells \
|
||||
cellZones faceZones pointZones \
|
||||
meshModifiers \
|
||||
parallelData \
|
||||
sets \
|
||||
cellLevel pointLevel \
|
||||
level0Edge \
|
||||
refinementHistory \
|
||||
surfaceIndex \
|
||||
;
|
||||
do
|
||||
if [ -n "$optDryRun" ]
|
||||
then
|
||||
# Use constant/polyMesh
|
||||
meshDir=constant/"$meshDir"
|
||||
echo "${optDryRun} rm -rf $directory/{$i,$i.gz}"
|
||||
else
|
||||
echo "Error: no 'constant/$meshDir' in $caseDir" 1>&2
|
||||
exit 1
|
||||
rm -rf -- "$directory/$i" "$directory/$i.gz"
|
||||
fi
|
||||
else
|
||||
if [ -d constant/"$meshDir" ]
|
||||
then
|
||||
# Use constant/polyMesh
|
||||
meshDir=constant/"$meshDir"
|
||||
elif [ -d "$meshDir" ]
|
||||
then
|
||||
# Likely already in constant/ - do not adjust anything
|
||||
done
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
meshDir="constant/${regionName}${regionName:+/}polyMesh"
|
||||
|
||||
if [ -d "$meshDir" ]
|
||||
then
|
||||
# [OK] has constant/<region>/polyMesh
|
||||
:
|
||||
|
||||
elif [ -n "$caseDir" ]
|
||||
then
|
||||
# Specified -case, so no extra magic...
|
||||
echo "Error: no <$meshDir> in $caseDir" 1>&2
|
||||
exit 1
|
||||
|
||||
else
|
||||
# Try some other combinations
|
||||
other="${meshDir#constant/}"
|
||||
|
||||
if [ -d "$other" ]
|
||||
then
|
||||
# Probably already within constant/
|
||||
meshDir="$other}"
|
||||
elif [ "${PWD##*/}" = polyMesh ] && [ -z "$regionName" ]
|
||||
then
|
||||
# Apparently already within polyMesh/
|
||||
@ -98,31 +142,8 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# Remove files (mesh itself, modifiers, snappyHexMesh ones) and subdirectories
|
||||
# also remove .gz versions of the same files
|
||||
echo "Cleaning ${caseDir:-.}/$meshDir" 1>&2
|
||||
|
||||
for i in \
|
||||
points \
|
||||
faces \
|
||||
owner \
|
||||
neighbour \
|
||||
cells \
|
||||
boundary \
|
||||
pointZones \
|
||||
faceZones \
|
||||
cellZones \
|
||||
meshModifiers \
|
||||
parallelData \
|
||||
sets \
|
||||
cellLevel \
|
||||
pointLevel \
|
||||
level0Edge \
|
||||
refinementHistory \
|
||||
surfaceIndex \
|
||||
;
|
||||
do
|
||||
rm -rf "$meshDir/$i" "$meshDir/$i.gz"
|
||||
done
|
||||
removeFiles "$meshDir"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -108,54 +108,116 @@ cleanPostProcessing()
|
||||
}
|
||||
|
||||
|
||||
# ---------------
|
||||
# Remove constant/finite-area/faMesh or constant/finite-area/{region}/faMesh
|
||||
#
|
||||
# Accepts following options:
|
||||
# -region <name> The region name
|
||||
# -- End of options
|
||||
# ---------------
|
||||
cleanFaMesh()
|
||||
{
|
||||
if [ -e constant/finite-area/faMesh ]
|
||||
local region
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
('') ;; # Ignore empty option
|
||||
(--) shift; break ;; # Stop option parsing
|
||||
|
||||
(-region) region="$2"; shift ;;
|
||||
(*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# safety
|
||||
if [ "$region" = "--" ]; then unset region; fi
|
||||
|
||||
local meshDir="constant/finite-area/${region}${region:+/}faMesh"
|
||||
|
||||
if [ -e "$meshDir" ]
|
||||
then
|
||||
rm -rf constant/finite-area/faMesh
|
||||
[ -n "$region" ] && echo "Clearing $meshDir" 1>&2
|
||||
rm -rf -- "$meshDir"
|
||||
fi
|
||||
if [ -e constant/faMesh ]
|
||||
|
||||
# Legacy location <constant/faMesh>
|
||||
# - may still have remnant <constant/faMesh/faMeshDefinition>
|
||||
|
||||
meshDir="constant/faMesh"
|
||||
if [ -e "$meshDir" ] && [ -z "$region" ]
|
||||
then
|
||||
if [ -e constant/faMesh/faMeshDefinition ]
|
||||
if [ -e "$meshDir"/faMeshDefinition ]
|
||||
then
|
||||
# Old constant/faMesh location for faMeshDefinition still in use:
|
||||
# - warn but don't remove anything
|
||||
# VERY OLD LOCATION
|
||||
echo
|
||||
echo "Warning: not removing constant/faMesh/"
|
||||
echo "WARNING: not removing $meshDir/"
|
||||
echo " It contains a 'faMeshDefinition' file"
|
||||
echo " Please relocate file(s) to system/ !!"
|
||||
echo " Please relocate file(s) to system/finite-area/ !!"
|
||||
echo
|
||||
else
|
||||
# Can remove constant/faMesh/ entirely (no faMeshDefinition)
|
||||
rm -rf constant/faMesh
|
||||
echo "Clearing $meshDir" 1>&2
|
||||
rm -rf -- "$meshDir"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# ---------------
|
||||
# Remove constant/polyMesh or constant/<region>/polyMesh
|
||||
#
|
||||
# Accepts following options:
|
||||
# -region <name> The region name
|
||||
# -- End of options
|
||||
# ---------------
|
||||
cleanPolyMesh()
|
||||
{
|
||||
if [ -e constant/polyMesh ]
|
||||
local region
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
('') ;; # Ignore empty option
|
||||
(--) shift; break ;; # Stop option parsing
|
||||
|
||||
(-region) region="$2"; shift ;;
|
||||
(*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# safety
|
||||
if [ "$region" = "--" ]; then unset region; fi
|
||||
|
||||
local meshDir="constant/${region}${region:+/}polyMesh"
|
||||
|
||||
if [ -e "$meshDir" ]
|
||||
then
|
||||
if [ -e constant/polyMesh/blockMeshDict ] \
|
||||
|| [ -e constant/polyMesh/blockMeshDict.m4 ]
|
||||
[ -n "$region" ] && echo "Clearing $meshDir" 1>&2
|
||||
|
||||
if [ -e "$meshDir"/blockMeshDict ] \
|
||||
|| [ -e "$meshDir"/blockMeshDict.m4 ]
|
||||
then
|
||||
# Old constant/polyMesh location for blockMeshDict still in use:
|
||||
# - warn but don't remove anything
|
||||
# VERY OLD LOCATION
|
||||
echo
|
||||
echo "Warning: not removing constant/polyMesh/"
|
||||
echo "WARNING: not removing $meshDir/"
|
||||
echo " It contains a 'blockMeshDict' or 'blockMeshDict.m4' file"
|
||||
echo " Please relocate file(s) to system/ !!"
|
||||
echo
|
||||
else
|
||||
# Can remove constant/polyMesh/ entirely (no blockMeshDict)
|
||||
rm -rf constant/polyMesh
|
||||
rm -rf -- "$meshDir"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e system/blockMeshDict.m4 ]
|
||||
meshDir="system${region:+/}${region}"
|
||||
if [ -e "$meshDir"/blockMeshDict.m4 ]
|
||||
then
|
||||
rm -f system/blockMeshDict
|
||||
rm -f -- "$meshDir"/blockMeshDict
|
||||
fi
|
||||
}
|
||||
|
||||
@ -212,7 +274,7 @@ cleanCase0()
|
||||
removeCase()
|
||||
{
|
||||
echo "Removing case ${1:-unknown}"
|
||||
[ "$#" -ge 1 ] && rm -rf "$1"
|
||||
[ "$#" -ge 1 ] && rm -rf -- "$1"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -517,9 +517,11 @@ cloneParallelCase()
|
||||
}
|
||||
|
||||
|
||||
# ---------------
|
||||
# If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case]
|
||||
# * -processor : copy into processor directories instead
|
||||
# * -all : copy into serial and processor directories
|
||||
# ---------------
|
||||
restore0Dir()
|
||||
{
|
||||
if [ ! -d 0.orig ]
|
||||
@ -553,4 +555,61 @@ restore0Dir()
|
||||
}
|
||||
|
||||
|
||||
# ---------------
|
||||
# Helper routine to remove specified fields from the 0/ directory.
|
||||
# Often used in combination with foamListRegions.
|
||||
#
|
||||
# Accepts following options:
|
||||
# -region <name> The region name
|
||||
# -- End of options
|
||||
#
|
||||
# any remaining parameters are taken to be fields names
|
||||
# ---------------
|
||||
remove0DirFields()
|
||||
{
|
||||
local region
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
('') ;; # Ignore empty option
|
||||
(--) shift; break ;; # Stop option parsing
|
||||
|
||||
(-region) region="$2"; shift ;;
|
||||
(*) break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# safety
|
||||
if [ "$region" = "--" ]; then unset region; fi
|
||||
|
||||
if [ "$#" -eq 0 ]
|
||||
then
|
||||
echo "No fields specified for ${region:+region=$region }" 1>&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Remove 0/ fields${region:+ [$region]} : $@" 1>&2
|
||||
|
||||
local subdir
|
||||
for subdir in 0/"$region" processor*/0/"$region"
|
||||
do
|
||||
if [ -d "$subdir" ]
|
||||
then
|
||||
for field in $@ ## unquoted for IFS splitting [SIC]
|
||||
do
|
||||
# Cautious with removal
|
||||
if [ -f "$subdir/$field" ]
|
||||
then
|
||||
rm -f -- "$subdir/$field"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -140,6 +140,11 @@ _of_complete_()
|
||||
# Could use "foamListTimes -withZero", but still doesn't address ranges
|
||||
COMPREPLY=($(compgen -d -X '![-0-9]*' -- ${cur}))
|
||||
;;
|
||||
-area-region)
|
||||
# Or: $(find system/finite-area -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -e 's%.*/%%')
|
||||
choices=$(\ls -d system/finite-area/*/ 2>/dev/null | sed -e 's%/$%%; s%^.*/%%')
|
||||
COMPREPLY=($(compgen -W "$choices" -- ${cur}))
|
||||
;;
|
||||
-region)
|
||||
# Or: $(find system -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -e 's%.*/%%')
|
||||
choices=$(\ls -d system/*/ 2>/dev/null | sed -e 's%/$%%; s%^.*/%%')
|
||||
|
||||
@ -351,7 +351,8 @@ $(vtk)/topoSet/foamVtkWriteFaceSet.C
|
||||
$(vtk)/topoSet/foamVtkWritePointSet.C
|
||||
$(vtk)/topoSet/foamVtkWriteCellSetFaces.C
|
||||
|
||||
regionModel/regionProperties/regionProperties.C
|
||||
regionModel/regionProperties/regionProperties.cxx
|
||||
regionModel/regionProperties/regionModelProperties.cxx
|
||||
|
||||
tetOverlapVolume/tetOverlapVolume.C
|
||||
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2025 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "regionProperties.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
// The enable/disable flag for allowFaModels()
|
||||
static bool allowFaModels_ = true;
|
||||
|
||||
bool Foam::regionModels::allowFaModels() noexcept
|
||||
{
|
||||
return allowFaModels_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::regionModels::allowFaModels(bool on) noexcept
|
||||
{
|
||||
bool old(allowFaModels_);
|
||||
allowFaModels_ = on;
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -46,18 +46,39 @@ Description
|
||||
\endverbatim
|
||||
|
||||
SourceFiles
|
||||
regionProperties.C
|
||||
regionProperties.cxx
|
||||
regionModelProperties.cxx
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef Foam_regionProperties_H
|
||||
#define Foam_regionProperties_H
|
||||
|
||||
#include "HashTable.H"
|
||||
#include "fileName.H"
|
||||
#include "wordList.H"
|
||||
#include "HashTable.H"
|
||||
#include "IOobjectOption.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// General controls
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace regionModels
|
||||
{
|
||||
|
||||
//- The enable/disable state for regionFaModel (default: true)
|
||||
bool allowFaModels() noexcept;
|
||||
|
||||
//- Set enable/disable state for regionFaModel
|
||||
// \return previous state
|
||||
bool allowFaModels(bool on) noexcept;
|
||||
|
||||
} // End namespace regionModels
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -119,6 +140,17 @@ public:
|
||||
~regionProperties() = default;
|
||||
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- The expected search path (eg, constant/regionProperties).
|
||||
// Can be useful when generation error messages
|
||||
static fileName objectRelPath
|
||||
(
|
||||
const Time& runTime,
|
||||
const fileName& local = fileName::null
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Total count of all region names.
|
||||
|
||||
@ -31,6 +31,21 @@ License
|
||||
#include "Time.H"
|
||||
#include "wordRes.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::regionProperties::objectRelPath
|
||||
(
|
||||
const Time& runTime,
|
||||
const fileName& local
|
||||
)
|
||||
{
|
||||
return
|
||||
(
|
||||
runTime.time().constant()/local/"regionProperties"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::regionProperties::regionProperties
|
||||
@ -56,6 +71,18 @@ Foam::regionProperties::regionProperties
|
||||
)
|
||||
);
|
||||
|
||||
// For optional reading:
|
||||
// - applies to the file and its overall contents.
|
||||
// - if read and has content, "regions" becomes mandatory
|
||||
|
||||
if (IOobjectOption::isReadOptional(rOpt))
|
||||
{
|
||||
if (iodict.hasHeaderClass() && !iodict.empty())
|
||||
{
|
||||
rOpt = IOobjectOption::MUST_READ;
|
||||
}
|
||||
}
|
||||
|
||||
iodict.readEntry("regions", props, keyType::LITERAL, rOpt);
|
||||
}
|
||||
|
||||
@ -13,10 +13,11 @@ restore0Dir
|
||||
runApplication splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="nut alphat epsilon k U p_rgh"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
@ -12,10 +12,11 @@ restore0Dir
|
||||
runApplication splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="nut alphat epsilon k U p_rgh"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
@ -11,10 +11,11 @@ runApplication splitMeshRegions -cellZones -overwrite
|
||||
rm -rf 0/domain3 constant/domain3 system/domain3
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="rho nut alphat epsilon k U p_rgh qr G IDefault"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/$region/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
|
||||
rm -f processor*/0/$region/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
# Set the initial fields
|
||||
|
||||
@ -12,10 +12,11 @@ restore0Dir
|
||||
runApplication splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="nut alphat epsilon k U p_rgh"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
@ -26,10 +26,11 @@ restore0Dir -processor
|
||||
runParallel $decompDict splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="nut alphat epsilon k U p_rgh"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
rm -f processor*/0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
@ -21,10 +21,11 @@ restore0Dir
|
||||
runApplication splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="nut alphat epsilon k U p_rgh"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
rm -f processor*/0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
@ -32,10 +32,11 @@ restore0Dir -processor
|
||||
runParallel $decompDict splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="nut alphat epsilon k U p_rgh"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
@ -13,10 +13,11 @@ runApplication splitMeshRegions -cellZones -overwrite
|
||||
rm -rf 0/domain3 constant/domain3 system/domain3
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="rho nut alphat epsilon k U p_rgh qr G IDefault"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
|
||||
rm -f processor*/0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
# Set the initial fields
|
||||
|
||||
@ -13,10 +13,11 @@ restore0Dir
|
||||
runApplication splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="nut alphat epsilon k U p_rgh"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
rm -f processor*/0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
@ -13,10 +13,11 @@ restore0Dir
|
||||
runApplication splitMeshRegions -cellZones -overwrite
|
||||
|
||||
# Remove fluid fields from solid regions (important for post-processing)
|
||||
fields="rho nut alphat epsilon k U p_rgh qr G IDefault"
|
||||
|
||||
for region in $(foamListRegions solid)
|
||||
do
|
||||
rm -f 0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
|
||||
rm -f processor*/0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
|
||||
remove0DirFields -region "$region" -- $fields
|
||||
done
|
||||
|
||||
for region in $(foamListRegions)
|
||||
|
||||
Reference in New Issue
Block a user