From d38a680dae92ab54bdbf98d9b906029eca76801f Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 18 Jan 2020 23:04:49 +0000 Subject: [PATCH] surfaceFeatures: Separated "closness" option into "faceCloseness" and "pointCloseness" For complex geometries the calculation of surface face and point "closeness" can be quite time consuming and usually only one or other is required; the new options allow the user to specify which should be calculated and written. --- .../surface/surfaceFeatures/surfaceFeatures.C | 22 ++++-- etc/caseDicts/annotated/surfaceFeaturesDict | 9 ++- etc/caseDicts/surface/surfaceFeaturesDict | 2 +- .../triSurfaceMesh/extractCloseness.C | 71 ++++++++++--------- 4 files changed, 62 insertions(+), 42 deletions(-) diff --git a/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C b/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C index 269d919e05..1177493e75 100644 --- a/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C +++ b/applications/utilities/surface/surfaceFeatures/surfaceFeatures.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -172,8 +172,10 @@ namespace Foam dict.lookupOrDefault("curvature", "off"); const Switch featureProximity = dict.lookupOrDefault("featureProximity", "off"); - const Switch closeness = - dict.lookupOrDefault("closeness", "off"); + const Switch faceCloseness = + dict.lookupOrDefault("faceCloseness", "off"); + const Switch pointCloseness = + dict.lookupOrDefault("pointCloseness", "off"); Info<< nl << "Feature line extraction is only valid on closed manifold " @@ -424,7 +426,7 @@ namespace Foam // Find distance between close features - if (closeness) + if (faceCloseness || pointCloseness) { Info<< nl << "Extracting internal and external closeness of " << "surface." << endl; @@ -442,13 +444,19 @@ namespace Foam surf ); + if (faceCloseness) { Pair> closenessFields ( searchSurf.extractCloseness() ); + Info<< " writing " + << closenessFields.first()->name() << endl; closenessFields.first()->write(); + + Info<< " writing " + << closenessFields.second()->name() << endl; closenessFields.second()->write(); if (writeVTK) @@ -481,13 +489,19 @@ namespace Foam } } + if (pointCloseness) { Pair> closenessFields ( searchSurf.extractPointCloseness() ); + Info<< " writing " + << closenessFields.first()->name() << endl; closenessFields.first()->write(); + + Info<< " writing " + << closenessFields.second()->name() << endl; closenessFields.second()->write(); if (writeVTK) diff --git a/etc/caseDicts/annotated/surfaceFeaturesDict b/etc/caseDicts/annotated/surfaceFeaturesDict index 7599176713..742fb064bf 100644 --- a/etc/caseDicts/annotated/surfaceFeaturesDict +++ b/etc/caseDicts/annotated/surfaceFeaturesDict @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class dictionary; - object surfaceFeatureExtractDict; + object surfaceFeaturesDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -99,8 +99,11 @@ surface2 // points and edges maxFeatureProximity 1; - // Out put the closeness of surface elements to other surface elements. - closeness no; + // Output the closeness of surface elements to other surface elements. + faceCloseness no; + + // Output the closeness of surface points to other surface elements. + pointCloseness no; // Write features to obj format for postprocessing writeObj yes; diff --git a/etc/caseDicts/surface/surfaceFeaturesDict b/etc/caseDicts/surface/surfaceFeaturesDict index a1991f6db0..1a089588ea 100644 --- a/etc/caseDicts/surface/surfaceFeaturesDict +++ b/etc/caseDicts/surface/surfaceFeaturesDict @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class dictionary; - object surfaceFeatureExtractDict; + object surfaceFeaturesDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/searchableSurfaces/triSurfaceMesh/extractCloseness.C b/src/meshTools/searchableSurfaces/triSurfaceMesh/extractCloseness.C index 80c875e1f7..aa829d1822 100644 --- a/src/meshTools/searchableSurfaces/triSurfaceMesh/extractCloseness.C +++ b/src/meshTools/searchableSurfaces/triSurfaceMesh/extractCloseness.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2018-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -40,42 +40,45 @@ void Foam::triSurfaceMesh::drawHitProblem const pointIndexHitList& hitInfo ) const { - const List& tris = *this; - const pointField& points = this->points(); - - Info<< nl << "# findLineAll did not hit its own face." - << nl << "# fi " << fi - << nl << "# start " << start - << nl << "# point " << p - << nl << "# end " << end - << nl << "# hitInfo " << hitInfo - << endl; - - meshTools::writeOBJ(Info, start); - meshTools::writeOBJ(Info, p); - meshTools::writeOBJ(Info, end); - - Info<< "l 1 2 3" << endl; - - meshTools::writeOBJ(Info, points[tris[fi][0]]); - meshTools::writeOBJ(Info, points[tris[fi][1]]); - meshTools::writeOBJ(Info, points[tris[fi][2]]); - - Info<< "f 4 5 6" << endl; - - forAll(hitInfo, hi) + if (debug) { - label hfi = hitInfo[hi].index(); + const List& tris = *this; + const pointField& points = this->points(); - meshTools::writeOBJ(Info, points[tris[hfi][0]]); - meshTools::writeOBJ(Info, points[tris[hfi][1]]); - meshTools::writeOBJ(Info, points[tris[hfi][2]]); - - Info<< "f " - << 3*hi + 7 << " " - << 3*hi + 8 << " " - << 3*hi + 9 + Info<< nl << "# findLineAll did not hit its own face." + << nl << "# fi " << fi + << nl << "# start " << start + << nl << "# point " << p + << nl << "# end " << end + << nl << "# hitInfo " << hitInfo << endl; + + meshTools::writeOBJ(Info, start); + meshTools::writeOBJ(Info, p); + meshTools::writeOBJ(Info, end); + + Info<< "l 1 2 3" << endl; + + meshTools::writeOBJ(Info, points[tris[fi][0]]); + meshTools::writeOBJ(Info, points[tris[fi][1]]); + meshTools::writeOBJ(Info, points[tris[fi][2]]); + + Info<< "f 4 5 6" << endl; + + forAll(hitInfo, hi) + { + label hfi = hitInfo[hi].index(); + + meshTools::writeOBJ(Info, points[tris[hfi][0]]); + meshTools::writeOBJ(Info, points[tris[hfi][1]]); + meshTools::writeOBJ(Info, points[tris[hfi][2]]); + + Info<< "f " + << 3*hi + 7 << " " + << 3*hi + 8 << " " + << 3*hi + 9 + << endl; + } } }