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 d45b9b4e41
commit 6d045eabc1
5 changed files with 68 additions and 22 deletions

View File

@ -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.
@ -185,12 +185,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
@ -780,12 +794,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

View File

@ -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.
@ -265,6 +265,27 @@ void Foam::faMesh::clearOut() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
void Foam::faMesh::syncGeom()
{
if (UPstream::parRun())
{
// areaCentres()
if (centresPtr_)
{
centresPtr_->boundaryFieldRef()
.evaluateCoupled<processorFaPatch>();
}
// faceAreaNormals()
if (faceAreaNormalsPtr_)
{
faceAreaNormalsPtr_->boundaryFieldRef()
.evaluateCoupled<processorFaPatch>();
}
}
}
bool Foam::faMesh::init(const bool doInit)
{
if (doInit)
@ -284,18 +305,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<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>();
}
syncGeom();
return false;
}
@ -955,7 +965,6 @@ bool Foam::faMesh::movePoints()
clearGeomNotAreas();
// To satisfy the motion interface for MeshObject, const cast is needed
if (patchPtr_)
{
patchPtr_->movePoints(newPoints);
@ -969,6 +978,8 @@ bool Foam::faMesh::movePoints()
// Note: Fluxes were dummy?
syncGeom();
return true;
}

View File

@ -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.
@ -599,6 +599,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

View File

@ -603,6 +603,12 @@ void Foam::faMesh::calcAreaCentres() const
}
}
}
// Parallel consistency, exchange on processor patches
if (UPstream::parRun())
{
centres.boundaryFieldRef().evaluateCoupled<processorFaPatch>();
}
}
@ -750,6 +756,12 @@ void Foam::faMesh::calcFaceAreaNormals() const
{
faceNormals.boundaryFieldRef()[patchI] = edgeNormalsBoundary[patchI];
}
// Parallel consistency, exchange on processor patches
if (UPstream::parRun())
{
faceNormals.boundaryFieldRef().evaluateCoupled<processorFaPatch>();
}
}

View File

@ -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();
}