From 73cd7b2972dde33a6438722922b58c4c398c67f0 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Mon, 21 Dec 2020 12:23:48 +0000 Subject: [PATCH] BUG: cyclicACMI - corrected ordering to achieve expected patch face area scaling. See #1953 --- .../meshes/primitiveMesh/primitiveMesh.H | 4 ++ .../meshes/primitiveMesh/primitiveMeshClear.C | 14 +++++++ .../cyclicACMIPolyPatch/cyclicACMIPolyPatch.C | 41 +++++++++++-------- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index 3ef4a22261a..ecbcbe277a5 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -899,6 +899,10 @@ public: //- Clear geometry void clearGeom(); + //- Clear cell-based geometry only + // Use with care! currently used by cyclicACMI + void clearCellGeom(); + //- Clear topological data void clearAddressing(); diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.C index 2efd5cb8617..bf19ed1ffe4 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.C @@ -140,6 +140,20 @@ void Foam::primitiveMesh::clearGeom() } +void Foam::primitiveMesh::clearCellGeom() +{ + if (debug) + { + Pout<< "primitiveMesh::clearCellGeom() : " + << "clearing cell centres and volumes" + << endl; + } + + deleteDemandDrivenData(cellCentresPtr_); + deleteDemandDrivenData(cellVolumesPtr_); +} + + void Foam::primitiveMesh::clearAddressing() { if (debug) diff --git a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C index f14f2758280..b7c63b02714 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C +++ b/src/meshTools/AMIInterpolation/patches/cyclicACMI/cyclicACMIPolyPatch/cyclicACMIPolyPatch.C @@ -288,24 +288,27 @@ void Foam::cyclicACMIPolyPatch::resetAMI(const UList<point>& points) const { DebugPout << "cyclicACMIPolyPatch::resetAMI : clearing cellCentres" - << " for " << name() << " and " << nonOverlapPatch.name() - << endl; - - WarningInFunction - << "The mesh already has cellCentres calculated when" - << " resetting ACMI " << name() << "." << nl - << "This is a problem since ACMI adapts the face areas" - << " (to close cells) so this has" << nl - << "to be done before cell centre calculation." << nl - << "This can happen if e.g. the cyclicACMI is after" - << " any processor patches in the boundary." << endl; - const_cast<polyMesh&>(mesh).primitiveMesh::clearGeom(); + << " for " << name() << " and " << nonOverlapPatch.name() << nl + << "The mesh already has cellCentres calculated when" + << " resetting ACMI " << name() << "." << nl + << "This is a problem since ACMI adapts the face areas" + << " (to close cells) so this has" << nl + << "to be done before cell centre calculation." << nl + << "This can happen if e.g. the cyclicACMI is after" + << " any processor patches in the boundary." << endl; + + const_cast<polyMesh&>(mesh).primitiveMesh::clearCellGeom(); } - - // Trigger re-building of faceAreas - (void)mesh.faceAreas(); - + // At this point we want face geometry but not cell geometry since we want + // correct the face area on duplicate baffles before calculating the cell + // centres and volumes. + if (!mesh.hasFaceAreas()) + { + FatalErrorInFunction + << "primitiveMesh must already have face geometry" + << abort(FatalError); + } // Calculate the AMI using partial face-area-weighted. This leaves // the weights as fractions of local areas (sum(weights) = 1 means @@ -423,9 +426,13 @@ void Foam::cyclicACMIPolyPatch::initMovePoints DebugPout<< "cyclicACMIPolyPatch::initMovePoints : " << name() << endl; // Note: calculates transformation and triggers face centre calculation - // - Note: resetAMI called by cyclicAMIPolyPatch::initMovePoints cyclicAMIPolyPatch::initMovePoints(pBufs, p); + if (!createAMIFaces_ && canResetAMI()) + { + resetAMI(); + } + scalePatchFaceAreas(); } -- GitLab