From ccef40cc0a08d117fc9cfc4729401d1d29769059 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 21 Nov 2015 21:35:00 +0000 Subject: [PATCH] meshRefinementBaffles: Correct faceZone orientation Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1479 Patches provided by Bruno Santos based on the work of Mattijs Janssens --- .../meshRefinement/meshRefinement.H | 8 +- .../meshRefinement/meshRefinementBaffles.C | 199 ++++++++---------- 2 files changed, 92 insertions(+), 115 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H index 7281a3d52..741416991 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.H @@ -369,7 +369,7 @@ private: const labelList& globalToSlavePatch ) const; - //- Determine patches for baffles + //- Determine patches for baffles on all intersected unnamed faces void getBafflePatches ( const labelList& globalToMasterPatch, @@ -514,6 +514,8 @@ private: labelList& cellToZone ) const; + //- Make namedSurfaceIndex consistent with cellToZone + // - clear out any blocked faces inbetween same cell zone. void makeConsistentFaceIndex ( const labelList& cellToZone, @@ -536,11 +538,11 @@ private: // Some patch utilities - //- Get all faces in namedSurfaceIndex that have no cellZone on + //- Get all faces in faceToZone that have no cellZone on // either side. labelList freeStandingBaffleFaces ( - const labelList& namedSurfaceIndex, + const labelList& faceToZone, const labelList& cellToZone, const labelList& neiCellZone ) const; diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 3d0242153..1f2101155 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -51,9 +51,6 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// Repatches external face or creates baffle for internal face -// with user specified patches (might be different for both sides). -// Returns label of added face. Foam::label Foam::meshRefinement::createBaffle ( const label faceI, @@ -128,52 +125,11 @@ Foam::label Foam::meshRefinement::createBaffle } -//// Check if we are a boundary face and normal of surface does -//// not align with test vector. In this case there'd probably be -//// a freestanding 'baffle' so we might as well not create it. -//// Note that since it is not a proper baffle we cannot detect it -//// afterwards so this code cannot be merged with the -//// filterDuplicateFaces code. -//bool Foam::meshRefinement::validBaffleTopology -//( -// const label faceI, -// const vector& n1, -// const vector& n2, -// const vector& testDir -//) const -//{ -// -// label patchI = mesh_.boundaryMesh().whichPatch(faceI); -// if (patchI == -1 || mesh_.boundaryMesh()[patchI].coupled()) -// { -// return true; -// } -// else if (mag(n1&n2) > cos(degToRad(30))) -// { -// // Both normals aligned. Check that test vector perpendicularish to -// // surface normal -// scalar magTestDir = mag(testDir); -// if (magTestDir > VSMALL) -// { -// if (mag(n1&(testDir/magTestDir)) < cos(degToRad(45))) -// { -// //Pout<< "** disabling baffling face " -// // << mesh_.faceCentres()[faceI] << endl; -// return false; -// } -// } -// } -// return true; -//} - - -// Determine patches for baffles on all intersected unnamed faces void Foam::meshRefinement::getBafflePatches ( const labelList& globalToMasterPatch, const labelList& neiLevel, const pointField& neiCc, - labelList& ownPatch, labelList& neiPatch ) const @@ -386,7 +342,6 @@ Foam::Map Foam::meshRefinement::getZoneBafflePatches } -// Create baffle for every face where ownPatch != -1 Foam::autoPtr Foam::meshRefinement::createBaffles ( const labelList& ownPatch, @@ -659,17 +614,16 @@ Foam::autoPtr Foam::meshRefinement::createZoneBaffles } -// Extract those baffles (duplicate) faces that are on the edge of a baffle -// region. These are candidates for merging. -// Done by counting the number of baffles faces per mesh edge. If edge -// has 2 boundary faces and both are baffle faces it is the edge of a baffle -// region. Foam::List Foam::meshRefinement::freeStandingBaffles ( const List& couples, const scalar planarAngle ) const { + // Done by counting the number of baffles faces per mesh edge. If edge + // has 2 boundary faces and both are baffle faces it is the edge of a baffle + // region. + // All duplicate faces on edge of the patch are to be merged. // So we count for all edges of duplicate faces how many duplicate // faces use them. @@ -918,7 +872,6 @@ Foam::List Foam::meshRefinement::freeStandingBaffles } -// Merge baffles. Gets pairs of faces. Foam::autoPtr Foam::meshRefinement::mergeBaffles ( const List& couples @@ -1420,10 +1373,6 @@ bool Foam::meshRefinement::calcRegionToZone } -// Finds region per cell. Assumes: -// - region containing keepPoint does not go into a cellZone -// - all other regions can be found by crossing faces marked in -// namedSurfaceIndex. void Foam::meshRefinement::findCellZoneTopo ( const point& keepPoint, @@ -1432,6 +1381,11 @@ void Foam::meshRefinement::findCellZoneTopo labelList& cellToZone ) const { + // Assumes: + // - region containing keepPoint does not go into a cellZone + // - all other regions can be found by crossing faces marked in + // namedSurfaceIndex. + // Analyse regions. Reuse regionsplit boolList blockedFace(mesh_.nFaces()); @@ -1629,8 +1583,6 @@ void Foam::meshRefinement::findCellZoneTopo } -// Make namedSurfaceIndex consistent with cellToZone - clear out any blocked -// faces inbetween same cell zone. void Foam::meshRefinement::makeConsistentFaceIndex ( const labelList& cellToZone, @@ -1810,7 +1762,7 @@ void Foam::meshRefinement::handleSnapProblems Foam::labelList Foam::meshRefinement::freeStandingBaffleFaces ( - const labelList& namedSurfaceIndex, + const labelList& faceToZone, const labelList& cellToZone, const labelList& neiCellZone ) const @@ -1820,17 +1772,30 @@ Foam::labelList Foam::meshRefinement::freeStandingBaffleFaces const labelList& faceNeighbour = mesh_.faceNeighbour(); - DynamicList