Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
fvMeshDistribute Class Reference

Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing. More...

Collaboration diagram for fvMeshDistribute:
Collaboration graph
[legend]

Public Member Functions

 ClassName ("fvMeshDistribute")
 
 fvMeshDistribute (fvMesh &mesh, const scalar mergeTol)
 Construct from mesh and absolute merge tolerance. More...
 
autoPtr< mapDistributePolyMeshdistribute (const labelList &dist)
 Send cells to neighbours according to distribution. More...
 

Static Public Member Functions

static labelList countCells (const labelList &)
 Helper function: count cells per processor in wanted distribution. More...
 
static void printCoupleInfo (const primitiveMesh &, const labelList &, const labelList &, const labelList &, const labelList &)
 Print some info on coupling data. More...
 
template<class GeoField >
static void printFieldInfo (const fvMesh &)
 Print some field info. More...
 
static void printMeshInfo (const fvMesh &)
 Print some info on mesh. More...
 
static tmp< surfaceScalarFieldgenerateTestField (const fvMesh &)
 Generate a test field on faces. More...
 
static void testField (const surfaceScalarField &)
 Check whether field consistent with face orientation. More...
 

Private Member Functions

label findNonEmptyPatch () const
 Find patch to put exposed faces into. More...
 
template<class T , class Mesh >
void saveBoundaryFields (PtrList< FieldField< fvsPatchField, T > > &bflds) const
 Save boundary fields. More...
 
template<class T , class Mesh >
void mapBoundaryFields (const mapPolyMesh &map, const PtrList< FieldField< fvsPatchField, T > > &oldBflds)
 Map boundary fields. More...
 
template<class T >
void saveInternalFields (PtrList< Field< T > > &iflds) const
 Save internal fields of surfaceFields. More...
 
template<class T >
void mapExposedFaces (const mapPolyMesh &map, const PtrList< Field< T > > &oldFlds)
 Set value of patch faces resulting from internal faces. More...
 
template<class GeoField , class PatchFieldType >
void initPatchFields (const typename GeoField::value_type &initVal)
 Init patch fields of certain type. More...
 
template<class GeoField >
void correctBoundaryConditions ()
 Call correctBoundaryConditions on fields. More...
 
autoPtr< mapPolyMeshdeleteProcPatches (const label patchI)
 Delete all processor patches. Move any processor faces into. More...
 
autoPtr< mapPolyMeshrepatch (const labelList &newPatchID, labelListList &constructFaceMap)
 Repatch the mesh. This is only necessary for the proc. More...
 
autoPtr< mapPolyMeshmergeSharedPoints (labelListList &constructPointMap)
 Merge any shared points that are geometrically shared. Needs. More...
 
void getNeighbourData (const labelList &distribution, labelList &sourceFace, labelList &sourceProc, labelList &sourcePatch, labelList &sourceNewProc) const
 Construct the local environment of all boundary faces. More...
 
autoPtr< mapPolyMeshdoRemoveCells (const labelList &cellsToRemove, const label oldInternalPatchI)
 Remove cells. Add all exposed faces to patch oldInternalPatchI. More...
 
void addProcPatches (const labelList &, const labelList &, List< Map< label > > &procPatchID)
 Add processor patches. Changes mesh and returns per neighbour. More...
 
 fvMeshDistribute (const fvMeshDistribute &)
 Disallow default bitwise copy construct. More...
 
void operator= (const fvMeshDistribute &)
 Disallow default bitwise assignment. More...
 

Static Private Member Functions

static void inplaceRenumberWithFlip (const labelUList &oldToNew, const bool oldToNewHasFlip, const bool lstHasFlip, labelUList &lst)
 
static labelList select (const bool selectEqual, const labelList &values, const label value)
 Find indices with value. More...
 
static void checkEqualWordList (const string &, const wordList &)
 Check all procs have same names and in exactly same order. More...
 
static wordList mergeWordList (const wordList &)
 Merge wordlists over all processors. More...
 
static void subsetBoundaryData (const fvMesh &mesh, const labelList &faceMap, const labelList &cellMap, const labelList &oldDistribution, const labelList &oldFaceOwner, const labelList &oldFaceNeighbour, const label oldInternalFaces, const labelList &sourceFace, const labelList &sourceProc, const labelList &sourcePatch, const labelList &sourceNewProc, labelList &subFace, labelList &subProc, labelList &subPatch, labelList &subNewProc)
 
static void findCouples (const primitiveMesh &, const labelList &sourceFace, const labelList &sourceProc, const labelList &sourcePatch, const label domain, const primitiveMesh &domainMesh, const labelList &domainFace, const labelList &domainProc, const labelList &domainPatch, labelList &masterCoupledFaces, labelList &slaveCoupledFaces)
 Find cells on mesh whose faceID/procID match the neighbour. More...
 
static labelList mapBoundaryData (const primitiveMesh &mesh, const mapAddedPolyMesh &map, const labelList &boundaryData0, const label nInternalFaces1, const labelList &boundaryData1)
 Map data on boundary faces to new mesh (resulting from adding. More...
 
static labelList getBoundaryPatch (const labelList &neighbourNewProc, const labelList &referPatchID, const List< Map< label > > &procPatchID)
 Get boundary faces to be repatched. Is -1 or new patchID. More...
 
static void sendMesh (const label domain, const fvMesh &mesh, const wordList &pointZoneNames, const wordList &facesZoneNames, const wordList &cellZoneNames, const labelList &sourceFace, const labelList &sourceProc, const labelList &sourcePatch, const labelList &sourceNewProc, Ostream &toDomain)
 Send mesh and coupling data. More...
 
template<class GeoField >
static void sendFields (const label domain, const wordList &fieldNames, const fvMeshSubset &, Ostream &toNbr)
 Send subset of fields. More...
 
static autoPtr< fvMeshreceiveMesh (const label domain, const wordList &pointZoneNames, const wordList &facesZoneNames, const wordList &cellZoneNames, const Time &runTime, labelList &domainSourceFace, labelList &domainSourceProc, labelList &domainSourcePatch, labelList &domainSourceNewProc, Istream &fromNbr)
 Receive mesh. Opposite of sendMesh. More...
 
template<class GeoField >
static void receiveFields (const label domain, const wordList &fieldNames, fvMesh &, PtrList< GeoField > &, const dictionary &fieldDicts)
 Receive fields. Opposite of sendFields. More...
 

Private Attributes

fvMeshmesh_
 Underlying fvMesh. More...
 
const scalar mergeTol_
 Absolute merging tolerance (constructing meshes gets done using. More...
 

Detailed Description

Sends/receives parts of mesh+fvfields to neighbouring processors. Used in load balancing.

Input is per local cell the processor it should move to. Moves meshes and volFields/surfaceFields and returns map which can be used to distribute other.

Notes:

Source files

Definition at line 70 of file fvMeshDistribute.H.

Constructor & Destructor Documentation

◆ fvMeshDistribute() [1/2]

fvMeshDistribute ( const fvMeshDistribute )
private

Disallow default bitwise copy construct.

◆ fvMeshDistribute() [2/2]

fvMeshDistribute ( fvMesh mesh,
const scalar  mergeTol 
)

Construct from mesh and absolute merge tolerance.

Definition at line 1579 of file fvMeshDistribute.C.

Member Function Documentation

◆ inplaceRenumberWithFlip()

void inplaceRenumberWithFlip ( const labelUList oldToNew,
const bool  oldToNewHasFlip,
const bool  lstHasFlip,
labelUList lst 
)
staticprivate

Definition at line 89 of file fvMeshDistribute.C.

References Foam::exit(), Foam::FatalError, FatalErrorInFunction, forAll, Foam::inplaceRenumber(), Foam::sign(), and UList::size().

Here is the call graph for this function:

◆ select()

Foam::labelList select ( const bool  selectEqual,
const labelList values,
const label  value 
)
staticprivate

Find indices with value.

Definition at line 163 of file fvMeshDistribute.C.

References forAll, and n.

◆ checkEqualWordList()

void checkEqualWordList ( const string msg,
const wordList lst 
)
staticprivate

Check all procs have same names and in exactly same order.

Definition at line 195 of file fvMeshDistribute.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, and FatalErrorInFunction.

Here is the call graph for this function:

◆ mergeWordList()

Foam::wordList mergeWordList ( const wordList procNames)
staticprivate

Merge wordlists over all processors.

Definition at line 220 of file fvMeshDistribute.C.

References forAll, Pstream::gatherList(), HashSet< Key, Hash >::insert(), UPstream::myProcNo(), UPstream::nProcs(), Pstream::scatterList(), and HashTable< nil, word, string::hash >::toc().

Here is the call graph for this function:

◆ findNonEmptyPatch()

Foam::label findNonEmptyPatch ( ) const
private

Find patch to put exposed faces into.

Definition at line 327 of file fvMeshDistribute.C.

References Foam::abort(), polyPatch::coupled(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, forAllReverse, patches, and Foam::Pout.

Here is the call graph for this function:

◆ saveBoundaryFields()

void saveBoundaryFields ( PtrList< FieldField< fvsPatchField, T > > &  bflds) const
private

Save boundary fields.

Definition at line 61 of file fvMeshDistributeTemplates.C.

References fld(), forAllConstIter(), and HashTable::size().

Here is the call graph for this function:

◆ mapBoundaryFields()

void mapBoundaryFields ( const mapPolyMesh map,
const PtrList< FieldField< fvsPatchField, T > > &  oldBflds 
)
private

◆ saveInternalFields()

void saveInternalFields ( PtrList< Field< T > > &  iflds) const
private

Save internal fields of surfaceFields.

Definition at line 149 of file fvMeshDistributeTemplates.C.

References fld(), forAllConstIter(), and HashTable::size().

Here is the call graph for this function:

◆ mapExposedFaces()

void mapExposedFaces ( const mapPolyMesh map,
const PtrList< Field< T > > &  oldFlds 
)
private

Set value of patch faces resulting from internal faces.

Definition at line 178 of file fvMeshDistributeTemplates.C.

References Foam::abort(), Foam::faceMap(), mapPolyMesh::faceMap(), Foam::FatalError, FatalErrorInFunction, fld(), mapPolyMesh::flipFaceFlux(), forAll, forAllIter, HashTable::found(), fvsPatchField::patch(), HashTable::size(), and fvPatch::start().

Here is the call graph for this function:

◆ initPatchFields()

void initPatchFields ( const typename GeoField::value_type &  initVal)
private

Init patch fields of certain type.

Definition at line 239 of file fvMeshDistributeTemplates.C.

References fld(), forAll, and forAllIter.

Here is the call graph for this function:

◆ correctBoundaryConditions()

void correctBoundaryConditions
private

Call correctBoundaryConditions on fields.

Definition at line 268 of file fvMeshDistributeTemplates.C.

References fld(), and forAllIter.

Here is the call graph for this function:

◆ deleteProcPatches()

Foam::autoPtr< Foam::mapPolyMesh > deleteProcPatches ( const label  patchI)
private

Delete all processor patches. Move any processor faces into.

patchI.

Definition at line 495 of file fvMeshDistribute.C.

References polyPatch::boundaryMesh(), Foam::endl(), forAll, Foam::identity(), patchIdentifier::name(), Foam::Pout, fvMeshTools::reorderPatches(), and polyPatch::start().

Here is the call graph for this function:

◆ repatch()

Foam::autoPtr< Foam::mapPolyMesh > repatch ( const labelList newPatchID,
labelListList constructFaceMap 
)
private

Repatch the mesh. This is only necessary for the proc.

boundary faces. newPatchID is over all boundary faces: -1 or new patchID. constructFaceMap is being adapted for the possible new face position (since proc faces get automatically matched)

Definition at line 567 of file fvMeshDistribute.C.

References Foam::abort(), polyTopoChange::changeMesh(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, Foam::findIndex(), faceZone::flipMap(), forAll, polyTopoChange::setAction(), and faceZone::whichFace().

Here is the call graph for this function:

◆ mergeSharedPoints()

Foam::autoPtr< Foam::mapPolyMesh > mergeSharedPoints ( labelListList constructPointMap)
private

Merge any shared points that are geometrically shared. Needs.

parallel valid mesh - uses globalMeshData. constructPointMap is adapted for the new point labels.

Definition at line 687 of file fvMeshDistribute.C.

References Foam::abort(), polyTopoChange::changeMesh(), Foam::FatalError, FatalErrorInFunction, polyMeshAdder::findSharedPoints(), forAll, polyMeshAdder::mergePoints(), and Foam::returnReduce().

Here is the call graph for this function:

◆ getNeighbourData()

void getNeighbourData ( const labelList distribution,
labelList sourceFace,
labelList sourceProc,
labelList sourcePatch,
labelList sourceNewProc 
) const
private

◆ subsetBoundaryData()

void subsetBoundaryData ( const fvMesh mesh,
const labelList faceMap,
const labelList cellMap,
const labelList oldDistribution,
const labelList oldFaceOwner,
const labelList oldFaceNeighbour,
const label  oldInternalFaces,
const labelList sourceFace,
const labelList sourceProc,
const labelList sourcePatch,
const labelList sourceNewProc,
labelList subFace,
labelList subProc,
labelList subPatch,
labelList subNewProc 
)
staticprivate

Definition at line 895 of file fvMeshDistribute.C.

References Foam::faceMap(), polyMesh::faceOwner(), forAll, mesh, UPstream::myProcNo(), primitiveMesh::nFaces(), primitiveMesh::nInternalFaces(), and List::setSize().

Here is the call graph for this function:

◆ findCouples()

void findCouples ( const primitiveMesh mesh,
const labelList sourceFace,
const labelList sourceProc,
const labelList sourcePatch,
const label  domain,
const primitiveMesh domainMesh,
const labelList domainFace,
const labelList domainProc,
const labelList domainPatch,
labelList masterCoupledFaces,
labelList slaveCoupledFaces 
)
staticprivate

Find cells on mesh whose faceID/procID match the neighbour.

cell/proc of domainMesh. Store the matching face.

Definition at line 965 of file fvMeshDistribute.C.

References Foam::endl(), HashTable::find(), forAll, HashTable::insert(), mesh, primitiveMesh::nInternalFaces(), Foam::nl, Foam::Pout, List::setSize(), and List::size().

Here is the call graph for this function:

◆ mapBoundaryData()

Foam::labelList mapBoundaryData ( const primitiveMesh mesh,
const mapAddedPolyMesh map,
const labelList boundaryData0,
const label  nInternalFaces1,
const labelList boundaryData1 
)
staticprivate

Map data on boundary faces to new mesh (resulting from adding.

two meshes)

Definition at line 1040 of file fvMeshDistribute.C.

References mapAddedPolyMesh::addedFaceMap(), forAll, mesh, primitiveMesh::nFaces(), primitiveMesh::nInternalFaces(), mapAddedPolyMesh::nOldInternalFaces(), and mapAddedPolyMesh::oldFaceMap().

Here is the call graph for this function:

◆ doRemoveCells()

Foam::autoPtr< Foam::mapPolyMesh > doRemoveCells ( const labelList cellsToRemove,
const label  oldInternalPatchI 
)
private

Remove cells. Add all exposed faces to patch oldInternalPatchI.

Definition at line 1079 of file fvMeshDistribute.C.

References polyTopoChange::changeMesh(), removeCells::getExposedFaces(), removeCells::setRefinement(), and List::size().

Here is the call graph for this function:

◆ addProcPatches()

void addProcPatches ( const labelList nbrProc,
const labelList referPatchID,
List< Map< label > > &  procPatchID 
)
private

Add processor patches. Changes mesh and returns per neighbour.

proc the processor patchID.

Definition at line 1157 of file fvMeshDistribute.C.

References fvMeshTools::addPatch(), forAll, found, UPstream::myProcNo(), patchIdentifier::name(), Foam::name(), UPstream::nProcs(), Foam::sortedOrder(), and coupledPolyPatch::transform().

Here is the call graph for this function:

◆ getBoundaryPatch()

Foam::labelList getBoundaryPatch ( const labelList neighbourNewProc,
const labelList referPatchID,
const List< Map< label > > &  procPatchID 
)
staticprivate

Get boundary faces to be repatched. Is -1 or new patchID.

Definition at line 1275 of file fvMeshDistribute.C.

References forAll, and UPstream::myProcNo().

Here is the call graph for this function:

◆ sendMesh()

void sendMesh ( const label  domain,
const fvMesh mesh,
const wordList pointZoneNames,
const wordList facesZoneNames,
const wordList cellZoneNames,
const labelList sourceFace,
const labelList sourceProc,
const labelList sourcePatch,
const labelList sourceNewProc,
Ostream toDomain 
)
staticprivate

◆ sendFields()

void sendFields ( const label  domain,
const wordList fieldNames,
const fvMeshSubset subsetter,
Ostream toNbr 
)
staticprivate

◆ receiveMesh()

Foam::autoPtr< Foam::fvMesh > receiveMesh ( const label  domain,
const wordList pointZoneNames,
const wordList facesZoneNames,
const wordList cellZoneNames,
const Time runTime,
labelList domainSourceFace,
labelList domainSourceProc,
labelList domainSourcePatch,
labelList domainSourceNewProc,
Istream fromNbr 
)
staticprivate

◆ receiveFields()

void receiveFields ( const label  domain,
const wordList fieldNames,
fvMesh mesh,
PtrList< GeoField > &  fields,
const dictionary fieldDicts 
)
staticprivate

Receive fields. Opposite of sendFields.

Definition at line 338 of file fvMeshDistributeTemplates.C.

References IOobject::AUTO_WRITE, Foam::endl(), Foam::fieldNames(), fields, forAll, mesh, IOobject::NO_READ, Foam::Pout, List::size(), dictionary::subDict(), fvMesh::time(), and Time::timeName().

Here is the call graph for this function:

◆ operator=()

void operator= ( const fvMeshDistribute )
private

Disallow default bitwise assignment.

◆ ClassName()

ClassName ( "fvMeshDistribute"  )

◆ countCells()

Foam::labelList countCells ( const labelList distribution)
static

Helper function: count cells per processor in wanted distribution.

Definition at line 1589 of file fvMeshDistribute.C.

References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, forAll, and UPstream::nProcs().

Referenced by meshRefinement::balance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ distribute()

Foam::autoPtr< Foam::mapDistributePolyMesh > distribute ( const labelList dist)

◆ printCoupleInfo()

void printCoupleInfo ( const primitiveMesh mesh,
const labelList sourceFace,
const labelList sourceProc,
const labelList sourcePatch,
const labelList sourceNewNbrProc 
)
static

Print some info on coupling data.

Definition at line 300 of file fvMeshDistribute.C.

References Foam::endl(), primitiveMesh::faceCentres(), forAll, mesh, primitiveMesh::nInternalFaces(), Foam::nl, and Foam::Pout.

Here is the call graph for this function:

◆ printFieldInfo()

void printFieldInfo ( const fvMesh mesh)
static

Print some field info.

Definition at line 31 of file fvMeshDistributeTemplates.C.

References Foam::endl(), fld(), forAll, forAllConstIter(), mesh, and Foam::Pout.

Here is the call graph for this function:

◆ printMeshInfo()

void printMeshInfo ( const fvMesh mesh)
static

◆ generateTestField()

Foam::tmp< Foam::surfaceScalarField > generateTestField ( const fvMesh mesh)
static

Generate a test field on faces.

Definition at line 389 of file fvMeshDistribute.C.

References Foam::dimless, fld(), forAll, Foam::mag(), fvMesh::magSf(), mesh, n, IOobject::NO_READ, IOobject::NO_WRITE, fvMesh::Sf(), fvMesh::time(), and Time::timeName().

Here is the call graph for this function:

◆ testField()

void testField ( const surfaceScalarField fld)
static

Check whether field consistent with face orientation.

Definition at line 436 of file fvMeshDistribute.C.

References Foam::cos(), Foam::e, Foam::endl(), primitiveMesh::faceCentres(), fld(), forAll, Foam::mag(), fvMesh::magSf(), mesh, n, fvPatch::name(), fvsPatchField::patch(), fvMesh::Sf(), fvPatch::start(), and WarningInFunction.

Here is the call graph for this function:

Field Documentation

◆ mesh_

fvMesh& mesh_
private

Underlying fvMesh.

Definition at line 75 of file fvMeshDistribute.H.

◆ mergeTol_

const scalar mergeTol_
private

Absolute merging tolerance (constructing meshes gets done using.

geometric matching)

Definition at line 79 of file fvMeshDistribute.H.


The documentation for this class was generated from the following files: