From 478fdb60e828cb2c1d907d97dc34880507e10052 Mon Sep 17 00:00:00 2001 From: Alexey Matveichev Date: Fri, 8 May 2015 10:11:30 +0200 Subject: [PATCH] Remove empty patches after conversion Empty defaultFaces should not be in the list of boundaries. --- .../mesh/conversion/gmshToFoam/gmshToFoam.C | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C index ffea381fc..c7b4fe7f3 100644 --- a/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C +++ b/applications/utilities/mesh/conversion/gmshToFoam/gmshToFoam.C @@ -713,6 +713,48 @@ void readCells Info<< endl; } +// Simplified version of the function from createPatch utility. +void removeEmptyPatches(polyMesh& mesh) +{ + Info<< "\n"; + + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + DynamicList nonEmptyPatches(patches.size()); + + forAll(patches, idx) + { + const polyPatch& pp = patches[idx]; + + if (pp.size() > 0) + { + nonEmptyPatches.append + ( + pp.clone + ( + patches, + nonEmptyPatches.size(), + pp.size(), + pp.start() + ).ptr() + ); + } + else + { + Info<< "Removing empty patch " << pp.name() << endl; + } + } + + if (patches.size() != nonEmptyPatches.size()) + { + nonEmptyPatches.shrink(); + mesh.removeBoundary(); + mesh.addPatches(nonEmptyPatches); + } + + Info<< "\n"; +} + // Main program: @@ -1053,6 +1095,8 @@ int main(int argc, char *argv[]) { mesh.addZones(List(0), fz, cz); } + + removeEmptyPatches(mesh); mesh.write();