diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 3f281664211f13b22c7f6feada901c32540beed2..f66d7eb1d44737e65f2513fc809db38e90fc3fd1 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -86,18 +86,6 @@ Foam::mappedPatchBase::offsetModeNames_ // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::mappedPatchBase::calcGeometry(PstreamBuffers& pBufs) -{} - - -void Foam::mappedPatchBase::movePoints -( - PstreamBuffers& pBufs, - const pointField& p -) -{} - - void Foam::mappedPatchBase::updateMesh(PstreamBuffers& pBufs) { clearOut(); @@ -1705,49 +1693,58 @@ bool Foam::mappedPatchBase::upToDate() const : true ); - if (!thisUpToDate && thisMesh.moving()) + + // Lambda to check for points on the patch being the same + auto checkPointMovement = [] + ( + const polyMesh& mesh, + const polyPatch& patch, + regIOobject& state + ) -> bool { - // Moving (but not topoChanging mesh) : do more accurate check: - // compare actual patch point position + bool upToDate = true; + const auto& oldPoints = mesh.oldPoints(); + const auto& points = mesh.points(); - thisUpToDate = true; - for (const label pointi : patch_.meshPoints()) + for (const label pointi : patch.meshPoints()) { - const point& oldPt = thisMesh.oldPoints()[pointi]; - const point& thisPt = thisMesh.points()[pointi]; - if (mag(oldPt-thisPt) > SMALL) + const point& oldPt = oldPoints[pointi]; + const point& currentPt = points[pointi]; + + if (mag(oldPt - currentPt) > SMALL) { - thisUpToDate = false; + upToDate = false; break; } } - Pstream::reduceAnd(thisUpToDate); - if (thisUpToDate) + Pstream::reduceAnd(upToDate); + + if (upToDate) { - updateMeshTime().setUpToDate(); + state.setUpToDate(); } + + return upToDate; + }; + + + if (!thisUpToDate && thisMesh.moving()) + { + // Moving (but not topoChanging mesh) : do more accurate check: + // compare actual patch point position + + thisUpToDate = checkPointMovement(thisMesh, patch_, updateMeshTime()); } if (!sampleUpToDate && sampleMesh().moving()) { - sampleUpToDate = true; - for (const label pointi : samplePolyPatch().meshPoints()) - { - const point& oldPt = sampleMesh().oldPoints()[pointi]; - const point& samplePt = sampleMesh().points()[pointi]; - if (mag(oldPt-samplePt) > SMALL) - { - sampleUpToDate = false; - break; - } - } - Pstream::reduceAnd(sampleUpToDate); - - if (sampleUpToDate) - { - updateSampleMeshTime().setUpToDate(); - } + sampleUpToDate = checkPointMovement + ( + sampleMesh(), + samplePolyPatch(), + updateSampleMeshTime() + ); } return (thisUpToDate && sampleUpToDate); diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H index de3715d2634d1ebbf8e0a85448eaa2f5c156d376..b0d0d1fcab784ef453983c3bea67f725db2d175a 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H @@ -308,14 +308,16 @@ protected: {} //- Calculate the patch geometry - virtual void calcGeometry(PstreamBuffers&); + virtual void calcGeometry(PstreamBuffers&) + {} //- Initialise the patches for moving points virtual void initMovePoints(PstreamBuffers&, const pointField&) {} //- Correct patches after moving points - virtual void movePoints(PstreamBuffers&, const pointField&); + virtual void movePoints(PstreamBuffers&, const pointField&) + {} //- Initialise the update of the patch topology virtual void initUpdateMesh(PstreamBuffers&)