mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: subsetMesh -exclude-patches (#2947)
STYLE: use -exclude-patches instead of -excludePatch for other utilities - avoids inconsistencies with utilities like foamToVTK etc.
This commit is contained in:
@ -70,7 +70,7 @@ label getExposedPatchId(const polyMesh& mesh, const word& patchName)
|
|||||||
|
|
||||||
Info<< "Adding exposed internal faces to "
|
Info<< "Adding exposed internal faces to "
|
||||||
<< (patchId == -1 ? "new" : "existing")
|
<< (patchId == -1 ? "new" : "existing")
|
||||||
<< " patch \"" << patchName << "\"" << nl << endl;
|
<< " patch: " << patchName << nl << endl;
|
||||||
|
|
||||||
return patchId;
|
return patchId;
|
||||||
}
|
}
|
||||||
@ -357,6 +357,12 @@ int main(int argc, char *argv[])
|
|||||||
"Add exposed internal faces to closest of specified patches"
|
"Add exposed internal faces to closest of specified patches"
|
||||||
" instead of \"oldInternalFaces\""
|
" instead of \"oldInternalFaces\""
|
||||||
);
|
);
|
||||||
|
argList::addOption
|
||||||
|
(
|
||||||
|
"exclude-patches",
|
||||||
|
"wordRes",
|
||||||
|
"Exclude single or multiple patches from the -patches selection"
|
||||||
|
);
|
||||||
argList::addBoolOption
|
argList::addBoolOption
|
||||||
(
|
(
|
||||||
"zone",
|
"zone",
|
||||||
@ -400,53 +406,60 @@ int main(int argc, char *argv[])
|
|||||||
// Default exposed patch id
|
// Default exposed patch id
|
||||||
labelList exposedPatchIDs(one{}, -1);
|
labelList exposedPatchIDs(one{}, -1);
|
||||||
|
|
||||||
if (args.found("patches"))
|
wordRes includePatches, excludePatches;
|
||||||
{
|
|
||||||
const wordRes patchNames(args.getList<wordRe>("patches"));
|
|
||||||
|
|
||||||
if (patchNames.size() == 1 && patchNames.front().isLiteral())
|
if (!args.readListIfPresent<wordRe>("patches", includePatches))
|
||||||
{
|
{
|
||||||
exposedPatchIDs.front() =
|
if (args.found("patch"))
|
||||||
getExposedPatchId(mesh, patchNames.front());
|
{
|
||||||
|
includePatches.resize(1);
|
||||||
|
includePatches.front() = args.get<word>("patch");
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
args.readListIfPresent<wordRe>("exclude-patches", excludePatches);
|
||||||
|
|
||||||
|
if (includePatches.size() == 1 && includePatches.front().isLiteral())
|
||||||
{
|
{
|
||||||
// Patches selected
|
// Select a single patch - no exclude possible
|
||||||
labelHashSet patchIds
|
exposedPatchIDs.front() =
|
||||||
(
|
getExposedPatchId(mesh, includePatches.front());
|
||||||
mesh.boundaryMesh().patchSet(patchNames)
|
}
|
||||||
);
|
else if (!includePatches.empty())
|
||||||
|
{
|
||||||
|
// Patches selected (sorted order)
|
||||||
|
exposedPatchIDs =
|
||||||
|
mesh.boundaryMesh().indices(includePatches, excludePatches);
|
||||||
|
|
||||||
// Only retain initial, non-processor patches
|
// Only retain initial, non-processor patches
|
||||||
label nNonProcessor
|
const label nNonProcessor
|
||||||
(
|
(
|
||||||
mesh.boundaryMesh().nNonProcessor()
|
mesh.boundaryMesh().nNonProcessor()
|
||||||
);
|
);
|
||||||
|
|
||||||
patchIds.filterKeys
|
forAll(exposedPatchIDs, i)
|
||||||
(
|
{
|
||||||
[=](label patchi) { return (patchi < nNonProcessor); }
|
if (exposedPatchIDs[i] > nNonProcessor)
|
||||||
);
|
{
|
||||||
|
exposedPatchIDs.resize(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exposedPatchIDs = patchIds.sortedToc();
|
const wordList allPatchNames(mesh.boundaryMesh().names());
|
||||||
|
|
||||||
Info<< "Adding exposed internal faces to nearest of patches "
|
Info<< "Adding exposed internal faces to nearest of patches:" << nl
|
||||||
<< flatOutput(patchNames) << nl << endl;
|
<< " include: " << flatOutput(includePatches) << nl
|
||||||
|
<< " exclude: " << flatOutput(excludePatches) << nl
|
||||||
|
<< nl;
|
||||||
|
|
||||||
if (exposedPatchIDs.empty())
|
if (exposedPatchIDs.empty())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< nl << "No patches matched. Patches: "
|
<< nl << "No patches matched. Patches: "
|
||||||
<< flatOutput(mesh.boundaryMesh().names()) << nl
|
<< flatOutput(allPatchNames) << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (args.found("patch"))
|
|
||||||
{
|
|
||||||
exposedPatchIDs.front() =
|
|
||||||
getExposedPatchId(mesh, args.get<word>("patch"));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< "Adding exposed internal faces to patch \""
|
Info<< "Adding exposed internal faces to patch \""
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -145,12 +145,13 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
argList::addOption
|
argList::addOption
|
||||||
(
|
(
|
||||||
"excludePatches",
|
"exclude-patches",
|
||||||
"wordRes",
|
"wordRes",
|
||||||
"Specify single patch or multiple patches to exclude from writing."
|
"Specify single patch or multiple patches to exclude from -patches."
|
||||||
" Eg, 'outlet' or '( inlet \".*Wall\" )'",
|
" Eg, 'outlet' or '( inlet \".*Wall\" )'",
|
||||||
true // mark as an advanced option
|
true // mark as an advanced option
|
||||||
);
|
);
|
||||||
|
argList::addOptionCompat("exclude-patches", {"excludePatches", 2306});
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
@ -167,16 +168,13 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Extracting surface from boundaryMesh ..." << nl << nl;
|
Info<< "Extracting surface from boundaryMesh ..." << nl << nl;
|
||||||
|
|
||||||
const bool includeProcPatches =
|
const bool includeProcPatches =
|
||||||
!(
|
(!UPstream::parRun() && !args.found("excludeProcPatches"));
|
||||||
args.found("excludeProcPatches")
|
|
||||||
|| Pstream::parRun()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (includeProcPatches)
|
if (includeProcPatches)
|
||||||
{
|
{
|
||||||
Info<< "Including all processor patches." << nl << endl;
|
Info<< "Including all processor patches." << nl << endl;
|
||||||
}
|
}
|
||||||
else if (Pstream::parRun())
|
else if (UPstream::parRun())
|
||||||
{
|
{
|
||||||
Info<< "Excluding all processor patches." << nl << endl;
|
Info<< "Excluding all processor patches." << nl << endl;
|
||||||
}
|
}
|
||||||
@ -187,7 +185,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Including patches " << flatOutput(includePatches)
|
Info<< "Including patches " << flatOutput(includePatches)
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
}
|
}
|
||||||
if (args.readListIfPresent<wordRe>("excludePatches", excludePatches))
|
if (args.readListIfPresent<wordRe>("exclude-patches", excludePatches))
|
||||||
{
|
{
|
||||||
Info<< "Excluding patches " << flatOutput(excludePatches)
|
Info<< "Excluding patches " << flatOutput(excludePatches)
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -45,11 +45,11 @@ Usage
|
|||||||
-patches '( front \".*back\" )'
|
-patches '( front \".*back\" )'
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
- \par -excludePatches NAME | LIST
|
- \par -exclude-patches NAME | LIST
|
||||||
Exclude single or multiple patches (name or regex) from extracting.
|
Exclude single or multiple patches (name or regex) from extracting.
|
||||||
For example,
|
For example,
|
||||||
\verbatim
|
\verbatim
|
||||||
-excludePatches '( inlet_1 inlet_2 "proc.*")'
|
-exclude-patches '( inlet_1 inlet_2 "proc.*" )'
|
||||||
\endverbatim
|
\endverbatim
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -79,11 +79,12 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
argList::addOption
|
argList::addOption
|
||||||
(
|
(
|
||||||
"excludePatches",
|
"exclude-patches",
|
||||||
"wordRes",
|
"wordRes",
|
||||||
"Exclude single or multiple patches (name or regex) from extracting.\n"
|
"Exclude single or multiple patches (name or regex) from extracting.\n"
|
||||||
"Eg, 'outlet' or '( inlet \".*Wall\" )'"
|
"Eg, 'outlet' or '( inlet \".*Wall\" )'"
|
||||||
);
|
);
|
||||||
|
argList::addOptionCompat("exclude-patches", {"excludePatches", 2306});
|
||||||
|
|
||||||
argList::addArgument("input", "The input surface file");
|
argList::addArgument("input", "The input surface file");
|
||||||
|
|
||||||
@ -114,7 +115,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Including patches " << flatOutput(includePatches)
|
Info<< "Including patches " << flatOutput(includePatches)
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
}
|
}
|
||||||
if (args.readListIfPresent<wordRe>("excludePatches", excludePatches))
|
if (args.readListIfPresent<wordRe>("exclude-patches", excludePatches))
|
||||||
{
|
{
|
||||||
Info<< "Excluding patches " << flatOutput(excludePatches)
|
Info<< "Excluding patches " << flatOutput(excludePatches)
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
|
|||||||
@ -233,7 +233,7 @@ _of_complete_cache_[SRFSimpleFoam]="-case -decomposeParDict -fileHandler -world
|
|||||||
_of_complete_cache_[star4ToFoam]="-case -fileHandler -scale | -ascii -noFunctionObjects -solids -doc -help"
|
_of_complete_cache_[star4ToFoam]="-case -fileHandler -scale | -ascii -noFunctionObjects -solids -doc -help"
|
||||||
_of_complete_cache_[steadyParticleTracks]="-case -dict -fileHandler -region -time | -constant -latestTime -noFunctionObjects -noZero -verbose -doc -help"
|
_of_complete_cache_[steadyParticleTracks]="-case -dict -fileHandler -region -time | -constant -latestTime -noFunctionObjects -noZero -verbose -doc -help"
|
||||||
_of_complete_cache_[stitchMesh]="-case -dict -fileHandler -region -toleranceDict | -integral -intermediate -overwrite -partial -perfect -doc -help"
|
_of_complete_cache_[stitchMesh]="-case -dict -fileHandler -region -toleranceDict | -integral -intermediate -overwrite -partial -perfect -doc -help"
|
||||||
_of_complete_cache_[subsetMesh]="-case -decomposeParDict -fileHandler -patch -patches -region -resultTime -world | -mpi-threads -overwrite -parallel -zone -doc -help"
|
_of_complete_cache_[subsetMesh]="-case -decomposeParDict -exclude-patches -fileHandler -patch -patches -region -resultTime -world | -mpi-threads -overwrite -parallel -zone -doc -help"
|
||||||
_of_complete_cache_[surfaceAdd]="-case -fileHandler -points -scale | -mergeRegions -noFunctionObjects -verbose -doc -help"
|
_of_complete_cache_[surfaceAdd]="-case -fileHandler -points -scale | -mergeRegions -noFunctionObjects -verbose -doc -help"
|
||||||
_of_complete_cache_[surfaceBooleanFeatures]="-case -fileHandler -scale -trim | -invertedSpace -no-cgal -noFunctionObjects -perturb -surf1Baffle -surf2Baffle -doc -help"
|
_of_complete_cache_[surfaceBooleanFeatures]="-case -fileHandler -scale -trim | -invertedSpace -no-cgal -noFunctionObjects -perturb -surf1Baffle -surf2Baffle -doc -help"
|
||||||
_of_complete_cache_[surfaceCheck]="-case -fileHandler -outputThreshold -writeSets | -blockMesh -checkSelfIntersection -noFunctionObjects -splitNonManifold -verbose -doc -help"
|
_of_complete_cache_[surfaceCheck]="-case -fileHandler -outputThreshold -writeSets | -blockMesh -checkSelfIntersection -noFunctionObjects -splitNonManifold -verbose -doc -help"
|
||||||
@ -249,7 +249,7 @@ _of_complete_cache_[surfaceInflate]="-case -featureAngle -fileHandler -nSmooth |
|
|||||||
_of_complete_cache_[surfaceLambdaMuSmooth]="-featureFile | -doc -help"
|
_of_complete_cache_[surfaceLambdaMuSmooth]="-featureFile | -doc -help"
|
||||||
_of_complete_cache_[surfaceMeshConvert]="-case -dict -fileHandler -from -read-format -read-scale -to -write-format -write-scale | -clean -noFunctionObjects -tri -verbose -doc -help"
|
_of_complete_cache_[surfaceMeshConvert]="-case -dict -fileHandler -from -read-format -read-scale -to -write-format -write-scale | -clean -noFunctionObjects -tri -verbose -doc -help"
|
||||||
_of_complete_cache_[surfaceMeshExport]="-case -dict -fileHandler -from -name -read-scale -to -write-format -write-scale | -clean -noFunctionObjects -verbose -doc -help"
|
_of_complete_cache_[surfaceMeshExport]="-case -dict -fileHandler -from -name -read-scale -to -write-format -write-scale | -clean -noFunctionObjects -verbose -doc -help"
|
||||||
_of_complete_cache_[surfaceMeshExtract]="-case -decomposeParDict -excludePatches -faceZones -fileHandler -patches -region -time -world | -constant -excludeProcPatches -latestTime -mpi-threads -noFunctionObjects -noZero -parallel -doc -help"
|
_of_complete_cache_[surfaceMeshExtract]="-case -decomposeParDict -exclude-patches -faceZones -fileHandler -patches -region -time -world | -constant -excludeProcPatches -latestTime -mpi-threads -noFunctionObjects -noZero -parallel -doc -help"
|
||||||
_of_complete_cache_[surfaceMeshImport]="-case -dict -fileHandler -from -name -read-format -read-scale -to -write-scale | -clean -noFunctionObjects -verbose -doc -help"
|
_of_complete_cache_[surfaceMeshImport]="-case -dict -fileHandler -from -name -read-format -read-scale -to -write-scale | -clean -noFunctionObjects -verbose -doc -help"
|
||||||
_of_complete_cache_[surfaceMeshInfo]="-case -fileHandler -scale | -areas -noFunctionObjects -xml -doc -help"
|
_of_complete_cache_[surfaceMeshInfo]="-case -fileHandler -scale | -areas -noFunctionObjects -xml -doc -help"
|
||||||
_of_complete_cache_[surfaceOrient]="-case -fileHandler -scale | -inside -noFunctionObjects -usePierceTest -doc -help"
|
_of_complete_cache_[surfaceOrient]="-case -fileHandler -scale | -inside -noFunctionObjects -usePierceTest -doc -help"
|
||||||
@ -257,7 +257,7 @@ _of_complete_cache_[surfacePatch]="-case -dict -fileHandler | -noFunctionObjects
|
|||||||
_of_complete_cache_[surfacePointMerge]="-case -fileHandler -scale | -noFunctionObjects -doc -help"
|
_of_complete_cache_[surfacePointMerge]="-case -fileHandler -scale | -noFunctionObjects -doc -help"
|
||||||
_of_complete_cache_[surfaceRedistributePar]="-case -decomposeParDict -fileHandler -world | -keepNonMapped -mpi-threads -noFunctionObjects -parallel -doc -help"
|
_of_complete_cache_[surfaceRedistributePar]="-case -decomposeParDict -fileHandler -world | -keepNonMapped -mpi-threads -noFunctionObjects -parallel -doc -help"
|
||||||
_of_complete_cache_[surfaceRefineRedGreen]="-case -fileHandler -steps | -noFunctionObjects -doc -help"
|
_of_complete_cache_[surfaceRefineRedGreen]="-case -fileHandler -steps | -noFunctionObjects -doc -help"
|
||||||
_of_complete_cache_[surfaceSplitByPatch]="-case -excludePatches -fileHandler -patches | -noFunctionObjects -doc -help"
|
_of_complete_cache_[surfaceSplitByPatch]="-case -exclude-patches -fileHandler -patches | -noFunctionObjects -doc -help"
|
||||||
_of_complete_cache_[surfaceSplitByTopology]=" | -doc -help"
|
_of_complete_cache_[surfaceSplitByTopology]=" | -doc -help"
|
||||||
_of_complete_cache_[surfaceSplitNonManifolds]="-case -fileHandler | -debug -noFunctionObjects -doc -help"
|
_of_complete_cache_[surfaceSplitNonManifolds]="-case -fileHandler | -debug -noFunctionObjects -doc -help"
|
||||||
_of_complete_cache_[surfaceSubset]="-case -fileHandler | -noFunctionObjects -doc -help"
|
_of_complete_cache_[surfaceSubset]="-case -fileHandler | -noFunctionObjects -doc -help"
|
||||||
|
|||||||
Reference in New Issue
Block a user