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:
Mark Olesen
2025-10-09 23:58:44 +02:00
committed by Andrew Heather
parent ccb57c0499
commit c7b5f1e3eb
20 changed files with 571 additions and 142 deletions

View File

@ -30,7 +30,8 @@ Group
grpPostProcessingUtilities grpPostProcessingUtilities
Description Description
List regions from constant/regionProperties. List volume regions from constant/regionProperties
or area regions from constant/finite-area/regionProperties
Usage Usage
\b foamListRegions [OPTION] \b foamListRegions [OPTION]
@ -72,6 +73,12 @@ int main(int argc, char *argv[])
"List constant/finite-area/regionProperties (if available)" "List constant/finite-area/regionProperties (if available)"
); );
argList::addBoolOption
(
"optional",
"A missing regionProperties is not treated as an error"
);
argList::addDryRunOption argList::addDryRunOption
( (
"Make reading optional and add verbosity" "Make reading optional and add verbosity"
@ -92,14 +99,20 @@ int main(int argc, char *argv[])
++optVerbose; ++optVerbose;
} }
// File is optional, not an error
const bool isOptional = args.found("optional");
// Use finite-area regions // Use finite-area regions
const bool doFiniteArea = args.found("finite-area"); 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); 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; readOpt = IOobjectOption::READ_IF_PRESENT;
} }
@ -116,58 +129,70 @@ int main(int argc, char *argv[])
if (doFiniteArea) if (doFiniteArea)
{ {
regionProps = regionProperties(runTime, faMeshPrefix, readOpt); 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 else
{ {
regionProps = regionProperties(runTime, readOpt); regionProps = regionProperties(runTime, readOpt);
if (regionProps.empty())
{
// Probably only occurs with -dry-run option
InfoErr<< "No region types" << nl;
}
else if (optVerbose)
{
InfoErr
<< "Have " << regionProps.size() << " region types, "
<< regionProps.count() << " regions" << nl << nl;
}
} }
// We now handle checking args and general sanity etc. // Some reporting...
wordList regionTypes; if (regionProps.empty())
if (args.size() > 1)
{ {
regionTypes.resize(args.size()-1); if (doFiniteArea)
{
InfoErr<< "No finite-area region types" << nl;
}
else if (isOptional)
{
InfoErr<< "No region types" << nl;
}
}
else if (optVerbose)
{
InfoErr << "Have " << regionProps.size();
// No duplicates if (doFiniteArea)
{
InfoErr<< " finite-area";
}
InfoErr
<< " region types, "
<< regionProps.count() << " regions" << nl << nl;
}
// We now handle checking args and general sanity etc.
DynamicList<word> regionTypes;
if (isOptional && regionProps.empty())
{
// Nothing to do...
}
else if (nFilters > 0)
{
// Apply region filters
regionTypes.reserve_exact
(
Foam::min(nFilters, regionProps.size())
);
// No duplicates, and no duplicate warnings
wordHashSet uniq; wordHashSet uniq;
label nTypes = 0;
for (label argi = 1; argi < args.size(); ++argi) for (label argi = 1; argi < args.size(); ++argi)
{ {
regionTypes[nTypes] = args[argi]; word regType(args[argi]);
const word& regType = regionTypes[nTypes];
if (uniq.insert(regType)) if (uniq.insert(regType))
{ {
if (regionProps.contains(regType)) if (regionProps.contains(regType))
{ {
++nTypes; if (!regionTypes.contains(regType))
{
regionTypes.push_back(std::move(regType));
}
} }
else else
{ {
@ -175,22 +200,22 @@ int main(int argc, char *argv[])
} }
} }
} }
regionTypes.resize(nTypes);
} }
else else
{ {
// Take all regions
regionTypes = regionProps.sortedToc(); regionTypes = regionProps.sortedToc();
} }
for (const word& regionType : regionTypes) for (const word& regionType : regionTypes)
{ {
const wordList& regionNames = regionProps[regionType]; if (const auto iter = regionProps.cfind(regionType); iter.good())
for (const word& regionName : regionNames)
{ {
Info<< regionName << nl; for (const word& regionName : iter.val())
{
Info<< regionName << nl;
}
} }
} }

138
bin/foamCleanFaMesh Executable file
View 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"
#------------------------------------------------------------------------------

View File

@ -7,7 +7,7 @@
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2022 OpenCFD Ltd. # Copyright (C) 2022,2025 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -27,9 +27,10 @@ usage() {
Usage: ${0##*/} [OPTION] Usage: ${0##*/} [OPTION]
options: options:
-case <dir> specify alternative case directory, default is the cwd -case <dir> case directory, default is the cwd
-region <name> specify alternative mesh region -region <name> mesh region
-help print the usage -dry-run | -n report actions but do not remove
-help print the usage
Remove the contents of the constant/polyMesh directory as per the Remove the contents of the constant/polyMesh directory as per the
Foam::polyMesh::removeFiles() method. Foam::polyMesh::removeFiles() method.
@ -38,58 +39,101 @@ USAGE
exit 1 exit 1
} }
unset caseDir regionName #------------------------------------------------------------------------------
# Parse options
unset caseDir regionName optDryRun
# Parse a single option
while [ "$#" -gt 0 ] while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-h | -help*) -h | -help*)
usage usage
;; ;;
-dry-run | -n)
optDryRun="(dry-run) "
;;
-case=*)
caseDir="${1#*=}"
;;
-case) -case)
caseDir="$2"
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
cd "$2" 2>/dev/null || usage "directory does not exist: '$2'" cd "$2" 2>/dev/null || usage "directory does not exist: '$2'"
caseDir=$2 caseDir=$2
shift 2 shift
;; ;;
-region) -region)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
regionName=$2 regionName="$2"
shift 2 shift
;; ;;
*)
(*)
usage "unknown option/argument: '$*'" usage "unknown option/argument: '$*'"
;; ;;
esac esac
shift
done done
meshDir=polyMesh #------------------------------------------------------------------------------
if [ -n "$regionName" ]
then
meshDir="$regionName/$meshDir"
fi
# If -case was specified: insist upon 'constant/polyMesh' # Remove files (mesh itself, modifiers, snappyHexMesh ones) and subdirectories
if [ -n "$caseDir" ] # 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
echo "${optDryRun} rm -rf $directory/{$i,$i.gz}"
else
rm -rf -- "$directory/$i" "$directory/$i.gz"
fi
done
}
#------------------------------------------------------------------------------
meshDir="constant/${regionName}${regionName:+/}polyMesh"
if [ -d "$meshDir" ]
then then
if [ -d constant/"$meshDir" ] # [OK] has constant/<region>/polyMesh
then :
# Use constant/polyMesh
meshDir=constant/"$meshDir" elif [ -n "$caseDir" ]
else then
echo "Error: no 'constant/$meshDir' in $caseDir" 1>&2 # Specified -case, so no extra magic...
exit 1 echo "Error: no <$meshDir> in $caseDir" 1>&2
fi exit 1
else else
if [ -d constant/"$meshDir" ] # Try some other combinations
other="${meshDir#constant/}"
if [ -d "$other" ]
then then
# Use constant/polyMesh # Probably already within constant/
meshDir=constant/"$meshDir" meshDir="$other}"
elif [ -d "$meshDir" ]
then
# Likely already in constant/ - do not adjust anything
:
elif [ "${PWD##*/}" = polyMesh ] && [ -z "$regionName" ] elif [ "${PWD##*/}" = polyMesh ] && [ -z "$regionName" ]
then then
# Apparently already within polyMesh/ # Apparently already within polyMesh/
@ -98,31 +142,8 @@ else
fi fi
# Remove files (mesh itself, modifiers, snappyHexMesh ones) and subdirectories
# also remove .gz versions of the same files
echo "Cleaning ${caseDir:-.}/$meshDir" 1>&2 echo "Cleaning ${caseDir:-.}/$meshDir" 1>&2
for i in \ removeFiles "$meshDir"
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
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -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() 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 then
rm -rf constant/finite-area/faMesh [ -n "$region" ] && echo "Clearing $meshDir" 1>&2
rm -rf -- "$meshDir"
fi 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 then
if [ -e constant/faMesh/faMeshDefinition ] if [ -e "$meshDir"/faMeshDefinition ]
then then
# Old constant/faMesh location for faMeshDefinition still in use: # VERY OLD LOCATION
# - warn but don't remove anything
echo echo
echo "Warning: not removing constant/faMesh/" echo "WARNING: not removing $meshDir/"
echo " It contains a 'faMeshDefinition' file" echo " It contains a 'faMeshDefinition' file"
echo " Please relocate file(s) to system/ !!" echo " Please relocate file(s) to system/finite-area/ !!"
echo echo
else else
# Can remove constant/faMesh/ entirely (no faMeshDefinition) # Can remove constant/faMesh/ entirely (no faMeshDefinition)
rm -rf constant/faMesh echo "Clearing $meshDir" 1>&2
rm -rf -- "$meshDir"
fi fi
fi fi
} }
# ---------------
# Remove constant/polyMesh or constant/<region>/polyMesh
#
# Accepts following options:
# -region <name> The region name
# -- End of options
# ---------------
cleanPolyMesh() 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 then
if [ -e constant/polyMesh/blockMeshDict ] \ [ -n "$region" ] && echo "Clearing $meshDir" 1>&2
|| [ -e constant/polyMesh/blockMeshDict.m4 ]
if [ -e "$meshDir"/blockMeshDict ] \
|| [ -e "$meshDir"/blockMeshDict.m4 ]
then then
# Old constant/polyMesh location for blockMeshDict still in use: # VERY OLD LOCATION
# - warn but don't remove anything
echo echo
echo "Warning: not removing constant/polyMesh/" echo "WARNING: not removing $meshDir/"
echo " It contains a 'blockMeshDict' or 'blockMeshDict.m4' file" echo " It contains a 'blockMeshDict' or 'blockMeshDict.m4' file"
echo " Please relocate file(s) to system/ !!" echo " Please relocate file(s) to system/ !!"
echo echo
else else
# Can remove constant/polyMesh/ entirely (no blockMeshDict) # Can remove constant/polyMesh/ entirely (no blockMeshDict)
rm -rf constant/polyMesh rm -rf -- "$meshDir"
fi fi
fi fi
if [ -e system/blockMeshDict.m4 ] meshDir="system${region:+/}${region}"
if [ -e "$meshDir"/blockMeshDict.m4 ]
then then
rm -f system/blockMeshDict rm -f -- "$meshDir"/blockMeshDict
fi fi
} }
@ -212,7 +274,7 @@ cleanCase0()
removeCase() removeCase()
{ {
echo "Removing case ${1:-unknown}" echo "Removing case ${1:-unknown}"
[ "$#" -ge 1 ] && rm -rf "$1" [ "$#" -ge 1 ] && rm -rf -- "$1"
} }

View File

@ -517,9 +517,11 @@ cloneParallelCase()
} }
# ---------------
# If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case] # If 0.orig/ exists, copy (overwrite) into 0/ [ie, serial case]
# * -processor : copy into processor directories instead # * -processor : copy into processor directories instead
# * -all : copy into serial and processor directories # * -all : copy into serial and processor directories
# ---------------
restore0Dir() restore0Dir()
{ {
if [ ! -d 0.orig ] 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
}
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -140,6 +140,11 @@ _of_complete_()
# Could use "foamListTimes -withZero", but still doesn't address ranges # Could use "foamListTimes -withZero", but still doesn't address ranges
COMPREPLY=($(compgen -d -X '![-0-9]*' -- ${cur})) 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) -region)
# Or: $(find system -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed -e 's%.*/%%') # 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%^.*/%%') choices=$(\ls -d system/*/ 2>/dev/null | sed -e 's%/$%%; s%^.*/%%')

View File

@ -351,7 +351,8 @@ $(vtk)/topoSet/foamVtkWriteFaceSet.C
$(vtk)/topoSet/foamVtkWritePointSet.C $(vtk)/topoSet/foamVtkWritePointSet.C
$(vtk)/topoSet/foamVtkWriteCellSetFaces.C $(vtk)/topoSet/foamVtkWriteCellSetFaces.C
regionModel/regionProperties/regionProperties.C regionModel/regionProperties/regionProperties.cxx
regionModel/regionProperties/regionModelProperties.cxx
tetOverlapVolume/tetOverlapVolume.C tetOverlapVolume/tetOverlapVolume.C

View File

@ -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;
}
// ************************************************************************* //

View File

@ -46,18 +46,39 @@ Description
\endverbatim \endverbatim
SourceFiles SourceFiles
regionProperties.C regionProperties.cxx
regionModelProperties.cxx
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef Foam_regionProperties_H #ifndef Foam_regionProperties_H
#define Foam_regionProperties_H #define Foam_regionProperties_H
#include "HashTable.H"
#include "fileName.H" #include "fileName.H"
#include "wordList.H" #include "wordList.H"
#include "HashTable.H"
#include "IOobjectOption.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 namespace Foam
@ -119,6 +140,17 @@ public:
~regionProperties() = default; ~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 // Member Functions
//- Total count of all region names. //- Total count of all region names.

View File

@ -31,6 +31,21 @@ License
#include "Time.H" #include "Time.H"
#include "wordRes.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 * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regionProperties::regionProperties 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); iodict.readEntry("regions", props, keyType::LITERAL, rOpt);
} }

View File

@ -13,10 +13,11 @@ restore0Dir
runApplication splitMeshRegions -cellZones -overwrite runApplication splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # Remove fluid fields from solid regions (important for post-processing)
fields="nut alphat epsilon k U p_rgh"
for region in $(foamListRegions solid) for region in $(foamListRegions solid)
do do
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
done done
for region in $(foamListRegions) for region in $(foamListRegions)

View File

@ -12,10 +12,11 @@ restore0Dir
runApplication splitMeshRegions -cellZones -overwrite runApplication splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # Remove fluid fields from solid regions (important for post-processing)
fields="nut alphat epsilon k U p_rgh"
for region in $(foamListRegions solid) for region in $(foamListRegions solid)
do do
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
done done
for region in $(foamListRegions) for region in $(foamListRegions)

View File

@ -11,10 +11,11 @@ runApplication splitMeshRegions -cellZones -overwrite
rm -rf 0/domain3 constant/domain3 system/domain3 rm -rf 0/domain3 constant/domain3 system/domain3
# Remove fluid fields from solid regions (important for post-processing) # 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) for region in $(foamListRegions solid)
do do
rm -f 0/$region/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/$region/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
done done
# Set the initial fields # Set the initial fields

View File

@ -12,10 +12,11 @@ restore0Dir
runApplication splitMeshRegions -cellZones -overwrite runApplication splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # Remove fluid fields from solid regions (important for post-processing)
fields="nut alphat epsilon k U p_rgh"
for region in $(foamListRegions solid) for region in $(foamListRegions solid)
do do
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
done done
for region in $(foamListRegions) for region in $(foamListRegions)

View File

@ -26,10 +26,11 @@ restore0Dir -processor
runParallel $decompDict splitMeshRegions -cellZones -overwrite runParallel $decompDict splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # Remove fluid fields from solid regions (important for post-processing)
fields="nut alphat epsilon k U p_rgh"
for region in $(foamListRegions solid) for region in $(foamListRegions solid)
do do
rm -f 0/"$region"/{nut,alphat,epsilon,k,U,p_rgh} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
done done
for region in $(foamListRegions) for region in $(foamListRegions)

View File

@ -21,10 +21,11 @@ restore0Dir
runApplication splitMeshRegions -cellZones -overwrite runApplication splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # Remove fluid fields from solid regions (important for post-processing)
fields="nut alphat epsilon k U p_rgh"
for region in $(foamListRegions solid) for region in $(foamListRegions solid)
do do
rm -f 0/"$region"/{nut,alphat,epsilon,k,U,p_rgh} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
done done
for region in $(foamListRegions) for region in $(foamListRegions)

View File

@ -32,10 +32,11 @@ restore0Dir -processor
runParallel $decompDict splitMeshRegions -cellZones -overwrite runParallel $decompDict splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # Remove fluid fields from solid regions (important for post-processing)
fields="nut alphat epsilon k U p_rgh"
for region in $(foamListRegions solid) for region in $(foamListRegions solid)
do do
rm -f 0/$region/{nut,alphat,epsilon,k,U,p_rgh} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/$region/{nut,alphat,epsilon,k,U,p_rgh}
done done
for region in $(foamListRegions) for region in $(foamListRegions)

View File

@ -13,10 +13,11 @@ runApplication splitMeshRegions -cellZones -overwrite
rm -rf 0/domain3 constant/domain3 system/domain3 rm -rf 0/domain3 constant/domain3 system/domain3
# Remove fluid fields from solid regions (important for post-processing) # 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) for region in $(foamListRegions solid)
do do
rm -f 0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
done done
# Set the initial fields # Set the initial fields

View File

@ -13,10 +13,11 @@ restore0Dir
runApplication splitMeshRegions -cellZones -overwrite runApplication splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # Remove fluid fields from solid regions (important for post-processing)
fields="nut alphat epsilon k U p_rgh"
for region in $(foamListRegions solid) for region in $(foamListRegions solid)
do do
rm -f 0/"$region"/{nut,alphat,epsilon,k,U,p_rgh} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/"$region"/{nut,alphat,epsilon,k,U,p_rgh}
done done
for region in $(foamListRegions) for region in $(foamListRegions)

View File

@ -13,10 +13,11 @@ restore0Dir
runApplication splitMeshRegions -cellZones -overwrite runApplication splitMeshRegions -cellZones -overwrite
# Remove fluid fields from solid regions (important for post-processing) # 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) for region in $(foamListRegions solid)
do do
rm -f 0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault} remove0DirFields -region "$region" -- $fields
rm -f processor*/0/"$region"/{rho,nut,alphat,epsilon,k,U,p_rgh,qr,G,IDefault}
done done
for region in $(foamListRegions) for region in $(foamListRegions)