diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index e4928adc3ba4133b951efe0b077070ef19fe82d0..15431135d941bf1a122162f1fc810ec2f3a06535 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -724,6 +724,8 @@ void Foam::mappedPatchBase::findSamples void Foam::mappedPatchBase::calcMapping() const { + DebugInFunction; + static bool hasWarned = false; if (mapPtr_) { @@ -1051,6 +1053,9 @@ void Foam::mappedPatchBase::calcMapping() const } } } + + updateMeshTime().setUpToDate(); + updateSampleMeshTime().setUpToDate(); } diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H index fc327fc260ceeee1c8fcaa6bccaec5bf45cb88fd..f2a90f90917877bec69a129dab6d12cad1e51472 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.H @@ -96,6 +96,7 @@ SourceFiles #include "pointIndexHit.H" #include "AMIPatchToPatchInterpolation.H" #include "coupleGroupIdentifier.H" +#include "uniformDimensionedFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -288,6 +289,16 @@ protected: dictionary surfDict_; + // Mesh update IOobjects + + //- Local mesh update time + mutable autoPtr<uniformDimensionedScalarField> updateMeshTimePtr_; + + //- Sample mesh update time + mutable autoPtr<uniformDimensionedScalarField> + updateSampleMeshTimePtr_; + + // Protected Member Functions //- Add a world-world connection @@ -515,6 +526,14 @@ public: //- Cached sampleRegion != mesh.name() inline bool sameRegion() const noexcept; + //- Local mesh update time + inline uniformDimensionedScalarField& updateSampleMeshTime() const; + + //- Sample mesh upate time + inline uniformDimensionedScalarField& updateMeshTime() const; + + inline 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 f80c3defb182e1a84c0bd68ba7c6d30674f12614..9f753e9efa5575d46be816717b082922dcf4e557 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBaseI.H @@ -196,16 +196,78 @@ inline bool Foam::mappedPatchBase::sameRegion() const noexcept } -inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const +inline Foam::uniformDimensionedScalarField& +Foam::mappedPatchBase::updateSampleMeshTime() const +{ + if (!updateSampleMeshTimePtr_) + { + const auto& mesh = sampleMesh(); + + updateSampleMeshTimePtr_ = + autoPtr<uniformDimensionedScalarField>::New + ( + IOobject + ( + "updateSampleMeshTime", + mesh.pointsInstance(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ) + ); + } + + return updateSampleMeshTimePtr_(); +} + + +inline Foam::uniformDimensionedScalarField& +Foam::mappedPatchBase::updateMeshTime() const +{ + if (!updateMeshTimePtr_) + { + const auto& mesh = patch_.boundaryMesh().mesh(); + + updateMeshTimePtr_ = + autoPtr<uniformDimensionedScalarField>::New + ( + IOobject + ( + "updateMeshTime", + mesh.pointsInstance(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ) + ); + } + + return updateMeshTimePtr_(); +} + + +inline bool Foam::mappedPatchBase::upToDate() const { const polyMesh& thisMesh = patch_.boundaryMesh().mesh(); - bool topoChange = - (sameWorld() && sampleMesh().topoChanging()) - || thisMesh.topoChanging(); - if (topoChange) + return + (sameWorld() && sampleMesh().upToDatePoints(updateSampleMeshTime())) + && thisMesh.upToDatePoints(updateMeshTime()); +} + + +inline const Foam::mapDistribute& Foam::mappedPatchBase::map() const +{ + if (!upToDate()) { mapPtr_.reset(nullptr); + + if (AMIPtr_) + { + AMIPtr_->upToDate() = false; + } } if (!mapPtr_) @@ -222,12 +284,13 @@ inline const Foam::AMIPatchToPatchInterpolation& Foam::mappedPatchBase::AMI bool forceUpdate ) const { - const polyMesh& thisMesh = patch_.boundaryMesh().mesh(); - bool topoChange = - (sameWorld() && sampleMesh().topoChanging()) - || thisMesh.topoChanging(); + if (!upToDate()) + { + mapPtr_.reset(nullptr); + AMIPtr_->upToDate() = false; + } - if (topoChange || forceUpdate) + if (forceUpdate) { AMIPtr_->upToDate() = false; }