38 template<
class T,
class CombineOp>
39 void Foam::syncTools::combine
49 if (iter != pointValues.end())
55 pointValues.insert(index, val);
60 template<
class T,
class CombineOp>
61 void Foam::syncTools::combine
63 EdgeMap<T>& edgeValues,
71 if (iter != edgeValues.end())
77 edgeValues.insert(index, val);
82 template<
class T,
class CombineOp,
class TransformOp>
88 const TransformOp& top
97 Map<T> sharedPointValues(0);
106 sharedPointValues.
resize(sharedPtAddr.
size());
111 label meshPointi = sharedPtLabels[i];
114 pointValues.
find(meshPointi);
116 if (fnd != pointValues.
end())
140 isA<processorPolyPatch>(patches[
patchi])
141 && patches[patchi].
nPoints() > 0
145 refCast<const processorPolyPatch>(patches[
patchi]);
154 Map<T> patchInfo(meshPts.size() / 20);
159 pointValues.
find(meshPts[i]);
161 if (iter != pointValues.
end())
163 patchInfo.insert(nbrPts[i], iter());
168 toNeighb << patchInfo;
180 isA<processorPolyPatch>(patches[
patchi])
181 && patches[patchi].
nPoints() > 0
185 refCast<const processorPolyPatch>(patches[
patchi]);
188 Map<T> nbrPatchInfo(fromNb);
191 top(procPatch, nbrPatchInfo);
202 meshPts[nbrIter.key()],
213 if (isA<cyclicPolyPatch>(patches[
patchi]))
216 refCast<const cyclicPolyPatch>(patches[
patchi]);
218 if (cycPatch.
owner())
229 Map<T> half1Values(half0Values.size());
233 const edge&
e = coupledPoints[i];
236 pointValues.
find(meshPtsA[e[0]]);
238 if (point0Fnd != pointValues.
end())
240 half0Values.insert(i, point0Fnd());
244 pointValues.
find(meshPtsB[e[1]]);
246 if (point1Fnd != pointValues.
end())
248 half1Values.insert(i, point1Fnd());
253 top(cycPatch, half1Values);
254 top(nbrPatch, half0Values);
258 const edge&
e = coupledPoints[i];
263 if (half0Fnd != half0Values.end())
277 if (half1Fnd != half1Values.end())
315 Map<T> nbrValues(fromSlave);
339 toSlave << sharedPointValues;
351 toMaster << sharedPointValues;
360 fromMaster >> sharedPointValues;
373 sharedToMeshPoint.insert(sharedPtAddr[i], sharedPtLabels[i]);
380 sharedPointValues.
find(iter.key());
382 if (sharedFnd != sharedPointValues.
end())
384 pointValues.
set(iter(), sharedFnd());
391 template<
class T,
class CombineOp,
class TransformOp>
396 const CombineOp& cop,
397 const TransformOp& top
420 isA<processorPolyPatch>(patches[
patchi])
421 && patches[patchi].nEdges() > 0
425 refCast<const processorPolyPatch>(patches[
patchi]);
438 const edge&
e = edges[i];
439 const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
442 edgeValues.
find(meshEdge);
444 if (iter != edgeValues.
end())
446 const edge nbrEdge(nbrPts[e[0]], nbrPts[e[1]]);
447 patchInfo.insert(nbrEdge, iter());
452 toNeighb << patchInfo;
464 isA<processorPolyPatch>(patches[
patchi])
465 && patches[patchi].nEdges() > 0
469 refCast<const processorPolyPatch>(patches[
patchi]);
474 fromNbr >> nbrPatchInfo;
478 top(procPatch, nbrPatchInfo);
486 const edge&
e = nbrIter.key();
487 const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
507 if (isA<cyclicPolyPatch>(patches[
patchi]))
510 refCast<const cyclicPolyPatch>(patches[
patchi]);
512 if (cycPatch.
owner())
525 Map<T> half1Values(half0Values.size());
529 const edge& twoEdges = coupledEdges[i];
532 const edge& e0 = edgesA[twoEdges[0]];
533 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
536 edgeValues.
find(meshEdge0);
538 if (iter != edgeValues.
end())
540 half0Values.insert(i, iter());
544 const edge& e1 = edgesB[twoEdges[1]];
545 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
548 edgeValues.
find(meshEdge1);
550 if (iter != edgeValues.
end())
552 half1Values.insert(i, iter());
558 top(cycPatch, half1Values);
559 top(nbrPatch, half0Values);
566 const edge& twoEdges = coupledEdges[i];
571 if (half1Fnd != half1Values.end())
573 const edge& e0 = edgesA[twoEdges[0]];
574 const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
587 if (half0Fnd != half0Values.end())
589 const edge& e1 = edgesB[twoEdges[1]];
590 const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
618 meshToShared.insert(sharedPtLabels[i], sharedPtAddr[i]);
622 EdgeMap<T> sharedEdgeValues(meshToShared.size());
642 if (v0Fnd != meshToShared.
end())
646 if (v1Fnd != meshToShared.
end())
648 const edge meshEdge(v0, v1);
651 const edge sharedEdge(v0Fnd(), v1Fnd());
654 potentialSharedEdge.insert(sharedEdge, meshEdge);
657 edgeValues.
find(meshEdge);
659 if (edgeFnd != edgeValues.
end())
720 toSlave << sharedEdgeValues;
732 toMaster << sharedEdgeValues;
741 fromMaster >> sharedEdgeValues;
753 const edge& sharedEdge = iter.key();
754 const edge& meshEdge = iter();
758 sharedEdgeValues.
find(sharedEdge);
760 if (sharedFnd != sharedEdgeValues.
end())
992 template<
class T,
class CombineOp,
class TransformOp>
997 const CombineOp& cop,
999 const TransformOp& top
1005 <<
"Number of values " << pointValues.
size()
1006 <<
" is not equal to the number of points in the mesh " 1035 template<
class T,
class CombineOp,
class TransformOp>
1041 const CombineOp& cop,
1043 const TransformOp& top
1046 if (pointValues.
size() != meshPoints.
size())
1049 <<
"Number of values " << pointValues.
size()
1050 <<
" is not equal to the number of meshPoints " 1061 label pointi = meshPoints[i];
1063 if (iter != mpm.
end())
1065 cppFld[iter()] = pointValues[i];
1082 label pointi = meshPoints[i];
1084 if (iter != mpm.
end())
1086 pointValues[i] = cppFld[iter()];
1149 template<
class T,
class CombineOp,
class TransformOp>
1154 const CombineOp& cop,
1156 const TransformOp& top
1162 <<
"Number of values " << edgeValues.
size()
1163 <<
" is not equal to the number of edges in the mesh " 1188 edgeValues[meshEdges[i]] = cppFld[i];
1237 template<
class T,
class CombineOp,
class TransformOp>
1243 const CombineOp& cop,
1245 const TransformOp& top
1248 if (edgeValues.
size() != meshEdges.
size())
1251 <<
"Number of values " << edgeValues.
size()
1252 <<
" is not equal to the number of meshEdges " 1263 label edgeI = meshEdges[i];
1265 if (iter != mpm.
end())
1267 cppFld[iter()] = edgeValues[i];
1284 label edgeI = meshEdges[i];
1286 if (iter != mpm.
end())
1288 edgeValues[i] = cppFld[iter()];
1293 template<
class T,
class CombineOp,
class TransformOp>
1298 const CombineOp& cop,
1299 const TransformOp& top,
1305 if (faceValues.
size() != nBFaces)
1308 <<
"Number of values " << faceValues.
size()
1309 <<
" is not equal to the number of boundary faces in the mesh " 1325 isA<processorPolyPatch>(patches[
patchi])
1326 && patches[patchi].size() > 0
1330 refCast<const processorPolyPatch>(patches[
patchi]);
1335 toNbr << SubField<T>(faceValues, procPatch.size(), patchStart);
1349 isA<processorPolyPatch>(patches[
patchi])
1350 && patches[patchi].size() > 0
1354 refCast<const processorPolyPatch>(patches[
patchi]);
1356 Field<T> nbrPatchInfo(procPatch.size());
1359 fromNeighb >> nbrPatchInfo;
1361 top(procPatch, nbrPatchInfo);
1367 cop(faceValues[bFacei++], nbrPatchInfo[i]);
1376 if (isA<cyclicPolyPatch>(patches[
patchi]))
1379 refCast<const cyclicPolyPatch>(patches[
patchi]);
1381 if (cycPatch.
owner())
1388 label sz = cycPatch.size();
1392 top(nbrPatch, ownVals);
1395 top(cycPatch, nbrVals);
1397 label i0 = ownStart;
1400 cop(faceValues[i0++], nbrVals[i]);
1403 label i1 = nbrStart;
1406 cop(faceValues[i1++], ownVals[i]);
1416 template<
unsigned nBits,
class CombineOp>
1421 const CombineOp& cop,
1428 <<
"Number of values " << faceValues.
size()
1429 <<
" is not equal to the number of faces in the mesh " 1445 isA<processorPolyPatch>(patches[
patchi])
1446 && patches[patchi].size() > 0
1450 refCast<const processorPolyPatch>(patches[
patchi]);
1455 patchInfo[i] = faceValues[procPatch.
start()+i];
1472 isA<processorPolyPatch>(patches[
patchi])
1473 && patches[patchi].size() > 0
1477 refCast<const processorPolyPatch>(patches[
patchi]);
1482 fromNbr >> patchInfo;
1488 unsigned int patchVal = patchInfo[i];
1490 unsigned int faceVal = faceValues[meshFacei];
1491 cop(faceVal, patchVal);
1492 faceValues[meshFacei] = faceVal;
1501 if (isA<cyclicPolyPatch>(patches[
patchi]))
1504 refCast<const cyclicPolyPatch>(patches[
patchi]);
1506 if (cycPatch.
owner())
1511 for (
label i = 0; i < cycPatch.size(); i++)
1514 unsigned int val0 = faceValues[meshFace0];
1516 unsigned int val1 = faceValues[meshFace1];
1518 unsigned int t = val0;
1520 faceValues[meshFace0] = t;
1523 faceValues[meshFace1] = val1;
1542 <<
"Number of cell values " << cellData.
size()
1543 <<
" is not equal to the number of cells in the mesh " 1551 neighbourCellData.
setSize(nBnd);
1560 neighbourCellData[bFacei] = cellData[faceCells[i]];
1567 template<
unsigned nBits>
1578 template<
unsigned nBits,
class CombineOp>
1583 const CombineOp& cop,
1584 const unsigned int nullValue
1590 <<
"Number of values " << pointValues.
size()
1591 <<
" is not equal to the number of points in the mesh " 1601 cppFld[i] = pointValues[meshPoints[i]];
1616 pointValues[meshPoints[i]] = cppFld[i];
1621 template<
unsigned nBits,
class CombineOp>
1626 const CombineOp& cop,
1627 const unsigned int nullValue
1633 <<
"Number of values " << edgeValues.
size()
1634 <<
" is not equal to the number of edges in the mesh " 1644 cppFld[i] = edgeValues[meshEdges[i]];
1659 edgeValues[meshEdges[i]] = cppFld[i];
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
const Map< label > & coupledPatchMeshEdgeMap() const
Return map from mesh edges to coupledPatch edges.
label nPoints() const
Return number of points supporting patch faces.
const labelListList & globalPointSlaves() const
#define forAll(list, i)
Loop across all elements in list.
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static int masterNo()
Process index of the master.
const labelListList & globalPointTransformedSlaves() const
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
An STL-conforming const_iterator.
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
A face is a list of labels corresponding to mesh vertices.
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label nInternalFaces() const
static int firstSlave()
Process index of first slave.
const mapDistribute & globalEdgeSlavesMap() const
HashTable< T, label, Hash< label > >::iterator iterator
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
void size(const label)
Override size to be inconsistent with allocated storage.
label fcIndex(const label i) const
Return the forward circular index, i.e. the next index.
Template function to specify if the data of a type are contiguous.
const mapDistribute & globalPointSlavesMap() const
static bool master(const label communicator=0)
Am I the master process.
const labelListList & globalEdgeSlaves() const
const labelList & coupledPatchMeshEdges() const
Return map from coupledPatch edges to mesh edges.
Pre-declare related SubField type.
const edgeList & coupledEdges() const
Return connected edges (from patch local to neighbour patch local).
const labelList & meshPoints() const
Return labelList of mesh points in patch. They are constructed.
Neighbour processor patch.
Input inter-processor communications stream.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Input inter-processor communications stream operating on external buffer.
A list of faces which address into the list of points.
virtual bool owner() const
Does this side own the patch ?
label nGlobalPoints() const
Return number of globally shared points.
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
const globalIndexAndTransform & globalTransforms() const
Global transforms numbering.
A dynamically allocatable list of packed unsigned integers.
const labelUList & faceCells() const
Return face-cell addressing.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
const globalMeshData & globalData() const
Return parallel info.
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
virtual const faceList & faces() const
Return raw faces.
int neighbProcNo() const
Return neighbour processor number.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Output inter-processor communications stream operating on external buffer.
label nEdges() const
Return number of edges in patch.
Map from edge (expressed as its endpoints) to value.
Output inter-processor communications stream.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
static void syncData(List< Type > &pointData, const labelListList &slaves, const labelListList &transformedSlaves, const mapDistribute &slavesMap, const globalIndexAndTransform &, const CombineOp &cop, const TransformOp &top)
Helper: synchronise data with transforms.
label constructSize() const
Constructed data size.
void setSize(const label)
Reset size of List.
bool set(const label &, const T &newElmt)
Assign a new hashedEntry, overwriting existing entries.
static bool & parRun()
Is this a parallel run?
Class containing processor-to-processor mapping information.
A List with indirect addressing.
label start() const
Return start label of this patch in the polyMesh face list.
void resize(const label newSize)
Resize the hash table for efficiency.
const doubleScalar e
Elementary charge.
label size() const
Number of entries.
Mesh consisting of general polyhedral cells.
A patch is a list of labels that address the faces in the global face list.
const cyclicPolyPatch & neighbPatch() const
label size() const
Return the number of elements in the UList.
friend class iterator
Declare friendship with the iterator.
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points.
static int lastSlave(const label communicator=0)
Process index of last slave.
A HashTable to objects of type <T> with a label key.
const labelListList & globalEdgeTransformedSlaves() const
void syncPointData(List< Type > &pointData, const CombineOp &cop, const TransformOp &top) const
Helper to synchronise coupled patch point data.