mappedPolyPatch, mappedWallPolyPatch: Added "reMapAfterMove" control

This is an optimisation control that allows the user to specify whether
or not mapping is re-calculated as a result of mesh motion. It is true
by default, as this is guaranteed to work in all scenarios.

Setting this control to false will provide computational benefit for
cases in which mapped patches move consistently, but if the patches do
not move consistently then it will result in incorrect behaviour.
This commit is contained in:
Will Bainbridge
2023-02-02 11:48:27 +00:00
parent efa8cae943
commit efca6df9f7
4 changed files with 48 additions and 15 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -50,7 +50,8 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(name, size, start, index, bm, patchType), polyPatch(name, size, start, index, bm, patchType),
mappedPatchBase(static_cast<const polyPatch&>(*this)) mappedPatchBase(static_cast<const polyPatch&>(*this)),
reMapAfterMove_(true)
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), typeName) == -1) if (findIndex(inGroups(), typeName) == -1)
@ -70,7 +71,8 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(name, dict, index, bm, patchType), polyPatch(name, dict, index, bm, patchType),
mappedPatchBase(*this, dict, false) mappedPatchBase(*this, dict, false),
reMapAfterMove_(dict.lookupOrDefault<bool>("reMapAfterMove", true))
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), typeName) == -1) if (findIndex(inGroups(), typeName) == -1)
@ -87,7 +89,8 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(pp, bm), polyPatch(pp, bm),
mappedPatchBase(*this, pp) mappedPatchBase(*this, pp),
reMapAfterMove_(true)
{} {}
@ -101,7 +104,8 @@ Foam::mappedPolyPatch::mappedPolyPatch
) )
: :
polyPatch(pp, bm, index, newSize, newStart), polyPatch(pp, bm, index, newSize, newStart),
mappedPatchBase(*this, pp) mappedPatchBase(*this, pp),
reMapAfterMove_(true)
{} {}
@ -143,7 +147,10 @@ void Foam::mappedPolyPatch::movePoints
) )
{ {
polyPatch::movePoints(pBufs, p); polyPatch::movePoints(pBufs, p);
mappedPatchBase::clearOut(); if (reMapAfterMove_)
{
mappedPatchBase::clearOut();
}
} }
@ -164,6 +171,7 @@ void Foam::mappedPolyPatch::write(Ostream& os) const
{ {
polyPatch::write(os); polyPatch::write(os);
mappedPatchBase::write(os); mappedPatchBase::write(os);
writeEntryIfDifferent<bool>(os, "reMapAfterMove", true, reMapAfterMove_);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,9 +55,17 @@ class mappedPolyPatch
public polyPatch, public polyPatch,
public mappedPatchBase public mappedPatchBase
{ {
// Private Data
//- Do we need to re-calculate the mapping if mesh motion takes place?
// Defaults to true.
const bool reMapAfterMove_;
protected: protected:
// Protected Member Functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initCalcGeometry(PstreamBuffers&); virtual void initCalcGeometry(PstreamBuffers&);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,7 +56,8 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(name, size, start, index, bm, patchType), wallPolyPatch(name, size, start, index, bm, patchType),
mappedPatchBase(static_cast<const polyPatch&>(*this)) mappedPatchBase(static_cast<const polyPatch&>(*this)),
reMapAfterMove_(true)
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
@ -84,7 +85,8 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
neighbourRegion, neighbourRegion,
neighbourPatch, neighbourPatch,
cyclicTransform(true) cyclicTransform(true)
) ),
reMapAfterMove_(true)
{} {}
@ -98,7 +100,8 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(name, dict, index, bm, patchType), wallPolyPatch(name, dict, index, bm, patchType),
mappedPatchBase(*this, dict, true) mappedPatchBase(*this, dict, true),
reMapAfterMove_(dict.lookupOrDefault<bool>("reMapAfterMove", true))
{ {
// mapped is not constraint type so add mapped group explicitly // mapped is not constraint type so add mapped group explicitly
if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1) if (findIndex(inGroups(), mappedPolyPatch::typeName) == -1)
@ -115,7 +118,8 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(pp, bm), wallPolyPatch(pp, bm),
mappedPatchBase(*this, pp) mappedPatchBase(*this, pp),
reMapAfterMove_(true)
{} {}
@ -129,7 +133,8 @@ Foam::mappedWallPolyPatch::mappedWallPolyPatch
) )
: :
wallPolyPatch(pp, bm, index, newSize, newStart), wallPolyPatch(pp, bm, index, newSize, newStart),
mappedPatchBase(*this, pp) mappedPatchBase(*this, pp),
reMapAfterMove_(true)
{} {}
@ -171,7 +176,10 @@ void Foam::mappedWallPolyPatch::movePoints
) )
{ {
wallPolyPatch::movePoints(pBufs, p); wallPolyPatch::movePoints(pBufs, p);
mappedPatchBase::clearOut(); if (reMapAfterMove_)
{
mappedPatchBase::clearOut();
}
} }
@ -192,6 +200,7 @@ void Foam::mappedWallPolyPatch::write(Ostream& os) const
{ {
wallPolyPatch::write(os); wallPolyPatch::write(os);
mappedPatchBase::write(os); mappedPatchBase::write(os);
writeEntryIfDifferent<bool>(os, "reMapAfterMove", true, reMapAfterMove_);
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org \\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -55,9 +55,17 @@ class mappedWallPolyPatch
public wallPolyPatch, public wallPolyPatch,
public mappedPatchBase public mappedPatchBase
{ {
// Private Data
//- Do we need to re-calculate the mapping if mesh motion takes place?
// Defaults to true.
const bool reMapAfterMove_;
protected: protected:
// Protected Member Functions
//- Initialise the calculation of the patch geometry //- Initialise the calculation of the patch geometry
virtual void initCalcGeometry(PstreamBuffers&); virtual void initCalcGeometry(PstreamBuffers&);