mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: decomposePar - updated to handle multiple processor cyclic patches - mantis 879
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -130,7 +130,7 @@ class domainDecomposition
|
|||||||
//- Append single element to list
|
//- Append single element to list
|
||||||
static void append(labelList&, const label);
|
static void append(labelList&, const label);
|
||||||
|
|
||||||
//- Add face to interProcessor patch.
|
//- Add face to inter-processor patch
|
||||||
void addInterProcFace
|
void addInterProcFace
|
||||||
(
|
(
|
||||||
const label facei,
|
const label facei,
|
||||||
@ -141,6 +141,19 @@ class domainDecomposition
|
|||||||
List<DynamicList<DynamicList<label> > >&
|
List<DynamicList<DynamicList<label> > >&
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Generate sub patch info for processor cyclics
|
||||||
|
template <class BinaryOp>
|
||||||
|
void processInterCyclics
|
||||||
|
(
|
||||||
|
const polyBoundaryMesh& patches,
|
||||||
|
List<DynamicList<DynamicList<label> > >& interPatchFaces,
|
||||||
|
List<Map<label> >& procNbrToInterPatch,
|
||||||
|
List<labelListList>& subPatchIDs,
|
||||||
|
List<labelListList>& subPatchStarts,
|
||||||
|
bool owner,
|
||||||
|
BinaryOp bop
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -187,6 +200,12 @@ public:
|
|||||||
} // End namespace Foam
|
} // End namespace Foam
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "domainDecompositionTemplates.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -32,9 +32,7 @@ Description
|
|||||||
|
|
||||||
#include "domainDecomposition.H"
|
#include "domainDecomposition.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "SLPtrList.H"
|
|
||||||
#include "boolList.H"
|
#include "boolList.H"
|
||||||
#include "primitiveMesh.H"
|
|
||||||
#include "cyclicPolyPatch.H"
|
#include "cyclicPolyPatch.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -209,10 +207,11 @@ void Foam::domainDecomposition::decomposeMesh()
|
|||||||
// Done internal bits of the new mesh and the ordinary patches.
|
// Done internal bits of the new mesh and the ordinary patches.
|
||||||
|
|
||||||
|
|
||||||
// Per processor, from neighbour processor to the interprocessorpatch that
|
// Per processor, from neighbour processor to the inter-processor patch
|
||||||
// communicates with that neighbour.
|
// that communicates with that neighbour
|
||||||
List<Map<label> > procNbrToInterPatch(nProcs_);
|
List<Map<label> > procNbrToInterPatch(nProcs_);
|
||||||
// Per processor the faces per interprocessorpatch.
|
|
||||||
|
// Per processor the faces per inter-processor patch
|
||||||
List<DynamicList<DynamicList<label> > > interPatchFaces(nProcs_);
|
List<DynamicList<DynamicList<label> > > interPatchFaces(nProcs_);
|
||||||
|
|
||||||
// Processor boundaries from internal faces
|
// Processor boundaries from internal faces
|
||||||
@ -248,95 +247,73 @@ void Foam::domainDecomposition::decomposeMesh()
|
|||||||
subPatchStarts[procI].setSize(nInterfaces, labelList(1, label(0)));
|
subPatchStarts[procI].setSize(nInterfaces, labelList(1, label(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Processor boundaries from split cyclics
|
|
||||||
forAll(patches, patchi)
|
|
||||||
{
|
|
||||||
if (isA<cyclicPolyPatch>(patches[patchi]))
|
|
||||||
{
|
|
||||||
const cyclicPolyPatch& pp = refCast<const cyclicPolyPatch>
|
|
||||||
(
|
|
||||||
patches[patchi]
|
|
||||||
);
|
|
||||||
|
|
||||||
// cyclic: check opposite side on this processor
|
// Special handling needed for the case that multiple processor cyclic
|
||||||
const labelUList& patchFaceCells = pp.faceCells();
|
// patches are created on each local processor domain, e.g. if a 3x3 case
|
||||||
const labelUList& nbrPatchFaceCells =
|
// is decomposed using the decomposition:
|
||||||
pp.neighbPatch().faceCells();
|
//
|
||||||
|
// | 1 | 0 | 2 |
|
||||||
|
// cyclic left | 2 | 0 | 1 | cyclic right
|
||||||
|
// | 2 | 0 | 1 |
|
||||||
|
//
|
||||||
|
// - processors 1 and 2 will both have pieces of both cyclic left- and
|
||||||
|
// right sub-patches present
|
||||||
|
// - the interface patch faces are stored in a single list, where each
|
||||||
|
// sub-patch is referenced into the list using a patch start index and
|
||||||
|
// size
|
||||||
|
// - if the patches are in order (in the boundary file) of left, right
|
||||||
|
// - processor 1 will send: left, right
|
||||||
|
// - processor 1 will need to receive in reverse order: right, left
|
||||||
|
// - similarly for processor 2
|
||||||
|
// - the sub-patches are therefore generated in 4 passes of the patch lists
|
||||||
|
// 1. add faces from owner patch where local proc i < nbr proc i
|
||||||
|
// 2. add faces from nbr patch where local proc i < nbr proc i
|
||||||
|
// 3. add faces from owner patch where local proc i > nbr proc i
|
||||||
|
// 4. add faces from nbr patch where local proc i > nbr proc i
|
||||||
|
|
||||||
// Store old sizes. Used to detect which inter-proc patches
|
processInterCyclics
|
||||||
// have been added to.
|
(
|
||||||
labelListList oldInterfaceSizes(nProcs_);
|
patches,
|
||||||
forAll(oldInterfaceSizes, procI)
|
interPatchFaces,
|
||||||
{
|
procNbrToInterPatch,
|
||||||
labelList& curOldSizes = oldInterfaceSizes[procI];
|
subPatchIDs,
|
||||||
|
subPatchStarts,
|
||||||
|
true,
|
||||||
|
lessOp<label>()
|
||||||
|
);
|
||||||
|
|
||||||
curOldSizes.setSize(interPatchFaces[procI].size());
|
processInterCyclics
|
||||||
forAll(curOldSizes, interI)
|
(
|
||||||
{
|
patches,
|
||||||
curOldSizes[interI] =
|
interPatchFaces,
|
||||||
interPatchFaces[procI][interI].size();
|
procNbrToInterPatch,
|
||||||
}
|
subPatchIDs,
|
||||||
}
|
subPatchStarts,
|
||||||
|
false,
|
||||||
|
lessOp<label>()
|
||||||
|
);
|
||||||
|
|
||||||
// Add faces with different owner and neighbour processors
|
processInterCyclics
|
||||||
forAll(patchFaceCells, facei)
|
(
|
||||||
{
|
patches,
|
||||||
const label ownerProc = cellToProc_[patchFaceCells[facei]];
|
interPatchFaces,
|
||||||
const label nbrProc = cellToProc_[nbrPatchFaceCells[facei]];
|
procNbrToInterPatch,
|
||||||
if (ownerProc != nbrProc)
|
subPatchIDs,
|
||||||
{
|
subPatchStarts,
|
||||||
// inter - processor patch face found.
|
false,
|
||||||
addInterProcFace
|
greaterOp<label>()
|
||||||
(
|
);
|
||||||
pp.start()+facei,
|
|
||||||
ownerProc,
|
|
||||||
nbrProc,
|
|
||||||
procNbrToInterPatch,
|
|
||||||
interPatchFaces
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. Check if any faces added to existing interfaces
|
processInterCyclics
|
||||||
forAll(oldInterfaceSizes, procI)
|
(
|
||||||
{
|
patches,
|
||||||
const labelList& curOldSizes = oldInterfaceSizes[procI];
|
interPatchFaces,
|
||||||
|
procNbrToInterPatch,
|
||||||
forAll(curOldSizes, interI)
|
subPatchIDs,
|
||||||
{
|
subPatchStarts,
|
||||||
label oldSz = curOldSizes[interI];
|
true,
|
||||||
if (interPatchFaces[procI][interI].size() > oldSz)
|
greaterOp<label>()
|
||||||
{
|
);
|
||||||
// Added faces to this interface. Add an entry
|
|
||||||
append(subPatchIDs[procI][interI], patchi);
|
|
||||||
append(subPatchStarts[procI][interI], oldSz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Any new interfaces
|
|
||||||
forAll(subPatchIDs, procI)
|
|
||||||
{
|
|
||||||
label nIntfcs = interPatchFaces[procI].size();
|
|
||||||
subPatchIDs[procI].setSize(nIntfcs, labelList(1, patchi));
|
|
||||||
subPatchStarts[procI].setSize(nIntfcs, labelList(1, label(0)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Shrink processor patch face addressing
|
|
||||||
forAll(interPatchFaces, procI)
|
|
||||||
{
|
|
||||||
DynamicList<DynamicList<label> >& curInterPatchFaces =
|
|
||||||
interPatchFaces[procI];
|
|
||||||
|
|
||||||
forAll(curInterPatchFaces, i)
|
|
||||||
{
|
|
||||||
curInterPatchFaces[i].shrink();
|
|
||||||
}
|
|
||||||
curInterPatchFaces.shrink();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Sort inter-proc patch by neighbour
|
// Sort inter-proc patch by neighbour
|
||||||
@ -356,18 +333,18 @@ void Foam::domainDecomposition::decomposeMesh()
|
|||||||
// Get sorted neighbour processors
|
// Get sorted neighbour processors
|
||||||
const Map<label>& curNbrToInterPatch = procNbrToInterPatch[procI];
|
const Map<label>& curNbrToInterPatch = procNbrToInterPatch[procI];
|
||||||
labelList nbrs = curNbrToInterPatch.toc();
|
labelList nbrs = curNbrToInterPatch.toc();
|
||||||
|
|
||||||
sortedOrder(nbrs, order);
|
sortedOrder(nbrs, order);
|
||||||
|
|
||||||
DynamicList<DynamicList<label> >& curInterPatchFaces =
|
DynamicList<DynamicList<label> >& curInterPatchFaces =
|
||||||
interPatchFaces[procI];
|
interPatchFaces[procI];
|
||||||
|
|
||||||
forAll(order, i)
|
forAll(nbrs, i)
|
||||||
{
|
{
|
||||||
const label nbrProc = nbrs[i];
|
const label nbrProc = nbrs[i];
|
||||||
const label interPatch = curNbrToInterPatch[nbrProc];
|
const label interPatch = curNbrToInterPatch[nbrProc];
|
||||||
|
|
||||||
procNeighbourProcessors_[procI][i] =
|
procNeighbourProcessors_[procI][i] = nbrProc;
|
||||||
nbrProc;
|
|
||||||
procProcessorPatchSize_[procI][i] =
|
procProcessorPatchSize_[procI][i] =
|
||||||
curInterPatchFaces[interPatch].size();
|
curInterPatchFaces[interPatch].size();
|
||||||
procProcessorPatchStartIndex_[procI][i] =
|
procProcessorPatchStartIndex_[procI][i] =
|
||||||
|
|||||||
@ -0,0 +1,125 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cyclicPolyPatch.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template <class BinaryOp>
|
||||||
|
void Foam::domainDecomposition::processInterCyclics
|
||||||
|
(
|
||||||
|
const polyBoundaryMesh& patches,
|
||||||
|
List<DynamicList<DynamicList<label> > >& interPatchFaces,
|
||||||
|
List<Map<label> >& procNbrToInterPatch,
|
||||||
|
List<labelListList>& subPatchIDs,
|
||||||
|
List<labelListList>& subPatchStarts,
|
||||||
|
bool owner,
|
||||||
|
BinaryOp bop
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Processor boundaries from split cyclics
|
||||||
|
forAll(patches, patchi)
|
||||||
|
{
|
||||||
|
if (isA<cyclicPolyPatch>(patches[patchi]))
|
||||||
|
{
|
||||||
|
const cyclicPolyPatch& pp = refCast<const cyclicPolyPatch>
|
||||||
|
(
|
||||||
|
patches[patchi]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pp.owner() != owner)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cyclic: check opposite side on this processor
|
||||||
|
const labelUList& patchFaceCells = pp.faceCells();
|
||||||
|
const labelUList& nbrPatchFaceCells =
|
||||||
|
pp.neighbPatch().faceCells();
|
||||||
|
|
||||||
|
// Store old sizes. Used to detect which inter-proc patches
|
||||||
|
// have been added to.
|
||||||
|
labelListList oldInterfaceSizes(nProcs_);
|
||||||
|
forAll(oldInterfaceSizes, procI)
|
||||||
|
{
|
||||||
|
labelList& curOldSizes = oldInterfaceSizes[procI];
|
||||||
|
|
||||||
|
curOldSizes.setSize(interPatchFaces[procI].size());
|
||||||
|
forAll(curOldSizes, interI)
|
||||||
|
{
|
||||||
|
curOldSizes[interI] =
|
||||||
|
interPatchFaces[procI][interI].size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add faces with different owner and neighbour processors
|
||||||
|
forAll(patchFaceCells, facei)
|
||||||
|
{
|
||||||
|
const label ownerProc = cellToProc_[patchFaceCells[facei]];
|
||||||
|
const label nbrProc = cellToProc_[nbrPatchFaceCells[facei]];
|
||||||
|
if (bop(ownerProc, nbrProc))
|
||||||
|
{
|
||||||
|
// inter - processor patch face found.
|
||||||
|
addInterProcFace
|
||||||
|
(
|
||||||
|
pp.start()+facei,
|
||||||
|
ownerProc,
|
||||||
|
nbrProc,
|
||||||
|
procNbrToInterPatch,
|
||||||
|
interPatchFaces
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. Check if any faces added to existing interfaces
|
||||||
|
forAll(oldInterfaceSizes, procI)
|
||||||
|
{
|
||||||
|
const labelList& curOldSizes = oldInterfaceSizes[procI];
|
||||||
|
|
||||||
|
forAll(curOldSizes, interI)
|
||||||
|
{
|
||||||
|
label oldSz = curOldSizes[interI];
|
||||||
|
if (interPatchFaces[procI][interI].size() > oldSz)
|
||||||
|
{
|
||||||
|
// Added faces to this interface. Add an entry
|
||||||
|
append(subPatchIDs[procI][interI], patchi);
|
||||||
|
append(subPatchStarts[procI][interI], oldSz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Any new interfaces
|
||||||
|
forAll(subPatchIDs, procI)
|
||||||
|
{
|
||||||
|
label nIntfcs = interPatchFaces[procI].size();
|
||||||
|
subPatchIDs[procI].setSize(nIntfcs, labelList(1, patchi));
|
||||||
|
subPatchStarts[procI].setSize(nIntfcs, labelList(1, label(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user