BUG: inconsistent faceArea on processor boundaries (fixes #2683)

- was missing evaluateCoupled on the initial faceAreaNormals field
  (related to #2507)

ENH: simplify/consistent geometry updating
This commit is contained in:
Mark Olesen
2023-01-24 14:40:06 +01:00
parent d8c6b6b811
commit a597c044c7
5 changed files with 68 additions and 22 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -180,12 +180,26 @@ Foam::faBoundaryMesh::faBoundaryMesh
void Foam::faBoundaryMesh::calcGeometry() 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 // This uses parallel comms and hence will not be trigggered
// on processors that do not have a processorFaPatch so instead // on processors that do not have a processorFaPatch so instead
// force construction. // force construction.
(void)mesh_.edgeAreaNormals();
(void)mesh_.pointAreaNormals(); (void)mesh_.pointAreaNormals();
(void)mesh_.areaCentres();
(void)mesh_.faceAreaNormals();
PstreamBuffers pBufs(Pstream::defaultCommsType); PstreamBuffers pBufs(Pstream::defaultCommsType);
if if
@ -773,12 +787,15 @@ bool Foam::faBoundaryMesh::checkDefinition(const bool report) const
void Foam::faBoundaryMesh::movePoints(const pointField& p) void Foam::faBoundaryMesh::movePoints(const pointField& p)
{ {
// processorFaPatch geometry triggers calculation of pointNormals. // See comments in calcGeometry()
// This uses parallel comms and hence will not be trigggered
// on processors that do not have a processorFaPatch so instead (void)mesh_.edgeAreaNormals();
// force construction.
(void)mesh_.pointAreaNormals(); (void)mesh_.pointAreaNormals();
(void)mesh_.areaCentres();
(void)mesh_.faceAreaNormals();
PstreamBuffers pBufs(Pstream::defaultCommsType); PstreamBuffers pBufs(Pstream::defaultCommsType);
if if

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2020-2022 OpenCFD Ltd. Copyright (C) 2020-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -277,6 +277,27 @@ void Foam::faMesh::clearOut() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
void Foam::faMesh::syncGeom()
{
if (UPstream::parRun())
{
// areaCentres()
if (faceCentresPtr_)
{
faceCentresPtr_->boundaryFieldRef()
.evaluateCoupled<processorFaPatch>();
}
// faceAreaNormals()
if (faceAreaNormalsPtr_)
{
faceAreaNormalsPtr_->boundaryFieldRef()
.evaluateCoupled<processorFaPatch>();
}
}
}
bool Foam::faMesh::init(const bool doInit) bool Foam::faMesh::init(const bool doInit)
{ {
if (doInit) if (doInit)
@ -296,18 +317,7 @@ bool Foam::faMesh::init(const bool doInit)
// Calculate the geometry for the patches (transformation tensors etc.) // Calculate the geometry for the patches (transformation tensors etc.)
boundary_.calcGeometry(); boundary_.calcGeometry();
// Ensure processor/processor information is properly synchronised syncGeom();
if (Pstream::parRun())
{
const_cast<areaVectorField&>(areaCentres()).boundaryFieldRef()
.evaluateCoupled<processorFaPatch>();
// This roughly corresponds to what OpenFOAM-v2112 (and earlier) had,
// but should nominally be unnecessary.
//
/// const_cast<areaVectorField&>(faceAreaNormals()).boundaryFieldRef()
/// .evaluateCoupled<processorFaPatch>();
}
return false; return false;
} }
@ -989,7 +999,6 @@ bool Foam::faMesh::movePoints()
clearGeomNotAreas(); clearGeomNotAreas();
// To satisfy the motion interface for MeshObject, const cast is needed
if (patchPtr_) if (patchPtr_)
{ {
patchPtr_->movePoints(newPoints); patchPtr_->movePoints(newPoints);
@ -1003,6 +1012,8 @@ bool Foam::faMesh::movePoints()
// Note: Fluxes were dummy? // Note: Fluxes were dummy?
syncGeom();
return true; return true;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2021-2022 OpenCFD Ltd. Copyright (C) 2021-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -617,6 +617,10 @@ public:
//- Initialise non-demand-driven data etc //- Initialise non-demand-driven data etc
bool init(const bool doInit); bool init(const bool doInit);
//- Processor/processor synchronisation for geometry fields.
// Largely internal use only (slightly hacky).
void syncGeom();
// Database // Database

View File

@ -898,6 +898,12 @@ void Foam::faMesh::calcFaceCentres() const
} }
} }
} }
// Parallel consistency, exchange on processor patches
if (UPstream::parRun())
{
centres.boundaryFieldRef().evaluateCoupled<processorFaPatch>();
}
} }
@ -1110,6 +1116,12 @@ void Foam::faMesh::calcFaceAreaNormals() const
= edgeNormalsBoundary[patchi]; = edgeNormalsBoundary[patchi];
} }
} }
// Parallel consistency, exchange on processor patches
if (UPstream::parRun())
{
faceNormals.boundaryFieldRef().evaluateCoupled<processorFaPatch>();
}
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2015-2022 OpenCFD Ltd. Copyright (C) 2015-2023 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -61,6 +61,8 @@ void Foam::faMeshTools::forceDemandDriven(faMesh& mesh)
(void)mesh.pointAreaNormals(); (void)mesh.pointAreaNormals();
(void)mesh.faceCurvatures(); (void)mesh.faceCurvatures();
(void)mesh.edgeTransformTensors(); (void)mesh.edgeTransformTensors();
mesh.syncGeom();
} }