Added globalProcFaceIndex

This commit is contained in:
Hrvoje Jasak 2018-05-10 09:57:13 +01:00
parent 20e6a816a2
commit 31adfb3200
5 changed files with 332 additions and 7 deletions

View file

@ -427,6 +427,7 @@ globalMeshData = $(polyMesh)/globalMeshData
$(globalMeshData)/globalMeshData.C $(globalMeshData)/globalMeshData.C
$(globalMeshData)/globalPoints.C $(globalMeshData)/globalPoints.C
$(globalMeshData)/globalIndex.C $(globalMeshData)/globalIndex.C
$(globalMeshData)/globalProcFaceIndex.C
$(polyMesh)/syncTools/syncTools.C $(polyMesh)/syncTools/syncTools.C

View file

@ -31,7 +31,6 @@ Description
globalIndex globalFaces(mesh.nFaces()); globalIndex globalFaces(mesh.nFaces());
label globalFaceI = globalFaces.toGlobal(faceI); label globalFaceI = globalFaces.toGlobal(faceI);
SourceFiles SourceFiles
globalIndex.C globalIndex.C
@ -63,7 +62,7 @@ class globalIndex
{ {
// Private data // Private data
//- Start off procI + 1. (so like CompactListList) //- Processor offsets
labelList offsets_; labelList offsets_;
@ -83,10 +82,6 @@ public:
// Member Functions // Member Functions
////- Start of procI+1 data
//inline const labelList& offsets() const;
// Queries relating to my processor // Queries relating to my processor
//- my local size //- my local size

View file

@ -83,7 +83,6 @@ Description
- mark indices for which information has changed - mark indices for which information has changed
endloop until nothing changes. endloop until nothing changes.
SourceFiles SourceFiles
globalPoints.C globalPoints.C

View file

@ -0,0 +1,190 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "globalProcFaceIndex.H"
#include "processorPolyPatch.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::globalProcFaceIndex::calcFaceIndex()
{
// Count number of unique faces on this processor
nUniqueFaces_[Pstream::myProcNo()] = mesh_.nInternalFaces();
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Assing unique face label to all master processor faces
// Count faces and processor faces per processor
forAll (patches, patchI)
{
// Only skip slave processor patches
if (isA<processorPolyPatch>(patches[patchI]))
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patches[patchI]);
if (procPatch.master())
{
// Found unique faces
nUniqueFaces_[Pstream::myProcNo()] += procPatch.size();
}
// else Slave processor patch. Skip it
}
else
{
// Regular patch. Add faces to count
nUniqueFaces_[Pstream::myProcNo()] += patches[patchI].size();
}
}
// Gather data to master processor
Pstream::gatherList(nUniqueFaces_);
Pstream::scatterList(nUniqueFaces_);
// Adjust all lists to calculate offsets on the master processor only
if (Pstream::master())
{
for (label procI = 1; procI < procFaceOffset_.size(); procI++)
{
// Number of unique faces for this processor is equal to the number
// of faces on previous processor + number of local unique faces
procFaceOffset_[procI] =
procFaceOffset_[procI - 1] + nUniqueFaces_[procI - 1];
}
}
// Scatter offset data to all processors
Pstream::scatter(procFaceOffset_);
// Assemble global label list for mesh faces
label globalFaceIndex = procFaceOffset_[Pstream::myProcNo()];
for (label faceI = 0; faceI < mesh_.nInternalFaces(); faceI++)
{
globalLabel_[faceI] = globalFaceIndex;
globalFaceIndex++;
}
// Assign and send from master
forAll (patches, patchI)
{
const label patchSize = patches[patchI].size();
const label patchStart = patches[patchI].start();
if (isA<processorPolyPatch>(patches[patchI]))
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patches[patchI]);
if (procPatch.master())
{
// Master processor patch: assign face index
for
(
label patchFaceI = patchStart;
patchFaceI < patchStart + patchSize;
patchFaceI++
)
{
globalLabel_[patchFaceI] = globalFaceIndex;
globalFaceIndex++;
}
// Make a slice and send it
labelList curFaceLabels(procPatch.patchSlice(globalLabel_));
OPstream toProc
(
Pstream::nonBlocking,
procPatch.neighbProcNo()
);
toProc<< curFaceLabels;
}
}
else
{
// Regular patch: assign face index
for
(
label patchFaceI = patchStart;
patchFaceI < patchStart + patchSize;
patchFaceI++
)
{
globalLabel_[patchFaceI] = globalFaceIndex;
globalFaceIndex++;
}
}
}
// Receive on slave
forAll (patches, patchI)
{
if (isA<processorPolyPatch>(patches[patchI]))
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patches[patchI]);
if (!procPatch.master())
{
// Slave processor patch
// Receive the data from master and insert into the list
IPstream fromProc
(
Pstream::nonBlocking,
procPatch.neighbProcNo()
);
labelList masterFaceLabels(fromProc);
// Insert the data into the list
const label patchStart = patches[patchI].start();
forAll (masterFaceLabels, patchFaceI)
{
globalLabel_[patchStart + patchFaceI] =
masterFaceLabels[patchFaceI];
}
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::globalProcFaceIndex::globalProcFaceIndex(const polyMesh& mesh)
:
mesh_(mesh),
nUniqueFaces_(Pstream::nProcs(), 0),
procFaceOffset_(Pstream::nProcs(), 0),
globalLabel_(mesh_.nFaces())
{
calcFaceIndex();
}
// ************************************************************************* //

View file

@ -0,0 +1,140 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::globalProcFaceIndex
Description
The class creates a unique global face index for each processor face (pair)
in the mesh. Master and slave processor face carry the same index.
The data is presented as a labelListList, which is set only for
processor patches.
Face offsets counts a number of unique faces on each processor,
excluding slave processor patch faces, which are given master face index.
If needed, global face indes from all faces can be derived from this data
Currently, faces are ordered with internal faces first, followed by patch
faces in patch order, excluding slave processor patches.
If needed, this can be changed to group processor faces with internal faces
to facilitate parallel I/O. HJ, 4/May/2018
Author
Hrvoje Jasak, Wikki Ltd.
SourceFiles
globalProcFaceIndex.C
\*---------------------------------------------------------------------------*/
#ifndef globalProcFaceIndex_H
#define globalProcFaceIndex_H
#include "polyMesh.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
/*---------------------------------------------------------------------------*\
Class globalProcFaceIndex Declaration
\*---------------------------------------------------------------------------*/
class globalProcFaceIndex
{
// Private data
//- Mesh reference
const polyMesh& mesh_;
//- Number of unique faces per processor
labelList nUniqueFaces_;
//- Processor face index offset
labelList procFaceOffset_;
//- Global face label for all faces of current mesh
// Sized to number of live faces in the mesh
labelList globalLabel_;
// Private Member Functions
//- Disallow default bitwise copy construct
globalProcFaceIndex(const globalProcFaceIndex&);
//- Disallow default bitwise assignment
void operator=(const globalProcFaceIndex&);
//- Calculate face index
void calcFaceIndex();
public:
// Constructors
//- Construct from mesh
globalProcFaceIndex(const polyMesh&);
//- Destructor - default
// Member Functions
//- Return number of unique faces per processor
inline const labelList& nUniqueFaces() const
{
return nUniqueFaces_;
}
//- Return face index offset per processor
inline const labelList& procFaceOffset() const
{
return procFaceOffset_;
}
//- Return lobal face label for all faces of current mesh
// Sized to number of live faces in the mesh
const labelList globalLabel() const
{
return globalLabel_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //