ENH: mapped: keep coupling info. Fixes #3090

This commit is contained in:
mattijs
2024-01-18 16:11:32 +00:00
committed by Andrew Heather
parent d310f82402
commit 3d0cb79be3
5 changed files with 122 additions and 36 deletions

View File

@ -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

View File

@ -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;

View File

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

View File

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

View File

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