From ae49b511827429a70a6e22dcd1660e455469e4be Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 23 Nov 2020 19:58:31 +0000 Subject: [PATCH] ENH: improve offsets handling in extrudeToRegionMesh (#1933) - non-uniform offsets are generated due to truncation errors, which can lead to problems later on (e.g. redistributePar). Detect if the offsets are close to being uniform. --- .../extrudeToRegionMesh/extrudeToRegionMesh.C | 61 +++++++++++++++---- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index cba010f5c5..2c0f91dae9 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -1134,18 +1134,55 @@ void setCouplingInfo if (isA(pp)) { - newPatches[patchi] = new mappedWallPolyPatch - ( - pp.name(), - pp.size(), - pp.start(), - patchi, - sampleRegion, // sampleRegion - mode, // sampleMode - pp.name(), // samplePatch - offsets[zoneI], // offset - patches - ); + const boundBox bb(pp.points(), pp.meshPoints(), true); + const vector avgOffset = gAverage(offsets[zoneI]); + const scalar mergeSqrDist = + gMax(magSqr(offsets[zoneI]-avgOffset)); + + // Verify uniformity of offset + // (same check as blockMesh geom merge) + if (mergeSqrDist < magSqr(10*SMALL*bb.span())) + { + Info<< "Adding on " << mesh.name() + << " coupling patch " << pp.name() + << " with uniform offset " << avgOffset << endl; + + // Uniform offset + newPatches[patchi] = new mappedWallPolyPatch + ( + pp.name(), + pp.size(), + pp.start(), + patchi, + sampleRegion, // sampleRegion + mode, // sampleMode + pp.name(), // samplePatch + + avgOffset, // uniform offset + patches + ); + } + else + { + Info<< "Adding on " << mesh.name() + << " coupling patch " << pp.name() + << " with non-uniform offset" << endl; + + // Uniform offset + newPatches[patchi] = new mappedWallPolyPatch + ( + pp.name(), + pp.size(), + pp.start(), + patchi, + sampleRegion, // sampleRegion + mode, // sampleMode + pp.name(), // samplePatch + + offsets[zoneI], // non-uniform offsets + patches + ); + } } } }