From e8d651060dee39b1fab2a897132d044daa5e3721 Mon Sep 17 00:00:00 2001 From: laurence Date: Wed, 18 Sep 2013 14:58:28 +0100 Subject: [PATCH 1/8] ENH: foamyHexMesh: Insert referred points that are outside convex hull --- .../DelaunayMesh/DistributedDelaunayMesh.C | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C index 152a82c7f2..40c76aec9d 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/DelaunayMesh/DistributedDelaunayMesh.C @@ -966,6 +966,15 @@ Foam::DistributedDelaunayMesh::rangeInsertReferredWithInfo ) << "Point is outside affine hull! pt = " << pointToInsert << endl; } + else if (lt == Triangulation::OUTSIDE_CONVEX_HULL) + { + // @todo Can this be optimised? + // + // Only want to insert if a connection is formed between + // pointToInsert and an internal or internal boundary point. + hint = Triangulation::insert(pointToInsert, c); + inserted = true; + } else { // Get the cells that conflict with p in a vector V, From b4a742fc893ae4721d5c90b0003e310b7e5b1a08 Mon Sep 17 00:00:00 2001 From: laurence Date: Wed, 18 Sep 2013 15:31:58 +0100 Subject: [PATCH 2/8] ENH: collapseEdges: Points now get a priority. The higher the number, the more likely the collapse will be towards that point --- .../advanced/collapseEdges/collapseEdges.C | 65 +- .../conformalVoronoiMesh.C | 20 +- .../conformalVoronoiMesh.H | 15 +- .../conformalVoronoiMeshCalcDualMesh.C | 458 ++--- .../conformalVoronoiMeshIO.C | 202 +-- .../indexedCell/indexedCell.H | 5 + .../indexedCell/indexedCellI.H | 81 + .../indexedVertex/indexedVertex.H | 2 + .../indexedVertex/indexedVertexEnum.C | 8 +- .../indexedVertex/indexedVertexEnum.H | 28 +- .../indexedVertex/indexedVertexI.H | 20 + src/dynamicMesh/Make/files | 1 + .../polyMeshFilter/polyMeshFilter.C | 1580 ++++++----------- .../polyMeshFilter/polyMeshFilter.H | 85 +- .../polyTopoChange/edgeCollapser.C | 276 +-- 15 files changed, 1281 insertions(+), 1565 deletions(-) diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C index 7a07b63d8f..0515205c78 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C @@ -95,24 +95,56 @@ int main(int argc, char *argv[]) const bool collapseFaces = args.optionFound("collapseFaces"); const bool collapseFaceZone = args.optionFound("collapseFaceZone"); + if (collapseFaces && collapseFaceZone) + { + FatalErrorIn("main(int, char*[])") + << "Both face zone collapsing and face collapsing have been" + << "selected. Choose only one of:" << nl + << " -collapseFaces" << nl + << " -collapseFaceZone " + << abort(FatalError); + } + + labelIOList pointPriority + ( + IOobject + ( + "pointPriority", + runTime.timeName(), + runTime, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + labelList(mesh.nPoints(), labelMin) + ); + forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Info<< "Time = " << runTime.timeName() << endl; - polyMeshFilter meshFilter(mesh); + autoPtr meshFilterPtr; - // newMesh will be empty until it is filtered - const autoPtr& newMesh = meshFilter.filteredMesh(); + label nBadFaces = 0; - // Filter small edges only. This reduces the number of faces so that - // the face filtering is sped up. - label nBadFaces = meshFilter.filterEdges(0); { - polyTopoChange meshMod(newMesh); + meshFilterPtr.set(new polyMeshFilter(mesh, pointPriority)); + polyMeshFilter& meshFilter = meshFilterPtr(); - meshMod.changeMesh(mesh, false); + // newMesh will be empty until it is filtered + const autoPtr& newMesh = meshFilter.filteredMesh(); + + // Filter small edges only. This reduces the number of faces so that + // the face filtering is sped up. + nBadFaces = meshFilter.filterEdges(0); + { + polyTopoChange meshMod(newMesh); + + meshMod.changeMesh(mesh, false); + } + + pointPriority = meshFilter.pointPriority(); } if (collapseFaceZone) @@ -121,18 +153,30 @@ int main(int argc, char *argv[]) const faceZone& fZone = mesh.faceZones()[faceZoneName]; + meshFilterPtr.reset(new polyMeshFilter(mesh, pointPriority)); + polyMeshFilter& meshFilter = meshFilterPtr(); + + const autoPtr& newMesh = meshFilter.filteredMesh(); + // Filter faces. Pass in the number of bad faces that are present // from the previous edge filtering to use as a stopping criterion. - meshFilter.filterFaceZone(fZone); + meshFilter.filter(fZone); { polyTopoChange meshMod(newMesh); meshMod.changeMesh(mesh, false); } + + pointPriority = meshFilter.pointPriority(); } if (collapseFaces) { + meshFilterPtr.reset(new polyMeshFilter(mesh, pointPriority)); + polyMeshFilter& meshFilter = meshFilterPtr(); + + const autoPtr& newMesh = meshFilter.filteredMesh(); + // Filter faces. Pass in the number of bad faces that are present // from the previous edge filtering to use as a stopping criterion. meshFilter.filter(nBadFaces); @@ -141,6 +185,8 @@ int main(int argc, char *argv[]) meshMod.changeMesh(mesh, false); } + + pointPriority = meshFilter.pointPriority(); } // Write resulting mesh @@ -157,6 +203,7 @@ int main(int argc, char *argv[]) << runTime.timeName() << nl << endl; mesh.write(); + pointPriority.write(); } Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 8224492921..e5a5d9e1bf 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -41,9 +41,26 @@ License namespace Foam { -defineTypeNameAndDebug(conformalVoronoiMesh, 0); + defineTypeNameAndDebug(conformalVoronoiMesh, 0); + + template<> + const char* Foam::NamedEnum + < + Foam::conformalVoronoiMesh::dualMeshPointType, + 5 + >::names[] = + { + "internal", + "surface", + "featureEdge", + "featurePoint", + "constrained" + }; } +const Foam::NamedEnum + Foam::conformalVoronoiMesh::dualMeshPointTypeNames_; + // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // @@ -1600,7 +1617,6 @@ void Foam::conformalVoronoiMesh::move() printVertexInfo(Info); } - // Write the intermediate mesh, do not filter the dual faces. if (time().outputTime()) { writeMesh(time().timeName()); diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index eb75909d1c..1daffd4c74 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -120,6 +120,17 @@ private: // Static data + enum dualMeshPointType + { + internal = 0, + surface = 1, + featureEdge = 2, + featurePoint = 3, + constrained = 4 + }; + + static const NamedEnum dualMeshPointTypeNames_; + static const scalar searchConeAngle; static const scalar searchAngleOppositeSurface; @@ -682,14 +693,12 @@ private: //- Merge vertices that are identical void mergeIdenticalDualVertices ( - const pointField& pts, - const labelList& boundaryPts + const pointField& pts ); label mergeIdenticalDualVertices ( const pointField& pts, - const labelList& boundaryPts, Map