syncToolsTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "syncTools.H"
27 #include "polyMesh.H"
28 #include "processorPolyPatch.H"
29 #include "cyclicPolyPatch.H"
30 #include "globalMeshData.H"
31 #include "contiguous.H"
32 #include "transform.H"
33 #include "transformList.H"
34 #include "SubField.H"
35 
36 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
37 
38 // Combine val with existing value at index
39 template<class T, class CombineOp>
41 (
42  Map<T>& pointValues,
43  const CombineOp& cop,
44  const label index,
45  const T& val
46 )
47 {
48  typename Map<T>::iterator iter = pointValues.find(index);
49 
50  if (iter != pointValues.end())
51  {
52  cop(iter(), val);
53  }
54  else
55  {
56  pointValues.insert(index, val);
57  }
58 }
59 
60 
61 // Combine val with existing value at (implicit index) e.
62 template<class T, class CombineOp>
64 (
65  EdgeMap<T>& edgeValues,
66  const CombineOp& cop,
67  const edge& index,
68  const T& val
69 )
70 {
71  typename EdgeMap<T>::iterator iter = edgeValues.find(index);
72 
73  if (iter != edgeValues.end())
74  {
75  cop(iter(), val);
76  }
77  else
78  {
79  edgeValues.insert(index, val);
80  }
81 }
82 
83 
84 template<class T, class CombineOp, class TransformOp>
86 (
87  const polyMesh& mesh,
88  Map<T>& pointValues, // from mesh point label to value
89  const CombineOp& cop,
90  const TransformOp& top
91 )
92 {
93  const polyBoundaryMesh& patches = mesh.boundaryMesh();
94 
95  // Synchronize multiple shared points.
96  const globalMeshData& pd = mesh.globalData();
97 
98  // Values on shared points. Keyed on global shared index.
99  Map<T> sharedPointValues(0);
100 
101  if (pd.nGlobalPoints() > 0)
102  {
103  // meshPoint per local index
104  const labelList& sharedPtLabels = pd.sharedPointLabels();
105  // global shared index per local index
106  const labelList& sharedPtAddr = pd.sharedPointAddr();
107 
108  sharedPointValues.resize(sharedPtAddr.size());
109 
110  // Fill my entries in the shared points
111  forAll(sharedPtLabels, i)
112  {
113  label meshPointI = sharedPtLabels[i];
114 
115  typename Map<T>::const_iterator fnd =
116  pointValues.find(meshPointI);
117 
118  if (fnd != pointValues.end())
119  {
120  combine
121  (
122  sharedPointValues,
123  cop,
124  sharedPtAddr[i], // index
125  fnd() // value
126  );
127  }
128  }
129  }
130 
131 
132  if (Pstream::parRun())
133  {
134  PstreamBuffers pBufs(Pstream::nonBlocking);
135 
136  // Send
137 
138  forAll(patches, patchI)
139  {
140  if
141  (
142  isA<processorPolyPatch>(patches[patchI])
143  && patches[patchI].nPoints() > 0
144  )
145  {
146  const processorPolyPatch& procPatch =
147  refCast<const processorPolyPatch>(patches[patchI]);
148 
149  // Get data per patchPoint in neighbouring point numbers.
150 
151  const labelList& meshPts = procPatch.meshPoints();
152  const labelList& nbrPts = procPatch.neighbPoints();
153 
154  // Extract local values. Create map from nbrPoint to value.
155  // Note: how small initial size?
156  Map<T> patchInfo(meshPts.size() / 20);
157 
158  forAll(meshPts, i)
159  {
160  typename Map<T>::const_iterator iter =
161  pointValues.find(meshPts[i]);
162 
163  if (iter != pointValues.end())
164  {
165  patchInfo.insert(nbrPts[i], iter());
166  }
167  }
168 
169  UOPstream toNeighb(procPatch.neighbProcNo(), pBufs);
170  toNeighb << patchInfo;
171  }
172  }
173 
174  pBufs.finishedSends();
175 
176  // Receive and combine.
177 
178  forAll(patches, patchI)
179  {
180  if
181  (
182  isA<processorPolyPatch>(patches[patchI])
183  && patches[patchI].nPoints() > 0
184  )
185  {
186  const processorPolyPatch& procPatch =
187  refCast<const processorPolyPatch>(patches[patchI]);
188 
189  UIPstream fromNb(procPatch.neighbProcNo(), pBufs);
190  Map<T> nbrPatchInfo(fromNb);
191 
192  // Transform
193  top(procPatch, nbrPatchInfo);
194 
195  const labelList& meshPts = procPatch.meshPoints();
196 
197  // Only update those values which come from neighbour
198  forAllConstIter(typename Map<T>, nbrPatchInfo, nbrIter)
199  {
200  combine
201  (
202  pointValues,
203  cop,
204  meshPts[nbrIter.key()],
205  nbrIter()
206  );
207  }
208  }
209  }
210  }
211 
212  // Do the cyclics.
213  forAll(patches, patchI)
214  {
215  if (isA<cyclicPolyPatch>(patches[patchI]))
216  {
217  const cyclicPolyPatch& cycPatch =
218  refCast<const cyclicPolyPatch>(patches[patchI]);
219 
220  if (cycPatch.owner())
221  {
222  // Owner does all.
223 
224  const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
225  const edgeList& coupledPoints = cycPatch.coupledPoints();
226  const labelList& meshPtsA = cycPatch.meshPoints();
227  const labelList& meshPtsB = nbrPatch.meshPoints();
228 
229  // Extract local values. Create map from coupled-edge to value.
230  Map<T> half0Values(meshPtsA.size() / 20);
231  Map<T> half1Values(half0Values.size());
232 
233  forAll(coupledPoints, i)
234  {
235  const edge& e = coupledPoints[i];
236 
237  typename Map<T>::const_iterator point0Fnd =
238  pointValues.find(meshPtsA[e[0]]);
239 
240  if (point0Fnd != pointValues.end())
241  {
242  half0Values.insert(i, point0Fnd());
243  }
244 
245  typename Map<T>::const_iterator point1Fnd =
246  pointValues.find(meshPtsB[e[1]]);
247 
248  if (point1Fnd != pointValues.end())
249  {
250  half1Values.insert(i, point1Fnd());
251  }
252  }
253 
254  // Transform to receiving side
255  top(cycPatch, half1Values);
256  top(nbrPatch, half0Values);
257 
258  forAll(coupledPoints, i)
259  {
260  const edge& e = coupledPoints[i];
261 
262  typename Map<T>::const_iterator half0Fnd =
263  half0Values.find(i);
264 
265  if (half0Fnd != half0Values.end())
266  {
267  combine
268  (
269  pointValues,
270  cop,
271  meshPtsB[e[1]],
272  half0Fnd()
273  );
274  }
275 
276  typename Map<T>::const_iterator half1Fnd =
277  half1Values.find(i);
278 
279  if (half1Fnd != half1Values.end())
280  {
281  combine
282  (
283  pointValues,
284  cop,
285  meshPtsA[e[0]],
286  half1Fnd()
287  );
288  }
289  }
290  }
291  }
292  }
293 
294  // Synchronize multiple shared points.
295  if (pd.nGlobalPoints() > 0)
296  {
297  // meshPoint per local index
298  const labelList& sharedPtLabels = pd.sharedPointLabels();
299  // global shared index per local index
300  const labelList& sharedPtAddr = pd.sharedPointAddr();
301 
302  // Reduce on master.
303 
304  if (Pstream::parRun())
305  {
306  if (Pstream::master())
307  {
308  // Receive the edges using shared points from the slave.
309  for
310  (
311  int slave=Pstream::firstSlave();
312  slave<=Pstream::lastSlave();
313  slave++
314  )
315  {
316  IPstream fromSlave(Pstream::scheduled, slave);
317  Map<T> nbrValues(fromSlave);
318 
319  // Merge neighbouring values with my values
320  forAllConstIter(typename Map<T>, nbrValues, iter)
321  {
322  combine
323  (
324  sharedPointValues,
325  cop,
326  iter.key(), // edge
327  iter() // value
328  );
329  }
330  }
331 
332  // Send back
333  for
334  (
335  int slave=Pstream::firstSlave();
336  slave<=Pstream::lastSlave();
337  slave++
338  )
339  {
340  OPstream toSlave(Pstream::scheduled, slave);
341  toSlave << sharedPointValues;
342  }
343  }
344  else
345  {
346  // Slave: send to master
347  {
348  OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
349  toMaster << sharedPointValues;
350  }
351  // Receive merged values
352  {
353  IPstream fromMaster
354  (
355  Pstream::scheduled,
356  Pstream::masterNo()
357  );
358  fromMaster >> sharedPointValues;
359  }
360  }
361  }
362 
363 
364  // Merge sharedPointValues (keyed on sharedPointAddr) into
365  // pointValues (keyed on mesh points).
366 
367  // Map from global shared index to meshpoint
368  Map<label> sharedToMeshPoint(2*sharedPtAddr.size());
369  forAll(sharedPtAddr, i)
370  {
371  sharedToMeshPoint.insert(sharedPtAddr[i], sharedPtLabels[i]);
372  }
373 
374  forAllConstIter(Map<label>, sharedToMeshPoint, iter)
375  {
376  // Do I have a value for my shared point
377  typename Map<T>::const_iterator sharedFnd =
378  sharedPointValues.find(iter.key());
379 
380  if (sharedFnd != sharedPointValues.end())
381  {
382  pointValues.set(iter(), sharedFnd());
383  }
384  }
385  }
386 }
387 
388 
389 template<class T, class CombineOp, class TransformOp>
391 (
392  const polyMesh& mesh,
393  EdgeMap<T>& edgeValues,
394  const CombineOp& cop,
395  const TransformOp& top
396 )
397 {
398  const polyBoundaryMesh& patches = mesh.boundaryMesh();
399 
400 
401  // Do synchronisation without constructing globalEdge addressing
402  // (since this constructs mesh edge addressing)
403 
404 
405  // Swap proc patch info
406  // ~~~~~~~~~~~~~~~~~~~~
407 
408  if (Pstream::parRun())
409  {
410  PstreamBuffers pBufs(Pstream::nonBlocking);
411 
412  // Send
413 
414  forAll(patches, patchI)
415  {
416  if
417  (
418  isA<processorPolyPatch>(patches[patchI])
419  && patches[patchI].nEdges() > 0
420  )
421  {
422  const processorPolyPatch& procPatch =
423  refCast<const processorPolyPatch>(patches[patchI]);
424 
425 
426  // Get data per patch edge in neighbouring edge.
427 
428  const edgeList& edges = procPatch.edges();
429  const labelList& meshPts = procPatch.meshPoints();
430  const labelList& nbrPts = procPatch.neighbPoints();
431 
432  EdgeMap<T> patchInfo(edges.size() / 20);
433 
434  forAll(edges, i)
435  {
436  const edge& e = edges[i];
437  const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
438 
439  typename EdgeMap<T>::const_iterator iter =
440  edgeValues.find(meshEdge);
441 
442  if (iter != edgeValues.end())
443  {
444  const edge nbrEdge(nbrPts[e[0]], nbrPts[e[1]]);
445  patchInfo.insert(nbrEdge, iter());
446  }
447  }
448 
449  UOPstream toNeighb(procPatch.neighbProcNo(), pBufs);
450  toNeighb << patchInfo;
451  }
452  }
453 
454  pBufs.finishedSends();
455 
456  // Receive and combine.
457 
458  forAll(patches, patchI)
459  {
460  if
461  (
462  isA<processorPolyPatch>(patches[patchI])
463  && patches[patchI].nEdges() > 0
464  )
465  {
466  const processorPolyPatch& procPatch =
467  refCast<const processorPolyPatch>(patches[patchI]);
468 
469  EdgeMap<T> nbrPatchInfo;
470  {
471  UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
472  fromNbr >> nbrPatchInfo;
473  }
474 
475  // Apply transform to convert to this side properties.
476  top(procPatch, nbrPatchInfo);
477 
478 
479  // Only update those values which come from neighbour
480  const labelList& meshPts = procPatch.meshPoints();
481 
482  forAllConstIter(typename EdgeMap<T>, nbrPatchInfo, nbrIter)
483  {
484  const edge& e = nbrIter.key();
485  const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
486 
487  combine
488  (
489  edgeValues,
490  cop,
491  meshEdge, // edge
492  nbrIter() // value
493  );
494  }
495  }
496  }
497  }
498 
499 
500  // Swap cyclic info
501  // ~~~~~~~~~~~~~~~~
502 
503  forAll(patches, patchI)
504  {
505  if (isA<cyclicPolyPatch>(patches[patchI]))
506  {
507  const cyclicPolyPatch& cycPatch =
508  refCast<const cyclicPolyPatch>(patches[patchI]);
509 
510  if (cycPatch.owner())
511  {
512  // Owner does all.
513 
514  const edgeList& coupledEdges = cycPatch.coupledEdges();
515  const labelList& meshPtsA = cycPatch.meshPoints();
516  const edgeList& edgesA = cycPatch.edges();
517  const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
518  const labelList& meshPtsB = nbrPatch.meshPoints();
519  const edgeList& edgesB = nbrPatch.edges();
520 
521  // Extract local values. Create map from edge to value.
522  Map<T> half0Values(edgesA.size() / 20);
523  Map<T> half1Values(half0Values.size());
524 
525  forAll(coupledEdges, i)
526  {
527  const edge& twoEdges = coupledEdges[i];
528 
529  {
530  const edge& e0 = edgesA[twoEdges[0]];
531  const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
532 
533  typename EdgeMap<T>::const_iterator iter =
534  edgeValues.find(meshEdge0);
535 
536  if (iter != edgeValues.end())
537  {
538  half0Values.insert(i, iter());
539  }
540  }
541  {
542  const edge& e1 = edgesB[twoEdges[1]];
543  const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
544 
545  typename EdgeMap<T>::const_iterator iter =
546  edgeValues.find(meshEdge1);
547 
548  if (iter != edgeValues.end())
549  {
550  half1Values.insert(i, iter());
551  }
552  }
553  }
554 
555  // Transform to this side
556  top(cycPatch, half1Values);
557  top(nbrPatch, half0Values);
558 
559 
560  // Extract and combine information
561 
562  forAll(coupledEdges, i)
563  {
564  const edge& twoEdges = coupledEdges[i];
565 
566  typename Map<T>::const_iterator half1Fnd =
567  half1Values.find(i);
568 
569  if (half1Fnd != half1Values.end())
570  {
571  const edge& e0 = edgesA[twoEdges[0]];
572  const edge meshEdge0(meshPtsA[e0[0]], meshPtsA[e0[1]]);
573 
574  combine
575  (
576  edgeValues,
577  cop,
578  meshEdge0, // edge
579  half1Fnd() // value
580  );
581  }
582 
583  typename Map<T>::const_iterator half0Fnd =
584  half0Values.find(i);
585  if (half0Fnd != half0Values.end())
586  {
587  const edge& e1 = edgesB[twoEdges[1]];
588  const edge meshEdge1(meshPtsB[e1[0]], meshPtsB[e1[1]]);
589 
590  combine
591  (
592  edgeValues,
593  cop,
594  meshEdge1, // edge
595  half0Fnd() // value
596  );
597  }
598  }
599  }
600  }
601  }
602 
603  // Synchronize multiple shared points.
604  // Problem is that we don't want to construct shared edges so basically
605  // we do here like globalMeshData but then using sparse edge representation
606  // (EdgeMap instead of mesh.edges())
607 
608  const globalMeshData& pd = mesh.globalData();
609  const labelList& sharedPtAddr = pd.sharedPointAddr();
610  const labelList& sharedPtLabels = pd.sharedPointLabels();
611 
612  // 1. Create map from meshPoint to globalShared index.
613  Map<label> meshToShared(2*sharedPtLabels.size());
614  forAll(sharedPtLabels, i)
615  {
616  meshToShared.insert(sharedPtLabels[i], sharedPtAddr[i]);
617  }
618 
619  // Values on shared points. From two sharedPtAddr indices to a value.
620  EdgeMap<T> sharedEdgeValues(meshToShared.size());
621 
622  // From shared edge to mesh edge. Used for merging later on.
623  EdgeMap<edge> potentialSharedEdge(meshToShared.size());
624 
625  // 2. Find any edges using two global shared points. These will always be
626  // on the outside of the mesh. (though might not be on coupled patch
627  // if is single edge and not on coupled face)
628  // Store value (if any) on sharedEdgeValues
629  for (label faceI = mesh.nInternalFaces(); faceI < mesh.nFaces(); faceI++)
630  {
631  const face& f = mesh.faces()[faceI];
632 
633  forAll(f, fp)
634  {
635  label v0 = f[fp];
636  label v1 = f[f.fcIndex(fp)];
637 
638  Map<label>::const_iterator v0Fnd = meshToShared.find(v0);
639 
640  if (v0Fnd != meshToShared.end())
641  {
642  Map<label>::const_iterator v1Fnd = meshToShared.find(v1);
643 
644  if (v1Fnd != meshToShared.end())
645  {
646  const edge meshEdge(v0, v1);
647 
648  // edge in shared point labels
649  const edge sharedEdge(v0Fnd(), v1Fnd());
650 
651  // Store mesh edge as a potential shared edge.
652  potentialSharedEdge.insert(sharedEdge, meshEdge);
653 
654  typename EdgeMap<T>::const_iterator edgeFnd =
655  edgeValues.find(meshEdge);
656 
657  if (edgeFnd != edgeValues.end())
658  {
659  // edge exists in edgeValues. See if already in map
660  // (since on same processor, e.g. cyclic)
661  combine
662  (
663  sharedEdgeValues,
664  cop,
665  sharedEdge, // edge
666  edgeFnd() // value
667  );
668  }
669  }
670  }
671  }
672  }
673 
674 
675  // Now sharedEdgeValues will contain per potential sharedEdge the value.
676  // (potential since an edge having two shared points is not necessary a
677  // shared edge).
678  // Reduce this on the master.
679 
680  if (Pstream::parRun())
681  {
682  if (Pstream::master())
683  {
684  // Receive the edges using shared points from the slave.
685  for
686  (
687  int slave=Pstream::firstSlave();
688  slave<=Pstream::lastSlave();
689  slave++
690  )
691  {
692  IPstream fromSlave(Pstream::scheduled, slave);
693  EdgeMap<T> nbrValues(fromSlave);
694 
695  // Merge neighbouring values with my values
696  forAllConstIter(typename EdgeMap<T>, nbrValues, iter)
697  {
698  combine
699  (
700  sharedEdgeValues,
701  cop,
702  iter.key(), // edge
703  iter() // value
704  );
705  }
706  }
707 
708  // Send back
709  for
710  (
711  int slave=Pstream::firstSlave();
712  slave<=Pstream::lastSlave();
713  slave++
714  )
715  {
716 
717  OPstream toSlave(Pstream::scheduled, slave);
718  toSlave << sharedEdgeValues;
719  }
720  }
721  else
722  {
723  // Send to master
724  {
725  OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
726  toMaster << sharedEdgeValues;
727  }
728  // Receive merged values
729  {
730  IPstream fromMaster(Pstream::scheduled, Pstream::masterNo());
731  fromMaster >> sharedEdgeValues;
732  }
733  }
734  }
735 
736 
737  // Merge sharedEdgeValues (keyed on sharedPointAddr) into edgeValues
738  // (keyed on mesh points).
739 
740  // Loop over all my shared edges.
741  forAllConstIter(typename EdgeMap<edge>, potentialSharedEdge, iter)
742  {
743  const edge& sharedEdge = iter.key();
744  const edge& meshEdge = iter();
745 
746  // Do I have a value for the shared edge?
747  typename EdgeMap<T>::const_iterator sharedFnd =
748  sharedEdgeValues.find(sharedEdge);
749 
750  if (sharedFnd != sharedEdgeValues.end())
751  {
752  combine
753  (
754  edgeValues,
755  cop,
756  meshEdge, // edge
757  sharedFnd() // value
758  );
759  }
760  }
761 }
762 
763 
764 //template<class T, class CombineOp, class TransformOp>
765 //void Foam::syncTools::syncPointList
766 //(
767 // const polyMesh& mesh,
768 // List<T>& pointValues,
769 // const CombineOp& cop,
770 // const T& nullValue,
771 // const TransformOp& top
772 //)
773 //{
774 // if (pointValues.size() != mesh.nPoints())
775 // {
776 // FatalErrorInFunction
777 // << "Number of values " << pointValues.size()
778 // << " is not equal to the number of points in the mesh "
779 // << mesh.nPoints() << abort(FatalError);
780 // }
781 //
782 // const polyBoundaryMesh& patches = mesh.boundaryMesh();
783 //
784 // // Synchronize multiple shared points.
785 // const globalMeshData& pd = mesh.globalData();
786 //
787 // // Values on shared points.
788 // Field<T> sharedPts(0);
789 // if (pd.nGlobalPoints() > 0)
790 // {
791 // // Values on shared points.
792 // sharedPts.setSize(pd.nGlobalPoints(), nullValue);
793 //
794 // forAll(pd.sharedPointLabels(), i)
795 // {
796 // label meshPointI = pd.sharedPointLabels()[i];
797 // // Fill my entries in the shared points
798 // sharedPts[pd.sharedPointAddr()[i]] = pointValues[meshPointI];
799 // }
800 // }
801 //
802 // if (Pstream::parRun())
803 // {
804 // PstreamBuffers pBufs(Pstream::nonBlocking);
805 //
806 // // Send
807 //
808 // forAll(patches, patchI)
809 // {
810 // if
811 // (
812 // isA<processorPolyPatch>(patches[patchI])
813 // && patches[patchI].nPoints() > 0
814 // )
815 // {
816 // const processorPolyPatch& procPatch =
817 // refCast<const processorPolyPatch>(patches[patchI]);
818 //
819 // // Get data per patchPoint in neighbouring point numbers.
820 // Field<T> patchInfo(procPatch.nPoints());
821 //
822 // const labelList& meshPts = procPatch.meshPoints();
823 // const labelList& nbrPts = procPatch.neighbPoints();
824 //
825 // forAll(nbrPts, pointI)
826 // {
827 // label nbrPointI = nbrPts[pointI];
828 // patchInfo[nbrPointI] = pointValues[meshPts[pointI]];
829 // }
830 //
831 // UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
832 // toNbr << patchInfo;
833 // }
834 // }
835 //
836 // pBufs.finishedSends();
837 //
838 // // Receive and combine.
839 //
840 // forAll(patches, patchI)
841 // {
842 // if
843 // (
844 // isA<processorPolyPatch>(patches[patchI])
845 // && patches[patchI].nPoints() > 0
846 // )
847 // {
848 // const processorPolyPatch& procPatch =
849 // refCast<const processorPolyPatch>(patches[patchI]);
850 //
851 // Field<T> nbrPatchInfo(procPatch.nPoints());
852 // {
853 // UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
854 // fromNbr >> nbrPatchInfo;
855 // }
856 //
857 // // Transform to this side
858 // top(procPatch, nbrPatchInfo);
859 //
860 // const labelList& meshPts = procPatch.meshPoints();
861 //
862 // forAll(meshPts, pointI)
863 // {
864 // label meshPointI = meshPts[pointI];
865 // cop(pointValues[meshPointI], nbrPatchInfo[pointI]);
866 // }
867 // }
868 // }
869 // }
870 //
871 // // Do the cyclics.
872 // forAll(patches, patchI)
873 // {
874 // if (isA<cyclicPolyPatch>(patches[patchI]))
875 // {
876 // const cyclicPolyPatch& cycPatch =
877 // refCast<const cyclicPolyPatch>(patches[patchI]);
878 //
879 // if (cycPatch.owner())
880 // {
881 // // Owner does all.
882 //
883 // const edgeList& coupledPoints = cycPatch.coupledPoints();
884 // const labelList& meshPts = cycPatch.meshPoints();
885 // const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
886 // const labelList& nbrMeshPoints = nbrPatch.meshPoints();
887 //
888 // Field<T> half0Values(coupledPoints.size());
889 // Field<T> half1Values(coupledPoints.size());
890 //
891 // forAll(coupledPoints, i)
892 // {
893 // const edge& e = coupledPoints[i];
894 // half0Values[i] = pointValues[meshPts[e[0]]];
895 // half1Values[i] = pointValues[nbrMeshPoints[e[1]]];
896 // }
897 //
898 // //SubField<T> slice0(half0Values, half0Values.size());
899 // //SubField<T> slice1(half1Values, half1Values.size());
900 // //top(cycPatch, reinterpret_cast<Field<T>&>(slice1));
901 // //top(nbrPatch, reinterpret_cast<Field<T>&>(slice0));
902 //
903 // top(cycPatch, half1Values);
904 // top(nbrPatch, half0Values);
905 //
906 // forAll(coupledPoints, i)
907 // {
908 // const edge& e = coupledPoints[i];
909 // cop(pointValues[meshPts[e[0]]], half1Values[i]);
910 // cop(pointValues[nbrMeshPoints[e[1]]], half0Values[i]);
911 // }
912 // }
913 // }
914 // }
915 //
916 // // Synchronize multiple shared points.
917 // const globalMeshData& pd = mesh.globalData();
918 //
919 // if (pd.nGlobalPoints() > 0)
920 // {
921 // // Combine on master.
922 // Pstream::listCombineGather(sharedPts, cop);
923 // Pstream::listCombineScatter(sharedPts);
924 //
925 // // Now we will all have the same information. Merge it back with
926 // // my local information.
927 // forAll(pd.sharedPointLabels(), i)
928 // {
929 // label meshPointI = pd.sharedPointLabels()[i];
930 // pointValues[meshPointI] = sharedPts[pd.sharedPointAddr()[i]];
931 // }
932 // }
933 //}
934 
935 
936 //template<class T, class CombineOp, class TransformOp>
937 //void Foam::syncTools::syncPointList
938 //(
939 // const polyMesh& mesh,
940 // const labelList& meshPoints,
941 // List<T>& pointValues,
942 // const CombineOp& cop,
943 // const T& nullValue,
944 // const TransformOp& top
945 //)
946 //{
947 // if (pointValues.size() != meshPoints.size())
948 // {
949 // FatalErrorInFunction
950 // << "Number of values " << pointValues.size()
951 // << " is not equal to the number of points "
952 // << meshPoints.size() << abort(FatalError);
953 // }
954 //
955 // if (!hasCouples(mesh.boundaryMesh()))
956 // {
957 // return;
958 // }
959 //
960 // Field<T> meshValues(mesh.nPoints(), nullValue);
961 //
962 // forAll(meshPoints, i)
963 // {
964 // meshValues[meshPoints[i]] = pointValues[i];
965 // }
966 //
967 // syncTools::syncPointList
968 // (
969 // mesh,
970 // meshValues,
971 // cop, // combine op
972 // nullValue, // null value
973 // top // position or field
974 // );
975 //
976 // forAll(meshPoints, i)
977 // {
978 // pointValues[i] = meshValues[meshPoints[i]];
979 // }
980 //}
981 
982 template<class T, class CombineOp, class TransformOp>
984 (
985  const polyMesh& mesh,
986  List<T>& pointValues,
987  const CombineOp& cop,
988  const T& nullValue,
989  const TransformOp& top
990 )
991 {
992  if (pointValues.size() != mesh.nPoints())
993  {
995  << "Number of values " << pointValues.size()
996  << " is not equal to the number of points in the mesh "
997  << mesh.nPoints() << abort(FatalError);
998  }
999 
1000  mesh.globalData().syncPointData(pointValues, cop, top);
1001 }
1002 
1003 
1004 //template<class CombineOp>
1005 //void Foam::syncTools::syncPointPositions
1006 //(
1007 // const polyMesh& mesh,
1008 // List<point>& pointValues,
1009 // const CombineOp& cop,
1010 // const point& nullValue
1011 //)
1012 //{
1013 // if (pointValues.size() != mesh.nPoints())
1014 // {
1015 // FatalErrorInFunction
1016 // << "Number of values " << pointValues.size()
1017 // << " is not equal to the number of points in the mesh "
1018 // << mesh.nPoints() << abort(FatalError);
1019 // }
1020 //
1021 // mesh.globalData().syncPointData(pointValues, cop, true);
1022 //}
1023 
1024 
1025 template<class T, class CombineOp, class TransformOp>
1028  const polyMesh& mesh,
1029  const labelList& meshPoints,
1030  List<T>& pointValues,
1031  const CombineOp& cop,
1032  const T& nullValue,
1033  const TransformOp& top
1034 )
1035 {
1036  if (pointValues.size() != meshPoints.size())
1037  {
1039  << "Number of values " << pointValues.size()
1040  << " is not equal to the number of meshPoints "
1041  << meshPoints.size() << abort(FatalError);
1042  }
1043  const globalMeshData& gd = mesh.globalData();
1044  const indirectPrimitivePatch& cpp = gd.coupledPatch();
1045  const Map<label>& mpm = cpp.meshPointMap();
1046 
1047  List<T> cppFld(cpp.nPoints(), nullValue);
1048 
1049  forAll(meshPoints, i)
1050  {
1051  label pointI = meshPoints[i];
1052  Map<label>::const_iterator iter = mpm.find(pointI);
1053  if (iter != mpm.end())
1054  {
1055  cppFld[iter()] = pointValues[i];
1056  }
1057  }
1058 
1059  globalMeshData::syncData
1060  (
1061  cppFld,
1062  gd.globalPointSlaves(),
1064  gd.globalPointSlavesMap(),
1065  gd.globalTransforms(),
1066  cop,
1067  top
1068  );
1069 
1070  forAll(meshPoints, i)
1071  {
1072  label pointI = meshPoints[i];
1073  Map<label>::const_iterator iter = mpm.find(pointI);
1074  if (iter != mpm.end())
1075  {
1076  pointValues[i] = cppFld[iter()];
1077  }
1078  }
1079 }
1080 
1081 
1082 //template<class CombineOp>
1083 //void Foam::syncTools::syncPointPositions
1084 //(
1085 // const polyMesh& mesh,
1086 // const labelList& meshPoints,
1087 // List<point>& pointValues,
1088 // const CombineOp& cop,
1089 // const point& nullValue
1090 //)
1091 //{
1092 // if (pointValues.size() != meshPoints.size())
1093 // {
1094 // FatalErrorInFunction
1095 // << "Number of values " << pointValues.size()
1096 // << " is not equal to the number of meshPoints "
1097 // << meshPoints.size() << abort(FatalError);
1098 // }
1099 // const globalMeshData& gd = mesh.globalData();
1100 // const indirectPrimitivePatch& cpp = gd.coupledPatch();
1101 // const Map<label>& mpm = cpp.meshPointMap();
1102 //
1103 // List<point> cppFld(cpp.nPoints(), nullValue);
1104 //
1105 // forAll(meshPoints, i)
1106 // {
1107 // label pointI = meshPoints[i];
1108 // Map<label>::const_iterator iter = mpm.find(pointI);
1109 // if (iter != mpm.end())
1110 // {
1111 // cppFld[iter()] = pointValues[i];
1112 // }
1113 // }
1114 //
1115 // globalMeshData::syncData
1116 // (
1117 // cppFld,
1118 // gd.globalPointSlaves(),
1119 // gd.globalPointTransformedSlaves(),
1120 // gd.globalPointSlavesMap(),
1121 // gd.globalTransforms(),
1122 // cop,
1123 // true, //position?
1124 // mapDistribute::transform() // not used
1125 // );
1126 //
1127 // forAll(meshPoints, i)
1128 // {
1129 // label pointI = meshPoints[i];
1130 // Map<label>::const_iterator iter = mpm.find(pointI);
1131 // if (iter != mpm.end())
1132 // {
1133 // pointValues[i] = cppFld[iter()];
1134 // }
1135 // }
1136 //}
1137 
1138 
1139 template<class T, class CombineOp, class TransformOp>
1142  const polyMesh& mesh,
1143  List<T>& edgeValues,
1144  const CombineOp& cop,
1145  const T& nullValue,
1146  const TransformOp& top
1147 )
1148 {
1149  if (edgeValues.size() != mesh.nEdges())
1150  {
1152  << "Number of values " << edgeValues.size()
1153  << " is not equal to the number of edges in the mesh "
1154  << mesh.nEdges() << abort(FatalError);
1155  }
1156 
1157  const globalMeshData& gd = mesh.globalData();
1158  const labelList& meshEdges = gd.coupledPatchMeshEdges();
1159  const globalIndexAndTransform& git = gd.globalTransforms();
1160  const mapDistribute& edgeMap = gd.globalEdgeSlavesMap();
1161 
1162  List<T> cppFld(UIndirectList<T>(edgeValues, meshEdges));
1163 
1164  globalMeshData::syncData
1165  (
1166  cppFld,
1167  gd.globalEdgeSlaves(),
1169  edgeMap,
1170  git,
1171  cop,
1172  top
1173  );
1174 
1175  // Extract back onto mesh
1176  forAll(meshEdges, i)
1177  {
1178  edgeValues[meshEdges[i]] = cppFld[i];
1179  }
1180 }
1181 
1182 
1183 //template<class CombineOp>
1184 //void Foam::syncTools::syncEdgePositions
1185 //(
1186 // const polyMesh& mesh,
1187 // List<point>& edgeValues,
1188 // const CombineOp& cop,
1189 // const point& nullValue
1190 //)
1191 //{
1192 // if (edgeValues.size() != mesh.nEdges())
1193 // {
1194 // FatalErrorInFunction
1195 // << "Number of values " << edgeValues.size()
1196 // << " is not equal to the number of edges in the mesh "
1197 // << mesh.nEdges() << abort(FatalError);
1198 // }
1199 //
1200 // const globalMeshData& gd = mesh.globalData();
1201 // const labelList& meshEdges = gd.coupledPatchMeshEdges();
1202 // const globalIndexAndTransform& git = gd.globalTransforms();
1203 // const mapDistribute& map = gd.globalEdgeSlavesMap();
1204 //
1205 // List<point> cppFld(UIndirectList<point>(edgeValues, meshEdges));
1206 //
1207 // globalMeshData::syncData
1208 // (
1209 // cppFld,
1210 // gd.globalEdgeSlaves(),
1211 // gd.globalEdgeTransformedSlaves(),
1212 // map,
1213 // git,
1214 // cop,
1215 // true, //position?
1216 // mapDistribute::transform() // not used
1217 // );
1218 //
1219 // // Extract back onto mesh
1220 // forAll(meshEdges, i)
1221 // {
1222 // edgeValues[meshEdges[i]] = cppFld[i];
1223 // }
1224 //}
1225 
1226 
1227 template<class T, class CombineOp, class TransformOp>
1230  const polyMesh& mesh,
1231  const labelList& meshEdges,
1232  List<T>& edgeValues,
1233  const CombineOp& cop,
1234  const T& nullValue,
1235  const TransformOp& top
1236 )
1237 {
1238  if (edgeValues.size() != meshEdges.size())
1239  {
1241  << "Number of values " << edgeValues.size()
1242  << " is not equal to the number of meshEdges "
1243  << meshEdges.size() << abort(FatalError);
1244  }
1245  const globalMeshData& gd = mesh.globalData();
1246  const indirectPrimitivePatch& cpp = gd.coupledPatch();
1247  const Map<label>& mpm = gd.coupledPatchMeshEdgeMap();
1248 
1249  List<T> cppFld(cpp.nEdges(), nullValue);
1250 
1251  forAll(meshEdges, i)
1252  {
1253  label edgeI = meshEdges[i];
1254  Map<label>::const_iterator iter = mpm.find(edgeI);
1255  if (iter != mpm.end())
1256  {
1257  cppFld[iter()] = edgeValues[i];
1258  }
1259  }
1260 
1261  globalMeshData::syncData
1262  (
1263  cppFld,
1264  gd.globalEdgeSlaves(),
1266  gd.globalEdgeSlavesMap(),
1267  gd.globalTransforms(),
1268  cop,
1269  top
1270  );
1271 
1272  forAll(meshEdges, i)
1273  {
1274  label edgeI = meshEdges[i];
1275  Map<label>::const_iterator iter = mpm.find(edgeI);
1276  if (iter != mpm.end())
1277  {
1278  edgeValues[i] = cppFld[iter()];
1279  }
1280  }
1281 }
1282 
1283 template<class T, class CombineOp, class TransformOp>
1286  const polyMesh& mesh,
1287  UList<T>& faceValues,
1288  const CombineOp& cop,
1289  const TransformOp& top,
1290  const bool parRun
1291 )
1292 {
1293  const label nBFaces = mesh.nFaces() - mesh.nInternalFaces();
1294 
1295  if (faceValues.size() != nBFaces)
1296  {
1298  << "Number of values " << faceValues.size()
1299  << " is not equal to the number of boundary faces in the mesh "
1300  << nBFaces << abort(FatalError);
1301  }
1302 
1303  const polyBoundaryMesh& patches = mesh.boundaryMesh();
1304 
1305  if (parRun)
1306  {
1307  PstreamBuffers pBufs(Pstream::nonBlocking);
1308 
1309  // Send
1310 
1311  forAll(patches, patchI)
1312  {
1313  if
1314  (
1315  isA<processorPolyPatch>(patches[patchI])
1316  && patches[patchI].size() > 0
1317  )
1318  {
1319  const processorPolyPatch& procPatch =
1320  refCast<const processorPolyPatch>(patches[patchI]);
1321 
1322  label patchStart = procPatch.start()-mesh.nInternalFaces();
1323 
1324  UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
1325  toNbr << SubField<T>(faceValues, procPatch.size(), patchStart);
1326  }
1327  }
1328 
1329 
1330  pBufs.finishedSends();
1331 
1332 
1333  // Receive and combine.
1334 
1335  forAll(patches, patchI)
1336  {
1337  if
1338  (
1339  isA<processorPolyPatch>(patches[patchI])
1340  && patches[patchI].size() > 0
1341  )
1342  {
1343  const processorPolyPatch& procPatch =
1344  refCast<const processorPolyPatch>(patches[patchI]);
1345 
1346  Field<T> nbrPatchInfo(procPatch.size());
1347 
1348  UIPstream fromNeighb(procPatch.neighbProcNo(), pBufs);
1349  fromNeighb >> nbrPatchInfo;
1350 
1351  top(procPatch, nbrPatchInfo);
1352 
1353  label bFaceI = procPatch.start()-mesh.nInternalFaces();
1354 
1355  forAll(nbrPatchInfo, i)
1356  {
1357  cop(faceValues[bFaceI++], nbrPatchInfo[i]);
1358  }
1359  }
1360  }
1361  }
1362 
1363  // Do the cyclics.
1364  forAll(patches, patchI)
1365  {
1366  if (isA<cyclicPolyPatch>(patches[patchI]))
1367  {
1368  const cyclicPolyPatch& cycPatch =
1369  refCast<const cyclicPolyPatch>(patches[patchI]);
1370 
1371  if (cycPatch.owner())
1372  {
1373  // Owner does all.
1374  const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
1375  label ownStart = cycPatch.start()-mesh.nInternalFaces();
1376  label nbrStart = nbrPatch.start()-mesh.nInternalFaces();
1377 
1378  label sz = cycPatch.size();
1379 
1380  // Transform (copy of) data on both sides
1381  Field<T> ownVals(SubField<T>(faceValues, sz, ownStart));
1382  top(nbrPatch, ownVals);
1383 
1384  Field<T> nbrVals(SubField<T>(faceValues, sz, nbrStart));
1385  top(cycPatch, nbrVals);
1386 
1387  label i0 = ownStart;
1388  forAll(nbrVals, i)
1389  {
1390  cop(faceValues[i0++], nbrVals[i]);
1391  }
1392 
1393  label i1 = nbrStart;
1394  forAll(ownVals, i)
1395  {
1396  cop(faceValues[i1++], ownVals[i]);
1397  }
1398  }
1399  }
1400  }
1401 }
1402 
1403 
1404 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1405 
1406 template<unsigned nBits, class CombineOp>
1409  const polyMesh& mesh,
1410  PackedList<nBits>& faceValues,
1411  const CombineOp& cop,
1412  const bool parRun
1413 )
1414 {
1415  if (faceValues.size() != mesh.nFaces())
1416  {
1418  << "Number of values " << faceValues.size()
1419  << " is not equal to the number of faces in the mesh "
1420  << mesh.nFaces() << abort(FatalError);
1421  }
1422 
1423  const polyBoundaryMesh& patches = mesh.boundaryMesh();
1424 
1425  if (parRun)
1426  {
1427  PstreamBuffers pBufs(Pstream::nonBlocking);
1428 
1429  // Send
1430 
1431  forAll(patches, patchI)
1432  {
1433  if
1434  (
1435  isA<processorPolyPatch>(patches[patchI])
1436  && patches[patchI].size() > 0
1437  )
1438  {
1439  const processorPolyPatch& procPatch =
1440  refCast<const processorPolyPatch>(patches[patchI]);
1441 
1442  List<unsigned int> patchInfo(procPatch.size());
1443  forAll(procPatch, i)
1444  {
1445  patchInfo[i] = faceValues[procPatch.start()+i];
1446  }
1447 
1448  UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
1449  toNbr << patchInfo;
1450  }
1451  }
1452 
1453 
1454  pBufs.finishedSends();
1455 
1456  // Receive and combine.
1457 
1458  forAll(patches, patchI)
1459  {
1460  if
1461  (
1462  isA<processorPolyPatch>(patches[patchI])
1463  && patches[patchI].size() > 0
1464  )
1465  {
1466  const processorPolyPatch& procPatch =
1467  refCast<const processorPolyPatch>(patches[patchI]);
1468 
1469  List<unsigned int> patchInfo(procPatch.size());
1470  {
1471  UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
1472  fromNbr >> patchInfo;
1473  }
1474 
1475  // Combine (bitwise)
1476  forAll(procPatch, i)
1477  {
1478  unsigned int patchVal = patchInfo[i];
1479  label meshFaceI = procPatch.start()+i;
1480  unsigned int faceVal = faceValues[meshFaceI];
1481  cop(faceVal, patchVal);
1482  faceValues[meshFaceI] = faceVal;
1483  }
1484  }
1485  }
1486  }
1487 
1488  // Do the cyclics.
1489  forAll(patches, patchI)
1490  {
1491  if (isA<cyclicPolyPatch>(patches[patchI]))
1492  {
1493  const cyclicPolyPatch& cycPatch =
1494  refCast<const cyclicPolyPatch>(patches[patchI]);
1495 
1496  if (cycPatch.owner())
1497  {
1498  // Owner does all.
1499  const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
1500 
1501  for (label i = 0; i < cycPatch.size(); i++)
1502  {
1503  label meshFace0 = cycPatch.start()+i;
1504  unsigned int val0 = faceValues[meshFace0];
1505  label meshFace1 = nbrPatch.start()+i;
1506  unsigned int val1 = faceValues[meshFace1];
1507 
1508  unsigned int t = val0;
1509  cop(t, val1);
1510  faceValues[meshFace0] = t;
1511 
1512  cop(val1, val0);
1513  faceValues[meshFace1] = val1;
1514  }
1515  }
1516  }
1517  }
1518 }
1519 
1520 
1521 template<class T>
1524  const polyMesh& mesh,
1525  const UList<T>& cellData,
1526  List<T>& neighbourCellData
1527 )
1528 {
1529  if (cellData.size() != mesh.nCells())
1530  {
1532  << "Number of cell values " << cellData.size()
1533  << " is not equal to the number of cells in the mesh "
1534  << mesh.nCells() << abort(FatalError);
1535  }
1536 
1537  const polyBoundaryMesh& patches = mesh.boundaryMesh();
1538 
1539  label nBnd = mesh.nFaces()-mesh.nInternalFaces();
1540 
1541  neighbourCellData.setSize(nBnd);
1542 
1543  forAll(patches, patchI)
1544  {
1545  const polyPatch& pp = patches[patchI];
1546  const labelUList& faceCells = pp.faceCells();
1547  forAll(faceCells, i)
1548  {
1549  label bFaceI = pp.start()+i-mesh.nInternalFaces();
1550  neighbourCellData[bFaceI] = cellData[faceCells[i]];
1551  }
1552  }
1553  syncTools::swapBoundaryFaceList(mesh, neighbourCellData);
1554 }
1555 
1556 
1557 template<unsigned nBits>
1560  const polyMesh& mesh,
1561  PackedList<nBits>& faceValues
1562 )
1563 {
1564  syncFaceList(mesh, faceValues, eqOp<unsigned int>());
1565 }
1566 
1567 
1568 template<unsigned nBits, class CombineOp>
1571  const polyMesh& mesh,
1572  PackedList<nBits>& pointValues,
1573  const CombineOp& cop,
1574  const unsigned int nullValue
1575 )
1576 {
1577  if (pointValues.size() != mesh.nPoints())
1578  {
1580  << "Number of values " << pointValues.size()
1581  << " is not equal to the number of points in the mesh "
1582  << mesh.nPoints() << abort(FatalError);
1583  }
1584 
1585  const globalMeshData& gd = mesh.globalData();
1586  const labelList& meshPoints = gd.coupledPatch().meshPoints();
1587 
1589  forAll(meshPoints, i)
1590  {
1591  cppFld[i] = pointValues[meshPoints[i]];
1592  }
1593 
1594  globalMeshData::syncData
1595  (
1596  cppFld,
1597  gd.globalPointSlaves(),
1599  gd.globalPointSlavesMap(),
1600  cop
1601  );
1602 
1603  // Extract back to mesh
1604  forAll(meshPoints, i)
1605  {
1606  pointValues[meshPoints[i]] = cppFld[i];
1607  }
1608 }
1609 
1610 
1611 template<unsigned nBits, class CombineOp>
1614  const polyMesh& mesh,
1615  PackedList<nBits>& edgeValues,
1616  const CombineOp& cop,
1617  const unsigned int nullValue
1618 )
1619 {
1620  if (edgeValues.size() != mesh.nEdges())
1621  {
1623  << "Number of values " << edgeValues.size()
1624  << " is not equal to the number of edges in the mesh "
1625  << mesh.nEdges() << abort(FatalError);
1626  }
1627 
1628  const globalMeshData& gd = mesh.globalData();
1629  const labelList& meshEdges = gd.coupledPatchMeshEdges();
1630 
1632  forAll(meshEdges, i)
1633  {
1634  cppFld[i] = edgeValues[meshEdges[i]];
1635  }
1636 
1637  globalMeshData::syncData
1638  (
1639  cppFld,
1640  gd.globalEdgeSlaves(),
1642  gd.globalEdgeSlavesMap(),
1643  cop
1644  );
1645 
1646  // Extract back to mesh
1647  forAll(meshEdges, i)
1648  {
1649  edgeValues[meshEdges[i]] = cppFld[i];
1650  }
1651 }
1652 
1653 
1654 // ************************************************************************* //
Foam::help::sharedEdge
edge sharedEdge(const faceType1 &f1, const faceType2 &f2)
return the edge shared by the faces
Definition: helperFunctionsTopologyManipulationI.H:343
Foam::globalMeshData::globalPointTransformedSlaves
const labelListList & globalPointTransformedSlaves() const
Definition: globalMeshData.C:2180
Foam::globalMeshData::globalPointSlaves
const labelListList & globalPointSlaves() const
Definition: globalMeshData.C:2170
Foam::UOPstream
Output inter-processor communications stream operating on external buffer.
Definition: UOPstream.H:54
SubField.H
Foam::globalMeshData::coupledPatchMeshEdgeMap
const Map< label > & coupledPatchMeshEdgeMap() const
Return map from mesh edges to coupledPatch edges.
Definition: globalMeshData.C:2127
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::PrimitivePatch::edges
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
Definition: PrimitivePatchTemplate.C:212
Foam::globalMeshData::globalEdgeSlavesMap
const mapDistribute & globalEdgeSlavesMap() const
Definition: globalMeshData.C:2245
cyclicPolyPatch.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::cyclicPolyPatch
Cyclic plane patch.
Definition: cyclicPolyPatch.H:63
Foam::OPstream
Output inter-processor communications stream.
Definition: OPstream.H:50
Foam::cyclicPolyPatch::neighbPatch
const cyclicPolyPatch & neighbPatch() const
Definition: cyclicPolyPatch.H:328
globalMeshData.H
Foam::syncTools::syncBoundaryFaceList
static void syncBoundaryFaceList(const polyMesh &, UList< T > &, const CombineOp &cop, const TransformOp &top, const bool parRun=Pstream::parRun())
Synchronize values on boundary faces only.
Definition: syncToolsTemplates.C:1285
Foam::ListListOps::combine
AccessType combine(const List< T > &, AccessOp aop=accessOp< T >())
Combines sublists into one big list.
Definition: ListListOps.C:34
Foam::PrimitivePatch::nEdges
label nEdges() const
Return number of edges in patch.
Definition: PrimitivePatchTemplate.H:299
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:85
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::HashTable< T, edge, Hash< edge > >::insert
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
Foam::Map< T >
Foam::processorPolyPatch::neighbProcNo
int neighbProcNo() const
Return neigbour processor number.
Definition: processorPolyPatch.H:255
Foam::globalMeshData::globalPointSlavesMap
const mapDistribute & globalPointSlavesMap() const
Definition: globalMeshData.C:2191
polyMesh.H
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::cyclicPolyPatch::coupledPoints
const edgeList & coupledPoints() const
Return connected points (from patch local to neighbour patch local)
Definition: cyclicPolyPatch.C:1012
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::SubField
Pre-declare related SubField type.
Definition: Field.H:61
Foam::syncTools::swapFaceList
static void swapFaceList(const polyMesh &mesh, UList< T > &l)
Swap coupled face values.
Definition: syncTools.H:463
Foam::globalMeshData::nGlobalPoints
label nGlobalPoints() const
Return number of globally shared points.
Definition: globalMeshData.C:1986
Foam::syncTools::syncEdgeMap
static void syncEdgeMap(const polyMesh &, EdgeMap< T > &edgeValues, const CombineOp &cop, const TransformOp &top)
Synchronize values on selected edges.
Definition: syncToolsTemplates.C:391
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field< T >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::globalMeshData::globalTransforms
const globalIndexAndTransform & globalTransforms() const
Global transforms numbering.
Definition: globalMeshData.C:2160
Foam::globalMeshData::coupledPatchMeshEdges
const labelList & coupledPatchMeshEdges() const
Return map from coupledPatch edges to mesh edges.
Definition: globalMeshData.C:2107
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:152
Foam::syncTools::combine
static void combine(Map< T > &pointValues, const CombineOp &cop, const label index, const T &val)
Combine value with existing value in map.
Definition: syncToolsTemplates.C:41
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:55
Foam::globalMeshData::globalEdgeSlaves
const labelListList & globalEdgeSlaves() const
Definition: globalMeshData.C:2214
Foam::syncTools::swapBoundaryCellList
static void swapBoundaryCellList(const polyMesh &mesh, const UList< T > &cellData, List< T > &neighbourCellData)
Swap to obtain neighbour cell values for all boundary faces.
Definition: syncToolsTemplates.C:1523
Foam::PstreamBuffers::finishedSends
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
Definition: PstreamBuffers.C:82
Foam::cyclicPolyPatch::coupledEdges
const edgeList & coupledEdges() const
Return connected edges (from patch local to neighbour patch local).
Definition: cyclicPolyPatch.C:1093
Foam::PrimitivePatch::nPoints
label nPoints() const
Return number of points supporting patch faces.
Definition: PrimitivePatchTemplate.H:293
Foam::cyclicPolyPatch::owner
virtual bool owner() const
Does this side own the patch ?
Definition: cyclicPolyPatch.H:318
Foam::FatalError
error FatalError
processorPolyPatch.H
Foam::globalMeshData
Various mesh related information for a parallel run. Upon construction, constructs all info using par...
Definition: globalMeshData.H:106
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::eqOp
Definition: ops.H:70
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::polyPatch::faceCells
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:340
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::HashTable< T, edge, Hash< edge > >::find
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Foam::mapDistributeBase::constructSize
label constructSize() const
Constructed data size.
Definition: mapDistributeBase.H:244
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::EdgeMap
Map from edge (expressed as its endpoints) to value.
Definition: EdgeMap.H:47
Foam::syncTools::syncPointMap
static void syncPointMap(const polyMesh &, Map< T > &pointValues, const CombineOp &cop, const TransformOp &top)
Synchronize values on selected points.
Definition: syncToolsTemplates.C:86
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::processorPolyPatch::neighbPoints
const labelList & neighbPoints() const
Return neighbour point labels. WIP.
Definition: processorPolyPatch.C:462
T
const volScalarField & T
Definition: createFields.H:25
Foam::syncTools::syncEdgeList
static void syncEdgeList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh edges.
Definition: syncToolsTemplates.C:1141
Foam::globalMeshData::globalEdgeTransformedSlaves
const labelListList & globalEdgeTransformedSlaves() const
Definition: globalMeshData.C:2224
f
labelList f(nPoints)
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::globalMeshData::coupledPatch
const indirectPrimitivePatch & coupledPatch() const
Return patch of all coupled faces.
Definition: globalMeshData.C:2046
Foam::PackedList
A dynamically allocatable list of packed unsigned integers.
Definition: PackedList.H:117
Foam::UList< T >
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: doubleFloat.H:94
Foam::globalMeshData::sharedPointLabels
const labelList & sharedPointLabels() const
Return indices of local points that are globally shared.
Definition: globalMeshData.C:1996
Foam::UIndirectList< T >
Foam::globalMeshData::sharedPointAddr
const labelList & sharedPointAddr() const
Return addressing into the complete globally shared points.
Definition: globalMeshData.C:2006
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::IPstream
Input inter-processor communications stream.
Definition: IPstream.H:50
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
Foam::PackedList::size
label size() const
Number of entries.
Definition: PackedListI.H:714
Foam::syncTools::syncFaceList
static void syncFaceList(const polyMesh &mesh, UList< T > &l, const CombineOp &cop)
Synchronize values on all mesh faces.
Definition: syncTools.H:381
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::UIPstream
Input inter-processor communications stream operating on external buffer.
Definition: UIPstream.H:53
transform.H
3D tensor transformation operations.
Foam::PrimitivePatch::meshPointMap
const Map< label > & meshPointMap() const
Mesh point map. Given the global point index find its.
Definition: PrimitivePatchTemplate.C:412
Foam::UList::size
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
transformList.H
Spatial transformation functions for primitive fields.
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatchTemplate.C:392
Foam::globalIndexAndTransform
Determination and storage of the possible independent transforms introduced by coupledPolyPatches,...
Definition: globalIndexAndTransform.H:60
Foam::syncTools::syncPointList
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
Definition: syncToolsTemplates.C:984
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88