diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index e1b457edd05607462c877b3c5aa1b6201e3d67d7..3f281664211f13b22c7f6feada901c32540beed2 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2015-2023 OpenCFD Ltd. + Copyright (C) 2015-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -86,6 +86,24 @@ 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(); +} + + Foam::autoPtr<Foam::fileName> Foam::mappedPatchBase::readDatabase ( const dictionary& dict @@ -1569,8 +1587,9 @@ Foam::mappedPatchBase::~mappedPatchBase() void Foam::mappedPatchBase::clearOut() { mapPtr_.reset(nullptr); - surfPtr_.reset(nullptr); AMIPtr_->upToDate(false); + + //Note: no need to clear out surface since not mesh related } @@ -1674,6 +1693,67 @@ const Foam::polyPatch& Foam::mappedPatchBase::samplePolyPatch() const } +bool Foam::mappedPatchBase::upToDate() const +{ + const polyMesh& thisMesh = patch_.boundaryMesh().mesh(); + + bool thisUpToDate = thisMesh.upToDatePoints(updateMeshTime()); + bool sampleUpToDate = + ( + sameWorld() + ? sampleMesh().upToDatePoints(updateSampleMeshTime()) + : true + ); + + if (!thisUpToDate && thisMesh.moving()) + { + // Moving (but not topoChanging mesh) : do more accurate check: + // compare actual patch point position + + thisUpToDate = true; + for (const label pointi : patch_.meshPoints()) + { + const point& oldPt = thisMesh.oldPoints()[pointi]; + const point& thisPt = thisMesh.points()[pointi]; + if (mag(oldPt-thisPt) > SMALL) + { + thisUpToDate = false; + break; + } + } + Pstream::reduceAnd(thisUpToDate); + + if (thisUpToDate) + { + updateMeshTime().setUpToDate(); + } + } + + 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(); + } + } + + return (thisUpToDate && sampleUpToDate); +} + + Foam::tmp<Foam::pointField> Foam::mappedPatchBase::samplePoints ( const pointField& fc diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H index f2a90f90917877bec69a129dab6d12cad1e51472..de3715d2634d1ebbf8e0a85448eaa2f5c156d376 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H @@ -301,6 +301,30 @@ protected: // Protected Member Functions + // polyPatch callbacks + + //- Initialise the calculation of the patch geometry + virtual void initGeometry(PstreamBuffers&) + {} + + //- Calculate the patch geometry + 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&); + + //- Initialise the update of the patch topology + virtual void initUpdateMesh(PstreamBuffers&) + {} + + //- Update of the patch topology + virtual void updateMesh(PstreamBuffers&); + + //- Add a world-world connection bool addWorldConnection(); @@ -532,7 +556,7 @@ public: //- Sample mesh upate time inline uniformDimensionedScalarField& updateMeshTime() const; - inline bool upToDate() const; + bool upToDate() const; //- Return reference to the parallel distribution map inline const mapDistribute& map() const; diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H index b2ebe51e9ff305e4eafcde389ee5046f860919aa..5c267312207a8c7a42e062827147202d080b6b6a 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H @@ -252,25 +252,6 @@ Foam::mappedPatchBase::updateMeshTime() const } -inline bool Foam::mappedPatchBase::upToDate() const -{ - const polyMesh& thisMesh = patch_.boundaryMesh().mesh(); - - if (sameWorld()) - { - return - sampleMesh().upToDatePoints(updateSampleMeshTime()) - && thisMesh.upToDatePoints(updateMeshTime()); - } - else - { - // If not the same world we do not know what the other side is doing - // so only check our local side - return thisMesh.upToDatePoints(updateMeshTime()); - } -} - - inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const { if (!upToDate()) diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C index 76d7f2bb827b8d7c3232b44f475bc5b785d72cb2..79ccb0a79bd465175ddb4cb7072028087df9bc0c 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPolyPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation - Copyright (C) 2021-2023 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -169,9 +169,7 @@ Foam::mappedPolyPatch::mappedPolyPatch // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::mappedPolyPatch::~mappedPolyPatch() -{ - mappedPatchBase::clearOut(); -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -179,13 +177,14 @@ Foam::mappedPolyPatch::~mappedPolyPatch() void Foam::mappedPolyPatch::initGeometry(PstreamBuffers& pBufs) { polyPatch::initGeometry(pBufs); + mappedPatchBase::initGeometry(pBufs); } void Foam::mappedPolyPatch::calcGeometry(PstreamBuffers& pBufs) { polyPatch::calcGeometry(pBufs); - mappedPatchBase::clearOut(); + mappedPatchBase::calcGeometry(pBufs); } @@ -196,6 +195,7 @@ void Foam::mappedPolyPatch::initMovePoints ) { polyPatch::initMovePoints(pBufs, p); + mappedPatchBase::initMovePoints(pBufs, p); } @@ -206,20 +206,21 @@ void Foam::mappedPolyPatch::movePoints ) { polyPatch::movePoints(pBufs, p); - mappedPatchBase::clearOut(); + mappedPatchBase::movePoints(pBufs, p); } void Foam::mappedPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) { polyPatch::initUpdateMesh(pBufs); + mappedPatchBase::initUpdateMesh(pBufs); } void Foam::mappedPolyPatch::updateMesh(PstreamBuffers& pBufs) { polyPatch::updateMesh(pBufs); - mappedPatchBase::clearOut(); + mappedPatchBase::updateMesh(pBufs); } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C index 759e07aaa13e4fcd00581a419d18f11077f87a92..223bfc0aeec7473015858a287a52a3ce44e3dd74 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedWallPolyPatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation - Copyright (C) 2021-2023 OpenCFD Ltd. + Copyright (C) 2021-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -175,9 +175,7 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::mappedWallPolyPatch::~mappedWallPolyPatch() -{ - mappedPatchBase::clearOut(); -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -191,7 +189,7 @@ void Foam::mappedWallPolyPatch::initGeometry(PstreamBuffers& pBufs) void Foam::mappedWallPolyPatch::calcGeometry(PstreamBuffers& pBufs) { wallPolyPatch::calcGeometry(pBufs); - mappedPatchBase::clearOut(); + mappedPatchBase::calcGeometry(pBufs); } @@ -202,6 +200,7 @@ void Foam::mappedWallPolyPatch::initMovePoints ) { wallPolyPatch::initMovePoints(pBufs, p); + mappedPatchBase::initMovePoints(pBufs, p); } @@ -212,20 +211,21 @@ void Foam::mappedWallPolyPatch::movePoints ) { wallPolyPatch::movePoints(pBufs, p); - mappedPatchBase::clearOut(); + mappedPatchBase::movePoints(pBufs, p); } void Foam::mappedWallPolyPatch::initUpdateMesh(PstreamBuffers& pBufs) { wallPolyPatch::initUpdateMesh(pBufs); + mappedPatchBase::initUpdateMesh(pBufs); } void Foam::mappedWallPolyPatch::updateMesh(PstreamBuffers& pBufs) { wallPolyPatch::updateMesh(pBufs); - mappedPatchBase::clearOut(); + mappedPatchBase::updateMesh(pBufs); }