From 8cea9a58dca9e626b8b9c864b19773828fdca1c4 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 6 Jul 2011 17:18:29 +0100 Subject: [PATCH 1/4] ENH: Limiting size of edge groups for very sharp edges. BUG: 1 + acos(na ^ nb), not 1 + acos(mag(na ^ nb)) --- .../conformalVoronoiMesh.C | 60 ++++++++++++++++++- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 6e0b0cbcae..855a86c794 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -565,8 +565,35 @@ void Foam::conformalVoronoiMesh::createExternalEdgePointGroup const vector& nA = feNormals[edNormalIs[0]]; const vector& nB = feNormals[edNormalIs[1]]; + if (mag(nA & nB) > 1 - SMALL) + { + // The normals are nearly parallel, so this is too sharp a feature to + // conform to. + + return; + } + + // Normalised distance of reference point from edge point + vector refVec((nA + nB)/(1 + (nA & nB))); + + if (magSqr(refVec) > sqr(5.0)) + { + // Limit the size of the conformation + ppDist *= 5.0/mag(refVec); + + // Pout<< nl << "createExternalEdgePointGroup limit " + // << "edgePt " << edgePt << nl + // << "refVec " << refVec << nl + // << "mag(refVec) " << mag(refVec) << nl + // << "ppDist " << ppDist << nl + // << "nA " << nA << nl + // << "nB " << nB << nl + // << "(nA & nB) " << (nA & nB) << nl + // << endl; + } + // Convex. So refPt will be inside domain and hence a master point - Foam::point refPt = edgePt - ppDist*(nA + nB)/(1 + (nA & nB) + VSMALL); + Foam::point refPt = edgePt - ppDist*refVec; // Result when the points are eventually inserted. // Add number_of_vertices() at insertion of first vertex to all numbers: @@ -616,8 +643,35 @@ void Foam::conformalVoronoiMesh::createInternalEdgePointGroup const vector& nA = feNormals[edNormalIs[0]]; const vector& nB = feNormals[edNormalIs[1]]; + if (mag(nA & nB) > 1 - SMALL) + { + // The normals are nearly parallel, so this is too sharp a feature to + // conform to. + + return; + } + + // Normalised distance of reference point from edge point + vector refVec((nA + nB)/(1 + (nA & nB))); + + if (magSqr(refVec) > sqr(5.0)) + { + // Limit the size of the conformation + ppDist *= 5.0/mag(refVec); + + // Pout<< nl << "createInternalEdgePointGroup limit " + // << "edgePt " << edgePt << nl + // << "refVec " << refVec << nl + // << "mag(refVec) " << mag(refVec) << nl + // << "ppDist " << ppDist << nl + // << "nA " << nA << nl + // << "nB " << nB << nl + // << "(nA & nB) " << (nA & nB) << nl + // << endl; + } + // Concave. master and reflected points inside the domain. - Foam::point refPt = edgePt - ppDist*(nA + nB)/(1 + (nA & nB) + VSMALL); + Foam::point refPt = edgePt - ppDist*refVec; // Generate reflected master to be outside. Foam::point reflMasterPt = refPt + 2*(edgePt - refPt); @@ -628,7 +682,7 @@ void Foam::conformalVoronoiMesh::createInternalEdgePointGroup Foam::point reflectedB = reflMasterPt - 2*ppDist*nB; scalar totalAngle = - radToDeg(constant::mathematical::pi + acos(mag(nA & nB))); + radToDeg(constant::mathematical::pi + acos(nA & nB)); // Number of quadrants the angle should be split into int nQuads = int(totalAngle/cvMeshControls().maxQuadAngle()) + 1; From 391f0d3b549299f86dab44de9591ac1a67b065c8 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 6 Jul 2011 22:20:27 +0100 Subject: [PATCH 2/4] BUG: reduce inside if statement, not valid on all processors. --- .../conformalVoronoiMeshCalcDualMesh.C | 9 +++------ .../conformalVoronoiMesh/conformalVoronoiMeshIO.C | 9 ++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 8d491429e4..d74df4f061 100644 --- a/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/src/mesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -1630,12 +1630,9 @@ Foam::labelHashSet Foam::conformalVoronoiMesh::checkPolyMeshQuality } } - if (checkFaces.size() < fAreas.size()) - { - Info<< "Excluding " - << returnReduce(fAreas.size() - checkFaces.size(), sumOp