indexedCellI.H
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) 2012-2015 OpenFOAM Foundation
6  \\/ M anipulation |
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 "indexedCellChecks.H"
27 
28 template<class Gt, class Cb>
30 (
31  const Foam::globalIndex& globalDelaunayVertexIndices
32 ) const
33 {
34  Foam::tetCell tVGI;
35 
36  for (int i = 0; i < 4; i++)
37  {
38  Vertex_handle v = this->vertex(i);
39 
40  // Finding the global index of each Delaunay vertex
41  tVGI[i] = globalDelaunayVertexIndices.toGlobal
42  (
44  v->index()
45  );
46  }
47 
48  return tVGI;
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 template<class Gt, class Cb>
56 :
57  Cb(),
58  index_(ctUnassigned),
59  filterCount_(0)
60 {}
61 
62 
63 template<class Gt, class Cb>
65 (
67 )
68 :
69  Cb(v0, v1, v2, v3),
70  index_(ctUnassigned),
71  filterCount_(0)
72 {}
73 
74 
75 template<class Gt, class Cb>
77 (
78  Vertex_handle v0,
79  Vertex_handle v1,
80  Vertex_handle v2,
81  Vertex_handle v3,
82  Cell_handle n0,
83  Cell_handle n1,
84  Cell_handle n2,
85  Cell_handle n3
86 )
87 :
88  Cb(v0, v1, v2, v3, n0, n1, n2, n3),
89  index_(ctUnassigned),
90  filterCount_(0)
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class Gt, class Cb>
98 {
99  return index_;
100 }
101 
102 
103 template<class Gt, class Cb>
105 {
106  return index_;
107 }
108 
109 
110 #ifdef CGAL_INEXACT
111 
112  template<class Gt, class Cb>
114  {
115  return reinterpret_cast<const Foam::point&>(this->circumcenter());
116  }
117 
118 #else
119 
120  template<class Gt, class Cb>
122  {
123  const typename Gt::Point_3& P = this->circumcenter();
124 
125  return Foam::point
126  (
127  CGAL::to_double(P.x()),
128  CGAL::to_double(P.y()),
129  CGAL::to_double(P.z())
130  );
131  }
132 
133 #endif
134 
135 
136 template<class Gt, class Cb>
138 {
139  return index_ == ctUnassigned;
140 }
141 
142 
143 template<class Gt, class Cb>
145 {
146  return filterCount_;
147 }
148 
149 
150 template<class Gt, class Cb>
152 {
153  return filterCount_;
154 }
155 
156 
157 template<class Gt, class Cb>
159 {
160  return
161  (
162  (
163  this->vertex(0)->real()
164  || this->vertex(1)->real()
165  || this->vertex(2)->real()
166  || this->vertex(3)->real()
167  )
168  &&
169  !(
170  this->vertex(0)->farPoint()
171  || this->vertex(1)->farPoint()
172  || this->vertex(2)->farPoint()
173  || this->vertex(3)->farPoint()
174  )
175  );
176 }
177 
178 
179 template<class Gt, class Cb>
181 {
182  return
183  (
184  this->vertex(0)->farPoint()
185  || this->vertex(1)->farPoint()
186  || this->vertex(2)->farPoint()
187  || this->vertex(3)->farPoint()
188  );
189 }
190 
191 
192 template<class Gt, class Cb>
194 {
195  return
196  (
197  this->vertex(0)->referred()
198  || this->vertex(1)->referred()
199  || this->vertex(2)->referred()
200  || this->vertex(3)->referred()
201  );
202 }
203 
204 
205 template<class Gt, class Cb>
207 {
208  return
209  (
210  this->vertex(0)->featurePoint()
211  || this->vertex(1)->featurePoint()
212  || this->vertex(2)->featurePoint()
213  || this->vertex(3)->featurePoint()
214  );
215 }
216 
217 
218 template<class Gt, class Cb>
220 {
221  return
222  (
223  this->vertex(0)->seedPoint()
224  || this->vertex(1)->seedPoint()
225  || this->vertex(2)->seedPoint()
226  || this->vertex(3)->seedPoint()
227  );
228 }
229 
230 
231 template<class Gt, class Cb>
233 {
234  return
235  (
236  this->vertex(0)->internalPoint()
237  || this->vertex(1)->internalPoint()
238  || this->vertex(2)->internalPoint()
239  || this->vertex(3)->internalPoint()
240  );
241 }
242 
243 
244 template<class Gt, class Cb>
246 {
247  return
248  (
249  this->vertex(0)->boundaryPoint()
250  || this->vertex(1)->boundaryPoint()
251  || this->vertex(2)->boundaryPoint()
252  || this->vertex(3)->boundaryPoint()
253  );
254 }
255 
256 
257 template<class Gt, class Cb>
259 {
260  return
261  (
262  this->vertex(0)->constrained()
263  || this->vertex(1)->constrained()
264  || this->vertex(2)->constrained()
265  || this->vertex(3)->constrained()
266  );
267 }
268 
269 
270 template<class Gt, class Cb>
272 {
273  return
274  (
275  !this->hasFarPoint()
276  &&
277  (
278  this->vertex(0)->referred()
279  || this->vertex(1)->referred()
280  || this->vertex(2)->referred()
281  || this->vertex(3)->referred()
282  )
283  &&
284  (
285  this->vertex(0)->real()
286  || this->vertex(1)->real()
287  || this->vertex(2)->real()
288  || this->vertex(3)->real()
289  )
290  );
291 }
292 
293 
294 template<class Gt, class Cb>
296 {
297  Foam::label lowestProc = -1;
298 
299  for (int i = 0; i < 4; ++i)
300  {
301  if (this->vertex(i)->referred())
302  {
303  lowestProc = min(lowestProc, this->vertex(i)->procIndex());
304  }
305  }
306 
307  return lowestProc;
308 }
309 
310 
311 template<class Gt, class Cb>
313 (
314  const Foam::globalIndex& globalDelaunayVertexIndices
315 ) const
316 {
317  // tetVertexGlobalIndices
318  Foam::tetCell tVGI
319  = unsortedVertexGlobalIndices(globalDelaunayVertexIndices);
320 
321  // bubble sort
322  for (int i = 0; i < tVGI.size(); i++)
323  {
324  for (int j = tVGI.size() - 1 ; j > i; j--)
325  {
326  if (tVGI[j - 1] > tVGI[j])
327  {
328  Foam::Swap(tVGI[j - 1], tVGI[j]);
329  }
330  }
331  }
332 
333  return tVGI;
334 }
335 
336 
337 template<class Gt, class Cb>
340 (
341  const Foam::globalIndex& globalDelaunayVertexIndices
342 ) const
343 {
344  // tetVertexGlobalIndices
345  Foam::tetCell tVGI
346  = unsortedVertexGlobalIndices(globalDelaunayVertexIndices);
347 
349 
350  // bubble sort
351  for (int i = 0; i < tVGI.size(); i++)
352  {
353  for (int j = tVGI.size() - 1 ; j > i; j--)
354  {
355  if (tVGI[j - 1] > tVGI[j])
356  {
357  Foam::Swap(tVGI[j - 1], tVGI[j]);
358  Foam::Swap(vertexMap[j - 1], vertexMap[j]);
359  }
360  }
361  }
362 
363  for (int i = 0; i < 4; i++)
364  {
365  tVGI[i] = vertexMap[i];
366  }
367 
368  return tVGI;
369 }
370 
371 
372 template<class Gt, class Cb>
374 {
375  return
376  (
377  this->vertex(0)->internalOrBoundaryPoint()
378  || this->vertex(1)->internalOrBoundaryPoint()
379  || this->vertex(2)->internalOrBoundaryPoint()
380  || this->vertex(3)->internalOrBoundaryPoint()
381  );
382 }
383 
384 
385 template<class Gt, class Cb>
387 {
388  return
389  (
390  this->vertex(0)->internalOrBoundaryPoint()
391  || this->vertex(0)->externalBoundaryPoint()
392  || this->vertex(1)->internalOrBoundaryPoint()
393  || this->vertex(1)->externalBoundaryPoint()
394  || this->vertex(2)->internalOrBoundaryPoint()
395  || this->vertex(2)->externalBoundaryPoint()
396  || this->vertex(3)->internalOrBoundaryPoint()
397  || this->vertex(3)->externalBoundaryPoint()
398  );
399 }
400 
401 
402 template<class Gt, class Cb>
404 {
405 // return
406 // (
407 // this->vertex(0)->boundaryPoint()
408 // && this->vertex(1)->boundaryPoint()
409 // && this->vertex(2)->boundaryPoint()
410 // && this->vertex(3)->boundaryPoint()
411 // );
412 
413  return
414  (
415  (
416  this->vertex(0)->internalBoundaryPoint()
417  || this->vertex(1)->internalBoundaryPoint()
418  || this->vertex(2)->internalBoundaryPoint()
419  || this->vertex(3)->internalBoundaryPoint()
420  )
421  && (
422  this->vertex(0)->externalBoundaryPoint()
423  || this->vertex(1)->externalBoundaryPoint()
424  || this->vertex(2)->externalBoundaryPoint()
425  || this->vertex(3)->externalBoundaryPoint()
426  )
427  );
428 
429 // Foam::label nBoundaryPoints = 0;
430 //
431 // for (Foam::label i = 0; i < 4; ++i)
432 // {
433 // Vertex_handle v = this->vertex(i);
434 //
435 // if (v->boundaryPoint())
436 // {
437 // nBoundaryPoints++;
438 // }
439 // }
440 //
441 // return (nBoundaryPoints > 1);
442 }
443 
444 
445 template<class Gt, class Cb>
447 {
448  return
449  (
450  (
451  this->vertex(0)->internalBaffleSurfacePoint()
452  || this->vertex(1)->internalBaffleSurfacePoint()
453  || this->vertex(2)->internalBaffleSurfacePoint()
454  || this->vertex(3)->internalBaffleSurfacePoint()
455  )
456  && (
457  this->vertex(0)->externalBaffleSurfacePoint()
458  || this->vertex(1)->externalBaffleSurfacePoint()
459  || this->vertex(2)->externalBaffleSurfacePoint()
460  || this->vertex(3)->externalBaffleSurfacePoint()
461  )
462  );
463 }
464 
465 
466 template<class Gt, class Cb>
468 {
469  return
470  (
471  (
472  this->vertex(0)->internalBaffleEdgePoint()
473  || this->vertex(1)->internalBaffleEdgePoint()
474  || this->vertex(2)->internalBaffleEdgePoint()
475  || this->vertex(3)->internalBaffleEdgePoint()
476  )
477  && (
478  this->vertex(0)->externalBaffleEdgePoint()
479  || this->vertex(1)->externalBaffleEdgePoint()
480  || this->vertex(2)->externalBaffleEdgePoint()
481  || this->vertex(3)->externalBaffleEdgePoint()
482  )
483  );
484 }
485 
486 
487 template<class Gt, class Cb>
489 {
490  return
491  (
492  this->vertex(0)->featureEdgePoint()
493  && this->vertex(1)->featureEdgePoint()
494  && this->vertex(2)->featureEdgePoint()
495  && this->vertex(3)->featureEdgePoint()
496  );
497 // (
498 // this->vertex(0)->featureEdgePoint()
499 // || this->vertex(1)->featureEdgePoint()
500 // || this->vertex(2)->featureEdgePoint()
501 // || this->vertex(3)->featureEdgePoint()
502 // )
503 // && (
504 // (
505 // this->vertex(0)->featureEdgePoint()
506 // || this->vertex(0)->featurePoint()
507 // )
508 // && (
509 // this->vertex(1)->featureEdgePoint()
510 // || this->vertex(1)->featurePoint()
511 // )
512 // && (
513 // this->vertex(2)->featureEdgePoint()
514 // || this->vertex(2)->featurePoint()
515 // )
516 // && (
517 // this->vertex(3)->featureEdgePoint()
518 // || this->vertex(3)->featurePoint()
519 // )
520 // )
521 // );
522 }
523 
524 
525 template<class Gt, class Cb>
527 {
528  return
529  (
530  this->vertex(0)->featurePoint()
531  && this->vertex(1)->featurePoint()
532  && this->vertex(2)->featurePoint()
533  && this->vertex(3)->featurePoint()
534  );
535 }
536 
537 
538 template<class Gt, class Cb>
540 {
541  return
542  (
543  this->vertex(0)->nearProcBoundary()
544  || this->vertex(1)->nearProcBoundary()
545  || this->vertex(2)->nearProcBoundary()
546  || this->vertex(3)->nearProcBoundary()
547  );
548 }
549 
550 
551 template<class Gt, class Cb>
553 {
554  Foam::label nMasters = 0;
555  Foam::label nSlaves = 0;
556 
557  Vertex_handle vM[2];
558  Vertex_handle vS[2];
559 
560  for (Foam::label i = 0; i < 4; ++i)
561  {
562  Vertex_handle v = this->vertex(i);
563 
564  if (v->internalBoundaryPoint())
565  {
566  vM[nMasters] = v;
567  nMasters++;
568  }
569 
570  if (v->externalBoundaryPoint())
571  {
572  vS[nSlaves] = v;
573  nSlaves++;
574  }
575  }
576 
577  Foam::label nPairs = 0;
578 
579  if (nMasters == 2 && nSlaves == 2)
580  {
583 
584  if
585  (
586  vM[0]->type() == vS[0]->index()
587  && vM[0]->index() == vS[0]->type()
588  )
589  {
590  vp0 = reinterpret_cast<const Foam::point&>(vM[0]->point())
591  - reinterpret_cast<const Foam::point&>(vS[0]->point());
592  nPairs++;
593  }
594  else if
595  (
596  vM[0]->type() == vS[1]->index()
597  && vM[0]->index() == vS[1]->type()
598  )
599  {
600  vp0 = reinterpret_cast<const Foam::point&>(vM[0]->point())
601  - reinterpret_cast<const Foam::point&>(vS[1]->point());
602  nPairs++;
603  }
604 
605  if
606  (
607  vM[1]->type() == vS[0]->index()
608  && vM[1]->index() == vS[0]->type()
609  )
610  {
611  vp1 = reinterpret_cast<const Foam::point&>(vM[1]->point())
612  - reinterpret_cast<const Foam::point&>(vS[0]->point());
613  nPairs++;
614  }
615  else if
616  (
617  vM[1]->type() == vS[1]->index()
618  && vM[1]->index() == vS[1]->type()
619  )
620  {
621  vp1 = reinterpret_cast<const Foam::point&>(vM[1]->point())
622  - reinterpret_cast<const Foam::point&>(vS[1]->point());
623  nPairs++;
624  }
625 
626  if (nPairs == 2)
627  {
628  if (Foam::vectorTools::areParallel(vp0, vp1))
629  {
630  Foam::Pout<< "PARALLEL" << Foam::endl;
631 
632  return true;
633  }
634  }
635  }
636 
637  return false;
638 }
639 
640 
641 template<class Gt, class Cb>
643 {
644  int featureVertex = -1;
645  for (int i = 0; i < 4; ++i)
646  {
647  if (this->vertex(i)->constrained())
648  {
649  featureVertex = i;
650  }
651  }
652 
653  // Pick cell with a face attached to an infinite cell
654 
655  if (featureVertex != -1)
656  {
657  Vertex_handle v1 =
658  this->vertex(Tds::vertex_triple_index(featureVertex, 0));
659  Vertex_handle v2 =
660  this->vertex(Tds::vertex_triple_index(featureVertex, 1));
661  Vertex_handle v3 =
662  this->vertex(Tds::vertex_triple_index(featureVertex, 2));
663 
664  if (v1->internalBoundaryPoint())
665  {
666  if
667  (
668  v2->externalBoundaryPoint()
669  && v3->externalBoundaryPoint()
670  )
671  {
672  return true;
673  }
674  }
675  else if (v2->internalBoundaryPoint())
676  {
677  if
678  (
679  v1->externalBoundaryPoint()
680  && v3->externalBoundaryPoint()
681  )
682  {
683  return true;
684  }
685  }
686  else if (v3->internalBoundaryPoint())
687  {
688  if
689  (
690  v1->externalBoundaryPoint()
691  && v2->externalBoundaryPoint()
692  )
693  {
694  return true;
695  }
696  }
697  }
698 
699  return false;
700 }
701 
702 
703 template<class Gt, class Cb>
705 {
706  int featureVertex = -1;
707  for (int i = 0; i < 4; ++i)
708  {
709  if (this->vertex(i)->constrained())
710  {
711  featureVertex = i;
712  }
713  }
714 
715  // Pick cell with a face attached to an infinite cell
716 
717  if (featureVertex != -1)
718  {
719  Vertex_handle v1 =
720  this->vertex(Tds::vertex_triple_index(featureVertex, 0));
721  Vertex_handle v2 =
722  this->vertex(Tds::vertex_triple_index(featureVertex, 1));
723  Vertex_handle v3 =
724  this->vertex(Tds::vertex_triple_index(featureVertex, 2));
725 
726  if (v1->externalBoundaryPoint())
727  {
728  if
729  (
730  v2->internalBoundaryPoint()
731  && v3->internalBoundaryPoint()
732  )
733  {
734  return true;
735  }
736  }
737  else if (v2->externalBoundaryPoint())
738  {
739  if
740  (
741  v1->internalBoundaryPoint()
742  && v3->internalBoundaryPoint()
743  )
744  {
745  return true;
746  }
747  }
748  else if (v3->externalBoundaryPoint())
749  {
750  if
751  (
752  v1->internalBoundaryPoint()
753  && v2->internalBoundaryPoint()
754  )
755  {
756  return true;
757  }
758  }
759  }
760 
761  return false;
762 }
763 
764 
765 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
bool hasFarPoint() const
Does the Delaunay cell have a far point.
Definition: indexedCellI.H:180
A tetrahedral cell primitive.
Definition: tetCell.H:58
bool hasBoundaryPoint() const
Definition: indexedCellI.H:245
CGAL::indexedCell< K > Cb
bool hasSeedPoint() const
Does the Delaunay cell have a seed point.
Definition: indexedCellI.H:219
vector point
Point is a vector.
Definition: point.H:41
bool potentialCoplanarCell() const
Definition: indexedCellI.H:552
bool unassigned() const
Definition: indexedCellI.H:137
bool featurePointExternalCell() const
Definition: indexedCellI.H:642
bool featureEdgeDualVertex() const
A dual vertex on a feature edge will result from this Delaunay cell.
Definition: indexedCellI.H:488
Cb::Vertex_handle Vertex_handle
Definition: indexedCell.H:118
Foam::label vertexLowestProc() const
Definition: indexedCellI.H:295
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
Definition: globalIndex.H:63
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
bool internalOrBoundaryDualVertex() const
Is the Delaunay cell part of the final dual mesh, i.e. any vertex.
Definition: indexedCellI.H:373
bool hasFeaturePoint() const
Does the Delaunay cell have a feature point.
Definition: indexedCellI.H:206
Foam::tetCell vertexGlobalIndices(const Foam::globalIndex &globalDelaunayVertexIndices) const
Using the globalIndex object, return a list of four (sorted) global.
Definition: indexedCellI.H:313
bool parallelDualVertex() const
Does the Dual vertex form part of a processor patch.
Definition: indexedCellI.H:271
bool featurePointInternalCell() const
Definition: indexedCellI.H:704
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
bool anyInternalOrBoundaryDualVertex() const
Is the Delaunay cell real or referred (or mixed), i.e. all vertices.
Definition: indexedCellI.H:386
label size() const
Return the number of elements in the FixedList.
Definition: FixedListI.H:408
bool featurePointDualVertex() const
A dual vertex on a feature point will result from this Delaunay cell.
Definition: indexedCellI.H:526
bool nearProcBoundary() const
Definition: indexedCellI.H:539
An indexed form of CGAL::Triangulation_cell_base_3<K> used to keep track of the Delaunay cells (tets)...
Definition: indexedCell.H:56
bool hasReferredPoint() const
Does the Delaunay cell have a referred point.
Definition: indexedCellI.H:193
bool baffleEdgeDualVertex() const
Definition: indexedCellI.H:467
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::FixedList< Foam::label, 4 > globallyOrderedCellVertices(const Foam::globalIndex &globalDelaunayVertexIndices) const
Using the globalIndex object, return a list of four vertices with.
Definition: indexedCellI.H:340
bool real() const
Is the Delaunay cell real, i.e. any real vertex.
Definition: indexedCellI.H:158
Foam::label & cellIndex()
Definition: indexedCellI.H:97
bool boundaryDualVertex() const
A dual vertex on the boundary will result from a Delaunay cell with.
Definition: indexedCellI.H:403
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
bool hasInternalPoint() const
Definition: indexedCellI.H:232
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:404
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
void Swap(T &a, T &b)
Definition: Swap.H:43
Cb::Cell_handle Cell_handle
Definition: indexedCell.H:119
label toGlobal(const label i) const
From local to global.
Definition: globalIndexI.H:82
static const Vector zero
Definition: Vector.H:80
const Foam::point dual()
Definition: indexedCellI.H:121
bool areParallel(const Vector< T > &a, const Vector< T > &b, const T &tolerance=SMALL)
Test if a and b are parallel: a^b = 0.
Definition: vectorTools.H:54
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
bool baffleSurfaceDualVertex() const
Definition: indexedCellI.H:446
bool hasConstrainedPoint() const
Definition: indexedCellI.H:258
prefixOSstream Pout(cout,"Pout")
Definition: IOstreams.H:53