From d136bf4e81b7d396bfc1b7d91b2fd49142b938e1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 19 Aug 2008 13:52:44 +0100 Subject: [PATCH] passing motionDict; geometric test on problem cells --- .../meshRefinement/meshRefinementBaffles.C | 360 ++++++++++++++++-- 1 file changed, 338 insertions(+), 22 deletions(-) diff --git a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 8b0236a7e2..e6bd37f670 100644 --- a/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -44,9 +44,9 @@ License #include "OFstream.H" #include "regionSplit.H" #include "removeCells.H" - - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +#include "motionSmoother.H" +#include "polyMeshGeometry.H" +#include "IOmanip.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -555,28 +555,28 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells boolList isBoundaryFace(mesh_.nFaces(), false); // Fill boundary data. All elements on meshed patches get marked. - forAll(globalToPatch, i) + // Get the labels of added patches. + labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch)); + + forAll(adaptPatchIDs, i) { - label patchI = globalToPatch[i]; + label patchI = adaptPatchIDs[i]; - if (patchI != -1) + const polyPatch& pp = patches[patchI]; + + label faceI = pp.start(); + + forAll(pp, j) { - const polyPatch& pp = patches[patchI]; + markBoundaryFace + ( + faceI, + isBoundaryFace, + isBoundaryEdge, + isBoundaryPoint + ); - label faceI = pp.start(); - - forAll(pp, j) - { - markBoundaryFace - ( - faceI, - isBoundaryFace, - isBoundaryEdge, - isBoundaryPoint - ); - - faceI++; - } + faceI++; } } @@ -872,6 +872,264 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells return facePatch; } +//XXXXXXXXXXXXXX +// Mark faces to be baffled to prevent snapping problems. Does +// test to find nearest surface and checks which faces would get squashed. +Foam::labelList Foam::meshRefinement::markFacesOnProblemCellsGeometric +( + const dictionary& motionDict, + const labelList& globalToPatch +) const +{ + // Get the labels of added patches. + labelList adaptPatchIDs(meshRefinement::addedPatches(globalToPatch)); + + // Construct addressing engine. + autoPtr ppPtr + ( + meshRefinement::makePatch + ( + mesh_, + adaptPatchIDs + ) + ); + const indirectPrimitivePatch& pp = ppPtr(); + const pointField& localPoints = pp.localPoints(); + const labelList& meshPoints = pp.meshPoints(); + + // Find nearest (non-baffle) surface + pointField newPoints(mesh_.points()); + { + List hitInfo; + labelList hitSurface; + surfaces_.findNearest + ( + surfaces_.getUnnamedSurfaces(), + localPoints, + scalarField(localPoints.size(), sqr(GREAT)), // sqr of attraction + hitSurface, + hitInfo + ); + + forAll(hitInfo, i) + { + if (hitInfo[i].hit()) + { + //label pointI = meshPoints[i]; + //Pout<< " " << pointI << " moved from " + // << mesh_.points()[pointI] << " by " + // << mag(hitInfo[i].hitPoint()-mesh_.points()[pointI]) + // << endl; + newPoints[meshPoints[i]] = hitInfo[i].hitPoint(); + } + } + } + + // Per face (internal or coupled!) the patch that the + // baffle should get (or -1). + labelList facePatch(mesh_.nFaces(), -1); + // Count of baffled faces + label nBaffleFaces = 0; + + +// // Sync position? Or not since same face on both side so just sync +// // result of baffle. +// +// const scalar minArea(readScalar(motionDict.lookup("minArea"))); +// +// Pout<< "markFacesOnProblemCellsGeometric : Comparing to minArea:" +// << minArea << endl; +// +// pointField facePoints; +// for (label faceI = mesh_.nInternalFaces(); faceI < mesh_.nFaces(); faceI++) +// { +// const face& f = mesh_.faces()[faceI]; +// +// bool usesPatchPoint = false; +// +// facePoints.setSize(f.size()); +// forAll(f, fp) +// { +// Map