From d3c6758319d145afd9b626b1ac29a5b343f5244e Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 11 Jun 2012 17:30:38 +0100 Subject: [PATCH 1/9] ENH: meshRefinement: #552: allow features without start or end --- .../meshRefinement/meshRefinementRefine.C | 68 ++++++++++++++++++- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C index 2664719b26..e1b76c44e1 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementRefine.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -272,7 +272,11 @@ Foam::label Foam::meshRefinement::markFeatureRefinement // Find all start cells of features. Is done by tracking from keepPoint. Cloud cloud(mesh_, IDLList()); - // Create particles on whichever processor holds the keepPoint. + + // Features are identical on all processors. Number them so we know + // what to seed. Do this on only the processor that + // holds the keepPoint. + label cellI = -1; label tetFaceI = -1; label tetPtI = -1; @@ -281,13 +285,25 @@ Foam::label Foam::meshRefinement::markFeatureRefinement if (cellI != -1) { + // I am the processor that holds the keepPoint + forAll(features_, featI) { const featureEdgeMesh& featureMesh = features_[featI]; const label featureLevel = features_.levels()[featI]; - const labelListList& pointEdges = featureMesh.pointEdges(); + // Find regions on edgeMesh + labelList edgeRegion; + label nRegions = featureMesh.regions(edgeRegion); + + + PackedBoolList regionVisited(nRegions); + + + // 1. Seed all 'knots' in edgeMesh + + forAll(pointEdges, pointI) { if (pointEdges[pointI].size() != 2) @@ -316,6 +332,50 @@ Foam::label Foam::meshRefinement::markFeatureRefinement pointI // end point ) ); + + // Mark + if (pointEdges[pointI].size() > 0) + { + label e0 = pointEdges[pointI][0]; + label regionI = edgeRegion[e0]; + regionVisited[regionI] = 1u; + } + } + } + + + // 2. Any regions that have not been visited at all? These can + // only be circular regions! + forAll(featureMesh.edges(), edgeI) + { + if (regionVisited.set(edgeRegion[edgeI], 1u)) + { + const edge& e = featureMesh.edges()[edgeI]; + label pointI = e.start(); + if (debug) + { + Pout<< "Adding particle from point:" << pointI + << " coord:" << featureMesh.points()[pointI] + << " on circular region:" << edgeRegion[edgeI] + << endl; + } + + // Non-manifold point. Create particle. + cloud.addParticle + ( + new trackedParticle + ( + mesh_, + keepPoint, + cellI, + tetFaceI, + tetPtI, + featureMesh.points()[pointI], // endpos + featureLevel, // level + featI, // featureMesh + pointI // end point + ) + ); } } } @@ -329,6 +389,8 @@ Foam::label Foam::meshRefinement::markFeatureRefinement trackedParticle::trackingData td(cloud, maxFeatureLevel); // Track all particles to their end position (= starting feature point) + // Note that the particle might have started on a different processor + // so this will transfer across nicely until we can start tracking proper. cloud.move(td, GREAT); // Reset level From 069c5ee218bf6e057ef8607149c87df966781113 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Jun 2012 10:25:48 +0100 Subject: [PATCH 2/9] ENH: renumberMesh: ignore inconsistent *ProcAddressing --- .../manipulation/renumberMesh/renumberMesh.C | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 395ee77cbe..e64f6cb78f 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -1018,6 +1018,11 @@ int main(int argc, char *argv[]) // Update proc maps if (cellProcAddressing.headerOk()) + if + ( + cellProcAddressing.headerOk() + && cellProcAddressing.size() == mesh.nCells() + ) { Info<< "Renumbering processor cell decomposition map " << cellProcAddressing.name() << endl; @@ -1028,6 +1033,11 @@ int main(int argc, char *argv[]) ); } if (faceProcAddressing.headerOk()) + if + ( + faceProcAddressing.headerOk() + && faceProcAddressing.size() == mesh.nFaces() + ) { Info<< "Renumbering processor face decomposition map " << faceProcAddressing.name() << endl; @@ -1054,6 +1064,11 @@ int main(int argc, char *argv[]) } } if (pointProcAddressing.headerOk()) + if + ( + pointProcAddressing.headerOk() + && pointProcAddressing.size() == mesh.nPoints() + ) { Info<< "Renumbering processor point decomposition map " << pointProcAddressing.name() << endl; @@ -1173,21 +1188,41 @@ int main(int argc, char *argv[]) mesh.write(); if (cellProcAddressing.headerOk()) + if + ( + cellProcAddressing.headerOk() + && cellProcAddressing.size() == mesh.nCells() + ) { cellProcAddressing.instance() = mesh.facesInstance(); cellProcAddressing.write(); } if (faceProcAddressing.headerOk()) + if + ( + faceProcAddressing.headerOk() + && faceProcAddressing.size() == mesh.nFaces() + ) { faceProcAddressing.instance() = mesh.facesInstance(); faceProcAddressing.write(); } if (pointProcAddressing.headerOk()) + if + ( + pointProcAddressing.headerOk() + && pointProcAddressing.size() == mesh.nPoints() + ) { pointProcAddressing.instance() = mesh.facesInstance(); pointProcAddressing.write(); } if (boundaryProcAddressing.headerOk()) + if + ( + boundaryProcAddressing.headerOk() + && boundaryProcAddressing.size() == mesh.boundaryMesh().size() + ) { boundaryProcAddressing.instance() = mesh.facesInstance(); boundaryProcAddressing.write(); From 616b3c8273a881a151466e1fc6e3f4daa8409eaf Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 13 Jun 2012 16:15:01 +0100 Subject: [PATCH 3/9] ENH: treeDataPrimitivePatch: refactored for single template arg --- .../backgroundMeshDecomposition.H | 4 +- src/dynamicMesh/boundaryMesh/boundaryMesh.C | 8 +- .../AMIInterpolation/AMIInterpolation.H | 2 +- .../indexedOctree/treeDataPrimitivePatch.C | 131 +++--------------- .../indexedOctree/treeDataPrimitivePatch.H | 28 +--- 5 files changed, 34 insertions(+), 139 deletions(-) diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H index 910732fa7a..bcdd163834 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.H @@ -78,10 +78,8 @@ SourceFiles namespace Foam { -typedef treeDataPrimitivePatch - treeDataBPatch; - typedef PrimitivePatch bPatch; +typedef treeDataPrimitivePatch treeDataBPatch; /*---------------------------------------------------------------------------*\ Class backgroundMeshDecomposition Declaration diff --git a/src/dynamicMesh/boundaryMesh/boundaryMesh.C b/src/dynamicMesh/boundaryMesh/boundaryMesh.C index 51be127dd7..4a705acead 100644 --- a/src/dynamicMesh/boundaryMesh/boundaryMesh.C +++ b/src/dynamicMesh/boundaryMesh/boundaryMesh.C @@ -924,10 +924,10 @@ Foam::labelList Foam::boundaryMesh::getNearest // Create the octrees indexedOctree < - treeDataPrimitivePatch + treeDataPrimitivePatch > leftTree ( - treeDataPrimitivePatch + treeDataPrimitivePatch ( false, // cacheBb leftPatch @@ -939,10 +939,10 @@ Foam::labelList Foam::boundaryMesh::getNearest ); indexedOctree < - treeDataPrimitivePatch + treeDataPrimitivePatch > rightTree ( - treeDataPrimitivePatch + treeDataPrimitivePatch ( false, // cacheBb rightPatch diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index 36cd661175..d8cb82c07c 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -82,7 +82,7 @@ class AMIInterpolation public AMIInterpolationName { //- local typedef to octree tree-type - typedef treeDataPrimitivePatch treeType; + typedef treeDataPrimitivePatch treeType; // Private data diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C index 6927cbaa50..4cd2968232 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C @@ -29,30 +29,14 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -Foam::scalar -Foam::treeDataPrimitivePatch:: -tolSqr = sqr(1e-6); +template +Foam::scalar Foam::treeDataPrimitivePatch::tolSqr = sqr(1e-6); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -Foam::treeBoundBox -Foam::treeDataPrimitivePatch:: -calcBb +template +Foam::treeBoundBox Foam::treeDataPrimitivePatch::calcBb ( const pointField& points, const face& f @@ -71,15 +55,8 @@ calcBb } -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -void Foam::treeDataPrimitivePatch:: -update() +template +void Foam::treeDataPrimitivePatch::update() { if (cacheBb_) { @@ -96,18 +73,11 @@ update() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from components -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -Foam::treeDataPrimitivePatch:: -treeDataPrimitivePatch +template +Foam::treeDataPrimitivePatch::treeDataPrimitivePatch ( const bool cacheBb, - const PrimitivePatch& patch + const PatchType& patch ) : patch_(patch), @@ -119,16 +89,8 @@ treeDataPrimitivePatch // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -Foam::pointField -Foam::treeDataPrimitivePatch:: -shapePoints() const +template +Foam::pointField Foam::treeDataPrimitivePatch::shapePoints() const { pointField cc(patch_.size()); @@ -143,27 +105,10 @@ shapePoints() const //- Get type (inside,outside,mixed,unknown) of point w.r.t. surface. // Only makes sense for closed surfaces. -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -Foam::label -Foam::treeDataPrimitivePatch:: -getVolumeType +template +Foam::label Foam::treeDataPrimitivePatch:: getVolumeType ( - const indexedOctree - < - treeDataPrimitivePatch - < - Face, - FaceList, - PointField, - PointType - > - >& oc, + const indexedOctree >& oc, const point& sample ) const { @@ -396,16 +341,8 @@ getVolumeType // Check if any point on shape is inside cubeBb. -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -bool -Foam::treeDataPrimitivePatch:: -overlaps +template +bool Foam::treeDataPrimitivePatch::overlaps ( const label index, const treeBoundBox& cubeBb @@ -462,16 +399,8 @@ overlaps // Check if any point on shape is inside sphere. -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -bool -Foam::treeDataPrimitivePatch:: -overlaps +template +bool Foam::treeDataPrimitivePatch::overlaps ( const label index, const point& centre, @@ -512,16 +441,8 @@ overlaps // Calculate nearest point to sample. Updates (if any) nearestDistSqr, minIndex, // nearestPoint. -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -void -Foam::treeDataPrimitivePatch:: -findNearest +template +void Foam::treeDataPrimitivePatch::findNearest ( const labelUList& indices, const point& sample, @@ -552,16 +473,8 @@ findNearest } -template -< - class Face, - template class FaceList, - class PointField, - class PointType -> -bool -Foam::treeDataPrimitivePatch:: -intersects +template +bool Foam::treeDataPrimitivePatch::intersects ( const label index, const point& start, diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H index 44f76d2c75..bbb3c74956 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.H +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,13 +59,7 @@ TemplateName(treeDataPrimitivePatch); Class treeDataPrimitivePatch Declaration \*---------------------------------------------------------------------------*/ -template -< - class Face, - template class FaceList, - class PointField, - class PointType=point -> +template class treeDataPrimitivePatch : public treeDataPrimitivePatchName @@ -78,7 +72,7 @@ class treeDataPrimitivePatch // Private data //- Underlying geometry - const PrimitivePatch& patch_; + const PatchType& patch_; //- Whether to precalculate and store face bounding box const bool cacheBb_; @@ -103,7 +97,7 @@ public: treeDataPrimitivePatch ( const bool cacheBb, - const PrimitivePatch& + const PatchType& ); @@ -121,8 +115,7 @@ public: pointField shapePoints() const; //- Return access to the underlying patch - const PrimitivePatch& - patch() const + const PatchType& patch() const { return patch_; } @@ -134,16 +127,7 @@ public: // Only makes sense for closed surfaces. label getVolumeType ( - const indexedOctree - < - treeDataPrimitivePatch - < - Face, - FaceList, - PointField, - PointType - > - >&, + const indexedOctree >&, const point& ) const; From 048b414ad3b6c306b2581251c531b3e705bb97b2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 15 Jun 2012 13:23:26 +0100 Subject: [PATCH 4/9] ENH: searchableSurface: extended api for getting nearest and normal --- .../searchableSurface/searchableSurface.C | 19 ++++++++++++++++++- .../searchableSurface/searchableSurface.H | 13 ++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/meshTools/searchableSurface/searchableSurface.C b/src/meshTools/searchableSurface/searchableSurface.C index b586ca191d..decd4c7259 100644 --- a/src/meshTools/searchableSurface/searchableSurface.C +++ b/src/meshTools/searchableSurface/searchableSurface.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -95,4 +95,21 @@ Foam::searchableSurface::~searchableSurface() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::searchableSurface::findNearest +( + const pointField& sample, + const scalarField& nearestDistSqr, + List& info, + vectorField& normal, + labelList& region +) const +{ + findNearest(sample, nearestDistSqr, info); + getNormal(info, normal); + getRegion(info, region); +} + + // ************************************************************************* // diff --git a/src/meshTools/searchableSurface/searchableSurface.H b/src/meshTools/searchableSurface/searchableSurface.H index 535997e900..94713fbf38 100644 --- a/src/meshTools/searchableSurface/searchableSurface.H +++ b/src/meshTools/searchableSurface/searchableSurface.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -323,6 +323,17 @@ public: List& ) const = 0; + //- Find nearest, normal and region. Can be overridden with + // optimised implementation + virtual void findNearest + ( + const pointField& sample, + const scalarField& nearestDistSqr, + List&, + vectorField& normal, + labelList& region + ) const; + // Other From 0fbcb8b83299f79c2fda10ea462f4ccde4e49c55 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 15 Jun 2012 13:24:34 +0100 Subject: [PATCH 5/9] ENH: snappyHexMesh: special handling for multi-patch points --- .../autoHexMeshDriver/autoSnapDriver.H | 5 +- .../autoHexMeshDriver/autoSnapDriverFeature.C | 186 +++++++++++++++--- 2 files changed, 165 insertions(+), 26 deletions(-) diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H index 2e908b7318..35d0822d2a 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -249,9 +249,10 @@ class autoSnapDriver const indirectPrimitivePatch& pp, const scalarField& snapDist, - const List >& pointFaceNormals, + const List >& pointFaceSurfNormals, const List >& pointFaceDisp, const List >& pointFaceCentres, + const labelListList& pointFacePatchID, vectorField& patchAttraction, List& patchConstraints diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C index 6347d5dd16..96e7faec10 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C @@ -71,14 +71,15 @@ namespace Foam } }; + template class listPlusEqOp { public: void operator() ( - List& x, - const List& y + List& x, + const List& y ) const { label sz = x.size(); @@ -486,7 +487,7 @@ void Foam::autoSnapDriver::binFeatureFaces const label pointI, - const List >& pointFaceNormals, + const List >& pointFaceSurfNormals, const List >& pointFaceDisp, const List >& pointFaceCentres, @@ -495,7 +496,7 @@ void Foam::autoSnapDriver::binFeatureFaces DynamicList