diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C index dee21f5617..7bd8ad7ca9 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2018-2022 OpenCFD Ltd. + Copyright (C) 2018-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -180,12 +180,26 @@ Foam::faBoundaryMesh::faBoundaryMesh void Foam::faBoundaryMesh::calcGeometry() { - // processorFaPatch geometry triggers calculation of pointNormals. + // processor initGeometry send/recv the following: + // - edgeCentres() : faMesh::edgeCentres() + // - edgeLengths() : faMesh::Le() + // - edgeFaceCentres() : faMesh::areaCentres() + // + // faMesh::Le() has its own point-to-point communication (OK) but + // triggers either/or edgeAreaNormals(), pointAreaNormals() + // with their own communication that can block. + // This uses parallel comms and hence will not be trigggered // on processors that do not have a processorFaPatch so instead // force construction. + + (void)mesh_.edgeAreaNormals(); (void)mesh_.pointAreaNormals(); + (void)mesh_.areaCentres(); + (void)mesh_.faceAreaNormals(); + + PstreamBuffers pBufs(Pstream::defaultCommsType); if @@ -773,12 +787,15 @@ bool Foam::faBoundaryMesh::checkDefinition(const bool report) const void Foam::faBoundaryMesh::movePoints(const pointField& p) { - // processorFaPatch geometry triggers calculation of pointNormals. - // This uses parallel comms and hence will not be trigggered - // on processors that do not have a processorFaPatch so instead - // force construction. + // See comments in calcGeometry() + + (void)mesh_.edgeAreaNormals(); (void)mesh_.pointAreaNormals(); + (void)mesh_.areaCentres(); + (void)mesh_.faceAreaNormals(); + + PstreamBuffers pBufs(Pstream::defaultCommsType); if diff --git a/src/finiteArea/faMesh/faMesh.C b/src/finiteArea/faMesh/faMesh.C index 7d33d34050..12d34152be 100644 --- a/src/finiteArea/faMesh/faMesh.C +++ b/src/finiteArea/faMesh/faMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2020-2022 OpenCFD Ltd. + Copyright (C) 2020-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -277,6 +277,27 @@ void Foam::faMesh::clearOut() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +void Foam::faMesh::syncGeom() +{ + if (UPstream::parRun()) + { + // areaCentres() + if (faceCentresPtr_) + { + faceCentresPtr_->boundaryFieldRef() + .evaluateCoupled(); + } + + // faceAreaNormals() + if (faceAreaNormalsPtr_) + { + faceAreaNormalsPtr_->boundaryFieldRef() + .evaluateCoupled(); + } + } +} + + bool Foam::faMesh::init(const bool doInit) { if (doInit) @@ -296,18 +317,7 @@ bool Foam::faMesh::init(const bool doInit) // Calculate the geometry for the patches (transformation tensors etc.) boundary_.calcGeometry(); - // Ensure processor/processor information is properly synchronised - if (Pstream::parRun()) - { - const_cast(areaCentres()).boundaryFieldRef() - .evaluateCoupled(); - - // This roughly corresponds to what OpenFOAM-v2112 (and earlier) had, - // but should nominally be unnecessary. - // - /// const_cast(faceAreaNormals()).boundaryFieldRef() - /// .evaluateCoupled(); - } + syncGeom(); return false; } @@ -989,7 +999,6 @@ bool Foam::faMesh::movePoints() clearGeomNotAreas(); - // To satisfy the motion interface for MeshObject, const cast is needed if (patchPtr_) { patchPtr_->movePoints(newPoints); @@ -1003,6 +1012,8 @@ bool Foam::faMesh::movePoints() // Note: Fluxes were dummy? + syncGeom(); + return true; } diff --git a/src/finiteArea/faMesh/faMesh.H b/src/finiteArea/faMesh/faMesh.H index bd391977ac..0e0fae393c 100644 --- a/src/finiteArea/faMesh/faMesh.H +++ b/src/finiteArea/faMesh/faMesh.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2021-2022 OpenCFD Ltd. + Copyright (C) 2021-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -617,6 +617,10 @@ public: //- Initialise non-demand-driven data etc bool init(const bool doInit); + //- Processor/processor synchronisation for geometry fields. + // Largely internal use only (slightly hacky). + void syncGeom(); + // Database diff --git a/src/finiteArea/faMesh/faMeshDemandDrivenData.C b/src/finiteArea/faMesh/faMeshDemandDrivenData.C index 0a7620fc8c..c2f0e5c7d1 100644 --- a/src/finiteArea/faMesh/faMeshDemandDrivenData.C +++ b/src/finiteArea/faMesh/faMeshDemandDrivenData.C @@ -898,6 +898,12 @@ void Foam::faMesh::calcFaceCentres() const } } } + + // Parallel consistency, exchange on processor patches + if (UPstream::parRun()) + { + centres.boundaryFieldRef().evaluateCoupled(); + } } @@ -1110,6 +1116,12 @@ void Foam::faMesh::calcFaceAreaNormals() const = edgeNormalsBoundary[patchi]; } } + + // Parallel consistency, exchange on processor patches + if (UPstream::parRun()) + { + faceNormals.boundaryFieldRef().evaluateCoupled(); + } } diff --git a/src/finiteArea/faMesh/faMeshTools/faMeshTools.C b/src/finiteArea/faMesh/faMeshTools/faMeshTools.C index e12c43c7b4..cce1e3c6d7 100644 --- a/src/finiteArea/faMesh/faMeshTools/faMeshTools.C +++ b/src/finiteArea/faMesh/faMeshTools/faMeshTools.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2015-2022 OpenCFD Ltd. + Copyright (C) 2015-2023 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -61,6 +61,8 @@ void Foam::faMeshTools::forceDemandDriven(faMesh& mesh) (void)mesh.pointAreaNormals(); (void)mesh.faceCurvatures(); (void)mesh.edgeTransformTensors(); + + mesh.syncGeom(); }