32 template<
class SourcePatch,
class TargetPatch>
35 const SourcePatch& srcPatch,
36 const TargetPatch& tgtPatch
41 if (Pstream::parRun())
43 List<label> facesPresentOnProc(Pstream::nProcs(), 0);
44 if ((srcPatch.size() > 0) || (tgtPatch.size() > 0))
46 facesPresentOnProc[Pstream::myProcNo()] = 1;
50 facesPresentOnProc[Pstream::myProcNo()] = 0;
53 Pstream::gatherList(facesPresentOnProc);
54 Pstream::scatterList(facesPresentOnProc);
56 label nHaveFaces =
sum(facesPresentOnProc);
64 <<
"AMI split across multiple processors" <<
endl;
67 else if (nHaveFaces == 1)
73 <<
"AMI local to processor" << proci <<
endl;
84 template<
class SourcePatch,
class TargetPatch>
88 const List<treeBoundBoxList>& procBb,
89 const treeBoundBox& bb,
93 overlaps.setSize(procBb.size());
104 if (bbs[bbI].overlaps(bb))
106 overlaps[proci] =
true;
116 template<
class SourcePatch,
class TargetPatch>
119 const mapDistribute& map,
120 const TargetPatch& pp,
121 const globalIndex& gi,
122 List<faceList>& faces,
123 List<pointField>& points,
124 List<labelList>& faceIDs
127 PstreamBuffers pBufs(Pstream::nonBlocking);
129 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
131 const labelList& sendElems = map.subMap()[domain];
133 if (domain != Pstream::myProcNo() && sendElems.size())
138 globalElems[i] = gi.toGlobal(sendElems[i]);
141 faceList subFaces(UIndirectList<face>(pp, sendElems));
144 SubList<face>(subFaces, subFaces.size()),
150 Pout<<
"distributePatches: to processor " << domain
151 <<
" sending faces " << subPatch.faceCentres() <<
endl;
154 UOPstream toDomain(domain, pBufs);
156 << subPatch.localFaces() << subPatch.localPoints()
162 pBufs.finishedSends();
164 faces.setSize(Pstream::nProcs());
165 points.setSize(Pstream::nProcs());
166 faceIDs.setSize(Pstream::nProcs());
170 const labelList& sendElems = map.subMap()[Pstream::myProcNo()];
171 faceList subFaces(UIndirectList<face>(pp, sendElems));
174 SubList<face>(subFaces, subFaces.size()),
181 Pout<<
"distributePatches: to processor " << Pstream::myProcNo()
182 <<
" sending faces " << subPatch.faceCentres() <<
endl;
185 faces[Pstream::myProcNo()] = subPatch.localFaces();
186 points[Pstream::myProcNo()] = subPatch.localPoints();
188 faceIDs[Pstream::myProcNo()].setSize(sendElems.size());
191 faceIDs[Pstream::myProcNo()][i] = gi.toGlobal(sendElems[i]);
196 for (
label domain = 0; domain < Pstream::nProcs(); domain++)
198 const labelList& recvElems = map.constructMap()[domain];
200 if (domain != Pstream::myProcNo() && recvElems.size())
202 UIPstream str(domain, pBufs);
212 template<
class SourcePatch,
class TargetPatch>
216 const mapDistribute& map,
217 const TargetPatch& tgtPatch,
218 const globalIndex& gi,
225 List<faceList> allFaces;
227 List<labelList> allTgtFaceIDs;
228 distributePatches(map, tgtPatch, gi, allFaces, allPoints, allTgtFaceIDs);
235 nFaces += allFaces[proci].size();
236 nPoints += allPoints[proci].size();
239 tgtFaces.setSize(nFaces);
240 tgtPoints.setSize(nPoints);
241 tgtFaceIDs.setSize(nFaces);
248 const labelList& faceIDs = allTgtFaceIDs[Pstream::myProcNo()];
249 SubList<label>(tgtFaceIDs, faceIDs.size()) = faceIDs;
251 const faceList& fcs = allFaces[Pstream::myProcNo()];
254 const face&
f = fcs[i];
255 face& newF = tgtFaces[nFaces++];
256 newF.setSize(f.size());
263 const pointField& pts = allPoints[Pstream::myProcNo()];
266 tgtPoints[nPoints++] = pts[i];
274 if (proci != Pstream::myProcNo())
276 const labelList& faceIDs = allTgtFaceIDs[proci];
277 SubList<label>(tgtFaceIDs, faceIDs.size(), nFaces) = faceIDs;
279 const faceList& fcs = allFaces[proci];
282 const face&
f = fcs[i];
283 face& newF = tgtFaces[nFaces++];
284 newF.setSize(f.size());
294 tgtPoints[nPoints++] = pts[i];
315 Pout<<
"Merged from " << tgtPoints.size()
316 <<
" down to " << newTgtPoints.size() <<
" points" <<
endl;
319 tgtPoints.transfer(newTgtPoints);
328 template<
class SourcePatch,
class TargetPatch>
332 const SourcePatch& srcPatch,
333 const TargetPatch& tgtPatch
337 List<treeBoundBoxList> procBb(Pstream::nProcs());
347 srcPatch.meshPoints()
358 forAll(procBb[Pstream::myProcNo()], bbI)
360 treeBoundBox& bb = procBb[Pstream::myProcNo()][bbI];
364 Pstream::gatherList(procBb);
365 Pstream::scatterList(procBb);
370 Info<<
"Determining extent of srcPatch per processor:" <<
nl 371 <<
"\tproc\tbb" <<
endl;
374 Info<<
'\t' << proci <<
'\t' << procBb[proci] <<
endl;
380 const faceList& faces = tgtPatch.localFaces();
381 const pointField& points = tgtPatch.localPoints();
387 List<DynamicList<label>> dynSendMap(Pstream::nProcs());
390 boolList procBbOverlaps(Pstream::nProcs());
394 if (faces[facei].size())
396 treeBoundBox faceBb(points, faces[facei]);
399 calcOverlappingProcs(procBb, faceBb, procBbOverlaps);
401 forAll(procBbOverlaps, proci)
403 if (procBbOverlaps[proci])
405 dynSendMap[proci].append(facei);
412 sendMap.setSize(Pstream::nProcs());
415 sendMap[proci].transfer(dynSendMap[proci]);
422 Pout<<
"Of my " << faces.size() <<
" I need to send to:" <<
nl 423 <<
"\tproc\tfaces" <<
endl;
426 Pout<<
'\t' << proci <<
'\t' << sendMap[proci].size() <<
endl;
433 sendSizes[Pstream::myProcNo()].setSize(Pstream::nProcs());
436 sendSizes[Pstream::myProcNo()][proci] = sendMap[proci].size();
438 Pstream::gatherList(sendSizes);
439 Pstream::scatterList(sendSizes);
446 constructMap[Pstream::myProcNo()] =
identity 448 sendMap[Pstream::myProcNo()].size()
451 label segmentI = constructMap[Pstream::myProcNo()].size();
452 forAll(constructMap, proci)
454 if (proci != Pstream::myProcNo())
457 label nRecv = sendSizes[proci][Pstream::myProcNo()];
458 constructMap[proci].setSize(nRecv);
460 for (
label i = 0; i < nRecv; i++)
462 constructMap[proci][i] = segmentI++;
467 autoPtr<mapDistribute> mapPtr
List< labelList > labelListList
A List of labelList.
List< treeBoundBox > treeBoundBoxList
List of bounding boxes.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
List< bool > boolList
Bool container classes.
vectorField pointField
pointField is a vectorField.
List< label > labelList
A List of labels.
prefixOSstream Pout(cout,"Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
PrimitivePatch< face, SubList, const pointField & > primitivePatch
Addressing for a faceList slice.
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
#define InfoInFunction
Report an information message using Foam::Info.