From 6f4202c08cb21bf2aaeb68037b56c85b1d39c5e9 Mon Sep 17 00:00:00 2001 From: laurence Date: Fri, 30 Aug 2013 12:18:15 +0100 Subject: [PATCH 01/28] ENH: foamyHexMesh: do not point motion to cross surfaces --- .../conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C | 2 ++ 1 file changed, 2 insertions(+) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index db77f62f5f..76a2f51c62 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -1613,6 +1613,7 @@ void Foam::conformalVoronoiMesh::limitDisplacement // Do not allow infinite recursion if (callCount > 7) { + displacement = vector::zero; return; } @@ -1661,6 +1662,7 @@ void Foam::conformalVoronoiMesh::limitDisplacement if (magSqr(pt - surfHit.hitPoint()) <= searchDistanceSqr) { // Cannot limit displacement, point closer than tolerance + displacement = vector::zero; return; } } From 5e3a0579658bb66b3deacc5e3fa2c339c8b19c9e Mon Sep 17 00:00:00 2001 From: laurence Date: Fri, 30 Aug 2013 12:19:48 +0100 Subject: [PATCH 02/28] ENH: foamyHexMesh: do not allow perturbation to cross surface --- .../rayShooting/rayShooting.C | 120 ++++++++++++++---- .../rayShooting/rayShooting.H | 10 ++ 2 files changed, 105 insertions(+), 25 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C index ebecad88e1..66dc10737d 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C @@ -37,6 +37,90 @@ namespace Foam defineTypeNameAndDebug(rayShooting, 0); addToRunTimeSelectionTable(initialPointsMethod, rayShooting, dictionary); + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void rayShooting::splitLine +( + const line& l, + const scalar& pert, + DynamicList& initialPoints +) const +{ + Foam::point midPoint(l.centre()); + const scalar localCellSize(cellShapeControls().cellSize(midPoint)); + const scalar lineLength(l.mag()); + + const scalar minDistFromSurfaceSqr + ( + minimumSurfaceDistanceCoeffSqr_ + *sqr(localCellSize) + ); + + if + ( + magSqr(midPoint - l.start()) > minDistFromSurfaceSqr + && magSqr(midPoint - l.end()) > minDistFromSurfaceSqr + ) + { + // Add extra points if line length is much bigger than local cell size +// if (lineLength > 4.0*localCellSize) +// { +// splitLine +// ( +// line(l.start(), midPoint), +// pert, +// initialPoints +// ); +// +// splitLine +// ( +// line(midPoint, l.end()), +// pert, +// initialPoints +// ); +// } + + if (randomiseInitialGrid_) + { + Foam::point newPt + ( + midPoint.x() + pert*(rndGen().scalar01() - 0.5), + midPoint.y() + pert*(rndGen().scalar01() - 0.5), + midPoint.z() + pert*(rndGen().scalar01() - 0.5) + ); + + if + ( + !geometryToConformTo().findSurfaceAnyIntersection + ( + midPoint, + newPt + ) + ) + { + midPoint = newPt; + } + else + { + WarningIn + ( + "rayShooting::splitLine" + "(" + " const line&," + " const scalar&," + " DynamicList&" + ")" + ) << "Point perturbation crosses a surface. Not inserting." + << endl; + } + } + + initialPoints.append(toPoint(midPoint)); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // rayShooting::rayShooting @@ -75,7 +159,7 @@ List rayShooting::initialPoints() const const searchableSurfaces& surfaces = geometryToConformTo().geometry(); const labelList& surfacesToConformTo = geometryToConformTo().surfaces(); - const scalar maxRayLength = surfaces.bounds().mag(); + const scalar maxRayLength(surfaces.bounds().mag()); // Initialise points list label initialPointsSize = 0; @@ -94,8 +178,7 @@ List rayShooting::initialPoints() const const pointField& faceCentres = faceCentresTmp(); Info<< " Shoot rays from " << s.name() << nl - << " nRays = " << faceCentres.size() << endl; - + << " nRays = " << faceCentres.size() << endl; forAll(faceCentres, fcI) { @@ -110,9 +193,11 @@ List rayShooting::initialPoints() const continue; } - const scalar pert = + const scalar pert + ( randomPerturbationCoeff_ - *cellShapeControls().cellSize(fC); + *cellShapeControls().cellSize(fC) + ); pointIndexHit surfHitStart; label hitSurfaceStart; @@ -181,27 +266,12 @@ List rayShooting::initialPoints() const } } - Foam::point midPoint(l.centre()); - - const scalar minDistFromSurfaceSqr = - minimumSurfaceDistanceCoeffSqr_ - *sqr(cellShapeControls().cellSize(midPoint)); - - if (randomiseInitialGrid_) - { - midPoint.x() += pert*(rndGen().scalar01() - 0.5); - midPoint.y() += pert*(rndGen().scalar01() - 0.5); - midPoint.z() += pert*(rndGen().scalar01() - 0.5); - } - - if + splitLine ( - magSqr(midPoint - l.start()) > minDistFromSurfaceSqr - && magSqr(midPoint - l.end()) > minDistFromSurfaceSqr - ) - { - initialPoints.append(toPoint(midPoint)); - } + l, + pert, + initialPoints + ); } } } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H index e66df62b7c..e5bd1936ff 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H @@ -61,6 +61,16 @@ private: scalar randomPerturbationCoeff_; + // Private Member Functions + + void splitLine + ( + const line& l, + const scalar& pert, + DynamicList& initialPoints + ) const; + + public: //- Runtime type information From 6d224df76a436fdca6440176b35fe53ae81e5a83 Mon Sep 17 00:00:00 2001 From: laurence Date: Fri, 30 Aug 2013 12:50:02 +0100 Subject: [PATCH 03/28] ENH: foamyHexMesh: change inside/outside test to check for nearest intersection --- .../conformationSurfaces.C | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 0360cf0d83..73bd6038d9 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -683,14 +683,18 @@ Foam::Field Foam::conformationSurfaces::wellInOutSide vector hitDir = info[0].rawPoint() - samplePts[i]; hitDir /= mag(hitDir) + SMALL; - if + pointIndexHit surfHit; + label hitSurface; + + findSurfaceNearestIntersection ( - findSurfaceAnyIntersection - ( - samplePts[i], - info[0].rawPoint() - 1e-3*mag(hitDir)*(hitDir) - ) - ) + samplePts[i], + info[0].rawPoint(), + surfHit, + hitSurface + ); + + if (surfHit.hit() && hitSurface != surfaces_[s]) { continue; } From d2d6514245363eaa9b3ee2b797cad19895b0f9f3 Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 10:54:39 +0100 Subject: [PATCH 04/28] BUG: foamyHexMesh: With surfaces of same priority do not overwrite cell size --- .../controlMeshRefinement.C | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C index b100d8eebb..8d954799a1 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/cellShapeControl/controlMeshRefinement/controlMeshRefinement.C @@ -295,14 +295,14 @@ void Foam::controlMeshRefinement::initialMeshPopulation shapeController_.minimumCellSize() ); } - else if (maxPriority == controlFunction.maxPriority()) - { - vertices[vI].targetCellSize() = max - ( - min(sizes[vI], size), - shapeController_.minimumCellSize() - ); - } +// else if (maxPriority == controlFunction.maxPriority()) +// { +// vertices[vI].targetCellSize() = max +// ( +// min(sizes[vI], size), +// shapeController_.minimumCellSize() +// ); +// } else { vertices[vI].targetCellSize() = max From c60419e850ca988e9cb6fd61b1f91c629845e9f4 Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 12:49:24 +0100 Subject: [PATCH 05/28] ENH: foamyHexMesh: insert surface points on close parallel surfaces --- .../conformalVoronoiMeshConformToSurface.C | 32 ++++++------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 76a2f51c62..0c2ed448dc 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -1750,17 +1750,19 @@ bool Foam::conformalVoronoiMesh::nearSurfacePoint const Foam::point& pt = pHit.first().hitPoint(); pointIndexHit closePoint; - const bool closeToSurfacePt = pointIsNearSurfaceLocation(pt, closePoint); if ( closeToSurfacePt - && mag(pt - closePoint.hitPoint()) > pointPairDistance(pt) + && ( + magSqr(pt - closePoint.hitPoint()) + > sqr(pointPairDistance(pt)) + ) ) { - const scalar cosAngle - = angleBetweenSurfacePoints(pt, closePoint.hitPoint()); + const scalar cosAngle = + angleBetweenSurfacePoints(pt, closePoint.hitPoint()); // @todo make this tolerance run-time selectable? if (cosAngle < searchAngleOppositeSurface) @@ -1770,11 +1772,6 @@ bool Foam::conformalVoronoiMesh::nearSurfacePoint const scalar searchDist = targetCellSize(closePoint.hitPoint()); - if (searchDist < SMALL) - { - Pout<< "WARNING: SMALL CELL SIZE" << endl; - } - geometryToConformTo_.findSurfaceNearest ( closePoint.hitPoint(), @@ -1791,15 +1788,15 @@ bool Foam::conformalVoronoiMesh::nearSurfacePoint norm ); - const vector nA = norm[0]; + const vector& nA = norm[0]; pointIndexHit oppositeHit; label oppositeSurfaceHit = -1; geometryToConformTo_.findSurfaceNearestIntersection ( - closePoint.hitPoint() + SMALL*nA, - closePoint.hitPoint() + mag(pt - closePoint.hitPoint())*nA, + closePoint.hitPoint() + 0.5*pointPairDistance(pt)*nA, + closePoint.hitPoint() + 5*targetCellSize(pt)*nA, oppositeHit, oppositeSurfaceHit ); @@ -1810,21 +1807,10 @@ bool Foam::conformalVoronoiMesh::nearSurfacePoint pHit.first() = oppositeHit; pHit.second() = oppositeSurfaceHit; -// appendToSurfacePtTree(pHit.first().hitPoint()); -// surfaceToTreeShape.append -// ( -// existingSurfacePtLocations_.size() - 1 -// ); - return !closeToSurfacePt; } } } - else - { -// appendToSurfacePtTree(pt); -// surfaceToTreeShape.append(existingSurfacePtLocations_.size() - 1); - } return closeToSurfacePt; } From 670cb9dda2a4449a7a263cb703a81e6f8dc3cbca Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 2 Sep 2013 13:12:00 +0100 Subject: [PATCH 06/28] ENH: nastranSurfaceWriter: added comment --- .../writers/nastran/nastranSurfaceWriter.H | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H index 35374a7d94..e80383a303 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H @@ -27,6 +27,19 @@ Class Description A surface writer for the Nastran file format - both surface mesh and fields + formatOptions + { + nastran + { + // From OpenFOAM field name to Nastran field name + fields ((pMean PLOAD2)); + // Optional scale + scale 2.0; + // Optional format + format free; //short, long, free + } + }; + SourceFiles nastranSurfaceWriter.C nastranSurfaceWriterTemplates.C From bf6837838942b042aaa46d0a177d00db6d91463e Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 14:16:46 +0100 Subject: [PATCH 07/28] BUG: foamyHexMesh: write to own processor file in parallel --- .../conformalVoronoiMesh/conformalVoronoiMesh.C | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index e580febdd8..8224492921 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1487,8 +1487,13 @@ void Foam::conformalVoronoiMesh::move() // Save displacements to file. if (foamyHexMeshControls().objOutput() && time().outputTime()) { - Pout<< "Writing point displacement vectors to file." << endl; - OFstream str("displacements_" + runTime_.timeName() + ".obj"); + Info<< "Writing point displacement vectors to file." << endl; + OFstream str + ( + time().path() + + "displacements_" + runTime_.timeName() + + ".obj" + ); for ( From 2545d88205a931798f21111cb2836fc51373f554 Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 15:28:13 +0100 Subject: [PATCH 08/28] ENH: foamyHexMesh: Insert surface points if internal points are exposed --- .../conformalVoronoiMeshConformToSurface.C | 149 +++++++++++++----- 1 file changed, 111 insertions(+), 38 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C index 0c2ed448dc..f5a023592c 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C @@ -550,53 +550,130 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation() } } +// for +// ( +// Delaunay::Finite_edges_iterator eit = finite_edges_begin(); +// eit != finite_edges_end(); +// ++eit +// ) +// { +// Cell_handle c = eit->first; +// Vertex_handle vA = c->vertex(eit->second); +// Vertex_handle vB = c->vertex(eit->third); +// +// if +// ( +// vA->referred() +// || vB->referred() +// ) +// { +// continue; +// } +// +// if +// ( +// (vA->internalPoint() && vA->referred()) +// || (vB->internalPoint() && vB->referred()) +// ) +// { +// continue; +// } +// +// if +// ( +// (vA->internalPoint() && vB->externalBoundaryPoint()) +// || (vB->internalPoint() && vA->externalBoundaryPoint()) +// || (vA->internalBoundaryPoint() && vB->internalBoundaryPoint()) +// ) +// { +// pointIndexHitAndFeatureDynList surfaceIntersections(0.5*AtoV); +// pointIndexHit surfHit; +// label hitSurface; +// +// geometryToConformTo_.findSurfaceNearest +// ( +// ( +// vA->internalPoint() +// ? topoint(vA->point()) +// : topoint(vB->point()) +// ), +// magSqr(topoint(vA->point()) - topoint(vB->point())), +// surfHit, +// hitSurface +// ); +// +// if (surfHit.hit()) +// { +// surfaceIntersections.append +// ( +// pointIndexHitAndFeature(surfHit, hitSurface) +// ); +// +// addSurfaceAndEdgeHits +// ( +// ( +// vA->internalPoint() +// ? topoint(vA->point()) +// : topoint(vB->point()) +// ), +// surfaceIntersections, +// surfacePtReplaceDistCoeffSqr, +// edgeSearchDistCoeffSqr, +// surfaceHits, +// featureEdgeHits, +// surfaceToTreeShape, +// edgeToTreeShape, +// surfacePtToEdgePtDist, +// false +// ); +// } +// } +// } + for ( - Delaunay::Finite_edges_iterator eit = finite_edges_begin(); - eit != finite_edges_end(); - ++eit + Delaunay::Finite_cells_iterator cit = finite_cells_begin(); + cit != finite_cells_end(); + ++cit ) { - Cell_handle c = eit->first; - Vertex_handle vA = c->vertex(eit->second); - Vertex_handle vB = c->vertex(eit->third); - - if - ( - vA->referred() - || vB->referred() - ) + label nInternal = 0; + for (label vI = 0; vI < 4; vI++) { - continue; + if (cit->vertex(vI)->internalPoint()) + { + nInternal++; + } } - if - ( - (vA->internalPoint() && vA->referred()) - || (vB->internalPoint() && vB->referred()) - ) + if (nInternal == 1 && cit->hasBoundaryPoint()) + //if (cit->boundaryDualVertex() && !cit->hasReferredPoint()) { - continue; - } + const Foam::point& pt = cit->dual(); + + const Foam::point cellCentre = + topoint + ( + CGAL::centroid + ( + CGAL::Tetrahedron_3 + ( + cit->vertex(0)->point(), + cit->vertex(1)->point(), + cit->vertex(2)->point(), + cit->vertex(3)->point() + ) + ) + ); - if - ( - (vA->internalPoint() && vB->externalBoundaryPoint()) - || (vB->internalPoint() && vA->externalBoundaryPoint()) - ) - { pointIndexHitAndFeatureDynList surfaceIntersections(0.5*AtoV); pointIndexHit surfHit; label hitSurface; - geometryToConformTo_.findSurfaceNearest + geometryToConformTo_.findSurfaceNearestIntersection ( - ( - vA->internalPoint() - ? topoint(vA->point()) - : topoint(vB->point()) - ), - magSqr(topoint(vA->point()) - topoint(vB->point())), + cellCentre, + pt, surfHit, hitSurface ); @@ -610,11 +687,7 @@ void Foam::conformalVoronoiMesh::buildSurfaceConformation() addSurfaceAndEdgeHits ( - ( - vA->internalPoint() - ? topoint(vA->point()) - : topoint(vB->point()) - ), + pt, surfaceIntersections, surfacePtReplaceDistCoeffSqr, edgeSearchDistCoeffSqr, From 25d81b1f71c8716bb1b878a170ef20c5383f18b7 Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 15:29:54 +0100 Subject: [PATCH 09/28] ENH: foamyHexMesh: add hasBoundaryPoint() to indexedCell --- .../conformalVoronoiMesh/indexedCell/indexedCell.H | 1 + .../conformalVoronoiMesh/indexedCell/indexedCellI.H | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H index 7a95b036a9..82bbe43b95 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCell.H @@ -183,6 +183,7 @@ public: inline bool hasSeedPoint() const; inline bool hasInternalPoint() const; + inline bool hasBoundaryPoint() const; inline bool hasConstrainedPoint() const; diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellI.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellI.H index 8e035dbc7b..2f5d076138 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellI.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell/indexedCellI.H @@ -228,6 +228,19 @@ inline bool CGAL::indexedCell::hasInternalPoint() const } +template +inline bool CGAL::indexedCell::hasBoundaryPoint() const +{ + return + ( + this->vertex(0)->boundaryPoint() + || this->vertex(1)->boundaryPoint() + || this->vertex(2)->boundaryPoint() + || this->vertex(3)->boundaryPoint() + ); +} + + template inline bool CGAL::indexedCell::hasConstrainedPoint() const { From baad5a48d9390b6ac9ca179d6c59ffc6692c63a3 Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 16:06:14 +0100 Subject: [PATCH 10/28] REVERT: foamyHexMesh: do not check inside/outside for surface points --- .../conformalVoronoiMeshI.H | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index 64534cb839..7f31fe9d52 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -225,18 +225,19 @@ inline void Foam::conformalVoronoiMesh::createPointPair const scalar ppDist, const Foam::point& surfPt, const vector& n, + const bool ptPair, DynamicList& pts ) const { vector ppDistn = ppDist*n; - const Foam::point internalPt = surfPt - ppDistn; - const Foam::point externalPt = surfPt + ppDistn; +// const Foam::point internalPt = surfPt - ppDistn; +// const Foam::point externalPt = surfPt + ppDistn; - bool internalInside = geometryToConformTo_.inside(internalPt); - bool externalOutside = geometryToConformTo_.outside(externalPt); +// bool internalInside = geometryToConformTo_.inside(internalPt); +// bool externalOutside = geometryToConformTo_.outside(externalPt); - if (internalInside && externalOutside) +// if (internalInside && externalOutside) { pts.append ( @@ -259,15 +260,24 @@ inline void Foam::conformalVoronoiMesh::createPointPair Pstream::myProcNo() ) ); + + if (ptPair) + { + ptPairs_.addPointPair + ( + pts[pts.size() - 2].index(), + pts[pts.size() - 1].index() // external 0 -> slave + ); + } } - else - { - Info<< "Warning: point pair not inside/outside" << nl - << " surfPt = " << surfPt << nl - << " internal = " << internalPt << " " << internalInside << nl - << " external = " << externalPt << " " << externalOutside - << endl; - } +// else +// { +// Info<< "Warning: point pair not inside/outside" << nl +// << " surfPt = " << surfPt << nl +// << " internal = " << internalPt << " " << internalInside << nl +// << " external = " << externalPt << " " << externalOutside +// << endl; +// } } From 505fef5112ace4d9c8b5875ddfd042067472a391 Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 16:08:14 +0100 Subject: [PATCH 11/28] REVERT: foamyHexMesh: correct function argument list --- .../conformalVoronoiMesh/conformalVoronoiMeshI.H | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index 7f31fe9d52..63f30adc77 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -225,7 +225,6 @@ inline void Foam::conformalVoronoiMesh::createPointPair const scalar ppDist, const Foam::point& surfPt, const vector& n, - const bool ptPair, DynamicList& pts ) const { From 298724b078c87a9db990791fd56db87e0f6ee4d2 Mon Sep 17 00:00:00 2001 From: laurence Date: Mon, 2 Sep 2013 16:09:32 +0100 Subject: [PATCH 12/28] REVERT: foamyHexMesh: correct function argument list --- .../conformalVoronoiMesh/conformalVoronoiMeshI.H | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index 63f30adc77..e9e03a6330 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -260,14 +260,14 @@ inline void Foam::conformalVoronoiMesh::createPointPair ) ); - if (ptPair) - { - ptPairs_.addPointPair - ( - pts[pts.size() - 2].index(), - pts[pts.size() - 1].index() // external 0 -> slave - ); - } +// if (ptPair) +// { +// ptPairs_.addPointPair +// ( +// pts[pts.size() - 2].index(), +// pts[pts.size() - 1].index() // external 0 -> slave +// ); +// } } // else // { From eaad256f319bc7704406e96b43ed78b5f5cdd420 Mon Sep 17 00:00:00 2001 From: laurence Date: Tue, 3 Sep 2013 11:09:16 +0100 Subject: [PATCH 13/28] face/cell zoning: Create new class surfaceZonesInfo --- .../conformationSurfaces.C | 296 +++++++----- .../conformationSurfaces.H | 9 +- .../conformationSurfacesI.H | 7 + .../generation/snappyHexMesh/snappyHexMesh.C | 130 +----- src/mesh/autoMesh/Make/files | 1 + .../autoHexMeshDriver/autoRefineDriver.C | 5 +- .../autoHexMeshDriver/autoSnapDriver.C | 50 ++- .../autoHexMeshDriver/autoSnapDriverFeature.C | 14 +- .../meshRefinement/meshRefinement.C | 11 +- .../meshRefinement/meshRefinementBaffles.C | 188 +++----- .../meshRefinementProblemCells.C | 2 +- .../refinementSurfaces/refinementSurfaces.C | 286 ++---------- .../refinementSurfaces/refinementSurfaces.H | 90 +--- .../refinementSurfaces/surfaceZonesInfo.C | 421 ++++++++++++++++++ .../refinementSurfaces/surfaceZonesInfo.H | 233 ++++++++++ 15 files changed, 1023 insertions(+), 720 deletions(-) create mode 100644 src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C create mode 100644 src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 73bd6038d9..0e4b857d4d 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -265,6 +265,7 @@ Foam::conformationSurfaces::conformationSurfaces allGeometryToSurfaces_(), normalVolumeTypes_(), patchNames_(), + surfZones_(), regionOffset_(), patchInfo_(), globalBounds_(), @@ -275,157 +276,198 @@ Foam::conformationSurfaces::conformationSurfaces surfaceConformationDict.subDict("geometryToConformTo") ); - const label nSurf = surfacesDict.size(); - const dictionary& additionalFeaturesDict ( surfaceConformationDict.subDict("additionalFeatures") ); + + // Wildcard specification : loop over all surface, all regions + // and try to find a match. + + // Count number of surfaces. + label surfI = 0; + forAll(allGeometry.names(), geomI) + { + const word& geomName = allGeometry_.names()[geomI]; + + if (surfacesDict.found(geomName)) + { + surfI++; + } + } + const label nAddFeat = additionalFeaturesDict.size(); Info<< nl << "Reading geometryToConformTo" << endl; - surfaces_.setSize(nSurf, -1); - allGeometryToSurfaces_.setSize(allGeometry_.size(), -1); - normalVolumeTypes_.setSize(nSurf); + normalVolumeTypes_.setSize(surfI); + surfaces_.setSize(surfI); + surfZones_.setSize(surfI); // Features may be attached to host surfaces or independent - features_.setSize(nSurf + nAddFeat); + features_.setSize(surfI + nAddFeat); label featureI = 0; - regionOffset_.setSize(nSurf, 0); + regionOffset_.setSize(surfI, 0); - PtrList globalPatchInfo(nSurf); - List > > regionPatchInfo(nSurf); - List globalVolumeTypes(nSurf); - List > regionVolumeTypes(nSurf); + PtrList globalPatchInfo(surfI); + List > > regionPatchInfo(surfI); + List globalVolumeTypes(surfI); + List > regionVolumeTypes(surfI); - label surfI = 0; + HashSet unmatchedKeys(surfacesDict.toc()); - forAllConstIter(dictionary, surfacesDict, iter) + surfI = 0; + forAll(allGeometry_.names(), geomI) { - word surfaceName = iter().keyword(); + const word& geomName = allGeometry_.names()[geomI]; - surfaces_[surfI] = allGeometry_.findSurfaceID(surfaceName); + const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true); - if (surfaces_[surfI] < 0) + if (ePtr) { - FatalErrorIn("Foam::conformationSurfaces::conformationSurfaces") - << "No surface " << surfaceName << " found. " - << "Valid geometry is " << nl << allGeometry_.names() - << exit(FatalError); - } + const dictionary& dict = ePtr->dict(); + unmatchedKeys.erase(ePtr->keyword()); - allGeometryToSurfaces_[surfaces_[surfI]] = surfI; + surfaces_[surfI] = geomI; - Info<< nl << " " << surfaceName << endl; + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; - const wordList& regionNames = - allGeometry_.regionNames()[surfaces_[surfI]]; - - patchNames_.append(regionNames); - - const dictionary& surfaceSubDict(surfacesDict.subDict(surfaceName)); - - globalVolumeTypes[surfI] = - ( - extendedFeatureEdgeMesh::sideVolumeTypeNames_ - [ - surfaceSubDict.lookupOrDefault("meshableSide", "inside") - ] - ); - - if (!globalVolumeTypes[surfI]) - { - if (!allGeometry_[surfaces_[surfI]].hasVolumeType()) + // Surface zones + if (dict.found("faceZone")) { - WarningIn("conformationSurfaces::conformationSurfaces(..)") - << "Non-baffle surface " - << allGeometry_[surfaces_[surfI]].name() - << " does not allow inside/outside queries." - << " This usually is an error." << endl; + surfZones_.set(surfI, new surfaceZonesInfo(surface, dict)); } - } - // Load patch info - if (surfaceSubDict.found("patchInfo")) - { - globalPatchInfo.set + allGeometryToSurfaces_[surfaces_[surfI]] = surfI; + + Info<< nl << " " << geomName << endl; + + const wordList& regionNames = + allGeometry_.regionNames()[surfaces_[surfI]]; + + patchNames_.append(regionNames); + + globalVolumeTypes[surfI] = ( - surfI, - surfaceSubDict.subDict("patchInfo").clone() + extendedFeatureEdgeMesh::sideVolumeTypeNames_ + [ + dict.lookupOrDefault + ( + "meshableSide", + "inside" + ) + ] ); - } - readFeatures - ( - surfI, - surfaceSubDict, - surfaceName, - featureI - ); - - const wordList& rNames = allGeometry_[surfaces_[surfI]].regions(); - - if (surfaceSubDict.found("regions")) - { - const dictionary& regionsDict = surfaceSubDict.subDict("regions"); - - forAll(rNames, regionI) + if (!globalVolumeTypes[surfI]) { - const word& regionName = rNames[regionI]; - - if (regionsDict.found(regionName)) + if (!surface.hasVolumeType()) { - Info<< " region " << regionName << endl; - - // Get the dictionary for region - const dictionary& regionDict = regionsDict.subDict - ( - regionName - ); - - if (regionDict.found("patchInfo")) - { - regionPatchInfo[surfI].insert - ( - regionI, - regionDict.subDict("patchInfo").clone() - ); - } - - regionVolumeTypes[surfI].insert - ( - regionI, - extendedFeatureEdgeMesh::sideVolumeTypeNames_ - [ - regionDict.lookupOrDefault - ( - "meshableSide", - "inside" - ) - ] - ); - - readFeatures(regionDict, regionName, featureI); + WarningIn("conformationSurfaces::conformationSurfaces(..)") + << "Non-baffle surface " + << surface.name() + << " does not allow inside/outside queries." + << " This usually is an error." << endl; } } - } - surfI++; + // Load patch info + if (dict.found("patchInfo")) + { + globalPatchInfo.set + ( + surfI, + dict.subDict("patchInfo").clone() + ); + } + + readFeatures + ( + surfI, + dict, + geomName, + featureI + ); + + const wordList& rNames = surface.regions(); + + if (dict.found("regions")) + { + const dictionary& regionsDict = dict.subDict("regions"); + + forAll(rNames, regionI) + { + const word& regionName = rNames[regionI]; + + if (regionsDict.found(regionName)) + { + Info<< " region " << regionName << endl; + + // Get the dictionary for region + const dictionary& regionDict = regionsDict.subDict + ( + regionName + ); + + if (regionDict.found("patchInfo")) + { + regionPatchInfo[surfI].insert + ( + regionI, + regionDict.subDict("patchInfo").clone() + ); + } + + regionVolumeTypes[surfI].insert + ( + regionI, + extendedFeatureEdgeMesh::sideVolumeTypeNames_ + [ + regionDict.lookupOrDefault + ( + "meshableSide", + "inside" + ) + ] + ); + + readFeatures(regionDict, regionName, featureI); + } + } + } + + surfI++; + } } + + if (unmatchedKeys.size() > 0) + { + IOWarningIn + ( + "conformationSurfaces::conformationSurfaces(..)", + surfacesDict + ) << "Not all entries in conformationSurfaces dictionary were used." + << " The following entries were not used : " + << unmatchedKeys.sortedToc() + << endl; + } + + // Calculate local to global region offset label nRegions = 0; forAll(surfaces_, surfI) { regionOffset_[surfI] = nRegions; - nRegions += allGeometry_[surfaces_[surfI]].regions().size(); + + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; + nRegions += surface.regions().size(); } // Rework surface specific information into information per global region @@ -434,7 +476,9 @@ Foam::conformationSurfaces::conformationSurfaces forAll(surfaces_, surfI) { - label nRegions = allGeometry_[surfaces_[surfI]].regions().size(); + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; + + label nRegions = surface.regions().size(); // Initialise to global (i.e. per surface) for (label i = 0; i < nRegions; i++) @@ -535,6 +579,30 @@ Foam::conformationSurfaces::conformationSurfaces Info<< features_[fI].name() << endl; } } + + Info<< "ZONES" << endl; + forAll(surfZones_, surfI) + { + if (surfZones_.set(surfI)) + { + const surfaceZonesInfo& sInfo = surfZones_[surfI]; + + Info<< " " << surfI << nl + << " faceZoneName = " << sInfo.faceZoneName() << nl + << " cellZoneName = " << sInfo.cellZoneName() << nl + << " zoneInside = " + << surfaceZonesInfo::areaSelectionAlgoNames[sInfo.zoneInside()] + << nl + << " zoneInsidePoint = " << sInfo.zoneInsidePoint() << nl + << " faceType = " + << surfaceZonesInfo::faceZoneTypeNames[sInfo.faceType()] + << endl; + } + else + { + Info<< " " << surfI << " EMPTY" << endl; + } + } } @@ -1165,13 +1233,7 @@ Foam::label Foam::conformationSurfaces::findPatch(const point& pt) const pointIndexHit surfHit; label hitSurface; - findSurfaceNearest - ( - pt, - sqr(GREAT), - surfHit, - hitSurface - ); + findSurfaceNearest(pt, sqr(GREAT), surfHit, hitSurface); return getPatchID(hitSurface, surfHit); } @@ -1229,11 +1291,7 @@ void Foam::conformationSurfaces::getNormal vectorField& normal ) const { - allGeometry_[hitSurface].getNormal - ( - surfHit, - normal - ); + allGeometry_[hitSurface].getNormal(surfHit, normal); const label patchID = regionOffset_[allGeometryToSurfaces_[hitSurface]]; diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H index 04013add36..68c5fd28b9 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.H @@ -40,6 +40,7 @@ SourceFiles #include "extendedFeatureEdgeMesh.H" #include "boolList.H" #include "volumeType.H" +#include "surfaceZonesInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,7 +48,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class conformationSurfaces Declaration + Class conformationSurfaces Declaration \*---------------------------------------------------------------------------*/ class conformationSurfaces @@ -86,6 +87,9 @@ class conformationSurfaces // surfaces to be reproduced in the meshed geometry List patchNames_; + //- List of surface zone (face and cell zone) information + PtrList surfZones_; + //- The offset between the patch indices of the individual surface and // the entry in the overall patch list labelList regionOffset_; @@ -170,6 +174,9 @@ public: //- Return the patch names inline const List& patchNames() const; + //- Return the surfaceZonesInfo + inline const PtrList& surfZones() const; + //- Return the patch info inline const PtrList& patchInfo() const; diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H index 17ae9636a2..e0a9296f9e 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfacesI.H @@ -56,6 +56,13 @@ const Foam::List& Foam::conformationSurfaces::patchNames() const } +const Foam::PtrList& +Foam::conformationSurfaces::surfZones() const +{ + return surfZones_; +} + + const Foam::PtrList& Foam::conformationSurfaces::patchInfo() const { diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 2475f2a043..4bef61c5e4 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -98,19 +98,8 @@ autoPtr createRefinementSurfaces labelList surfaces(surfI); wordList names(surfI); - wordList faceZoneNames(surfI); - wordList cellZoneNames(surfI); - List zoneInside - ( - surfI, - refinementSurfaces::NONE - ); - pointField zoneInsidePoints(surfI); - List faceType - ( - surfI, - refinementSurfaces::INTERNAL - ); + PtrList surfZones(surfI); + labelList regionOffset(surfI); labelList globalMinLevel(surfI, 0); @@ -123,21 +112,24 @@ autoPtr createRefinementSurfaces List > regionAngle(surfI); List > > regionPatchInfo(surfI); + HashSet unmatchedKeys(surfacesDict.toc()); + surfI = 0; forAll(allGeometry.names(), geomI) { const word& geomName = allGeometry.names()[geomI]; + const entry* ePtr = surfacesDict.lookupEntryPtr(geomName, false, true); - // Definition of surfaces to conform to - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - if (surfacesDict.found(geomName)) + if (ePtr) { + const dictionary& shapeDict = ePtr->dict(); + unmatchedKeys.erase(ePtr->keyword()); + names[surfI] = geomName; surfaces[surfI] = geomI; - const dictionary& shapeDict = shapeControlDict.subDict(geomName); + const searchableSurface& surface = allGeometry[geomI]; // Find the index in shapeControlDict // Invert surfaceCellSize to get the refinementLevel @@ -160,107 +152,26 @@ autoPtr createRefinementSurfaces globalMaxLevel[surfI] = refLevel; globalLevelIncr[surfI] = gapLevelIncrement; - const dictionary& dict = surfacesDict.subDict(geomName); - - // Global zone names per surface - if (dict.readIfPresent("faceZone", faceZoneNames[surfI])) - { - // Read optional entry to determine inside of faceZone - - word method; - bool hasSide = dict.readIfPresent("cellZoneInside", method); - if (hasSide) - { - zoneInside[surfI] = - refinementSurfaces::areaSelectionAlgoNames[method]; - if (zoneInside[surfI] == refinementSurfaces::INSIDEPOINT) - { - dict.lookup("insidePoint") >> zoneInsidePoints[surfI]; - } - - } - else - { - // Check old syntax - bool inside; - if (dict.readIfPresent("zoneInside", inside)) - { - hasSide = true; - zoneInside[surfI] = - ( - inside - ? refinementSurfaces::INSIDE - : refinementSurfaces::OUTSIDE - ); - } - } - - // Read optional cellZone name - - if (dict.readIfPresent("cellZone", cellZoneNames[surfI])) - { - if - ( - ( - zoneInside[surfI] == refinementSurfaces::INSIDE - || zoneInside[surfI] == refinementSurfaces::OUTSIDE - ) - && !allGeometry[surfaces[surfI]].hasVolumeType() - ) - { - IOWarningIn - ( - "createRefinementSurfaces(..)", - dict - ) << "Illegal entry zoneInside " - << refinementSurfaces::areaSelectionAlgoNames - [ - zoneInside[surfI] - ] - << " for faceZone " - << faceZoneNames[surfI] - << " since surface " << names[surfI] - << " is not closed." << endl; - } - } - else if (hasSide) - { - IOWarningIn - ( - "createRefinementSurfaces(..)", - dict - ) << "Unused entry zoneInside for faceZone " - << faceZoneNames[surfI] - << " since no cellZone specified." - << endl; - } - - // How to handle faces on faceZone - word faceTypeMethod; - if (dict.readIfPresent("faceType", faceTypeMethod)) - { - faceType[surfI] = - refinementSurfaces::faceZoneTypeNames[faceTypeMethod]; - } - } + // Surface zones + surfZones.set(surfI, new surfaceZonesInfo(surface, shapeDict)); // Global perpendicular angle - if (dict.found("patchInfo")) + if (shapeDict.found("patchInfo")) { globalPatchInfo.set ( surfI, - dict.subDict("patchInfo").clone() + shapeDict.subDict("patchInfo").clone() ); } // Per region override of patchInfo - if (dict.found("regions")) + if (shapeDict.found("regions")) { - const dictionary& regionsDict = dict.subDict("regions"); + const dictionary& regionsDict = shapeDict.subDict("regions"); const wordList& regionNames = allGeometry[surfaces[surfI]].regions(); @@ -333,6 +244,7 @@ autoPtr createRefinementSurfaces } } } + surfI++; } } @@ -403,11 +315,7 @@ autoPtr createRefinementSurfaces allGeometry, surfaces, names, - faceZoneNames, - cellZoneNames, - zoneInside, - zoneInsidePoints, - faceType, + surfZones, regionOffset, minLevel, maxLevel, @@ -1188,7 +1096,7 @@ int main(int argc, char *argv[]) Info<< surfaces.names()[surfI] << ':' << nl << nl; - if (surfaces.faceZoneNames()[surfI].empty()) + if (surfaces.surfZones()[surfI].faceZoneName().empty()) { // 'Normal' surface forAll(regNames, i) diff --git a/src/mesh/autoMesh/Make/files b/src/mesh/autoMesh/Make/files index 66cb3c6202..d5bfe6f751 100644 --- a/src/mesh/autoMesh/Make/files +++ b/src/mesh/autoMesh/Make/files @@ -18,6 +18,7 @@ $(autoHexMesh)/meshRefinement/meshRefinementMerge.C $(autoHexMesh)/meshRefinement/meshRefinementProblemCells.C $(autoHexMesh)/meshRefinement/meshRefinementRefine.C $(autoHexMesh)/refinementFeatures/refinementFeatures.C +$(autoHexMesh)/refinementSurfaces/surfaceZonesInfo.C $(autoHexMesh)/refinementSurfaces/refinementSurfaces.C $(autoHexMesh)/shellSurfaces/shellSurfaces.C $(autoHexMesh)/trackedParticle/trackedParticle.C diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C index f4cce333e4..a53b6f11eb 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoRefineDriver.C @@ -927,7 +927,10 @@ void Foam::autoRefineDriver::zonify // into that surface's faceZone. All cells inside faceZone get given the // same cellZone. - if (meshRefiner_.surfaces().getNamedSurfaces().size()) + const labelList namedSurfaces = + surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones()); + + if (namedSurfaces.size()) { Info<< nl << "Introducing zones for interfaces" << nl diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C index 822592771c..c710dc6538 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriver.C @@ -590,7 +590,8 @@ Foam::autoPtr Foam::autoSnapDriver::mergeZoneBaffles const List& baffles ) { - labelList zonedSurfaces = meshRefiner_.surfaces().getNamedSurfaces(); + labelList zonedSurfaces = + surfaceZonesInfo::getNamedSurfaces(meshRefiner_.surfaces().surfZones()); autoPtr map; @@ -815,9 +816,15 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface // Divide surfaces into zoned and unzoned labelList zonedSurfaces = - meshRefiner.surfaces().getNamedSurfaces(); + surfaceZonesInfo::getNamedSurfaces + ( + meshRefiner.surfaces().surfZones() + ); labelList unzonedSurfaces = - meshRefiner.surfaces().getUnnamedSurfaces(); + surfaceZonesInfo::getUnnamedSurfaces + ( + meshRefiner.surfaces().surfZones() + ); // 1. All points to non-interface surfaces @@ -854,7 +861,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Surfaces with zone information - const wordList& faceZoneNames = surfaces.faceZoneNames(); + const PtrList& surfZones = surfaces.surfZones(); // Current best snap distance scalarField minSnapDist(snapDist); @@ -863,6 +870,8 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface { label zoneSurfI = zonedSurfaces[i]; + const word& faceZoneName = surfZones[zoneSurfI].faceZoneName(); + const labelList surfacesToTest(1, zoneSurfI); // Get indices of points both on faceZone and on pp. @@ -872,7 +881,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface ( mesh, pp, - faceZoneNames[zoneSurfI] + faceZoneName ) ); @@ -1369,8 +1378,10 @@ Foam::autoPtr Foam::autoSnapDriver::repatchToSurface indirectPrimitivePatch& pp = ppPtr(); // Divide surfaces into zoned and unzoned - labelList zonedSurfaces = surfaces.getNamedSurfaces(); - labelList unzonedSurfaces = surfaces.getUnnamedSurfaces(); + labelList zonedSurfaces = + surfaceZonesInfo::getNamedSurfaces(surfaces.surfZones()); + labelList unzonedSurfaces = + surfaceZonesInfo::getUnnamedSurfaces(surfaces.surfZones()); // Faces that do not move @@ -1386,13 +1397,13 @@ Foam::autoPtr Foam::autoSnapDriver::repatchToSurface } // 2. All faces on zoned surfaces - const wordList& faceZoneNames = surfaces.faceZoneNames(); + const PtrList& surfZones = surfaces.surfZones(); const faceZoneMesh& fZones = mesh.faceZones(); forAll(zonedSurfaces, i) { const label zoneSurfI = zonedSurfaces[i]; - const faceZone& fZone = fZones[faceZoneNames[zoneSurfI]]; + const faceZone& fZone = fZones[surfZones[zoneSurfI].faceZoneName()]; forAll(fZone, i) { @@ -1557,9 +1568,7 @@ void Foam::autoSnapDriver::doSnap { const faceZoneMesh& fZones = mesh.faceZones(); const refinementSurfaces& surfaces = meshRefiner_.surfaces(); - const wordList& faceZoneNames = surfaces.faceZoneNames(); - const List& faceType = - surfaces.faceType(); + const PtrList& surfZones = surfaces.surfZones(); // Determine which // - faces to remove from list of baffles (so not merge) @@ -1568,18 +1577,23 @@ void Foam::autoSnapDriver::doSnap label nFilterFaces = 0; PackedBoolList duplicatePoint(mesh.nPoints()); label nDuplicatePoints = 0; - forAll(faceZoneNames, surfI) + forAll(surfZones, surfI) { + const word& faceZoneName = surfZones[surfI].faceZoneName(); + + const surfaceZonesInfo::faceZoneType& faceType = + surfZones[surfI].faceType(); + if ( - faceType[surfI] == refinementSurfaces::BAFFLE - || faceType[surfI] == refinementSurfaces::BOUNDARY + faceType == surfaceZonesInfo::BAFFLE + || faceType == surfaceZonesInfo::BOUNDARY ) { - if (faceZoneNames[surfI].size()) + if (faceZoneName.size()) { // Filter out all faces for this zone. - label zoneI = fZones.findZoneID(faceZoneNames[surfI]); + label zoneI = fZones.findZoneID(faceZoneName); const faceZone& fZone = fZones[zoneI]; forAll(fZone, i) { @@ -1588,7 +1602,7 @@ void Foam::autoSnapDriver::doSnap nFilterFaces++; } - if (faceType[surfI] == refinementSurfaces::BOUNDARY) + if (faceType == surfaceZonesInfo::BOUNDARY) { forAll(fZone, i) { diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C index 37e61cbbb7..ad2ad93a91 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C @@ -337,8 +337,10 @@ void Foam::autoSnapDriver::calcNearestFace faceSurfaceGlobalRegion = -1; // Divide surfaces into zoned and unzoned - labelList zonedSurfaces = surfaces.getNamedSurfaces(); - labelList unzonedSurfaces = surfaces.getUnnamedSurfaces(); + const labelList zonedSurfaces = + surfaceZonesInfo::getNamedSurfaces(surfaces.surfZones()); + const labelList unzonedSurfaces = + surfaceZonesInfo::getUnnamedSurfaces(surfaces.surfZones()); // Per pp face the current surface snapped to labelList snapSurf(pp.size(), -1); @@ -349,20 +351,22 @@ void Foam::autoSnapDriver::calcNearestFace // Zoned faces only attract to corresponding surface // Extract faces per zone - const wordList& faceZoneNames = surfaces.faceZoneNames(); + const PtrList& surfZones = surfaces.surfZones(); forAll(zonedSurfaces, i) { label zoneSurfI = zonedSurfaces[i]; + const word& faceZoneName = surfZones[zoneSurfI].faceZoneName(); + // Get indices of faces on pp that are also in zone - label zoneI = mesh.faceZones().findZoneID(faceZoneNames[zoneSurfI]); + label zoneI = mesh.faceZones().findZoneID(faceZoneName); if (zoneI == -1) { FatalErrorIn ( "autoSnapDriver::calcNearestFace(..)" - ) << "Problem. Cannot find zone " << faceZoneNames[zoneSurfI] + ) << "Problem. Cannot find zone " << faceZoneName << exit(FatalError); } const faceZone& fZone = mesh.faceZones()[zoneI]; diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index 123fd22281..86e129a3e9 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -1235,19 +1235,22 @@ Foam::autoPtr Foam::meshRefinement::balance // keep owner&neighbour of such a surface zone on the same // processor. - const wordList& fzNames = surfaces().faceZoneNames(); + const PtrList& surfZones = + surfaces().surfZones(); const faceZoneMesh& fZones = mesh_.faceZones(); const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); // Get faces whose owner and neighbour should stay together, // i.e. they are not 'blocked'. - forAll(fzNames, surfI) + forAll(surfZones, surfI) { - if (fzNames[surfI].size()) + const word& fzName = surfZones[surfI].faceZoneName(); + + if (fzName.size()) { // Get zone - const faceZone& fZone = fZones[fzNames[surfI]]; + const faceZone& fZone = fZones[fzName]; forAll(fZone, i) { diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 5dc6cb1c22..6e5a3f187c 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -287,7 +287,10 @@ void Foam::meshRefinement::getBafflePatches const pointField& cellCentres = mesh_.cellCentres(); // Surfaces that need to be baffled - const labelList surfacesToBaffle(surfaces_.getUnnamedSurfaces()); + const labelList surfacesToBaffle + ( + surfaceZonesInfo::getUnnamedSurfaces(surfaces_.surfZones()) + ); ownPatch.setSize(mesh_.nFaces()); ownPatch = -1; @@ -416,15 +419,17 @@ Foam::Map Foam::meshRefinement::getZoneBafflePatches { Map bafflePatch(mesh_.nFaces()/1000); - const wordList& faceZoneNames = surfaces_.faceZoneNames(); + const PtrList& surfZones = surfaces_.surfZones(); const faceZoneMesh& fZones = mesh_.faceZones(); - forAll(faceZoneNames, surfI) + forAll(surfZones, surfI) { - if (faceZoneNames[surfI].size()) + const word& faceZoneName = surfZones[surfI].faceZoneName(); + + if (faceZoneName.size()) { // Get zone - label zoneI = fZones.findZoneID(faceZoneNames[surfI]); + label zoneI = fZones.findZoneID(faceZoneName); const faceZone& fZone = fZones[zoneI]; @@ -703,7 +708,10 @@ Foam::autoPtr Foam::meshRefinement::createZoneBaffles List& baffles ) { - labelList zonedSurfaces = surfaces_.getNamedSurfaces(); + const labelList zonedSurfaces + ( + surfaceZonesInfo::getNamedSurfaces(surfaces_.surfZones()) + ); autoPtr map; @@ -1434,11 +1442,14 @@ void Foam::meshRefinement::findCellZoneInsideWalk // Force calculation of face decomposition (used in findCell) (void)mesh_.tetBasePtIs(); + const PtrList& surfZones = surfaces_.surfZones(); + // For all locationSurface find the cell forAll(locationSurfaces, i) { label surfI = locationSurfaces[i]; - const point& insidePoint = surfaces_.zoneInsidePoints()[surfI]; + + const point& insidePoint = surfZones[surfI].zoneInsidePoint(); Info<< "For surface " << surfaces_.names()[surfI] << " finding inside point " << insidePoint @@ -2503,143 +2514,36 @@ Foam::autoPtr Foam::meshRefinement::zonify const bool allowFreeStandingZoneFaces ) { - const wordList& cellZoneNames = surfaces_.cellZoneNames(); - const wordList& faceZoneNames = surfaces_.faceZoneNames(); + const PtrList& surfZones = surfaces_.surfZones(); - labelList namedSurfaces(surfaces_.getNamedSurfaces()); + labelList namedSurfaces(surfaceZonesInfo::getNamedSurfaces(surfZones)); forAll(namedSurfaces, i) { label surfI = namedSurfaces[i]; Info<< "Surface : " << surfaces_.names()[surfI] << nl - << " faceZone : " << faceZoneNames[surfI] << nl - << " cellZone : " << cellZoneNames[surfI] << endl; + << " faceZone : " << surfZones[surfI].faceZoneName() << nl + << " cellZone : " << surfZones[surfI].cellZoneName() << endl; } // Add zones to mesh + labelList surfaceToFaceZone = + surfaceZonesInfo::addFaceZonesToMesh + ( + surfZones, + namedSurfaces, + mesh_ + ); - labelList surfaceToFaceZone(faceZoneNames.size(), -1); - { - faceZoneMesh& faceZones = mesh_.faceZones(); - - forAll(namedSurfaces, i) - { - label surfI = namedSurfaces[i]; - - label zoneI = faceZones.findZoneID(faceZoneNames[surfI]); - - if (zoneI == -1) - { - zoneI = faceZones.size(); - faceZones.setSize(zoneI+1); - faceZones.set - ( - zoneI, - new faceZone - ( - faceZoneNames[surfI], //name - labelList(0), //addressing - boolList(0), //flipmap - zoneI, //index - faceZones //faceZoneMesh - ) - ); - } - - if (debug) - { - Pout<< "Faces on " << surfaces_.names()[surfI] - << " will go into faceZone " << zoneI << endl; - } - surfaceToFaceZone[surfI] = zoneI; - } - - // Check they are synced - List allFaceZones(Pstream::nProcs()); - allFaceZones[Pstream::myProcNo()] = faceZones.names(); - Pstream::gatherList(allFaceZones); - Pstream::scatterList(allFaceZones); - - for (label procI = 1; procI < allFaceZones.size(); procI++) - { - if (allFaceZones[procI] != allFaceZones[0]) - { - FatalErrorIn - ( - "meshRefinement::zonify" - "(const label, const point&)" - ) << "Zones not synchronised among processors." << nl - << " Processor0 has faceZones:" << allFaceZones[0] - << " , processor" << procI - << " has faceZones:" << allFaceZones[procI] - << exit(FatalError); - } - } - } - - labelList surfaceToCellZone(cellZoneNames.size(), -1); - { - cellZoneMesh& cellZones = mesh_.cellZones(); - - forAll(namedSurfaces, i) - { - label surfI = namedSurfaces[i]; - - if (cellZoneNames[surfI] != word::null) - { - label zoneI = cellZones.findZoneID(cellZoneNames[surfI]); - - if (zoneI == -1) - { - zoneI = cellZones.size(); - cellZones.setSize(zoneI+1); - cellZones.set - ( - 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; - } - surfaceToCellZone[surfI] = zoneI; - } - } - - // Check they are synced - List allCellZones(Pstream::nProcs()); - allCellZones[Pstream::myProcNo()] = cellZones.names(); - Pstream::gatherList(allCellZones); - Pstream::scatterList(allCellZones); - - for (label procI = 1; procI < allCellZones.size(); procI++) - { - if (allCellZones[procI] != allCellZones[0]) - { - FatalErrorIn - ( - "meshRefinement::zonify" - "(const label, const point&)" - ) << "Zones not synchronised among processors." << nl - << " Processor0 has cellZones:" << allCellZones[0] - << " , processor" << procI - << " has cellZones:" << allCellZones[procI] - << exit(FatalError); - } - } - } - + labelList surfaceToCellZone = + surfaceZonesInfo::addCellZonesToMesh + ( + surfZones, + namedSurfaces, + mesh_ + ); const pointField& cellCentres = mesh_.cellCentres(); @@ -2663,7 +2567,7 @@ Foam::autoPtr Foam::meshRefinement::zonify { // Statistics: number of faces per faceZone - labelList nSurfFaces(faceZoneNames.size(), 0); + labelList nSurfFaces(surfZones.size(), 0); // Note: for all internal faces? internal + coupled? // Since zonify is run after baffling the surfaceIndex_ on baffles is @@ -2767,7 +2671,7 @@ Foam::autoPtr Foam::meshRefinement::zonify } - // surfaceIndex migh have different surfaces on both sides if + // surfaceIndex might have different surfaces on both sides if // there happen to be a (obviously thin) surface with different // regions between the cell centres. If one is on a named surface // and the other is not this might give problems so sync. @@ -2806,7 +2710,15 @@ Foam::autoPtr Foam::meshRefinement::zonify // ~~~~~~~~~~~~~~~~~~~~~~~~ // Closed surfaces with cellZone specified. - labelList closedNamedSurfaces(surfaces_.getClosedNamedSurfaces()); + labelList closedNamedSurfaces + ( + surfaceZonesInfo::getClosedNamedSurfaces + ( + surfZones, + surfaces_.geometry(), + surfaces_.surfaces() + ) + ); if (closedNamedSurfaces.size()) { @@ -2830,7 +2742,11 @@ Foam::autoPtr Foam::meshRefinement::zonify // Set using provided locations // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - labelList locationSurfaces(surfaces_.getInsidePointNamedSurfaces()); + labelList locationSurfaces + ( + surfaceZonesInfo::getInsidePointNamedSurfaces(surfZones) + ); + if (locationSurfaces.size()) { Info<< "Found " << locationSurfaces.size() diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C index 9f881a52f3..8d7e38512b 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementProblemCells.C @@ -568,7 +568,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells labelList hitSurface; surfaces_.findNearest ( - surfaces_.getUnnamedSurfaces(), + surfaceZonesInfo::getUnnamedSurfaces(surfaces_.surfZones()), localPoints, scalarField(localPoints.size(), sqr(GREAT)), // sqr of attraction hitSurface, diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C index b61fa74be3..bee6ada5a8 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.C @@ -33,45 +33,6 @@ License #include "UPtrList.H" #include "volumeType.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - template<> - const char* Foam::NamedEnum - < - Foam::refinementSurfaces::areaSelectionAlgo, - 4 - >::names[] = - { - "inside", - "outside", - "insidePoint", - "none" - }; -} -const Foam::NamedEnum - Foam::refinementSurfaces::areaSelectionAlgoNames; - - -namespace Foam -{ - template<> - const char* Foam::NamedEnum - < - Foam::refinementSurfaces::faceZoneType, - 3 - >::names[] = - { - "internal", - "baffle", - "boundary" - }; -} -const Foam::NamedEnum - Foam::refinementSurfaces::faceZoneTypeNames; - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::refinementSurfaces::refinementSurfaces @@ -84,19 +45,15 @@ Foam::refinementSurfaces::refinementSurfaces allGeometry_(allGeometry), surfaces_(surfacesDict.size()), names_(surfacesDict.size()), - faceZoneNames_(surfacesDict.size()), - cellZoneNames_(surfacesDict.size()), - zoneInside_(surfacesDict.size(), NONE), - zoneInsidePoints_(surfacesDict.size()), - faceType_(surfacesDict.size(), INTERNAL), + surfZones_(surfacesDict.size()), regionOffset_(surfacesDict.size()) { - // Wilcard specification : loop over all surface, all regions + // Wildcard specification : loop over all surface, all regions // and try to find a match. // Count number of surfaces. label surfI = 0; - forAll(allGeometry.names(), geomI) + forAll(allGeometry_.names(), geomI) { const word& geomName = allGeometry_.names()[geomI]; @@ -109,10 +66,7 @@ Foam::refinementSurfaces::refinementSurfaces // Size lists surfaces_.setSize(surfI); names_.setSize(surfI); - faceZoneNames_.setSize(surfI); - cellZoneNames_.setSize(surfI); - zoneInside_.setSize(surfI, NONE); - faceType_.setSize(surfI, INTERNAL), + surfZones_.setSize(surfI); regionOffset_.setSize(surfI); labelList globalMinLevel(surfI, 0); @@ -130,7 +84,7 @@ Foam::refinementSurfaces::refinementSurfaces HashSet unmatchedKeys(surfacesDict.toc()); surfI = 0; - forAll(allGeometry.names(), geomI) + forAll(allGeometry_.names(), geomI) { const word& geomName = allGeometry_.names()[geomI]; @@ -173,80 +127,10 @@ Foam::refinementSurfaces::refinementSurfaces << exit(FatalIOError); } + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; - // Global zone names per surface - if (dict.readIfPresent("faceZone", faceZoneNames_[surfI])) - { - // Read optional entry to determine inside of faceZone - - word method; - bool hasSide = dict.readIfPresent("cellZoneInside", method); - if (hasSide) - { - zoneInside_[surfI] = areaSelectionAlgoNames[method]; - if (zoneInside_[surfI] == INSIDEPOINT) - { - dict.lookup("insidePoint") >> zoneInsidePoints_[surfI]; - } - - } - else - { - // Check old syntax - bool inside; - if (dict.readIfPresent("zoneInside", inside)) - { - hasSide = true; - zoneInside_[surfI] = (inside ? INSIDE : OUTSIDE); - } - } - - // Read optional cellZone name - - if (dict.readIfPresent("cellZone", cellZoneNames_[surfI])) - { - if - ( - ( - zoneInside_[surfI] == INSIDE - || zoneInside_[surfI] == OUTSIDE - ) - && !allGeometry_[surfaces_[surfI]].hasVolumeType() - ) - { - IOWarningIn - ( - "refinementSurfaces::refinementSurfaces(..)", - dict - ) << "Illegal entry zoneInside " - << areaSelectionAlgoNames[zoneInside_[surfI]] - << " for faceZone " - << faceZoneNames_[surfI] - << " since surface " << names_[surfI] - << " is not closed." << endl; - } - } - else if (hasSide) - { - IOWarningIn - ( - "refinementSurfaces::refinementSurfaces(..)", - dict - ) << "Unused entry zoneInside for faceZone " - << faceZoneNames_[surfI] - << " since no cellZone specified." - << endl; - } - - // How to handle faces on faceZone - word faceTypeMethod; - if (dict.readIfPresent("faceType", faceTypeMethod)) - { - faceType_[surfI] = faceZoneTypeNames[faceTypeMethod]; - } - } - - + // Surface zones + surfZones_.set(surfI, new surfaceZonesInfo(surface, dict)); // Global perpendicular angle if (dict.found("patchInfo")) @@ -262,8 +146,7 @@ Foam::refinementSurfaces::refinementSurfaces if (dict.found("regions")) { const dictionary& regionsDict = dict.subDict("regions"); - const wordList& regionNames = - allGeometry_[surfaces_[surfI]].regions(); + const wordList& regionNames = surface.regions(); forAll(regionNames, regionI) { @@ -307,8 +190,6 @@ Foam::refinementSurfaces::refinementSurfaces << exit(FatalIOError); } - - if (regionDict.found("perpendicularAngle")) { regionAngle[surfI].insert @@ -429,11 +310,7 @@ Foam::refinementSurfaces::refinementSurfaces const searchableSurfaces& allGeometry, const labelList& surfaces, const wordList& names, - const wordList& faceZoneNames, - const wordList& cellZoneNames, - const List& zoneInside, - const pointField& zoneInsidePoints, - const List& faceType, + const PtrList& surfZones, const labelList& regionOffset, const labelList& minLevel, const labelList& maxLevel, @@ -445,11 +322,7 @@ Foam::refinementSurfaces::refinementSurfaces allGeometry_(allGeometry), surfaces_(surfaces), names_(names), - faceZoneNames_(faceZoneNames), - cellZoneNames_(cellZoneNames), - zoneInside_(zoneInside), - zoneInsidePoints_(zoneInsidePoints), - faceType_(faceType), + surfZones_(surfZones), regionOffset_(regionOffset), minLevel_(minLevel), maxLevel_(maxLevel), @@ -469,90 +342,6 @@ Foam::refinementSurfaces::refinementSurfaces // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Get indices of unnamed surfaces (surfaces without faceZoneName) -Foam::labelList Foam::refinementSurfaces::getUnnamedSurfaces() const -{ - labelList anonymousSurfaces(faceZoneNames_.size()); - - label i = 0; - forAll(faceZoneNames_, surfI) - { - if (faceZoneNames_[surfI].empty()) - { - anonymousSurfaces[i++] = surfI; - } - } - anonymousSurfaces.setSize(i); - - return anonymousSurfaces; -} - - -// Get indices of named surfaces (surfaces with faceZoneName) -Foam::labelList Foam::refinementSurfaces::getNamedSurfaces() const -{ - labelList namedSurfaces(faceZoneNames_.size()); - - label namedI = 0; - forAll(faceZoneNames_, surfI) - { - if (faceZoneNames_[surfI].size()) - { - namedSurfaces[namedI++] = surfI; - } - } - namedSurfaces.setSize(namedI); - - return namedSurfaces; -} - - -// Get indices of closed named surfaces -Foam::labelList Foam::refinementSurfaces::getClosedNamedSurfaces() const -{ - labelList closed(cellZoneNames_.size()); - - label closedI = 0; - forAll(cellZoneNames_, surfI) - { - if - ( - cellZoneNames_[surfI].size() - && ( - zoneInside_[surfI] == INSIDE - || zoneInside_[surfI] == OUTSIDE - ) - && allGeometry_[surfaces_[surfI]].hasVolumeType() - ) - { - closed[closedI++] = surfI; - } - } - closed.setSize(closedI); - - return closed; -} - - -// Get indices of named surfaces with a -Foam::labelList Foam::refinementSurfaces::getInsidePointNamedSurfaces() const -{ - labelList closed(cellZoneNames_.size()); - - label closedI = 0; - forAll(cellZoneNames_, surfI) - { - if (cellZoneNames_[surfI].size() && zoneInside_[surfI] == INSIDEPOINT) - { - closed[closedI++] = surfI; - } - } - closed.setSize(closedI); - - return closed; -} - - // // Count number of triangles per surface region // Foam::labelList Foam::refinementSurfaces::countRegions(const triSurface& s) // { @@ -843,7 +632,9 @@ void Foam::refinementSurfaces::findAllHigherIntersections forAll(surfaces_, surfI) { - allGeometry_[surfaces_[surfI]].findLineAll(start, end, hitInfo); + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; + + surface.findLineAll(start, end, hitInfo); // Repack hits for surface into flat list // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -873,8 +664,8 @@ void Foam::refinementSurfaces::findAllHigherIntersections labelList surfRegion(n); vectorField surfNormal(n); - allGeometry_[surfaces_[surfI]].getRegion(surfInfo, surfRegion); - allGeometry_[surfaces_[surfI]].getNormal(surfInfo, surfNormal); + surface.getRegion(surfInfo, surfRegion); + surface.getNormal(surfInfo, surfNormal); surfInfo.clear(); @@ -929,9 +720,11 @@ void Foam::refinementSurfaces::findAllHigherIntersections labelList pRegions; vectorField pNormals; - forAll(surfaces_, surfI) + forAll(surfaces(), surfI) { - allGeometry_[surfaces_[surfI]].findLineAll(start, end, hitInfo); + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; + + surface.findLineAll(start, end, hitInfo); // Repack hits for surface into flat list // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -961,8 +754,8 @@ void Foam::refinementSurfaces::findAllHigherIntersections labelList surfRegion(n); vectorField surfNormal(n); - allGeometry_[surfaces_[surfI]].getRegion(surfInfo, surfRegion); - allGeometry_[surfaces_[surfI]].getNormal(surfInfo, surfNormal); + surface.getRegion(surfInfo, surfRegion); + surface.getNormal(surfInfo, surfNormal); // Extract back into pointwise // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1023,14 +816,16 @@ void Foam::refinementSurfaces::findNearestIntersection { label surfI = surfacesToTest[testI]; + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; + // See if any intersection between start and current nearest - allGeometry_[surfaces_[surfI]].findLine + surface.findLine ( start, nearest, nearestInfo ); - allGeometry_[surfaces_[surfI]].getRegion + surface.getRegion ( nearestInfo, region @@ -1076,14 +871,16 @@ void Foam::refinementSurfaces::findNearestIntersection { label surfI = surfacesToTest[testI]; + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; + // See if any intersection between end and current nearest - allGeometry_[surfaces_[surfI]].findLine + surface.findLine ( end, nearest, nearestInfo ); - allGeometry_[surfaces_[surfI]].getRegion + surface.getRegion ( nearestInfo, region @@ -1489,20 +1286,29 @@ void Foam::refinementSurfaces::findInside { label surfI = testSurfaces[i]; - if (zoneInside_[surfI] != INSIDE && zoneInside_[surfI] != OUTSIDE) + const searchableSurface& surface = allGeometry_[surfaces_[surfI]]; + + const surfaceZonesInfo::areaSelectionAlgo selectionMethod = + surfZones_[surfI].zoneInside(); + + if + ( + selectionMethod != surfaceZonesInfo::INSIDE + && selectionMethod != surfaceZonesInfo::OUTSIDE + ) { FatalErrorIn("refinementSurfaces::findInside(..)") << "Trying to use surface " - << allGeometry_[surfaces_[surfI]].name() + << surface.name() << " which has non-geometric inside selection method " - << areaSelectionAlgoNames[zoneInside_[surfI]] + << surfaceZonesInfo::areaSelectionAlgoNames[selectionMethod] << exit(FatalError); } - if (allGeometry_[surfaces_[surfI]].hasVolumeType()) + if (surface.hasVolumeType()) { List volType; - allGeometry_[surfaces_[surfI]].getVolumeType(pt, volType); + surface.getVolumeType(pt, volType); forAll(volType, pointI) { @@ -1512,11 +1318,11 @@ void Foam::refinementSurfaces::findInside ( ( volType[pointI] == volumeType::INSIDE - && zoneInside_[surfI] == INSIDE + && selectionMethod == surfaceZonesInfo::INSIDE ) || ( volType[pointI] == volumeType::OUTSIDE - && zoneInside_[surfI] == OUTSIDE + && selectionMethod == surfaceZonesInfo::OUTSIDE ) ) { diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H index e705e3a7d8..7f777daf33 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/refinementSurfaces.H @@ -41,6 +41,7 @@ SourceFiles #include "triSurfaceFields.H" #include "vectorList.H" #include "pointIndexHit.H" +#include "surfaceZonesInfo.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,31 +60,6 @@ typedef List pointList; class refinementSurfaces { -public: - - //- Types of selection of area - enum areaSelectionAlgo - { - INSIDE, - OUTSIDE, - INSIDEPOINT, - NONE - }; - - static const NamedEnum areaSelectionAlgoNames; - - //- What to do with faceZone faces - enum faceZoneType - { - INTERNAL, - BAFFLE, - BOUNDARY - }; - - static const NamedEnum faceZoneTypeNames; - -private: - // Private data //- Reference to all geometry. @@ -95,23 +71,8 @@ private: //- Surface name (word) wordList names_; - //- Per 'interface' surface : name of faceZone to put faces into - wordList faceZoneNames_; - - //- Per 'interface' surface : name of cellZone to put cells into - wordList cellZoneNames_; - - //- Per 'interface' surface : (only used if surface is closed) - // How to select zone cells : surface inside or outside or given - // inside location. - List zoneInside_; - - //- If zoneInside=location gives the corresponding inside point - pointField zoneInsidePoints_; - - //- Per 'interface' surface : - // What to do with outside - List faceType_; + //- List of surface zone (face and cell zone) information + PtrList surfZones_; //- From local region number to global region number labelList regionOffset_; @@ -159,11 +120,7 @@ public: const searchableSurfaces& allGeometry, const labelList& surfaces, const wordList& names, - const wordList& faceZoneNames, - const wordList& cellZoneNames, - const List& zoneInside, - const pointField& zoneInsidePoints, - const List& faceType, + const PtrList& surfZones, const labelList& regionOffset, const labelList& minLevel, const labelList& maxLevel, @@ -193,44 +150,9 @@ public: return names_; } - //- Per 'interface' surface : empty or name of faceZone to put - // faces into - const wordList& faceZoneNames() const + const PtrList& surfZones() const { - return faceZoneNames_; - } - - //- Per 'interface' surface : empty or name of cellZone to put - // cells into - const wordList& cellZoneNames() const - { - return cellZoneNames_; - } - - //- Get indices of unnamed surfaces (surfaces without faceZoneName) - labelList getUnnamedSurfaces() const; - - //- Get indices of named surfaces (surfaces with faceZoneName) - labelList getNamedSurfaces() const; - - //- Get indices of surfaces with a cellZone that are closed and - // have 'inside' or 'outside' selection. - labelList getClosedNamedSurfaces() const; - - //- Get indices of surfaces with a cellZone that have 'insidePoint' - // section. - labelList getInsidePointNamedSurfaces() const; - - //- Get specified inside locations for surfaces with a cellZone - const pointField& zoneInsidePoints() const - { - return zoneInsidePoints_; - } - - //- How to handle face of surfaces with a faceZone - const List& faceType() const - { - return faceType_; + return surfZones_; } //- From local region number to global region number diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C new file mode 100644 index 0000000000..4a8b82e129 --- /dev/null +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.C @@ -0,0 +1,421 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "surfaceZonesInfo.H" +#include "searchableSurface.H" +#include "searchableSurfaces.H" +#include "polyMesh.H" +#include "dictionary.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + template<> + const char* Foam::NamedEnum + < + Foam::surfaceZonesInfo::areaSelectionAlgo, + 4 + >::names[] = + { + "inside", + "outside", + "insidePoint", + "none" + }; +} +const Foam::NamedEnum + Foam::surfaceZonesInfo::areaSelectionAlgoNames; + + +namespace Foam +{ + template<> + const char* Foam::NamedEnum + < + Foam::surfaceZonesInfo::faceZoneType, + 3 + >::names[] = + { + "internal", + "baffle", + "boundary" + }; +} +const Foam::NamedEnum + Foam::surfaceZonesInfo::faceZoneTypeNames; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::surfaceZonesInfo::surfaceZonesInfo +( + const searchableSurface& surface, + const dictionary& surfacesDict +) +: + faceZoneName_(), + cellZoneName_(), + zoneInside_(NONE), + zoneInsidePoint_(point::min), + faceType_(INTERNAL) +{ + // Global zone names per surface + if (surfacesDict.readIfPresent("faceZone", faceZoneName_)) + { + // Read optional entry to determine inside of faceZone + + word method; + bool hasSide = surfacesDict.readIfPresent("cellZoneInside", method); + if (hasSide) + { + zoneInside_ = areaSelectionAlgoNames[method]; + if (zoneInside_ == INSIDEPOINT) + { + surfacesDict.lookup("insidePoint") >> zoneInsidePoint_; + } + + } + else + { + // Check old syntax + bool inside; + if (surfacesDict.readIfPresent("zoneInside", inside)) + { + hasSide = true; + zoneInside_ = (inside ? INSIDE : OUTSIDE); + } + } + + // Read optional cellZone name + + if (surfacesDict.readIfPresent("cellZone", cellZoneName_)) + { + if + ( + ( + zoneInside_ == INSIDE + || zoneInside_ == OUTSIDE + ) + && !surface.hasVolumeType() + ) + { + IOWarningIn + ( + "refinementSurfaces::refinementSurfaces(..)", + surfacesDict + ) << "Illegal entry zoneInside " + << areaSelectionAlgoNames[zoneInside_] + << " for faceZone " + << faceZoneName_ + << " since surface is not closed." << endl; + } + } + else if (hasSide) + { + IOWarningIn + ( + "refinementSurfaces::refinementSurfaces(..)", + surfacesDict + ) << "Unused entry zoneInside for faceZone " + << faceZoneName_ + << " since no cellZone specified." + << endl; + } + + // How to handle faces on faceZone + word faceTypeMethod; + if (surfacesDict.readIfPresent("faceType", faceTypeMethod)) + { + faceType_ = faceZoneTypeNames[faceTypeMethod]; + } + } +} + + +Foam::surfaceZonesInfo::surfaceZonesInfo +( + const word& faceZoneName, + const word& cellZoneName, + const areaSelectionAlgo& zoneInside, + const point& zoneInsidePoint, + const faceZoneType& faceType +) +: + faceZoneName_(faceZoneName), + cellZoneName_(cellZoneName), + zoneInside_(zoneInside), + zoneInsidePoint_(zoneInsidePoint), + faceType_(faceType) +{} + + +Foam::surfaceZonesInfo::surfaceZonesInfo(const surfaceZonesInfo& surfZone) +: + faceZoneName_(surfZone.faceZoneName()), + cellZoneName_(surfZone.cellZoneName()), + zoneInside_(surfZone.zoneInside()), + zoneInsidePoint_(surfZone.zoneInsidePoint()), + faceType_(surfZone.faceType()) +{} + + +// Get indices of unnamed surfaces (surfaces without faceZoneName) +Foam::labelList Foam::surfaceZonesInfo::getUnnamedSurfaces +( + const PtrList& surfList +) +{ + labelList anonymousSurfaces(surfList.size()); + + label i = 0; + forAll(surfList, surfI) + { + if (surfList[surfI].faceZoneName().empty()) + { + anonymousSurfaces[i++] = surfI; + } + } + anonymousSurfaces.setSize(i); + + return anonymousSurfaces; +} + + +// Get indices of named surfaces (surfaces with faceZoneName) +Foam::labelList Foam::surfaceZonesInfo::getNamedSurfaces +( + const PtrList& surfList +) +{ + labelList namedSurfaces(surfList.size()); + + label namedI = 0; + forAll(surfList, surfI) + { + if (surfList[surfI].faceZoneName().size()) + { + namedSurfaces[namedI++] = surfI; + } + } + namedSurfaces.setSize(namedI); + + return namedSurfaces; +} + + +// Get indices of closed named surfaces +Foam::labelList Foam::surfaceZonesInfo::getClosedNamedSurfaces +( + const PtrList& surfList, + const searchableSurfaces& allGeometry, + const labelList& surfaces +) +{ + labelList closed(surfList.size()); + + label closedI = 0; + forAll(surfList, surfI) + { + if + ( + surfList[surfI].cellZoneName().size() + && ( + surfList[surfI].zoneInside() == surfaceZonesInfo::INSIDE + || surfList[surfI].zoneInside() == surfaceZonesInfo::OUTSIDE + ) + && allGeometry[surfaces[surfI]].hasVolumeType() + ) + { + closed[closedI++] = surfI; + } + } + closed.setSize(closedI); + + return closed; +} + + +// Get indices of named surfaces with a +Foam::labelList Foam::surfaceZonesInfo::getInsidePointNamedSurfaces +( + const PtrList& surfList +) +{ + labelList closed(surfList.size()); + + label closedI = 0; + forAll(surfList, surfI) + { + if + ( + surfList[surfI].cellZoneName().size() + && surfList[surfI].zoneInside() == surfaceZonesInfo::INSIDEPOINT + ) + { + closed[closedI++] = surfI; + } + } + closed.setSize(closedI); + + return closed; +} + + +Foam::labelList Foam::surfaceZonesInfo::addCellZonesToMesh +( + const PtrList& surfList, + const labelList& namedSurfaces, + polyMesh& mesh +) +{ + labelList surfaceToCellZone(surfList.size(), -1); + + cellZoneMesh& cellZones = mesh.cellZones(); + + forAll(namedSurfaces, i) + { + label surfI = namedSurfaces[i]; + + const word& cellZoneName = surfList[surfI].cellZoneName(); + + if (cellZoneName != word::null) + { + label zoneI = cellZones.findZoneID(cellZoneName); + + if (zoneI == -1) + { + zoneI = cellZones.size(); + cellZones.setSize(zoneI+1); + cellZones.set + ( + zoneI, + new cellZone + ( + cellZoneName, //name + labelList(0), //addressing + zoneI, //index + cellZones //cellZoneMesh + ) + ); + } + + surfaceToCellZone[surfI] = zoneI; + } + } + + // Check they are synced + List allCellZones(Pstream::nProcs()); + allCellZones[Pstream::myProcNo()] = cellZones.names(); + Pstream::gatherList(allCellZones); + Pstream::scatterList(allCellZones); + + for (label procI = 1; procI < allCellZones.size(); procI++) + { + if (allCellZones[procI] != allCellZones[0]) + { + FatalErrorIn + ( + "meshRefinement::zonify" + "(const label, const point&)" + ) << "Zones not synchronised among processors." << nl + << " Processor0 has cellZones:" << allCellZones[0] + << " , processor" << procI + << " has cellZones:" << allCellZones[procI] + << exit(FatalError); + } + } + + return surfaceToCellZone; +} + + +Foam::labelList Foam::surfaceZonesInfo::addFaceZonesToMesh +( + const PtrList& surfList, + const labelList& namedSurfaces, + polyMesh& mesh +) +{ + labelList surfaceToFaceZone(surfList.size(), -1); + + faceZoneMesh& faceZones = mesh.faceZones(); + + forAll(namedSurfaces, i) + { + label surfI = namedSurfaces[i]; + + const word& faceZoneName = surfList[surfI].faceZoneName(); + + label zoneI = faceZones.findZoneID(faceZoneName); + + if (zoneI == -1) + { + zoneI = faceZones.size(); + faceZones.setSize(zoneI+1); + faceZones.set + ( + zoneI, + new faceZone + ( + faceZoneName, //name + labelList(0), //addressing + boolList(0), //flipmap + zoneI, //index + faceZones //faceZoneMesh + ) + ); + } + + surfaceToFaceZone[surfI] = zoneI; + } + + // Check they are synced + List allFaceZones(Pstream::nProcs()); + allFaceZones[Pstream::myProcNo()] = faceZones.names(); + Pstream::gatherList(allFaceZones); + Pstream::scatterList(allFaceZones); + + for (label procI = 1; procI < allFaceZones.size(); procI++) + { + if (allFaceZones[procI] != allFaceZones[0]) + { + FatalErrorIn + ( + "meshRefinement::zonify" + "(const label, const point&)" + ) << "Zones not synchronised among processors." << nl + << " Processor0 has faceZones:" << allFaceZones[0] + << " , processor" << procI + << " has faceZones:" << allFaceZones[procI] + << exit(FatalError); + } + } + + return surfaceToFaceZone; +} + + +// ************************************************************************* // diff --git a/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H new file mode 100644 index 0000000000..dbfd86e9f8 --- /dev/null +++ b/src/mesh/autoMesh/autoHexMesh/refinementSurfaces/surfaceZonesInfo.H @@ -0,0 +1,233 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::surfaceZonesInfo + +Description + +SourceFiles + surfaceZonesInfo.C + +\*---------------------------------------------------------------------------*/ + +#ifndef surfaceZonesInfo_H +#define surfaceZonesInfo_H + +#include "NamedEnum.H" +#include "point.H" +#include "word.H" +#include "PtrList.H" +#include "labelList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class searchableSurface; +class searchableSurfaces; +class polyMesh; +class dictionary; + +/*---------------------------------------------------------------------------*\ + Class surfaceZonesInfo Declaration +\*---------------------------------------------------------------------------*/ + +class surfaceZonesInfo +{ +public: + + //- Types of selection of area + enum areaSelectionAlgo + { + INSIDE, + OUTSIDE, + INSIDEPOINT, + NONE + }; + + static const NamedEnum areaSelectionAlgoNames; + + //- What to do with faceZone faces + enum faceZoneType + { + INTERNAL, + BAFFLE, + BOUNDARY + }; + + static const NamedEnum faceZoneTypeNames; + + +private: + + // Private data + + //- Per 'interface' surface : name of faceZone to put faces into + word faceZoneName_; + + //- Per 'interface' surface : name of cellZone to put cells into + word cellZoneName_; + + //- Per 'interface' surface : (only used if surface is closed) + // How to select zone cells : surface inside or outside or given + // inside location. + areaSelectionAlgo zoneInside_; + + //- If zoneInside=location gives the corresponding inside point + point zoneInsidePoint_; + + //- Per 'interface' surface : + // What to do with outside + faceZoneType faceType_; + + + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const surfaceZonesInfo&); + + +public: + + // Constructors + + //- Construct from surfaces and dictionary + surfaceZonesInfo + ( + const searchableSurface& surface, + const dictionary& surfacesDict + ); + + //- Construct from components + surfaceZonesInfo + ( + const word& faceZoneNames, + const word& cellZoneNames, + const areaSelectionAlgo& zoneInside, + const point& zoneInsidePoints, + const faceZoneType& faceType + ); + + //- Copy constructor + surfaceZonesInfo(const surfaceZonesInfo&); + + //- Return clone + autoPtr clone() const + { + return autoPtr(new surfaceZonesInfo(*this)); + } + + + // Member Functions + + // Access + + //- Per 'interface' surface : empty or name of faceZone to put + // faces into + const word& faceZoneName() const + { + return faceZoneName_; + } + + //- Per 'interface' surface : empty or name of cellZone to put + // cells into + const word& cellZoneName() const + { + return cellZoneName_; + } + + const areaSelectionAlgo& zoneInside() const + { + return zoneInside_; + } + + //- Get specified inside locations for surfaces with a cellZone + const point& zoneInsidePoint() const + { + return zoneInsidePoint_; + } + + //- How to handle face of surfaces with a faceZone + const faceZoneType& faceType() const + { + return faceType_; + } + + + // Query + + //- Get indices of unnamed surfaces (surfaces without faceZoneName) + static labelList getUnnamedSurfaces + ( + const PtrList& surfList + ); + + //- Get indices of named surfaces (surfaces with faceZoneName) + static labelList getNamedSurfaces + ( + const PtrList& surfList + ); + + //- Get indices of surfaces with a cellZone that are closed and + // have 'inside' or 'outside' selection. + static labelList getClosedNamedSurfaces + ( + const PtrList& surfList, + const searchableSurfaces& allGeometry, + const labelList& surfaces + ); + + //- Get indices of surfaces with a cellZone that have 'insidePoint' + // section. + static labelList getInsidePointNamedSurfaces + ( + const PtrList& surfList + ); + + static labelList addCellZonesToMesh + ( + const PtrList& surfList, + const labelList& namedSurfaces, + polyMesh& mesh + ); + + static labelList addFaceZonesToMesh + ( + const PtrList& surfList, + const labelList& namedSurfaces, + polyMesh& mesh + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From cadaee82b7f8e71e2437231851a8bb070a3162ca Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 3 Sep 2013 14:40:49 +0100 Subject: [PATCH 14/28] ENH: polyTopoChange: handle meshes without patches --- .../meshes/polyMesh/mapPolyMesh/mapPolyMesh.C | 47 +++++++++---------- .../polyTopoChange/polyTopoChange.C | 25 +++++----- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C index f892a0d7c8..faf2922955 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapPolyMesh.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,11 +26,8 @@ License #include "mapPolyMesh.H" #include "polyMesh.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from components Foam::mapPolyMesh::mapPolyMesh ( const polyMesh& mesh, @@ -115,7 +112,6 @@ Foam::mapPolyMesh::mapPolyMesh } -// Construct from components and optionally reuse storage Foam::mapPolyMesh::mapPolyMesh ( const polyMesh& mesh, @@ -177,31 +173,32 @@ Foam::mapPolyMesh::mapPolyMesh oldPatchStarts_(oldPatchStarts, reUse), oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse) { - // Calculate old patch sizes - for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++) + if (oldPatchStarts_.size() > 0) { - oldPatchSizes_[patchI] = - oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI]; - } - - // Set the last one by hand - const label lastPatchID = oldPatchStarts_.size() - 1; - - oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID]; - - if (polyMesh::debug) - { - if (min(oldPatchSizes_) < 0) + // Calculate old patch sizes + for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++) { - FatalErrorIn("mapPolyMesh::mapPolyMesh(...)") - << "Calculated negative old patch size. Error in mapping data" - << abort(FatalError); + oldPatchSizes_[patchI] = + oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI]; + } + + // Set the last one by hand + const label lastPatchID = oldPatchStarts_.size() - 1; + + oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID]; + + if (polyMesh::debug) + { + if (min(oldPatchSizes_) < 0) + { + FatalErrorIn("mapPolyMesh::mapPolyMesh(...)") + << "Calculated negative old patch size." + << " Error in mapping data" + << abort(FatalError); + } } } } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - - // ************************************************************************* // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 49ee1a445e..23e39f203d 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -818,22 +818,25 @@ void Foam::polyTopoChange::getFaceOrder patchSizes.setSize(nPatches_); patchSizes = 0; - patchStarts[0] = newFaceI; - - for (label faceI = 0; faceI < nActiveFaces; faceI++) + if (nPatches_ > 0) { - if (region_[faceI] >= 0) + patchStarts[0] = newFaceI; + + for (label faceI = 0; faceI < nActiveFaces; faceI++) { - patchSizes[region_[faceI]]++; + if (region_[faceI] >= 0) + { + patchSizes[region_[faceI]]++; + } } - } - label faceI = patchStarts[0]; + label faceI = patchStarts[0]; - forAll(patchStarts, patchI) - { - patchStarts[patchI] = faceI; - faceI += patchSizes[patchI]; + forAll(patchStarts, patchI) + { + patchStarts[patchI] = faceI; + faceI += patchSizes[patchI]; + } } //if (debug) From f2d8f6361cebe3e08c903be36395ef42c0930ac2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 3 Sep 2013 15:28:26 +0100 Subject: [PATCH 15/28] ENH: dictionary: added topDict() function --- src/OpenFOAM/db/dictionary/dictionary.C | 17 +++++++++++- src/OpenFOAM/db/dictionary/dictionary.H | 5 +++- .../functionEntries/codeStream/codeStream.C | 26 +++---------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index e6f7c6c7db..57ebd84f76 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -222,6 +222,21 @@ Foam::dictionary::~dictionary() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +const Foam::dictionary& Foam::dictionary::topDict() const +{ + const dictionary& p = parent(); + + if (&p != this && !p.name().empty()) + { + return p.topDict(); + } + else + { + return p; + } +} + + Foam::label Foam::dictionary::startLineNumber() const { if (size()) diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 2eab9e2778..f7e7f8668c 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -250,6 +250,9 @@ public: return parent_; } + //- Return the top of the tree + const dictionary& topDict() const; + //- Return line number of first token in dictionary label startLineNumber() const; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 1c774c352b..f855f79bc2 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -65,30 +65,12 @@ const Foam::word Foam::functionEntries::codeStream::codeTemplateC // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -const Foam::dictionary& Foam::functionEntries::codeStream::topDict -( - const dictionary& dict -) -{ - const dictionary& p = dict.parent(); - - if (&p != &dict && !p.name().empty()) - { - return topDict(p); - } - else - { - return dict; - } -} - - Foam::dlLibraryTable& Foam::functionEntries::codeStream::libs ( const dictionary& dict ) { - const IOdictionary& d = static_cast(topDict(dict)); + const IOdictionary& d = static_cast(dict.topDict()); return const_cast(d.time()).libs(); } @@ -114,7 +96,7 @@ Foam::functionEntries::codeStream::getFunction // see if library is loaded void* lib = NULL; - if (isA(topDict(parentDict))) + if (isA(parentDict.topDict())) { lib = libs(parentDict).findLibrary(libPath); } @@ -129,7 +111,7 @@ Foam::functionEntries::codeStream::getFunction // avoid compilation if possible by loading an existing library if (!lib) { - if (isA(topDict(parentDict))) + if (isA(parentDict.topDict())) { // Cached access to dl libs. Guarantees clean up upon destruction // of Time. @@ -267,7 +249,7 @@ Foam::functionEntries::codeStream::getFunction } } - if (isA(topDict(parentDict))) + if (isA(parentDict.topDict())) { // Cached access to dl libs. Guarantees clean up upon destruction // of Time. From 040e6d915926577a17450ecc9f365574c3775425 Mon Sep 17 00:00:00 2001 From: laurence Date: Tue, 3 Sep 2013 21:00:57 +0100 Subject: [PATCH 16/28] ENH: foamyHexMesh: add face/cell zoning --- .../mesh/generation/foamyHexMesh/Make/options | 1 + .../DelaunayMeshToolsTemplates.C | 8 +- .../conformalVoronoiMesh/Make/options | 4 +- .../conformalVoronoiMesh.H | 26 +- .../conformalVoronoiMeshCalcDualMesh.C | 28 +- .../conformalVoronoiMeshIO.C | 524 +++++++++++++++++- .../conformationSurfaces.C | 24 - .../generation/foamyQuadMesh/Make/options | 1 + .../refinementSurfaces/surfaceZonesInfo.C | 45 +- .../refinementSurfaces/surfaceZonesInfo.H | 8 + 10 files changed, 599 insertions(+), 70 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/Make/options b/applications/utilities/mesh/generation/foamyHexMesh/Make/options index 9461fa3725..f03dbf9097 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/Make/options +++ b/applications/utilities/mesh/generation/foamyHexMesh/Make/options @@ -21,6 +21,7 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/mesh/autoMesh/lnInclude \ -IvectorTools EXE_LIBS = \ diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C index 551380c6e2..1b570e90e7 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMeshTools/DelaunayMeshToolsTemplates.C @@ -279,11 +279,9 @@ Foam::tmp Foam::DelaunayMeshTools::allPoints const Triangulation& t ) { - tmp tpts(new pointField(t.number_of_vertices(), point::max)); + tmp tpts(new pointField(t.vertexCount(), point::max)); pointField& pts = tpts(); - label nVert = 0; - for ( typename Triangulation::Finite_vertices_iterator vit = @@ -292,9 +290,9 @@ Foam::tmp Foam::DelaunayMeshTools::allPoints ++vit ) { - if (vit->internalOrBoundaryPoint()) + if (vit->internalOrBoundaryPoint() && !vit->referred()) { - pts[nVert++] = topoint(vit->point()); + pts[vit->index()] = topoint(vit->point()); } } diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/options b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/options index 9963458aa5..2be5855323 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/options +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/options @@ -22,6 +22,7 @@ EXE_INC = \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/mesh/autoMesh/lnInclude \ -IPrintTable \ -I../vectorTools @@ -32,4 +33,5 @@ LIB_LIBS = \ -ltriSurface \ -ldynamicMesh \ -lsurfMesh \ - -lsampling + -lsampling \ + -lautoMesh diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index dcaf44f997..6dd0675993 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -600,6 +600,29 @@ private: PackedBoolList& boundaryFacesToRemove ); + //- From meshRefinementBaffles.C. Use insidePoint for a surface to + // determine the cell zone. + void findCellZoneInsideWalk + ( + const polyMesh& mesh, + const labelList& locationSurfaces, + const labelList& faceToSurface, + labelList& cellToSurface + ) const; + + //- Calculate the cell zones from cellCentres using all closed surfaces + labelList calcCellZones(const pointField& cellCentres) const; + + //- Calculate the face zones + void calcFaceZones + ( + const polyMesh& mesh, + const pointField& cellCentres, + const labelList& cellToSurface, + labelList& faceToSurface, + boolList& flipMap + ) const; + //- Tet mesh calculation void calcTetMesh ( @@ -712,9 +735,6 @@ private: bool includeEmptyPatches = false ) const; - //- Create the cell centres to use for the mesh - void createCellCentres(pointField& cellCentres) const; - //- Sort the faces, owner and neighbour lists into // upper-triangular order. For internal faces only, use // before adding patch faces diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 86892c28d9..c943ca978b 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -2852,32 +2852,6 @@ void Foam::conformalVoronoiMesh::createFacesOwnerNeighbourAndPatches } -void Foam::conformalVoronoiMesh::createCellCentres -( - pointField& cellCentres -) const -{ - cellCentres.setSize(number_of_vertices(), point::max); - - label vertI = 0; - - for - ( - Delaunay::Finite_vertices_iterator vit = finite_vertices_begin(); - vit != finite_vertices_end(); - ++vit - ) - { - if (vit->internalOrBoundaryPoint()) - { - cellCentres[vertI++] = topoint(vit->point()); - } - } - - cellCentres.setSize(vertI); -} - - void Foam::conformalVoronoiMesh::sortFaces ( faceList& faces, @@ -3095,7 +3069,7 @@ Foam::labelList Foam::conformalVoronoiMesh::removeUnusedCells { Info<< nl << "Removing unused cells" << endl; - PackedBoolList cellUsed(number_of_vertices(), false); + PackedBoolList cellUsed(vertexCount(), false); // Scan all faces to find all of the cells that are used diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index bb34cbd4a6..07fd509e1f 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -35,6 +35,11 @@ License #include "pointMesh.H" #include "indexedVertexOps.H" #include "DelaunayMeshTools.H" +#include "surfaceZonesInfo.H" +#include "polyModifyCell.H" +#include "polyModifyFace.H" +#include "syncTools.H" +#include "regionSplit.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -402,6 +407,376 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance) } +void Foam::conformalVoronoiMesh::findCellZoneInsideWalk +( + const polyMesh& mesh, + const labelList& locationSurfaces, // indices of surfaces with inside point + const labelList& faceToSurface, // per face index of named surface + labelList& cellToSurface +) const +{ + // Analyse regions. Reuse regionsplit + boolList blockedFace(mesh.nFaces()); + //selectSeparatedCoupledFaces(blockedFace); + + forAll(faceToSurface, faceI) + { + if (faceToSurface[faceI] == -1) + { + blockedFace[faceI] = false; + } + else + { + blockedFace[faceI] = true; + } + } + // No need to sync since namedSurfaceIndex already is synced + + // Set region per cell based on walking + regionSplit cellRegion(mesh, blockedFace); + blockedFace.clear(); + + + // Force calculation of face decomposition (used in findCell) + (void)mesh.tetBasePtIs(); + + const PtrList& surfZones = + geometryToConformTo().surfZones(); + + // For all locationSurface find the cell + forAll(locationSurfaces, i) + { + label surfI = locationSurfaces[i]; + + const Foam::point& insidePoint = surfZones[surfI].zoneInsidePoint(); + + const word& surfName = geometryToConformTo().geometry().names()[surfI]; + + Info<< " For surface " << surfName + << " finding inside point " << insidePoint + << endl; + + // Find the region containing the insidePoint + label keepRegionI = -1; + + label cellI = mesh.findCell(insidePoint); + + if (cellI != -1) + { + keepRegionI = cellRegion[cellI]; + } + reduce(keepRegionI, maxOp