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-2020 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 "bitSet.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 
85 template<class Type> 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  //- Local faces that were closed
104  labelList leakFaces_;
105 
106 
107  // Private Member Functions
108 
109  //- Get face with least distance along route
110  static label findMinFace
111  (
112  const polyMesh& mesh,
113  const label cellI,
114  const List<topoDistanceData<label>>& allFaceInfo,
115  const bitSet& isLeakPoint,
116  const bool minDistance,
117  const point& origin
118  );
119 
120  //- Sync the leak path data
121  void sync
122  (
123  const polyMesh& mesh,
124  bitSet& isLeakFace,
125  bitSet& isLeakPoint,
126  const label celli,
127  point& origin,
128  bool& findMinDistance
129  ) const;
130 
131  //- Calculate (topological) distance to cellI
132  void calculateDistance
133  (
134  const label iter,
135  const polyMesh& mesh,
136  const label cellI,
137 
138  List<topoDistanceData<label>>& allFaceInfo,
139  List<topoDistanceData<label>>& allCellInfo
140  ) const;
141 
142  //- Checks if face uses a leak point
143  bool touchesWall
144  (
145  const polyMesh& mesh,
146  const label facei,
147 
148  bitSet& isLeakFace,
149  const bitSet& isLeakPoint
150  ) const;
151 
152  //- Removes open-edged faces from set. Ignores edges with both points
153  // in isBlockedPoint. Returns global number of faces removed from set.
154  label erodeFaceSet
155  (
156  const polyMesh& mesh,
157  const bitSet& isBlockedPoint,
158  bitSet& isLeakFace
159  ) const;
160 
161  //- Mark faces inbetween leak cells
162  bitSet pathFaces(const polyMesh& mesh, const bitSet& isLeakCell) const;
163 
164  //- Calculate path between insideCelli (-1 if not on current processor)
165  // and outsidePoint. Appends cellcentres on path to track.
166  // isLeakCell : track passes through cell
167  // isLeakFace : faces of leak cells that are also on boundary
168  // isLeakPoint : points of leak faces ,,
169  // Returns true if new path found, false otherwise
170  bool genSingleLeakPath
171  (
172  const bool markLeakPath,
173  const label iter,
174  const polyMesh& mesh,
175  const bitSet& isBlockedFace,
176  const point& insidePoint,
177  const label insideCelli,
178  const point& outsidePoint,
179  const label outsideCelli,
180 
181  // Generated sampling points
182  const scalar trackLength,
183  DynamicList<point>& samplingPts,
184  DynamicList<label>& samplingCells,
185  DynamicList<label>& samplingFaces,
186  DynamicList<label>& samplingSegments,
187  DynamicList<scalar>& samplingCurveDist,
188 
189  // State of current leak paths
190  bitSet& isLeakCell,
191  bitSet& isLeakFace,
192  bitSet& isLeakPoint,
193 
194  // Work storage
195  List<topoDistanceData<label>>& allFaceInfo,
196  List<topoDistanceData<label>>& allCellInfo
197  ) const;
198 
199  //- Calculate path between insideCelli (-1 if not on current processor)
200  // and outsidePoint. Appends cellcentres on path to track.
201  // isLeakCell : track passes through cell
202  // isLeakFace : faces of leak cells that are also on boundary
203  // isLeakPoint : points of leak faces ,,
204  void genSamples
205  (
206  const bool markLeakPath,
207  const label maxIter,
208  const polyMesh& mesh,
209  const bitSet& isBlockedFace,
210  const point& insidePoint,
211  const label insideCelli,
212  const point& outsidePoint,
213 
214  DynamicList<point>& samplingPts,
215  DynamicList<label>& samplingCells,
216  DynamicList<label>& samplingFaces,
217  DynamicList<label>& samplingSegments,
218  DynamicList<scalar>& samplingCurveDist,
219  bitSet& isLeakCell,
220  bitSet& isLeakFace,
221  bitSet& isLeakPoint
222  ) const;
223 
224  //- Generate whole path. With markLeakPath it will block all faces
225  // along the whole path so will maximise the chances of finding
226  // multiple gaps. With markLeakPath=false it will only block any
227  // faces connected to a boundary. This makes for the nicest
228  // hole-filling.
229  void genSamples
230  (
231  const bool markLeakPath, // mark all cells along path
232  const label maxIter,
233  const polyMesh& mesh,
234  const labelUList& wallPatches,
235  const bitSet& blockedFace
236  );
237 
238 
239 public:
240 
241  //- Runtime type information
242  TypeName("shortestPath");
243 
244 
245  // Constructors
246 
247  //- Construct from components. blockedFace is an optional specification
248  // of face that behave as if a wall
250  (
251  const word& name,
252  const polyMesh& mesh,
253  const meshSearch& searchEngine,
254  const word& axis,
255  const bool markLeakPath,
256  const label maxIter,
257  const labelUList& wallPatches,
258  const pointField& insidePoints,
259  const pointField& outsidePoints,
260  const boolList& blockedFace
261  );
262 
263  //- Construct from dictionary
265  (
266  const word& name,
267  const polyMesh& mesh,
268  const meshSearch& searchEngine,
269  const dictionary& dict
270  );
271 
272 
273  //- Destructor
274  virtual ~shortestPathSet() = default;
275 
276 
277  // Member Functions
278 
279  //- Set of mesh faces needed to close the gap. Will close the gap but
280  // might be bigger than required
281  const labelList& leakFaces() const
282  {
283  return leakFaces_;
284  }
285 };
286 
287 
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
289 
290 } // End namespace Foam
291 
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
293 
294 #endif
295 
296 // ************************************************************************* //
Foam::sampledSet
Holds list of sampling points which is filled at construction time. Various implementations of this b...
Definition: sampledSet.H:83
Foam::shortestPathSet::leakFaces
const labelList & leakFaces() const
Set of mesh faces needed to close the gap. Will close the gap but.
Definition: shortestPathSet.H:305
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
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::topoDistanceData
For use with FaceCellWave. Determines topological distance to starting faces. Templated on passive tr...
Definition: topoDistanceData.H:53
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
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:63
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:1300
bitSet.H
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::Field< vector >
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:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledSet::mesh
const polyMesh & mesh() const
Definition: sampledSet.H:281
Foam::Vector< scalar >
Foam::List< label >
Foam::UList< label >
insidePoints
insidePoints((1 2 3))
Foam::shortestPathSet::~shortestPathSet
virtual ~shortestPathSet()=default
Destructor.