DistributedDelaunayMesh.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "meshSearch.H"
30 #include "mapDistribute.H"
32 #include "pointConversion.H"
33 #include "indexedVertexEnum.H"
34 #include "IOmanip.H"
35 
36 // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
37 
38 template<class Triangulation>
41 (
42  const List<label>& toProc
43 )
44 {
45  // Determine send map
46  // ~~~~~~~~~~~~~~~~~~
47 
48  // 1. Count
49  labelList nSend(Pstream::nProcs(), Zero);
50 
51  forAll(toProc, i)
52  {
53  label proci = toProc[i];
54 
55  nSend[proci]++;
56  }
57 
58 
59  // 2. Size sendMap
60  labelListList sendMap(Pstream::nProcs());
61 
62  forAll(nSend, proci)
63  {
64  sendMap[proci].setSize(nSend[proci]);
65 
66  nSend[proci] = 0;
67  }
68 
69  // 3. Fill sendMap
70  forAll(toProc, i)
71  {
72  label proci = toProc[i];
73 
74  sendMap[proci][nSend[proci]++] = i;
75  }
76 
77  // 4. Send over how many I need to receive
78  labelList recvSizes;
79  Pstream::exchangeSizes(sendMap, recvSizes);
80 
81 
82  // Determine receive map
83  // ~~~~~~~~~~~~~~~~~~~~~
84 
85  labelListList constructMap(Pstream::nProcs());
86 
87  // Local transfers first
88  constructMap[Pstream::myProcNo()] = identity
89  (
90  sendMap[Pstream::myProcNo()].size()
91  );
92 
93  label constructSize = constructMap[Pstream::myProcNo()].size();
94 
95  forAll(constructMap, proci)
96  {
97  if (proci != Pstream::myProcNo())
98  {
99  label nRecv = recvSizes[proci];
100 
101  constructMap[proci].setSize(nRecv);
102 
103  for (label i = 0; i < nRecv; i++)
104  {
105  constructMap[proci][i] = constructSize++;
106  }
107  }
108  }
109 
111  (
112  constructSize,
113  std::move(sendMap),
114  std::move(constructMap)
115  );
116 }
117 
118 
119 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
120 
121 template<class Triangulation>
123 (
124  const Time& runTime
125 )
126 :
127  DelaunayMesh<Triangulation>(runTime),
128  allBackgroundMeshBounds_()
129 {}
130 
131 
132 template<class Triangulation>
134 (
135  const Time& runTime,
136  const word& meshName
137 )
138 :
139  DelaunayMesh<Triangulation>(runTime, meshName),
140  allBackgroundMeshBounds_()
141 {}
142 
143 
144 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
145 
146 template<class Triangulation>
148 (
149  const boundBox& bb
150 )
151 {
152  allBackgroundMeshBounds_.reset(new List<boundBox>(Pstream::nProcs()));
153 
154  // Give the bounds of every processor to every other processor
155  allBackgroundMeshBounds_()[Pstream::myProcNo()] = bb;
156 
157  Pstream::gatherList(allBackgroundMeshBounds_());
158  Pstream::scatterList(allBackgroundMeshBounds_());
159 
160  return true;
161 }
162 
163 
164 template<class Triangulation>
166 (
167  const Vertex_handle& v
168 ) const
169 {
170  return isLocal(v->procIndex());
171 }
172 
173 
174 template<class Triangulation>
176 (
177  const label localProcIndex
178 ) const
179 {
180  return localProcIndex == Pstream::myProcNo();
181 }
182 
183 
184 template<class Triangulation>
186 (
187  const point& centre,
188  const scalar radiusSqr
189 ) const
190 {
191  DynamicList<label> toProc(Pstream::nProcs());
192 
193  forAll(allBackgroundMeshBounds_(), proci)
194  {
195  // Test against the bounding box of the processor
196  if
197  (
198  !isLocal(proci)
199  && allBackgroundMeshBounds_()[proci].overlaps(centre, radiusSqr)
200  )
201  {
202  toProc.append(proci);
203  }
204  }
205 
206  return toProc;
207 }
208 
209 
210 template<class Triangulation>
212 (
213  const Cell_handle& cit,
214  Map<labelList>& circumsphereOverlaps
215 ) const
216 {
217  const Foam::point& cc = cit->dual();
218 
219  const scalar crSqr = magSqr
220  (
221  cc - topoint(cit->vertex(0)->point())
222  );
223 
224  labelList circumsphereOverlap = overlapProcessors
225  (
226  cc,
227  sqr(1.01)*crSqr
228  );
229 
230  cit->cellIndex() = this->getNewCellIndex();
231 
232  if (!circumsphereOverlap.empty())
233  {
234  circumsphereOverlaps.insert(cit->cellIndex(), circumsphereOverlap);
235 
236  return true;
237  }
238 
239  return false;
240 }
241 
242 
243 template<class Triangulation>
245 (
246  Map<labelList>& circumsphereOverlaps
247 ) const
248 {
249  // Start by assuming that all the cells have no index
250  // If they do, they have already been visited so ignore them
251 
252  labelHashSet cellToCheck
253  (
254  Triangulation::number_of_finite_cells()
255  /Pstream::nProcs()
256  );
257 
258 // std::list<Cell_handle> infinite_cells;
259 // Triangulation::incident_cells
260 // (
261 // Triangulation::infinite_vertex(),
262 // std::back_inserter(infinite_cells)
263 // );
264 //
265 // for
266 // (
267 // typename std::list<Cell_handle>::iterator vcit
268 // = infinite_cells.begin();
269 // vcit != infinite_cells.end();
270 // ++vcit
271 // )
272 // {
273 // Cell_handle cit = *vcit;
274 //
275 // // Index of infinite vertex in this cell.
276 // label i = cit->index(Triangulation::infinite_vertex());
277 //
278 // Cell_handle c = cit->neighbor(i);
279 //
280 // if (c->unassigned())
281 // {
282 // c->cellIndex() = this->getNewCellIndex();
283 //
284 // if (checkProcBoundaryCell(c, circumsphereOverlaps))
285 // {
286 // cellToCheck.insert(c->cellIndex());
287 // }
288 // }
289 // }
290 //
291 //
292 // for
293 // (
294 // Finite_cells_iterator cit = Triangulation::finite_cells_begin();
295 // cit != Triangulation::finite_cells_end();
296 // ++cit
297 // )
298 // {
299 // if (cit->parallelDualVertex())
300 // {
301 // if (cit->unassigned())
302 // {
303 // if (checkProcBoundaryCell(cit, circumsphereOverlaps))
304 // {
305 // cellToCheck.insert(cit->cellIndex());
306 // }
307 // }
308 // }
309 // }
310 
311 
312  for
313  (
314  All_cells_iterator cit = Triangulation::all_cells_begin();
315  cit != Triangulation::all_cells_end();
316  ++cit
317  )
318  {
319  if (Triangulation::is_infinite(cit))
320  {
321  // Index of infinite vertex in this cell.
322  label i = cit->index(Triangulation::infinite_vertex());
323 
324  Cell_handle c = cit->neighbor(i);
325 
326  if (c->unassigned())
327  {
328  c->cellIndex() = this->getNewCellIndex();
329 
330  if (checkProcBoundaryCell(c, circumsphereOverlaps))
331  {
332  cellToCheck.insert(c->cellIndex());
333  }
334  }
335  }
336  else if (cit->parallelDualVertex())
337  {
338  if (cit->unassigned())
339  {
340  if (checkProcBoundaryCell(cit, circumsphereOverlaps))
341  {
342  cellToCheck.insert(cit->cellIndex());
343  }
344  }
345  }
346  }
347 
348  for
349  (
350  Finite_cells_iterator cit = Triangulation::finite_cells_begin();
351  cit != Triangulation::finite_cells_end();
352  ++cit
353  )
354  {
355  if (cellToCheck.found(cit->cellIndex()))
356  {
357  // Get the neighbours and check them
358  for (label adjCelli = 0; adjCelli < 4; ++adjCelli)
359  {
360  Cell_handle citNeighbor = cit->neighbor(adjCelli);
361 
362  // Ignore if has far point or previously visited
363  if
364  (
365  !citNeighbor->unassigned()
366  || !citNeighbor->internalOrBoundaryDualVertex()
367  || Triangulation::is_infinite(citNeighbor)
368  )
369  {
370  continue;
371  }
372 
373  if
374  (
375  checkProcBoundaryCell
376  (
377  citNeighbor,
378  circumsphereOverlaps
379  )
380  )
381  {
382  cellToCheck.insert(citNeighbor->cellIndex());
383  }
384  }
385 
386  cellToCheck.unset(cit->cellIndex());
387  }
388  }
389 }
390 
391 
392 template<class Triangulation>
394 (
395  const Map<labelList>& circumsphereOverlaps,
396  PtrList<labelPairHashSet>& referralVertices,
397  DynamicList<label>& targetProcessor,
398  DynamicList<Vb>& parallelInfluenceVertices
399 )
400 {
401  // Relying on the order of iteration of cells being the same as before
402  for
403  (
404  Finite_cells_iterator cit = Triangulation::finite_cells_begin();
405  cit != Triangulation::finite_cells_end();
406  ++cit
407  )
408  {
409  if (Triangulation::is_infinite(cit))
410  {
411  continue;
412  }
413 
414  const auto iter = circumsphereOverlaps.cfind(cit->cellIndex());
415 
416  // Pre-tested circumsphere potential influence
417  if (iter.found())
418  {
419  const labelList& citOverlaps = iter();
420 
421  for (const label proci : citOverlaps)
422  {
423  for (int i = 0; i < 4; i++)
424  {
425  Vertex_handle v = cit->vertex(i);
426 
427  if (v->farPoint())
428  {
429  continue;
430  }
431 
432  label vProcIndex = v->procIndex();
433  label vIndex = v->index();
434 
435  const labelPair procIndexPair(vProcIndex, vIndex);
436 
437  // Using the hashSet to ensure that each vertex is only
438  // referred once to each processor.
439  // Do not refer a vertex to its own processor.
440  if (vProcIndex != proci)
441  {
442  if (referralVertices[proci].insert(procIndexPair))
443  {
444  targetProcessor.append(proci);
445 
446  parallelInfluenceVertices.append
447  (
448  Vb
449  (
450  v->point(),
451  v->index(),
452  v->type(),
453  v->procIndex()
454  )
455  );
456 
457  parallelInfluenceVertices.last().targetCellSize() =
458  v->targetCellSize();
459  parallelInfluenceVertices.last().alignment() =
460  v->alignment();
461  }
462  }
463  }
464  }
465  }
466  }
467 }
468 
469 
470 template<class Triangulation>
472 (
473  const DynamicList<label>& targetProcessor,
474  DynamicList<Vb>& parallelVertices,
475  PtrList<labelPairHashSet>& referralVertices,
476  labelPairHashSet& receivedVertices
477 )
478 {
479  DynamicList<Vb> referredVertices(targetProcessor.size());
480 
481  const label preDistributionSize = parallelVertices.size();
482 
483  autoPtr<mapDistribute> pointMapPtr = buildMap(targetProcessor);
484  mapDistribute& pointMap = *pointMapPtr;
485 
486  // Make a copy of the original list.
487  DynamicList<Vb> originalParallelVertices(parallelVertices);
488 
489  pointMap.distribute(parallelVertices);
490 
491  for (label proci = 0; proci < Pstream::nProcs(); proci++)
492  {
493  const labelList& constructMap = pointMap.constructMap()[proci];
494 
495  if (constructMap.size())
496  {
497  forAll(constructMap, i)
498  {
499  const Vb& v = parallelVertices[constructMap[i]];
500 
501  if
502  (
503  v.procIndex() != Pstream::myProcNo()
504  && !receivedVertices.found(labelPair(v.procIndex(), v.index()))
505  )
506  {
507  referredVertices.append(v);
508 
509  receivedVertices.insert
510  (
511  labelPair(v.procIndex(), v.index())
512  );
513  }
514  }
515  }
516  }
517 
518  label preInsertionSize = Triangulation::number_of_vertices();
519 
520  labelPairHashSet pointsNotInserted = rangeInsertReferredWithInfo
521  (
522  referredVertices.begin(),
523  referredVertices.end(),
524  true
525  );
526 
527  if (!pointsNotInserted.empty())
528  {
529  forAllConstIters(pointsNotInserted, iter)
530  {
531  if (receivedVertices.found(iter.key()))
532  {
533  receivedVertices.erase(iter.key());
534  }
535  }
536  }
537 
538  boolList pointInserted(parallelVertices.size(), true);
539 
540  forAll(parallelVertices, vI)
541  {
542  const labelPair procIndexI
543  (
544  parallelVertices[vI].procIndex(),
545  parallelVertices[vI].index()
546  );
547 
548  if (pointsNotInserted.found(procIndexI))
549  {
550  pointInserted[vI] = false;
551  }
552  }
553 
554  pointMap.reverseDistribute(preDistributionSize, pointInserted);
555 
556  forAll(originalParallelVertices, vI)
557  {
558  const label procIndex = targetProcessor[vI];
559 
560  if (!pointInserted[vI])
561  {
562  if (referralVertices[procIndex].size())
563  {
564  if
565  (
566  !referralVertices[procIndex].unset
567  (
568  labelPair
569  (
570  originalParallelVertices[vI].procIndex(),
571  originalParallelVertices[vI].index()
572  )
573  )
574  )
575  {
576  Pout<< "*** not found "
577  << originalParallelVertices[vI].procIndex()
578  << " " << originalParallelVertices[vI].index() << endl;
579  }
580  }
581  }
582  }
583 
584  label postInsertionSize = Triangulation::number_of_vertices();
585 
586  reduce(preInsertionSize, sumOp<label>());
587  reduce(postInsertionSize, sumOp<label>());
588 
589  label nTotalToInsert = referredVertices.size();
590 
591  reduce(nTotalToInsert, sumOp<label>());
592 
593  if (preInsertionSize + nTotalToInsert != postInsertionSize)
594  {
595  label nNotInserted =
596  returnReduce(pointsNotInserted.size(), sumOp<label>());
597 
598  Info<< " Inserted = "
599  << setw(name(label(Triangulation::number_of_finite_cells())).size())
600  << nTotalToInsert - nNotInserted
601  << " / " << nTotalToInsert << endl;
602 
603  nTotalToInsert -= nNotInserted;
604  }
605  else
606  {
607  Info<< " Inserted = " << nTotalToInsert << endl;
608  }
609 
610  return nTotalToInsert;
611 }
612 
613 
614 template<class Triangulation>
616 (
617  const boundBox& bb,
618  PtrList<labelPairHashSet>& referralVertices,
619  labelPairHashSet& receivedVertices,
620  bool iterateReferral
621 )
622 {
623  if (!Pstream::parRun())
624  {
625  return;
626  }
627 
628  if (allBackgroundMeshBounds_.empty())
629  {
630  distributeBoundBoxes(bb);
631  }
632 
633  label nVerts = Triangulation::number_of_vertices();
634  label nCells = Triangulation::number_of_finite_cells();
635 
636  DynamicList<Vb> parallelInfluenceVertices(0.1*nVerts);
637  DynamicList<label> targetProcessor(0.1*nVerts);
638 
639  // Some of these values will not be used, i.e. for non-real cells
640  DynamicList<Foam::point> circumcentre(0.1*nVerts);
641  DynamicList<scalar> circumradiusSqr(0.1*nVerts);
642 
643  Map<labelList> circumsphereOverlaps(nCells);
644 
645  findProcessorBoundaryCells(circumsphereOverlaps);
646 
647  Info<< " Influences = "
648  << setw(name(nCells).size())
649  << returnReduce(circumsphereOverlaps.size(), sumOp<label>()) << " / "
650  << returnReduce(nCells, sumOp<label>());
651 
652  markVerticesToRefer
653  (
654  circumsphereOverlaps,
655  referralVertices,
656  targetProcessor,
657  parallelInfluenceVertices
658  );
659 
660  referVertices
661  (
662  targetProcessor,
663  parallelInfluenceVertices,
664  referralVertices,
665  receivedVertices
666  );
667 
668  if (iterateReferral)
669  {
670  label oldNReferred = 0;
671  label nIterations = 1;
672 
673  Info<< incrIndent << indent
674  << "Iteratively referring referred vertices..."
675  << endl;
676  do
677  {
678  Info<< indent << "Iteration " << nIterations++ << ":";
679 
680  circumsphereOverlaps.clear();
681  targetProcessor.clear();
682  parallelInfluenceVertices.clear();
683 
684  findProcessorBoundaryCells(circumsphereOverlaps);
685 
686  nCells = Triangulation::number_of_finite_cells();
687 
688  Info<< " Influences = "
689  << setw(name(nCells).size())
690  << returnReduce(circumsphereOverlaps.size(), sumOp<label>())
691  << " / "
692  << returnReduce(nCells, sumOp<label>());
693 
694  markVerticesToRefer
695  (
696  circumsphereOverlaps,
697  referralVertices,
698  targetProcessor,
699  parallelInfluenceVertices
700  );
701 
702  label nReferred = referVertices
703  (
704  targetProcessor,
705  parallelInfluenceVertices,
706  referralVertices,
707  receivedVertices
708  );
709 
710  if (nReferred == 0 || nReferred == oldNReferred)
711  {
712  break;
713  }
714 
715  oldNReferred = nReferred;
716 
717  } while (true);
718 
719  Info<< decrIndent;
720  }
721 }
722 
723 
724 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
725 
726 
727 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
728 
729 template<class Triangulation>
730 Foam::scalar
732 {
733  label nRealVertices = 0;
734 
735  for
736  (
737  Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
738  vit != Triangulation::finite_vertices_end();
739  ++vit
740  )
741  {
742  // Only store real vertices that are not feature vertices
743  if (vit->real() && !vit->featurePoint())
744  {
745  nRealVertices++;
746  }
747  }
748 
749  scalar globalNRealVertices = returnReduce
750  (
751  nRealVertices,
752  sumOp<label>()
753  );
754 
755  scalar unbalance = returnReduce
756  (
757  mag(1.0 - nRealVertices/(globalNRealVertices/Pstream::nProcs())),
758  maxOp<scalar>()
759  );
760 
761  Info<< " Processor unbalance " << unbalance << endl;
762 
763  return unbalance;
764 }
765 
766 
767 template<class Triangulation>
769 (
770  const boundBox& bb
771 )
772 {
774 
775  if (!Pstream::parRun())
776  {
777  return false;
778  }
779 
780  distributeBoundBoxes(bb);
781 
782  return true;
783 }
784 
785 
786 template<class Triangulation>
789 (
790  const backgroundMeshDecomposition& decomposition,
791  List<Foam::point>& points
792 )
793 {
794  if (!Pstream::parRun())
795  {
796  return nullptr;
797  }
798 
799  distributeBoundBoxes(decomposition.procBounds());
800 
801  return decomposition.distributePoints(points);
802 }
803 
804 
805 template<class Triangulation>
807 {
808  if (!Pstream::parRun())
809  {
810  return;
811  }
812 
813  if (allBackgroundMeshBounds_.empty())
814  {
815  distributeBoundBoxes(bb);
816  }
817 
818  const label nApproxReferred =
819  Triangulation::number_of_vertices()
820  /Pstream::nProcs();
821 
822  PtrList<labelPairHashSet> referralVertices(Pstream::nProcs());
823  forAll(referralVertices, proci)
824  {
825  if (!isLocal(proci))
826  {
827  referralVertices.set(proci, new labelPairHashSet(nApproxReferred));
828  }
829  }
830 
831  labelPairHashSet receivedVertices(nApproxReferred);
832 
833  sync
834  (
835  bb,
836  referralVertices,
837  receivedVertices,
838  true
839  );
840 }
841 
842 
843 template<class Triangulation>
844 template<class PointIterator>
847 (
848  PointIterator begin,
849  PointIterator end,
850  bool printErrors
851 )
852 {
853  const boundBox& bb = allBackgroundMeshBounds_()[Pstream::myProcNo()];
854 
855  typedef DynamicList
856  <
857  std::pair<scalar, label>
858  > vectorPairPointIndex;
859 
860  vectorPairPointIndex pointsBbDistSqr;
861 
862  label count = 0;
863  for (PointIterator it = begin; it != end; ++it)
864  {
865  const Foam::point samplePoint(topoint(it->point()));
866 
867  scalar distFromBbSqr = 0;
868 
869  if (!bb.contains(samplePoint))
870  {
871  const Foam::point nearestPoint = bb.nearest(samplePoint);
872 
873  distFromBbSqr = magSqr(nearestPoint - samplePoint);
874  }
875 
876  pointsBbDistSqr.append
877  (
878  std::make_pair(distFromBbSqr, count++)
879  );
880  }
881 
882  std::random_shuffle(pointsBbDistSqr.begin(), pointsBbDistSqr.end());
883 
884  // Sort in ascending order by the distance of the point from the centre
885  // of the processor bounding box
886  sort(pointsBbDistSqr.begin(), pointsBbDistSqr.end());
887 
888  typename Triangulation::Vertex_handle hint;
889 
890  typename Triangulation::Locate_type lt;
891  int li, lj;
892 
893  label nNotInserted = 0;
894 
895  labelPairHashSet uninserted
896  (
897  Triangulation::number_of_vertices()
898  /Pstream::nProcs()
899  );
900 
901  for
902  (
903  typename vectorPairPointIndex::const_iterator p =
904  pointsBbDistSqr.begin();
905  p != pointsBbDistSqr.end();
906  ++p
907  )
908  {
909  const size_t checkInsertion = Triangulation::number_of_vertices();
910 
911  const Vb& vert = *(begin + p->second);
912  const Point& pointToInsert = vert.point();
913 
914  // Locate the point
915  Cell_handle c = Triangulation::locate(pointToInsert, lt, li, lj, hint);
916 
917  bool inserted = false;
918 
919  if (lt == Triangulation::VERTEX)
920  {
921  if (printErrors)
922  {
923  Vertex_handle nearV =
924  Triangulation::nearest_vertex(pointToInsert);
925 
926  Pout<< "Failed insertion, point already exists" << nl
927  << "Failed insertion : " << vert.info()
928  << " nearest : " << nearV->info();
929  }
930  }
931  else if (lt == Triangulation::OUTSIDE_AFFINE_HULL)
932  {
934  << "Point is outside affine hull! pt = " << pointToInsert
935  << endl;
936  }
937  else if (lt == Triangulation::OUTSIDE_CONVEX_HULL)
938  {
939  // TODO: Can this be optimised?
940  //
941  // Only want to insert if a connection is formed between
942  // pointToInsert and an internal or internal boundary point.
943  hint = Triangulation::insert(pointToInsert, c);
944  inserted = true;
945  }
946  else
947  {
948  // Get the cells that conflict with p in a vector V,
949  // and a facet on the boundary of this hole in f.
950  std::vector<Cell_handle> V;
951  typename Triangulation::Facet f;
952 
953  Triangulation::find_conflicts
954  (
955  pointToInsert,
956  c,
957  CGAL::Oneset_iterator<typename Triangulation::Facet>(f),
958  std::back_inserter(V)
959  );
960 
961  for (size_t i = 0; i < V.size(); ++i)
962  {
963  Cell_handle conflictingCell = V[i];
964 
965  if
966  (
967  Triangulation::dimension() < 3 // 2D triangulation
968  ||
969  (
970  !Triangulation::is_infinite(conflictingCell)
971  && (
972  conflictingCell->real()
973  || conflictingCell->hasFarPoint()
974  )
975  )
976  )
977  {
978  hint = Triangulation::insert_in_hole
979  (
980  pointToInsert,
981  V.begin(),
982  V.end(),
983  f.first,
984  f.second
985  );
986 
987  inserted = true;
988 
989  break;
990  }
991  }
992  }
993 
994  if (inserted)
995  {
996  if (checkInsertion != Triangulation::number_of_vertices() - 1)
997  {
998  if (printErrors)
999  {
1000  Vertex_handle nearV =
1001  Triangulation::nearest_vertex(pointToInsert);
1002 
1003  Pout<< "Failed insertion : " << vert.info()
1004  << " nearest : " << nearV->info();
1005  }
1006  }
1007  else
1008  {
1009  hint->index() = vert.index();
1010  hint->type() = vert.type();
1011  hint->procIndex() = vert.procIndex();
1012  hint->targetCellSize() = vert.targetCellSize();
1013  hint->alignment() = vert.alignment();
1014  }
1015  }
1016  else
1017  {
1018  uninserted.insert(labelPair(vert.procIndex(), vert.index()));
1019  nNotInserted++;
1020  }
1021  }
1022 
1023  return uninserted;
1024 }
1025 
1026 
1027 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:71
insert
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
runTime
engineTime & runTime
Definition: createEngineTime.H:13
CGAL::indexedVertex::alignment
Foam::tensor & alignment()
Definition: indexedVertexI.H:189
p
volScalarField & p
Definition: createFieldRefs.H:8
pointConversion.H
stdFoam::begin
constexpr auto begin(C &c) -> decltype(c.begin())
Return iterator to the beginning of the container c.
Definition: stdFoam.H:97
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
CGAL::indexedVertex::type
vertexType & type()
Definition: indexedVertexI.H:174
CGAL::indexedVertex
An indexed form of CGAL::Triangulation_vertex_base_3<K> used to keep track of the Delaunay vertices i...
Definition: indexedVertex.H:54
Foam::boolList
List< bool > boolList
A List of bools.
Definition: List.H:69
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::HashSet
A HashTable with keys but without contents that is similar to std::unordered_set.
Definition: HashSet.H:83
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:327
Foam::DistributedDelaunayMesh::rangeInsertReferredWithInfo
labelPairHashSet rangeInsertReferredWithInfo(PointIterator begin, PointIterator end, bool printErrors=true)
Inserts points into the triangulation if the point is within.
Foam::topoint
pointFromPoint topoint(const Point &P)
Definition: pointConversion.H:72
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
Foam::labelPair
Pair< label > labelPair
A pair of labels.
Definition: Pair.H:54
Foam::DistributedDelaunayMesh::buildMap
static autoPtr< mapDistribute > buildMap(const List< label > &toProc)
Build a mapDistribute for the supplied destination processor data.
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
indexedVertexEnum.H
Foam::DistributedDelaunayMesh::sync
void sync(const boundBox &bb)
Refer vertices so that the processor interfaces are consistent.
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
CGAL::indexedVertex::index
Foam::label & index()
Definition: indexedVertexI.H:159
Foam::sort
void sort(UList< T > &a)
Definition: UList.C:254
IOmanip.H
Istream and Ostream manipulators taking arguments.
DistributedDelaunayMesh.H
Foam::DistributedDelaunayMesh
Definition: DistributedDelaunayMesh.H:58
Foam::DistributedDelaunayMesh::calculateLoadUnbalance
scalar calculateLoadUnbalance() const
CGAL::indexedVertex::info
Foam::InfoProxy< indexedVertex< Gt, Vb > > info() const
Info proxy, to print information to a stream.
Definition: indexedVertex.H:307
CGAL::indexedVertex::targetCellSize
Foam::scalar & targetCellSize()
Definition: indexedVertexI.H:203
reduce
reduce(hasMovingMesh, orOp< bool >())
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:121
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:334
Foam::setw
Omanip< int > setw(const int i)
Definition: IOmanip.H:199
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:320
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr< Foam::mapDistribute >
Foam::labelListList
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:56
CGAL::indexedVertex::procIndex
int procIndex() const
Definition: indexedVertexI.H:251
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
meshSearch.H
Foam::nl
constexpr char nl
Definition: Ostream.H:385
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::DistributedDelaunayMesh::distribute
bool distribute(const boundBox &bb)
mapDistribute.H
f
labelList f(nPoints)
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:74
Foam::Vector
Templated 3D Vector derived from VectorSpace adding construction from 3 components,...
Definition: Vector.H:62
Foam::labelPairHashSet
HashSet< labelPair, labelPair::Hash<> > labelPairHashSet
A HashSet for a labelPair. The hashing is based on labelPair (FixedList) and is thus non-commutative.
Definition: labelPairHashes.H:65
Foam::List< label >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Point
CGAL::Point_3< K > Point
Definition: CGALIndexedPolyhedron.H:53
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::labelHashSet
HashSet< label, Hash< label > > labelHashSet
A HashSet with label keys and label hasher.
Definition: HashSet.H:410
zeroGradientFvPatchFields.H
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:298
Foam::DelaunayMesh::reset
void reset()
Clear the entire triangulation.