FreeFOAM The Cross-Platform CFD Toolkit
findInjectorCell.H
Go to the documentation of this file.
1 {
2 
3 bool foundCell = false;
4 if (injectorCell >= 0)
5 {
6  const vector& C = mesh_.C()[injectorCell];
7  injectionPosition += 1.0e-9*(C - injectionPosition);
8 
9  foundCell = mesh_.pointInCell
10  (
11  injectionPosition,
12  injectorCell
13  );
14 }
15 
16 reduce(foundCell, orOp<bool>());
17 
18 // NN.
19 // Due to the disc injection, the injectionPosition
20 // can be moved outside the domain.
21 // try point injection
22 
23 if (!foundCell)
24 {
25  injectionPosition = it->position(n);
26  injectorCell = mesh_.findCell(injectionPosition);
27 
28  if (injectorCell >= 0)
29  {
30  const vector& C = mesh_.C()[injectorCell];
31  injectionPosition += 1.0e-6*(C - injectionPosition);
32 
33  foundCell = mesh_.pointInCell
34  (
35  injectionPosition,
36  injectorCell
37  );
38  }
39  reduce(foundCell, orOp<bool>());
40 
41  // if point injection also failed then
42  // find nearest cell and try that one
43  // the point is probably on an edge
44  if (!foundCell)
45  {
46  injectorCell =
47  mesh_.findNearestCell(injectionPosition);
48 
49  if (injectorCell >= 0)
50  {
51 
52  const vector& C = mesh_.C()[injectorCell];
53  injectionPosition += 1.0e-9*(C - injectionPosition);
54 
55  foundCell = mesh_.pointInCell
56  (
57  injectionPosition,
58  injectorCell
59  );
60  }
61  reduce(foundCell, orOp<bool>());
62 
63  if (!foundCell)
64  {
65  FatalError
66  << "Cannot find injection position "
67  << injectionPosition
68  << abort(FatalError);
69  }
70  }
71 }
72 
73 }
74 
75 // ************************ vim: set sw=4 sts=4 et: ************************ //