BUG: subsetMesh: map instead of truncate. See #1558.

This also is to do with redistributePar:
this uses subsetMesh to generate parts to
send to different processors.
2) related to 1558: make sure not to choose 'mapped'
patches to move the processor patches into so
we can use the mapper cloning and correctly
size additional data (e.g. offsets). This should
be generalised to hold for any patch type
holding local data ...
This commit is contained in:
mattijs
2020-11-23 19:58:31 +00:00
parent f9033cbf92
commit 9c26b5ce9f
2 changed files with 70 additions and 18 deletions

View File

@ -47,6 +47,7 @@ License
#include "ListOps.H"
#include "globalIndex.H"
#include "cyclicACMIPolyPatch.H"
#include "mappedPatchBase.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -335,7 +336,12 @@ Foam::label Foam::fvMeshDistribute::findNonEmptyPatch() const
{
const polyPatch& pp = patches[patchi];
if (!isA<emptyPolyPatch>(pp) && !isCoupledPatch(patchi))
if
(
!isA<emptyPolyPatch>(pp)
&& !isCoupledPatch(patchi)
&& !isA<mappedPatchBase>(pp)
)
{
nonEmptyPatchi = patchi;
break;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1055,6 +1055,28 @@ void Foam::fvMeshSubset::setCellSubset
{
const label newSize = boundaryPatchSizes[globalPatchMap[oldPatchi]];
if (oldInternalPatchID != oldPatchi)
{
// Pure subset of patch faces (no internal faces added to this
// patch). Can use mapping.
labelList map(newSize);
for (label patchFacei = 0; patchFacei < newSize; patchFacei++)
{
const label facei = patchStart+patchFacei;
const label oldFacei = faceMap_[facei];
map[patchFacei] = oldPatches[oldPatchi].whichFace(oldFacei);
}
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
(
fvMeshSubsetPtr_().boundaryMesh(),
nNewPatches,
map,
patchStart
).ptr();
}
else
{
// Clone (even if 0 size)
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
(
@ -1063,6 +1085,7 @@ void Foam::fvMeshSubset::setCellSubset
newSize,
patchStart
).ptr();
}
patchStart += newSize;
patchMap_[nNewPatches] = oldPatchi; // compact patchMap
@ -1115,6 +1138,28 @@ void Foam::fvMeshSubset::setCellSubset
{
const label newSize = boundaryPatchSizes[globalPatchMap[oldPatchi]];
if (oldInternalPatchID != oldPatchi)
{
// Pure subset of patch faces (no internal faces added to this
// patch). Can use mapping.
labelList map(newSize);
for (label patchFacei = 0; patchFacei < newSize; patchFacei++)
{
const label facei = patchStart+patchFacei;
const label oldFacei = faceMap_[facei];
map[patchFacei] = oldPatches[oldPatchi].whichFace(oldFacei);
}
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
(
fvMeshSubsetPtr_().boundaryMesh(),
nNewPatches,
map,
patchStart
).ptr();
}
else
{
// Patch still exists. Add it
newBoundary[nNewPatches] = oldPatches[oldPatchi].clone
(
@ -1123,6 +1168,7 @@ void Foam::fvMeshSubset::setCellSubset
newSize,
patchStart
).ptr();
}
//Pout<< " " << oldPatches[oldPatchi].name() << " : "
// << newSize << endl;