From 45a0059026c672b08675d9e7e000c27a3e805412 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Fri, 25 Jun 2021 08:46:34 +0100 Subject: [PATCH 1/2] splitBaffles, mergeBaffles: New utilities to replace mergeOrSplitBaffles splitBaffles identifies baffle faces; i.e., faces on the mesh boundary which share the exact same set of points as another boundary face. It then splits the points to convert these faces into completely separate boundary patches. This functionality was previously provided by calling mergeOrSplitBaffles with the "-split" option. mergeBaffles also identifes the duplicate baffle faces, but then merges them, converting them into a single set of internal faces. This functionality was previously provided by calling mergeOrSplitBaffles without the "-split" option. --- .../createBaffles/createBaffles.C | 3 +- .../mesh/manipulation/mergeBaffles/Make/files | 3 + .../Make/options | 0 .../mergeBaffles.C} | 217 ++++-------------- .../mergeOrSplitBaffles/Make/files | 3 - .../mesh/manipulation/splitBaffles/Make/files | 3 + .../manipulation/splitBaffles/Make/options | 9 + .../manipulation/splitBaffles/splitBaffles.C | 125 ++++++++++ bin/mergeOrSplitBaffles | 47 ++++ .../RAS/annularThermalMixer/Allrun | 2 +- .../shellAndTubeHeatExchanger/Allmesh.layers | 2 +- .../pimpleFoam/RAS/propeller/Allmesh | 2 +- .../laminar/mixerVesselAMI2D/Allrun | 2 +- .../particleFoam/mixerVesselAMI2D/Allrun | 2 +- .../interFoam/RAS/mixerVesselAMI/Allmesh | 2 +- .../interFoam/RAS/propeller/Allmesh | 2 +- .../laminar/mixerVesselAMI2D/Allrun | 2 +- 17 files changed, 237 insertions(+), 189 deletions(-) create mode 100644 applications/utilities/mesh/manipulation/mergeBaffles/Make/files rename applications/utilities/mesh/manipulation/{mergeOrSplitBaffles => mergeBaffles}/Make/options (100%) rename applications/utilities/mesh/manipulation/{mergeOrSplitBaffles/mergeOrSplitBaffles.C => mergeBaffles/mergeBaffles.C} (63%) delete mode 100644 applications/utilities/mesh/manipulation/mergeOrSplitBaffles/Make/files create mode 100644 applications/utilities/mesh/manipulation/splitBaffles/Make/files create mode 100644 applications/utilities/mesh/manipulation/splitBaffles/Make/options create mode 100644 applications/utilities/mesh/manipulation/splitBaffles/splitBaffles.C create mode 100755 bin/mergeOrSplitBaffles diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index b6e081d0ba..6469beca0e 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -25,8 +25,7 @@ Application createBaffles Description - Makes internal faces into boundary faces. Does not duplicate points, unlike - mergeOrSplitBaffles. + Makes internal faces into boundary faces. Does not duplicate points. Note: if any coupled patch face is selected for baffling the opposite member has to be selected for baffling as well. diff --git a/applications/utilities/mesh/manipulation/mergeBaffles/Make/files b/applications/utilities/mesh/manipulation/mergeBaffles/Make/files new file mode 100644 index 0000000000..5af43d4eca --- /dev/null +++ b/applications/utilities/mesh/manipulation/mergeBaffles/Make/files @@ -0,0 +1,3 @@ +mergeBaffles.C + +EXE = $(FOAM_APPBIN)/mergeBaffles diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/Make/options b/applications/utilities/mesh/manipulation/mergeBaffles/Make/options similarity index 100% rename from applications/utilities/mesh/manipulation/mergeOrSplitBaffles/Make/options rename to applications/utilities/mesh/manipulation/mergeBaffles/Make/options diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeBaffles/mergeBaffles.C similarity index 63% rename from applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C rename to applications/utilities/mesh/manipulation/mergeBaffles/mergeBaffles.C index 6ff2f20d06..b0867bdc80 100644 --- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C +++ b/applications/utilities/mesh/manipulation/mergeBaffles/mergeBaffles.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,22 +25,8 @@ Application mergeOrSplitBaffles Description - Detects faces that share points (baffles). Either merge them or - duplicate the points. - - Notes: - - can only handle pairwise boundary faces. So three faces using - the same points is not handled (is illegal mesh anyway) - - - there is no option to only split/merge some baffles. - - - surfaces consisting of duplicate faces can be topologically split - if the points on the interior of the surface cannot walk to all the - cells that use them in one go. - - - Parallel operation (where duplicate face is perpendicular to a coupled - boundary) is supported but not really tested. - (Note that coupled faces themselves are not seen as duplicate faces) + Detects faces that share points (baffles) and merge them into internal + faces. \*---------------------------------------------------------------------------*/ @@ -66,13 +52,42 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void insertDuplicateMerge +void mergeDuplicateBoundaryFaces ( const polyMesh& mesh, - const labelList& duplicates, polyTopoChange& meshMod ) { + // Get all duplicate face labels in the boundary + labelList duplicates = localPointRegion::findDuplicateFaces + ( + mesh, + identity(mesh.nFaces() - mesh.nInternalFaces()) + + mesh.nInternalFaces() + ); + + // Check that none are on processor patches + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + forAll(duplicates, bFacei) + { + if (duplicates[bFacei] != -1) + { + label facei = mesh.nInternalFaces() + bFacei; + label patchi = patches.whichPatch(facei); + + if (isA(patches[patchi])) + { + FatalErrorInFunction + << "Duplicate face " << facei + << " is on a processorPolyPatch." + << "This is not allowed." << nl + << "Face:" << facei + << " is on patch:" << patches[patchi].name() + << abort(FatalError); + } + } + } + const faceList& faces = mesh.faces(); const labelList& faceOwner = mesh.faceOwner(); const faceZoneMesh& faceZones = mesh.faceZones(); @@ -154,93 +169,17 @@ void insertDuplicateMerge } -labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) -{ - // Get all duplicate face labels (in boundaryFaces indices!). - labelList duplicates = localPointRegion::findDuplicateFaces - ( - mesh, - boundaryFaces - ); - - - // Check that none are on processor patches - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - forAll(duplicates, bFacei) - { - if (duplicates[bFacei] != -1) - { - label facei = mesh.nInternalFaces() + bFacei; - label patchi = patches.whichPatch(facei); - - if (isA(patches[patchi])) - { - FatalErrorInFunction - << "Duplicate face " << facei - << " is on a processorPolyPatch." - << "This is not allowed." << nl - << "Face:" << facei - << " is on patch:" << patches[patchi].name() - << abort(FatalError); - } - } - } - - - // Write to faceSet for ease of postprocessing. - { - faceSet duplicateSet - ( - mesh, - "duplicateFaces", - (mesh.nFaces() - mesh.nInternalFaces())/256 - ); - - forAll(duplicates, bFacei) - { - label otherFacei = duplicates[bFacei]; - - if (otherFacei != -1 && otherFacei > bFacei) - { - duplicateSet.insert(mesh.nInternalFaces() + bFacei); - duplicateSet.insert(mesh.nInternalFaces() + otherFacei); - } - } - - Pout<< "Writing " << duplicateSet.size() - << " duplicate faces to faceSet " << duplicateSet.localObjectPath() - << nl << endl; - duplicateSet.write(); - } - - return duplicates; -} - - - - int main(int argc, char *argv[]) { argList::addNote ( - "Detect faces that share points (baffles).\n" - "Merge them or duplicate the points." + "Detect faces that share points (baffles)\n" + "and merge them into internal faces." ); #include "addOverwriteOption.H" #include "addRegionOption.H" argList::addBoolOption - ( - "detectOnly", - "find baffles only, but do not merge or split them" - ); - argList::addBoolOption - ( - "split", - "topologically split duplicate surfaces" - ); - argList::addBoolOption ( "fields", "update fields" @@ -251,28 +190,10 @@ int main(int argc, char *argv[]) runTime.functionObjects().off(); #include "createNamedMesh.H" - const word oldInstance = mesh.pointsInstance(); - - const bool split = args.optionFound("split"); const bool overwrite = args.optionFound("overwrite"); - const bool detectOnly = args.optionFound("detectOnly"); const bool fields = args.optionFound("fields"); - // Collect all boundary faces - labelList boundaryFaces(mesh.nFaces() - mesh.nInternalFaces()); - - forAll(boundaryFaces, i) - { - boundaryFaces[i] = i+mesh.nInternalFaces(); - } - - - if (detectOnly) - { - findBaffles(mesh, boundaryFaces); - return 0; - } - + const word oldInstance = mesh.pointsInstance(); // Read objects in time directory IOobjectList objects(mesh, runTime.timeName()); @@ -283,39 +204,11 @@ int main(int argc, char *argv[]) #include "readSurfaceFields.H" #include "readPointFields.H" - Info<< endl; - - // Mesh change engine polyTopoChange meshMod(mesh); - - if (split) - { - Pout<< "Topologically splitting duplicate surfaces" - << ", i.e. duplicating points internal to duplicate surfaces." - << nl << endl; - - // Analyse which points need to be duplicated - localPointRegion regionSide(mesh); - - // Point duplication engine - duplicatePoints pointDuplicator(mesh); - - // Insert topo changes - pointDuplicator.setRefinement(regionSide, meshMod); - } - else - { - Pout<< "Merging duplicate faces." - << nl << endl; - - // Get all duplicate face labels (in boundaryFaces indices!). - labelList duplicates(findBaffles(mesh, boundaryFaces)); - - // Merge into internal faces. - insertDuplicateMerge(mesh, duplicates, meshMod); - } + // Merge duplicate boundary faces into internal faces. + mergeDuplicateBoundaryFaces(mesh, meshMod); if (!overwrite) { @@ -338,38 +231,10 @@ int main(int argc, char *argv[]) { mesh.setInstance(oldInstance); } - Pout<< "Writing mesh to time " << runTime.timeName() << endl; + + Info<< "Writing mesh to time " << runTime.timeName() << endl; mesh.write(); - // Dump duplicated points (if any) - if (split) - { - const labelList& pointMap = map().pointMap(); - - labelList nDupPerPoint(map().nOldPoints(), 0); - - pointSet dupPoints(mesh, "duplicatedPoints", 100); - - forAll(pointMap, pointi) - { - label oldPointi = pointMap[pointi]; - - nDupPerPoint[oldPointi]++; - - if (nDupPerPoint[oldPointi] > 1) - { - dupPoints.insert(map().reversePointMap()[oldPointi]); - dupPoints.insert(pointi); - } - } - - Pout<< "Writing " << dupPoints.size() - << " duplicated points to pointSet " - << dupPoints.localObjectPath() << nl << endl; - - dupPoints.write(); - } - Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/Make/files b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/Make/files deleted file mode 100644 index c3d7d3450e..0000000000 --- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -mergeOrSplitBaffles.C - -EXE = $(FOAM_APPBIN)/mergeOrSplitBaffles diff --git a/applications/utilities/mesh/manipulation/splitBaffles/Make/files b/applications/utilities/mesh/manipulation/splitBaffles/Make/files new file mode 100644 index 0000000000..88d32074eb --- /dev/null +++ b/applications/utilities/mesh/manipulation/splitBaffles/Make/files @@ -0,0 +1,3 @@ +splitBaffles.C + +EXE = $(FOAM_APPBIN)/splitBaffles diff --git a/applications/utilities/mesh/manipulation/splitBaffles/Make/options b/applications/utilities/mesh/manipulation/splitBaffles/Make/options new file mode 100644 index 0000000000..792a51bf7f --- /dev/null +++ b/applications/utilities/mesh/manipulation/splitBaffles/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -ldynamicMesh diff --git a/applications/utilities/mesh/manipulation/splitBaffles/splitBaffles.C b/applications/utilities/mesh/manipulation/splitBaffles/splitBaffles.C new file mode 100644 index 0000000000..53c259bb56 --- /dev/null +++ b/applications/utilities/mesh/manipulation/splitBaffles/splitBaffles.C @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 . + +Application + splitBaffles + +Description + Detects faces that share points (baffles) and duplicates the points to + separate them + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "polyTopoChange.H" +#include "localPointRegion.H" +#include "duplicatePoints.H" +#include "ReadFields.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "pointFields.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Detect faces that share points (baffles)\n" + "and duplicate the points to separate them." + ); + + #include "addOverwriteOption.H" + #include "addRegionOption.H" + argList::addBoolOption + ( + "fields", + "update fields" + ); + + #include "setRootCase.H" + #include "createTime.H" + runTime.functionObjects().off(); + #include "createNamedMesh.H" + + const bool overwrite = args.optionFound("overwrite"); + const bool fields = args.optionFound("fields"); + + const word oldInstance = mesh.pointsInstance(); + + // Read objects in time directory + IOobjectList objects(mesh, runTime.timeName()); + + if (fields) Info<< "Reading geometric fields" << nl << endl; + + #include "readVolFields.H" + #include "readSurfaceFields.H" + #include "readPointFields.H" + + // Mesh change engine + polyTopoChange meshMod(mesh); + + // Analyse which points need to be duplicated + localPointRegion regionSide(mesh); + + // Point duplication engine + duplicatePoints pointDuplicator(mesh); + + // Insert topo changes + pointDuplicator.setRefinement(regionSide, meshMod); + + if (!overwrite) + { + runTime++; + } + + // Change the mesh. No inflation. + autoPtr map = meshMod.changeMesh(mesh, false); + + // Update fields + mesh.updateMesh(map); + + // Move mesh (since morphing does not do this) + if (map().hasMotionPoints()) + { + mesh.movePoints(map().preMotionPoints()); + } + + if (overwrite) + { + mesh.setInstance(oldInstance); + } + + Info<< "Writing mesh to time " << runTime.timeName() << endl; + mesh.write(); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/bin/mergeOrSplitBaffles b/bin/mergeOrSplitBaffles new file mode 100755 index 0000000000..aacdc1b89d --- /dev/null +++ b/bin/mergeOrSplitBaffles @@ -0,0 +1,47 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | Website: https://openfoam.org +# \\ / A nd | Copyright (C) 2021 OpenFOAM Foundation +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# 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 . +# +# Script +# mergeOrSplitBaffles +# +# Description +# Script to inform the user that mergeOrSplitBaffles has been replaced +# by separate splitBaffles and mergeBaffles utilities. +# +#------------------------------------------------------------------------------ + +cat << EOF + +The mergeOrSplitBaffles utility has been replaced by the splitBaffles and +mergeBaffles utilities. + +If mergeOrSplitBaffles was previously being called with the "-split" option, +then splitBaffles should now be called instead. + +If mergeOrSplitBaffles was previously being called without the "-split" option, +then mergeBaffles should now be called instead. + +EOF + +#------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/Allrun b/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/Allrun index ed93cf4df6..30f4d7df62 100755 --- a/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/Allrun +++ b/tutorials/compressible/rhoPimpleFoam/RAS/annularThermalMixer/Allrun @@ -10,7 +10,7 @@ runApplication blockMesh runApplication snappyHexMesh -overwrite runApplication createBaffles -overwrite -runApplication mergeOrSplitBaffles -split -overwrite +runApplication splitBaffles -overwrite runApplication $(getApplication) diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/shellAndTubeHeatExchanger/Allmesh.layers b/tutorials/heatTransfer/chtMultiRegionFoam/shellAndTubeHeatExchanger/Allmesh.layers index 9c9a04ee3f..42b30cf416 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/shellAndTubeHeatExchanger/Allmesh.layers +++ b/tutorials/heatTransfer/chtMultiRegionFoam/shellAndTubeHeatExchanger/Allmesh.layers @@ -16,7 +16,7 @@ runParallel snappyHexMesh -overwrite # Convert the face zones into mapped wall baffles and split runParallel createBaffles -overwrite -runParallel mergeOrSplitBaffles -split -overwrite +runParallel splitBaffles -overwrite rm -rf processor*/constant/polyMesh/pointLevel # Run snappy again to create layers diff --git a/tutorials/incompressible/pimpleFoam/RAS/propeller/Allmesh b/tutorials/incompressible/pimpleFoam/RAS/propeller/Allmesh index e82c853498..0e0e01c1c2 100755 --- a/tutorials/incompressible/pimpleFoam/RAS/propeller/Allmesh +++ b/tutorials/incompressible/pimpleFoam/RAS/propeller/Allmesh @@ -14,7 +14,7 @@ runApplication snappyHexMesh -overwrite # Create the inlet/outlet and AMI patches runApplication createBaffles -overwrite -runApplication mergeOrSplitBaffles -split -overwrite +runApplication splitBaffles -overwrite # Renumbering runApplication renumberMesh -noFields -overwrite diff --git a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/Allrun b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/Allrun index 996a936a1f..515b738fe6 100755 --- a/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/Allrun +++ b/tutorials/incompressible/pimpleFoam/laminar/mixerVesselAMI2D/Allrun @@ -8,7 +8,7 @@ application=$(getApplication) runApplication blockMesh -dict $FOAM_TUTORIALS/resources/blockMesh/mixerVessel2D runApplication createBaffles -overwrite -runApplication mergeOrSplitBaffles -split -overwrite +runApplication splitBaffles -overwrite runApplication topoSet #runApplication $application diff --git a/tutorials/lagrangian/particleFoam/mixerVesselAMI2D/Allrun b/tutorials/lagrangian/particleFoam/mixerVesselAMI2D/Allrun index 663789514a..504c3b2aaf 100755 --- a/tutorials/lagrangian/particleFoam/mixerVesselAMI2D/Allrun +++ b/tutorials/lagrangian/particleFoam/mixerVesselAMI2D/Allrun @@ -6,6 +6,6 @@ cd ${0%/*} || exit 1 # Run from this directory runApplication blockMesh -dict $FOAM_TUTORIALS/resources/blockMesh/mixerVessel2D runApplication createBaffles -overwrite -runApplication mergeOrSplitBaffles -split -overwrite +runApplication splitBaffles -overwrite runApplication $(getApplication) diff --git a/tutorials/multiphase/interFoam/RAS/mixerVesselAMI/Allmesh b/tutorials/multiphase/interFoam/RAS/mixerVesselAMI/Allmesh index 57e7618cee..263819a0cd 100755 --- a/tutorials/multiphase/interFoam/RAS/mixerVesselAMI/Allmesh +++ b/tutorials/multiphase/interFoam/RAS/mixerVesselAMI/Allmesh @@ -12,6 +12,6 @@ runApplication blockMesh runApplication surfaceFeatures runApplication snappyHexMesh -overwrite runApplication createBaffles -overwrite -runApplication mergeOrSplitBaffles -split -overwrite +runApplication splitBaffles -overwrite #------------------------------------------------------------------------------ diff --git a/tutorials/multiphase/interFoam/RAS/propeller/Allmesh b/tutorials/multiphase/interFoam/RAS/propeller/Allmesh index 29d49db8fa..c088639466 100755 --- a/tutorials/multiphase/interFoam/RAS/propeller/Allmesh +++ b/tutorials/multiphase/interFoam/RAS/propeller/Allmesh @@ -13,7 +13,7 @@ runApplication snappyHexMesh -overwrite # Create the inlet/outlet and AMI patches runApplication createBaffles -overwrite -runApplication mergeOrSplitBaffles -split -overwrite +runApplication splitBaffles -overwrite # Renumbering runApplication renumberMesh -noFields -overwrite diff --git a/tutorials/multiphase/multiphaseEulerFoam/laminar/mixerVesselAMI2D/Allrun b/tutorials/multiphase/multiphaseEulerFoam/laminar/mixerVesselAMI2D/Allrun index 1c5bd7ee61..a53e8f9492 100755 --- a/tutorials/multiphase/multiphaseEulerFoam/laminar/mixerVesselAMI2D/Allrun +++ b/tutorials/multiphase/multiphaseEulerFoam/laminar/mixerVesselAMI2D/Allrun @@ -8,7 +8,7 @@ application=$(getApplication) runApplication blockMesh -dict $FOAM_TUTORIALS/resources/blockMesh/mixerVessel2D runApplication createBaffles -overwrite -runApplication mergeOrSplitBaffles -split -overwrite +runApplication splitBaffles -overwrite runApplication $application From 95e5008e291a122fde6a4a5bd171266df76d70b9 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Fri, 25 Jun 2021 09:38:26 +0100 Subject: [PATCH 2/2] bash_completion: Updated completion The generation script has also been modified slightly to prevent empty entries being generated for scripts with no options; e.g., the scripts in $WM_PROJECT_DIR/bin that report a change in application name --- bin/tools/foamGenerateBashCompletion | 3 +- etc/config.sh/bash_completion | 297 +++++---------------------- 2 files changed, 57 insertions(+), 243 deletions(-) diff --git a/bin/tools/foamGenerateBashCompletion b/bin/tools/foamGenerateBashCompletion index dd62679dfa..ec0c44a787 100755 --- a/bin/tools/foamGenerateBashCompletion +++ b/bin/tools/foamGenerateBashCompletion @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | Website: https://openfoam.org -# \\ / A nd | Copyright (C) 2020 OpenFOAM Foundation +# \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -235,6 +235,7 @@ do sed -n '/^options/,/^$/p' | \ grep -E "^[\t ]*-" | \ tr -s " ") + [ -z "$optList" ] && continue # Categorise options ... diff --git a/etc/config.sh/bash_completion b/etc/config.sh/bash_completion index 117e451054..29876b597a 100644 --- a/etc/config.sh/bash_completion +++ b/etc/config.sh/bash_completion @@ -2123,6 +2123,31 @@ _mdInitialise_ () } complete -o filenames -o nospace -F _mdInitialise_ mdInitialise +_mergeBaffles_ () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + local prev="${COMP_WORDS[COMP_CWORD-1]}" + local line=${COMP_LINE} + local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") + + opts="-case -doc -fields -fileHandler -help -hostRoots -libs -noFunctionObjects -overwrite -parallel -region -roots -srcDoc" + for o in $used ; do opts="${opts/$o/}" ; done + extra="" + + [ "$COMP_CWORD" = 1 ] || \ + case "$prev" in + -case) + opts="" ; extra="-d" ;; + -fileHandler) + opts="uncollated collated masterUncollated" ; extra="" ;; + -hostRoots|-libs|-region|-roots) + opts="" ; extra="" ;; + *) ;; + esac + COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) +} +complete -o filenames -o nospace -F _mergeBaffles_ mergeBaffles + _mergeMeshes_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -2149,31 +2174,6 @@ _mergeMeshes_ () } complete -o filenames -o nospace -F _mergeMeshes_ mergeMeshes -_mergeOrSplitBaffles_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="-case -detectOnly -doc -fields -fileHandler -help -hostRoots -libs -noFunctionObjects -overwrite -parallel -region -roots -split -srcDoc" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - -case) - opts="" ; extra="-d" ;; - -fileHandler) - opts="uncollated collated masterUncollated" ; extra="" ;; - -hostRoots|-libs|-region|-roots) - opts="" ; extra="" ;; - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _mergeOrSplitBaffles_ mergeOrSplitBaffles - _mhdFoam_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -3729,6 +3729,31 @@ _solidEquilibriumDisplacementFoam_ () } complete -o filenames -o nospace -F _solidEquilibriumDisplacementFoam_ solidEquilibriumDisplacementFoam +_splitBaffles_ () +{ + local cur="${COMP_WORDS[COMP_CWORD]}" + local prev="${COMP_WORDS[COMP_CWORD-1]}" + local line=${COMP_LINE} + local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") + + opts="-case -doc -fields -fileHandler -help -hostRoots -libs -noFunctionObjects -overwrite -parallel -region -roots -srcDoc" + for o in $used ; do opts="${opts/$o/}" ; done + extra="" + + [ "$COMP_CWORD" = 1 ] || \ + case "$prev" in + -case) + opts="" ; extra="-d" ;; + -fileHandler) + opts="uncollated collated masterUncollated" ; extra="" ;; + -hostRoots|-libs|-region|-roots) + opts="" ; extra="" ;; + *) ;; + esac + COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) +} +complete -o filenames -o nospace -F _splitBaffles_ splitBaffles + _splitCells_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -5038,62 +5063,26 @@ _zipUpMesh_ () } complete -o filenames -o nospace -F _zipUpMesh_ zipUpMesh -_coalChemistryFoam_ () +_foamCleanCase_ () { local cur="${COMP_WORDS[COMP_CWORD]}" local prev="${COMP_WORDS[COMP_CWORD-1]}" local line=${COMP_LINE} local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - opts="" + opts="-case -help" for o in $used ; do opts="${opts/$o/}" ; done extra="" [ "$COMP_CWORD" = 1 ] || \ case "$prev" in + -case) + opts="" ; extra="-d" ;; *) ;; esac COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) } -complete -o filenames -o nospace -F _coalChemistryFoam_ coalChemistryFoam - -_compressibleInterFilmFoam_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _compressibleInterFilmFoam_ compressibleInterFilmFoam - -_DPMFoam_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _DPMFoam_ DPMFoam +complete -o filenames -o nospace -F _foamCleanCase_ foamCleanCase _foamCleanPath_ () { @@ -5114,29 +5103,6 @@ _foamCleanPath_ () } complete -o filenames -o nospace -F _foamCleanPath_ foamCleanPath -_foamCleanPolyMesh_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="-case -help -region" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - -case) - opts="" ; extra="-d" ;; - -region) - opts="" ; extra="" ;; - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _foamCleanPolyMesh_ foamCleanPolyMesh - _foamCleanTutorials_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -5546,44 +5512,6 @@ _foamTags_ () } complete -o filenames -o nospace -F _foamTags_ foamTags -_icoUncoupledKinematicParcelFoam_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _icoUncoupledKinematicParcelFoam_ icoUncoupledKinematicParcelFoam - -_interPhaseChangeFoam_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _interPhaseChangeFoam_ interPhaseChangeFoam - _mpirunDebug_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -5603,25 +5531,6 @@ _mpirunDebug_ () } complete -o filenames -o nospace -F _mpirunDebug_ mpirunDebug -_MPPICFoam_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _MPPICFoam_ MPPICFoam - _paraFoam_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -5645,44 +5554,6 @@ _paraFoam_ () } complete -o filenames -o nospace -F _paraFoam_ paraFoam -_reactingParcelFoam_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _reactingParcelFoam_ reactingParcelFoam - -_uncoupledKinematicParcelFoam_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _uncoupledKinematicParcelFoam_ uncoupledKinematicParcelFoam - _wclean_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -5705,26 +5576,6 @@ _wclean_ () } complete -o filenames -o nospace -F _wclean_ wclean -_wcleanLnIncludeAll_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="-d" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - -*) ;; - *) opts="";; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _wcleanLnIncludeAll_ wcleanLnIncludeAll - _wcleanPlatform_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -5923,25 +5774,6 @@ _wmakePrintBuild_ () } complete -o filenames -o nospace -F _wmakePrintBuild_ wmakePrintBuild -_wmakeScheduler_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _wmakeScheduler_ wmakeScheduler - _wmakeSchedulerUptime_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -5961,25 +5793,6 @@ _wmakeSchedulerUptime_ () } complete -o filenames -o nospace -F _wmakeSchedulerUptime_ wmakeSchedulerUptime -_wrmdep_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _wrmdep_ wrmdep - _wrmo_ () { local cur="${COMP_WORDS[COMP_CWORD]}"