diff --git a/applications/utilities/mesh/generation/cvMesh/cvMesh.C b/applications/utilities/mesh/generation/cvMesh/cvMesh.C index e87525e5e3..cb55bcdd72 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/cvMesh.C @@ -66,12 +66,12 @@ int main(int argc, char *argv[]) runTime++; - Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" - << nl << endl; + << endl; } - Info << nl << "End\n" << endl; + Info<< nl << "End\n" << endl; return 0; } diff --git a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 401b4308cd..e23ce49130 100644 --- a/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/src/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -134,7 +134,7 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs { FatalErrorIn("Foam::conformalVoronoiMesh::insertPointPairs") << "surfacePpDist, surfacePoints and surfaceNormals are not " - << "the same size. Sizes" + << "the same size. Sizes " << surfacePpDist.size() << ' ' << surfacePoints.size() << ' ' << surfaceNormals.size() @@ -158,6 +158,189 @@ void Foam::conformalVoronoiMesh::insertSurfacePointPairs } +void Foam::conformalVoronoiMesh::insertEdgePointGroups +( + const List& edgeHits, + const labelList& featuresHit +) +{ + if (edgeHits.size() != featuresHit.size()) + { + FatalErrorIn("Foam::conformalVoronoiMesh::insertEdgePointGroups") + << "edgeHits and featuresHit are not the same size. Sizes " + << edgeHits.size() << ' ' + << featuresHit.size() + << exit(FatalError); + } + + forAll(edgeHits, i) + { + const featureEdgeMesh& feMesh + ( + geometryToConformTo_.features()[featuresHit[i]] + ); + + label edgeI = edgeHits[i].index(); + + featureEdgeMesh::edgeStatus edStatus = feMesh.getEdgeStatus(edgeI); + + if (edStatus == featureEdgeMesh::EXTERNAL) + { + insertExternalEdgePointGroup(feMesh, edgeHits[i]); + } + else if (edStatus == featureEdgeMesh::INTERNAL) + { + insertInternalEdgePointGroup(feMesh, edgeHits[i]); + } + else if (edStatus == featureEdgeMesh::FLAT) + { + insertFlatEdgePointGroup(feMesh, edgeHits[i]); + } + else if (edStatus == featureEdgeMesh::OPEN) + { + insertOpenEdgePointGroup(feMesh, edgeHits[i]); + } + else if (edStatus == featureEdgeMesh::MULTIPLE) + { + insertMultipleEdgePointGroup(feMesh, edgeHits[i]); + } + } +} + + +void Foam::conformalVoronoiMesh::insertExternalEdgePointGroup +( + const featureEdgeMesh& feMesh, + const pointIndexHit& edHit +) +{ + const point& edgePt = edHit.hitPoint(); + + scalar ppDist = pointPairDistance(edgePt); + + const vectorField& feNormals = feMesh.normals(); + const labelList& edNormalIs = feMesh.edgeNormals()[edHit.index()]; + + // As this is an external edge, there are two normals by definition + const vector& nA = feNormals[edNormalIs[0]]; + const vector& nB = feNormals[edNormalIs[1]]; + + // Convex. So refPt will be inside domain and hence a master point + point refPt = edgePt - ppDist*(nA + nB)/(1 + (nA & nB)); + + // Insert the master point referring the the first slave + label masterPtIndex = insertPoint(refPt, number_of_vertices() + 1); + + // Insert the slave points by reflecting refPt in both faces. + // with each slave refering to the master + + point reflectedA = refPt + 2*ppDist*nA; + insertPoint(reflectedA, masterPtIndex); + + point reflectedB = refPt + 2*ppDist*nB; + insertPoint(reflectedB, masterPtIndex); +} + + +void Foam::conformalVoronoiMesh::insertInternalEdgePointGroup +( + const featureEdgeMesh& feMesh, + const pointIndexHit& edHit +) +{ + const point& edgePt = edHit.hitPoint(); + + scalar ppDist = pointPairDistance(edgePt); + + const vectorField& feNormals = feMesh.normals(); + const labelList& edNormalIs = feMesh.edgeNormals()[edHit.index()]; + + // As this is an external edge, there are two normals by definition + const vector& nA = feNormals[edNormalIs[0]]; + const vector& nB = feNormals[edNormalIs[1]]; + + // Concave. master and reflected points inside the domain. + point refPt = edgePt - ppDist*(nA + nB)/(1 + (nA & nB)); + + // Generate reflected master to be outside. + point reflMasterPt = edgePt + 2*(edgePt - refPt); + + // Reflect reflMasterPt in both faces. + point reflectedA = reflMasterPt - 2*ppDist*nA; + + point reflectedB = reflMasterPt - 2*ppDist*nB; + + scalar totalAngle = + 180*(mathematicalConstant::pi + acos(mag(nA & nB))) + /mathematicalConstant::pi; + + // Number of quadrants the angle should be split into + int nQuads = int(totalAngle/cvMeshControls_.maxQuadAngle()) + 1; + + // The number of additional master points needed to obtain the + // required number of quadrants. + int nAddPoints = min(max(nQuads - 2, 0), 2); + + // index of reflMaster + label reflectedMaster = number_of_vertices() + 2 + nAddPoints; + + // Master A is inside. + label reflectedAI = insertPoint(reflectedA, reflectedMaster); + + // Master B is inside. + insertPoint(reflectedB, reflectedMaster); + + if (nAddPoints == 1) + { + // One additinal point is the reflection of the slave point, + // i.e. the original reference point + insertPoint(refPt, reflectedMaster); + } + else if (nAddPoints == 2) + { + point reflectedAa = refPt + ppDist*nB; + insertPoint(reflectedAa, reflectedMaster); + + point reflectedBb = refPt + ppDist*nA; + insertPoint(reflectedBb, reflectedMaster); + } + + // Slave is outside. + insertPoint(reflMasterPt, reflectedAI); +} + + +void Foam::conformalVoronoiMesh::insertFlatEdgePointGroup +( + const featureEdgeMesh& feMesh, + const pointIndexHit& edHit +) +{ + Info<< " NOT INSERTING FLAT EDGE POINT GROUP, NOT IMPLEMENTED" << endl; +} + + +void Foam::conformalVoronoiMesh::insertOpenEdgePointGroup +( + const featureEdgeMesh& feMesh, + const pointIndexHit& edHit +) +{ + Info<< " NOT INSERTING OPEN EDGE POINT GROUP, NOT IMPLEMENTED" << endl; +} + + +void Foam::conformalVoronoiMesh::insertMultipleEdgePointGroup +( + const featureEdgeMesh& feMesh, + const pointIndexHit& edHit +) +{ + Info<< " NOT INSERTING MULTIPLE EDGE POINT GROUP, NOT IMPLEMENTED" + << endl; +} + + void Foam::conformalVoronoiMesh::conformToFeaturePoints() { Info<< nl << "Conforming to feature points" << endl; @@ -1020,9 +1203,13 @@ void Foam::conformalVoronoiMesh::conformToSurface() startOfSurfacePointPairs_ = number_of_vertices(); + Info<< " EDGE DISTANCE COEFFS HARD-CODED." << endl; + scalar edgeSearchDistCoeffSqr = sqr(1.25); + scalar surfacePtReplaceDistCoeffSqr = sqr(0.3); + // Surface protrusion conformation - label nIterations = 1; + label nIterations = 2; for(label iterationNo = 0; iterationNo < nIterations; iterationNo++) { @@ -1031,6 +1218,10 @@ void Foam::conformalVoronoiMesh::conformToSurface() DynamicList surfacePoints; DynamicList surfaceNormals; + DynamicList featureEdgeHits; + DynamicList