From cd2d81b79acb50429fd72aa83769cfce1f1799a4 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 3 Oct 2024 16:06:03 +0100 Subject: [PATCH] ENH: extrudePatchMesh: support for features. See #2103 Optional 'featureAngle' entry to disable extrusion on sharp corners --- .../extrudePatchMesh/extrudePatchMesh.C | 30 +++++++++++++++---- .../extrudePatchMesh/extrudePatchMesh.H | 3 ++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C index 1e8a59d802..862758cbcc 100644 --- a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020-2023 OpenCFD Ltd. + Copyright (C) 2020-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,6 +33,7 @@ License #include "wallPolyPatch.H" #include "emptyPolyPatch.H" #include "wedgePolyPatch.H" +#include "unitConversion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -157,6 +158,12 @@ void Foam::extrudePatchMesh::extrudeMesh(polyPatchList& regionPatches) if (this->boundaryMesh().empty()) { const bool columnCells = dict_.get("columnCells"); + scalar featAngleCos = -GREAT; + scalar featAngle = -1; + if (dict_.readIfPresent("featureAngle", featAngle)) + { + featAngleCos = Foam::cos(degToRad(featAngle)); + } bitSet nonManifoldEdge(extrudedPatch_.nEdges()); for (label edgeI = 0; edgeI < extrudedPatch_.nInternalEdges(); edgeI++) @@ -165,11 +172,24 @@ void Foam::extrudePatchMesh::extrudeMesh(polyPatchList& regionPatches) { nonManifoldEdge.set(edgeI); } - else if (extrudedPatch_.edgeFaces()[edgeI].size() > 2) + else { - // TBD: issue #2780 : non-manifold edges get seen as internal - // This bit of code can be removed once #2780 is solved. - nonManifoldEdge.set(edgeI); + const auto& fcs = extrudedPatch_.edgeFaces()[edgeI]; + if (fcs.size() > 2) + { + // TBD: issue #2780 : non-manifold edges get seen as + // internal. + // This bit of code can be removed once #2780 is solved. + nonManifoldEdge.set(edgeI); + } + else if (fcs.size() == 2 && featAngleCos >= -1) + { + const auto& n = extrudedPatch_.faceNormals(); + if ((n[fcs[0]] & n[fcs[1]]) < featAngleCos) + { + nonManifoldEdge.set(edgeI); + } + } } } diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H index 5e9130095f..d65baef18f 100644 --- a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H @@ -44,6 +44,9 @@ Description expansionRatio 1; columnCells true; + // Optional feature angle to avoid extruding feature-angles + featureAngle 45; + // Patch information bottomCoeffs {