BUG: extrudeToRegionMesh: incorrect bounding box. Fixes #3241

This commit is contained in:
mattijs 2024-10-21 12:57:43 +01:00
parent fe0b71280e
commit 53052a5eb3

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd. Copyright (C) 2015-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1110,8 +1110,9 @@ void setCouplingInfo
fvMesh& mesh, fvMesh& mesh,
const labelList& zoneToPatch, const labelList& zoneToPatch,
const word& sampleRegion, const word& sampleRegion,
const mappedWallPolyPatch::sampleMode mode, const mappedPatchBase::sampleMode mode,
const List<pointField>& offsets const List<pointField>& offsets,
const List<boundBox>& bbs
) )
{ {
const polyBoundaryMesh& patches = mesh.boundaryMesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -1132,7 +1133,6 @@ void setCouplingInfo
if (isA<mappedWallPolyPatch>(pp)) if (isA<mappedWallPolyPatch>(pp))
{ {
const boundBox bb(pp.points(), pp.meshPoints(), true);
const vector avgOffset = gAverage(offsets[zoneI]); const vector avgOffset = gAverage(offsets[zoneI]);
const scalar mergeSqrDist = const scalar mergeSqrDist =
gMax(magSqr(offsets[zoneI]-avgOffset)); gMax(magSqr(offsets[zoneI]-avgOffset));
@ -1157,7 +1157,7 @@ void setCouplingInfo
// Verify uniformity of offset // Verify uniformity of offset
// (same check as blockMesh geom merge) // (same check as blockMesh geom merge)
if (mergeSqrDist < magSqr(10*SMALL*bb.span())) if (mergeSqrDist < magSqr(10*SMALL*bbs[zoneI].span()))
{ {
Info<< "uniform offset " << avgOffset << endl; Info<< "uniform offset " << avgOffset << endl;
} }
@ -2468,7 +2468,10 @@ int main(int argc, char *argv[])
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
List<pointField> topOffsets(zoneNames.size()); List<pointField> topOffsets(zoneNames.size());
List<boundBox> topBbs(zoneNames.size());
List<pointField> bottomOffsets(zoneNames.size()); List<pointField> bottomOffsets(zoneNames.size());
List<boundBox> bottomBbs(zoneNames.size());
forAll(regionMesh.boundaryMesh(), patchi) forAll(regionMesh.boundaryMesh(), patchi)
{ {
@ -2480,11 +2483,13 @@ int main(int argc, char *argv[])
{ {
label zoneI = interRegionTopPatch.find(patchi); label zoneI = interRegionTopPatch.find(patchi);
topOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp); topOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp);
topBbs[zoneI] = boundBox(pp.points(), pp.meshPoints(), true);
} }
else if (interRegionBottomPatch.found(patchi)) else if (interRegionBottomPatch.found(patchi))
{ {
label zoneI = interRegionBottomPatch.find(patchi); label zoneI = interRegionBottomPatch.find(patchi);
bottomOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp); bottomOffsets[zoneI] = calcOffset(extrudePatch, extruder, pp);
bottomBbs[zoneI] = boundBox(pp.points(), pp.meshPoints(), true);
} }
} }
} }
@ -2501,7 +2506,8 @@ int main(int argc, char *argv[])
interRegionTopPatch, interRegionTopPatch,
regionName, // name of main mesh regionName, // name of main mesh
sampleMode, // sampleMode sampleMode, // sampleMode
topOffsets topOffsets,
topBbs
); );
// Correct bottom patches for offset // Correct bottom patches for offset
@ -2511,7 +2517,8 @@ int main(int argc, char *argv[])
interRegionBottomPatch, interRegionBottomPatch,
regionName, regionName,
sampleMode, // sampleMode sampleMode, // sampleMode
bottomOffsets bottomOffsets,
bottomBbs
); );
// Remove any unused patches // Remove any unused patches
@ -2530,7 +2537,8 @@ int main(int argc, char *argv[])
interMeshTopPatch, interMeshTopPatch,
shellRegionName, // name of shell mesh shellRegionName, // name of shell mesh
sampleMode, // sampleMode sampleMode, // sampleMode
-topOffsets -topOffsets,
topBbs
); );
// Correct bottom patches for offset // Correct bottom patches for offset
@ -2540,7 +2548,8 @@ int main(int argc, char *argv[])
interMeshBottomPatch, interMeshBottomPatch,
shellRegionName, shellRegionName,
sampleMode, sampleMode,
-bottomOffsets -bottomOffsets,
bottomBbs
); );
} }