From 0b1fc8e0cd3dce01eac990b8dfa9695f559e6c25 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 30 Mar 2010 21:50:40 +0100 Subject: [PATCH] ENH: Changed behaviour of surfaces with zones. - if allowFreeStanding = false it also disables faceZones on boundaries. - can have surfaces with faceZone but no cellZone. --- .../meshRefinement/meshRefinementBaffles.C | 97 +++++++++---------- .../refinementSurfaces/refinementSurfaces.C | 46 ++++++--- .../refinementSurfaces/refinementSurfaces.H | 5 +- 3 files changed, 85 insertions(+), 63 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 8d6627882c..1b2a6391d0 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -246,27 +246,8 @@ void Foam::meshRefinement::getBafflePatches const pointField& cellCentres = mesh_.cellCentres(); - // Build list of surfaces that are not to be baffled. - const wordList& cellZoneNames = surfaces_.cellZoneNames(); - - labelList surfacesToBaffle(cellZoneNames.size()); - label baffleI = 0; - forAll(cellZoneNames, surfI) - { - if (cellZoneNames[surfI].size()) - { - if (debug) - { - Pout<< "getBafflePatches : Not baffling surface " - << surfaces_.names()[surfI] << endl; - } - } - else - { - surfacesToBaffle[baffleI++] = surfI; - } - } - surfacesToBaffle.setSize(baffleI); + // Surfaces that need to be baffled + const labelList surfacesToBaffle(surfaces_.getUnnamedSurfaces()); ownPatch.setSize(mesh_.nFaces()); ownPatch = -1; @@ -1254,7 +1235,7 @@ void Foam::meshRefinement::findCellZoneTopo { label surfI = namedSurfaceIndex[faceI]; - if (surfI != -1) + if (surfI != -1 && surfaceToCellZone[surfI] != -1) { // Calculate region to zone from cellRegions on either side // of internal face. @@ -1306,7 +1287,7 @@ void Foam::meshRefinement::findCellZoneTopo label surfI = namedSurfaceIndex[faceI]; - if (surfI != -1) + if (surfI != -1 && surfaceToCellZone[surfI] != -1) { bool changedCell = calcRegionToZone ( @@ -1440,6 +1421,15 @@ void Foam::meshRefinement::makeConsistentFaceIndex } } } + else + { + // Unzonify boundary faces + forAll(pp, i) + { + label faceI = pp.start()+i; + namedSurfaceIndex[faceI] = -1; + } + } } } @@ -2043,14 +2033,10 @@ Foam::autoPtr Foam::meshRefinement::zonify labelList namedSurfaces(surfaces_.getNamedSurfaces()); - boolList isNamedSurface(cellZoneNames.size(), false); - forAll(namedSurfaces, i) { label surfI = namedSurfaces[i]; - isNamedSurface[surfI] = true; - Info<< "Surface : " << surfaces_.names()[surfI] << nl << " faceZone : " << faceZoneNames[surfI] << nl << " cellZone : " << cellZoneNames[surfI] << endl; @@ -2126,31 +2112,34 @@ Foam::autoPtr Foam::meshRefinement::zonify { label surfI = namedSurfaces[i]; - label zoneI = cellZones.findZoneID(cellZoneNames[surfI]); - - if (zoneI == -1) + if (cellZoneNames[surfI] != word::null) { - zoneI = cellZones.size(); - cellZones.setSize(zoneI+1); - cellZones.set - ( - zoneI, - new cellZone + label zoneI = cellZones.findZoneID(cellZoneNames[surfI]); + + if (zoneI == -1) + { + zoneI = cellZones.size(); + cellZones.setSize(zoneI+1); + cellZones.set ( - cellZoneNames[surfI], //name - labelList(0), //addressing - zoneI, //index - cellZones //cellZoneMesh - ) - ); - } + zoneI, + new cellZone + ( + cellZoneNames[surfI], //name + labelList(0), //addressing + zoneI, //index + cellZones //cellZoneMesh + ) + ); + } - if (debug) - { - Pout<< "Cells inside " << surfaces_.names()[surfI] - << " will go into cellZone " << zoneI << endl; + if (debug) + { + Pout<< "Cells inside " << surfaces_.names()[surfI] + << " will go into cellZone " << zoneI << endl; + } + surfaceToCellZone[surfI] = zoneI; } - surfaceToCellZone[surfI] = zoneI; } // Check they are synced @@ -2322,6 +2311,11 @@ Foam::autoPtr Foam::meshRefinement::zonify if (closedNamedSurfaces.size()) { + Info<< "Found " << closedNamedSurfaces.size() + << " closed, named surfaces. Assigning cells in/outside" + << " these surfaces to the corresponding cellZone." + << nl << endl; + findCellZoneGeometric ( closedNamedSurfaces, // indices of closed surfaces @@ -2334,8 +2328,10 @@ Foam::autoPtr Foam::meshRefinement::zonify // Set using walking // ~~~~~~~~~~~~~~~~~ - //if (returnReduce(nSet, sumOp