shootRays_CGAL.H
Go to the documentation of this file.
1 // Maximum length for dynamicList
2 const label maxDynListLength
3 (
4  viewFactorDict.getOrDefault<label>("maxDynListLength", 1000000000)
5 );
6 
7 for (const int proci : Pstream::allProcs())
8 {
9  std::vector<Point> start;
10  start.reserve(coarseMesh.nFaces());
11 
12  std::vector<Point> end(start.size());
13  end.reserve(start.size());
14 
15  DynamicList<label> startIndex(start.size());
16  DynamicList<label> endIndex(start.size());
17 
18  DynamicList<label> startAgg(start.size());
19  DynamicList<label> endAgg(start.size());
20 
21  const pointField& myFc = remoteCoarseCf[Pstream::myProcNo()];
22  const vectorField& myArea = remoteCoarseSf[Pstream::myProcNo()];
23  const labelField& myAgg = remoteCoarseAgg[Pstream::myProcNo()];
24 
25  const pointField& remoteArea = remoteCoarseSf[proci];
26  const pointField& remoteFc = remoteCoarseCf[proci];
27  const labelField& remoteAgg = remoteCoarseAgg[proci];
28 
29  label i = 0;
30  label j = 0;
31  do
32  {
33  for (; i < myFc.size(); i++)
34  {
35  const point& fc = myFc[i];
36  const vector& fA = myArea[i];
37  const label& fAgg = myAgg[i];
38 
39  for (; j < remoteFc.size(); j++)
40  {
41  if (proci != Pstream::myProcNo() || i != j)
42  {
43  const point& remFc = remoteFc[j];
44  const vector& remA = remoteArea[j];
45  const label& remAgg = remoteAgg[j];
46 
47  const vector d(remFc - fc);
48 
49 
50  const vector nd = d/mag(d);
51  const vector nfA = fA/mag(fA);
52  const vector nremA = remA/mag(remA);
53 
54  if (((nd & nfA) < 0) && ((nd & nremA) > 0))
55  {
56  vector direction(d[0], d[1], d[2]);
57  vector s(fc[0], fc[1], fc[2]);
58  vector rayEnd(s + (1-intTol)*direction);
59  end.push_back(Point(rayEnd[0], rayEnd[1], rayEnd[2]));
60 
61  s += vector(intTol*d[0], intTol*d[1], intTol*d[2]);
62 
63  start.push_back(Point(s[0], s[1], s[2]));
64  startIndex.append(i);
65  if (useAgglomeration)
66  {
67  startAgg.append
68  (
69  globalNumbering.toGlobal(proci, fAgg)
70  );
71  endAgg.append
72  (
73  globalNumbering.toGlobal(proci, remAgg)
74  );
75  }
76 
77  label globalI = globalNumbering.toGlobal(proci, j);
78  endIndex.append(globalI);
79 
80  if (startIndex.size() > maxDynListLength)
81  {
83  << "Dynamic list need from capacity."
84  << "Actual size maxDynListLength : "
86  << abort(FatalError);
87  }
88  }
89  }
90  }
91 
92  if (j == remoteFc.size())
93  {
94  j = 0;
95  }
96  }
97 
98  } while (i < myFc.size());
99 
100  label totalRays(startIndex.size());
101  reduce(totalRays, sumOp<scalar>());
102 
103  if (debug)
104  {
105  Pout<< "Number of rays :" << totalRays << endl;
106  }
107 
108  for (unsigned long rayI = 0; rayI < start.size(); ++rayI)
109  {
110  Segment ray(start[rayI], end[rayI]);
111  Segment_intersection intersects = tree.any_intersection(ray);
112 
113  if (!intersects)
114  {
115  rayStartFace.append(startIndex[rayI]);
116  rayEndFace.append(endIndex[rayI]);
117  }
118  }
119  start.clear();
120 
121  if (debug)
122  {
123  Pout << "hits : " << rayStartFace.size()<< endl;
124  }
125 
126  startIndex.clear();
127  end.clear();
128  endIndex.clear();
129  startAgg.clear();
130  endAgg.clear();
131 }
Field< label > labelField
Specialisation of Field<T> for label.
Definition: labelField.H:48
uint8_t direction
Definition: direction.H:46
const label maxDynListLength(viewFactorDict.getOrDefault< label >("maxDynListLength", 1000000000))
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
Tree tree(triangles.begin(), triangles.end())
Vector< scalar > vector
Definition: vector.H:57
errorManip< error > abort(error &err)
Definition: errorManip.H:139
int debug
Static debugging option.
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:201
CGAL::Point_3< K > Point
vector point
Point is a vector.
Definition: point.H:37
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
Field< vector > vectorField
Specialisation of Field<T> for vector.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
CGAL::Segment_3< K > Segment