From 8c08ad66676f0e2d9bf13950083bfd6e122441ff Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 23 Nov 2016 12:09:31 +0000 Subject: [PATCH 1/4] ENH: mergeOrSplitBaffles: allow operation on selected patches. Fixes #314. --- .../mergeOrSplitBaffles/mergeOrSplitBaffles.C | 297 ++++++++++++++---- .../mergeOrSplitBafflesDict | 39 +++ 2 files changed, 274 insertions(+), 62 deletions(-) create mode 100644 applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBafflesDict diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C index ab692d4706..71013769a1 100644 --- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C +++ b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,15 +28,31 @@ Group grpMeshManipulationUtilities Description - Detects faces that share points (baffles). Either merge them or + Detects boundary faces that share points (baffles). Either merges them or duplicate the points. - Notes: +Usage + \b mergeOrSplitBaffles [OPTION] + + Options: + - \par -detect + Detect baffles and write to faceSet duplicateFaces. + + - \par -merge + Detect baffles and convert to internal faces. + + - \par -split + Detect baffles and duplicate the points (used so the two sides + can move independently) + + - \par -dict \ + Specify a dictionary to read actions from. + + +Note - 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. @@ -71,6 +87,7 @@ using namespace Foam; void insertDuplicateMerge ( const polyMesh& mesh, + const labelList& boundaryFaces, const labelList& duplicates, polyTopoChange& meshMod ) @@ -87,8 +104,8 @@ void insertDuplicateMerge { // Two duplicate faces. Merge. - label face0 = mesh.nInternalFaces() + bFacei; - label face1 = mesh.nInternalFaces() + otherFacei; + label face0 = boundaryFaces[bFacei]; + label face1 = boundaryFaces[otherFacei]; label own0 = faceOwner[face0]; label own1 = faceOwner[face1]; @@ -156,6 +173,45 @@ void insertDuplicateMerge } +label patchSize(const polyMesh& mesh, const labelList& patchIDs) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + label sz = 0; + forAll(patchIDs, i) + { + const polyPatch& pp = patches[patchIDs[i]]; + sz += pp.size(); + } + return sz; +} + + +labelList patchFaces(const polyMesh& mesh, const labelList& patchIDs) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + labelList faceIDs(patchSize(mesh, patchIDs)); + label sz = 0; + forAll(patchIDs, i) + { + const polyPatch& pp = patches[patchIDs[i]]; + + forAll(pp, ppi) + { + faceIDs[sz++] = pp.start()+ppi; + } + } + +if (faceIDs.size() != sz) +{ + FatalErrorInFunction << exit(FatalError); +} + + return faceIDs; +} + + labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) { // Get all duplicate face labels (in boundaryFaces indices!). @@ -173,7 +229,7 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) { if (duplicates[bFacei] != -1) { - label facei = mesh.nInternalFaces() + bFacei; + label facei = boundaryFaces[bFacei]; label patchi = patches.whichPatch(facei); if (isA(patches[patchi])) @@ -205,12 +261,12 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces) if (otherFacei != -1 && otherFacei > bFacei) { - duplicateSet.insert(mesh.nInternalFaces() + bFacei); - duplicateSet.insert(mesh.nInternalFaces() + otherFacei); + duplicateSet.insert(boundaryFaces[bFacei]); + duplicateSet.insert(boundaryFaces[otherFacei]); } } - Pout<< "Writing " << duplicateSet.size() + Info<< "Writing " << returnReduce(duplicateSet.size(), sumOp