shortestPathSet.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenCFD Ltd.
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 Class
27  Foam::shortestPathSet
28 
29 Description
30  Finds shortest path (in terms of cell centres) to walk on mesh from
31  any point in insidePoints to any point in outsidePoints.
32 
33 Usage
34  Example of function object specification:
35  \verbatim
36  leakFind
37  {
38  type sets;
39 
40  writeControl timeStep;
41  interpolationScheme cell;
42  setFormat vtk;
43 
44  sets
45  (
46  leakFind
47  {
48  type shortestPath;
49  insidePoints ((0.08 -0.020 -0.005) (-0.05 -0.020 -0.005));
50  outsidePoints ((-0.08 -0.020 -0.005)(0.05 -0.020 -0.005));
51  axis xyz;
52  }
53  );
54 
55  // Needs at least one field
56  fields ( p );
57  }
58  \endverbatim
59 
60  For a dictionary specification:
61  \table
62  Property | Description | Required | Default
63  type | shortestPath | yes |
64  axis | x, y, z, xyz, distance | yes |
65  insidePoints | The inside points | yes |
66  outsidePoints | The outside points | yes |
67  \endtable
68 
69 SourceFiles
70  shortestPathSet.C
71 
72 \*---------------------------------------------------------------------------*/
73 
74 #ifndef shortestPathSet_H
75 #define shortestPathSet_H
76 
77 #include "sampledSet.H"
78 #include "PackedBoolList.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 
85 class topoDistanceData;
86 
87 /*---------------------------------------------------------------------------*\
88  Class shortestPathSet Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class shortestPathSet
92 :
93  public sampledSet
94 {
95  // Private data
96 
97  //- Originating set of points
98  const pointField insidePoints_;
99 
100  //- Destination set of points
101  const pointField outsidePoints_;
102 
103 
104  // Private Member Functions
105 
106  //- Get face with least distance along route
107  static label findMinFace
108  (
109  const polyMesh& mesh,
110  const label cellI,
111  const List<topoDistanceData>& allFaceInfo,
112  const PackedBoolList& isLeakPoint,
113  const bool minDistance,
114  const point& origin
115  );
116 
117  //- Sync the leak path data
118  void sync
119  (
120  const polyMesh& mesh,
121  PackedBoolList& isLeakFace,
122  PackedBoolList& isLeakPoint,
123  const label celli,
124  point& origin,
125  bool& findMinDistance
126  ) const;
127 
128  //- Calculate (topological) distance to cellI
129  void calculateDistance
130  (
131  const label iter,
132  const polyMesh& mesh,
133  const label cellI,
134 
135  List<topoDistanceData>& allFaceInfo,
136  List<topoDistanceData>& allCellInfo
137  ) const;
138 
139  //- Checks if face uses a leak point
140  bool touchesWall
141  (
142  const polyMesh& mesh,
143  const label facei,
144 
145  PackedBoolList& isLeakFace,
146  const PackedBoolList& isLeakPoint
147  ) const;
148 
149  //- Calculate path between insideCelli (-1 if not on current processor)
150  // and outsidePoint. Appends cellcentres on path to track.
151  // isLeakCell : track passes through cell
152  // isLeakFace : faces of leak cells that are also on boundary
153  // isLeakPoint : points of leak faces ,,
154  void genSamples
155  (
156  const bool markLeakPath,
157  const label maxIter,
158  const polyMesh& mesh,
159  const boolList& isBlockedFace,
160  const point& insidePoint,
161  const label insideCelli,
162  const point& outsidePoint,
163 
164  DynamicList<point>& samplingPts,
165  DynamicList<label>& samplingCells,
166  DynamicList<label>& samplingFaces,
167  DynamicList<label>& samplingSegments,
168  DynamicList<scalar>& samplingCurveDist,
169  PackedBoolList& isLeakCell,
170  PackedBoolList& isLeakFace,
171  PackedBoolList& isLeakPoint
172  ) const;
173 
174  //- Generate whole path. With markLeakPath it will block all faces
175  // along the whole path so will maximise the chances of finding
176  // multiple gaps. With markLeakPath=false it will only block any
177  // faces connected to a boundary. This makes for the nicest
178  // hole-filling.
179  void genSamples
180  (
181  const bool markLeakPath, // mark all cells along path
182  const label maxIter,
183  const polyMesh& mesh,
184  const labelUList& wallPatches,
185  const boolList& blockedFace
186  );
187 
188 
189 public:
190 
191  //- Runtime type information
192  TypeName("shortestPath");
193 
194 
195  // Constructors
196 
197  //- Construct from components. blockedFace is an optional specification
198  // of face that behave as if a wall
200  (
201  const word& name,
202  const polyMesh& mesh,
203  const meshSearch& searchEngine,
204  const word& axis,
205  const bool markLeakPath,
206  const label maxIter,
207  const labelUList& wallPatches,
208  const pointField& insidePoints,
209  const pointField& outsidePoints,
210  const boolList& blockedFace
211  );
212 
213  //- Construct from dictionary
215  (
216  const word& name,
217  const polyMesh& mesh,
218  const meshSearch& searchEngine,
219  const dictionary& dict
220  );
221 
222 
223  //- Destructor
224  virtual ~shortestPathSet() = default;
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #endif
235 
236 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:83
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::shortestPathSet::TypeName
TypeName("shortestPath")
Runtime type information.
Foam::coordSet::name
const word & name() const
Definition: coordSet.H:125
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::meshSearch
Various (local, not parallel) searches on polyMesh; uses (demand driven) octree to search.
Definition: meshSearch.H:60
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:64
Foam::DynamicList< point >
Foam::sampledSet::searchEngine
const meshSearch & searchEngine() const
Definition: sampledSet.H:286
Foam::shortestPathSet::shortestPathSet
shortestPathSet(const word &name, const polyMesh &mesh, const meshSearch &searchEngine, const word &axis, const bool markLeakPath, const label maxIter, const labelUList &wallPatches, const pointField &insidePoints, const pointField &outsidePoints, const boolList &blockedFace)
Construct from components. blockedFace is an optional specification.
Definition: shortestPathSet.C:824
Foam::coordSet::axis
word axis() const
Definition: coordSet.H:130
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
sampledSet.H
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:62
Foam::Field< vector >
PackedBoolList.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::shortestPathSet
Finds shortest path (in terms of cell centres) to walk on mesh from any point in insidePoints to any ...
Definition: shortestPathSet.H:115
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledSet::mesh
const polyMesh & mesh() const
Definition: sampledSet.H:281
Foam::Vector< scalar >
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:102
Foam::UList< label >
insidePoints
insidePoints((1 2 3))
Foam::shortestPathSet::~shortestPathSet
virtual ~shortestPathSet()=default
Destructor.
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::PackedBoolList
bitSet PackedBoolList
Compatibility name. Superseded (MAR-2018) by Foam::bitSet.
Definition: PackedBoolList.H:40