1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Foam::distributedTriSurfaceMesh
29 IOoject and searching on distributed triSurface. All processor hold
30 (possibly overlapping) part of the overall surface. All queries are
31 distributed to the processor that can answer it and the result sent back.
33 Can work in three modes:
34 - follow : makes sure each processor has all the triangles inside the
35 externally provided bounding box (usually the mesh bounding box).
36 Guarantees minimum amount of communication since mesh-local queries
37 should be answerable without any comms.
38 - independent : surface is decomposed according to the triangle centres
39 so the decomposition might be radically different from the mesh
40 decomposition. Guarantees best memory balance but at the expense of
45 distributedTriSurfaceMesh.C
47 \*---------------------------------------------------------------------------*/
49 #ifndef distributedTriSurfaceMesh_H
50 #define distributedTriSurfaceMesh_H
52 #include "triSurfaceMesh.H"
53 #include "IOdictionary.H"
55 #include "globalIndex.H"
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 class decompositionMethod;
66 typedef Pair<point> segment;
68 inline bool contiguous<segment>() {return contiguous<point>();}
71 /*---------------------------------------------------------------------------*\
72 Class distributedTriSurfaceMesh Declaration
73 \*---------------------------------------------------------------------------*/
75 class distributedTriSurfaceMesh
90 static const NamedEnum<distributionType, 3> distributionTypeNames_;
94 // Private member data
99 //- Decomposition used when independently decomposing surface.
100 autoPtr<decompositionMethod> decomposer_;
102 //- Bounding box settings
105 //- bounding boxes of all processors
106 List<List<treeBoundBox> > procBb_;
108 //- Global triangle numbering
109 mutable autoPtr<globalIndex> globalTris_;
111 //- The distribution type.
112 distributionType distType_;
115 // Private Member Functions
119 //- Read my additional data
127 const List<treeBoundBox>& myBbs,
132 //- Split segment into subsegments overlapping the processor
134 //void Foam::distributedTriSurfaceMesh::splitSegment
136 // const label segmentI,
137 // const point& start,
139 // const treeBoundBox& bb,
141 // DynamicList<segment>& allSegments,
142 // DynamicList<label>& allSegmentMap,
143 // DynamicList<label> sendMap
146 //- Distribute segments into overlapping processor
147 // bounding boxes. Sort per processor.
148 void distributeSegment
154 DynamicList<segment>&,
156 List<DynamicList<label> >&
159 //- Divide edges into local and remote segments. Construct map to
160 // distribute and collect data.
161 autoPtr<mapDistribute> distributeSegments
163 const pointField& start,
164 const pointField& end,
166 List<segment>& allSegments,
167 List<label>& allSegmentMap
170 //- Split edges, distribute, test and collect.
173 const bool nearestIntersection,
174 const pointField& start,
175 const pointField& end,
176 List<pointIndexHit>& info
182 //- Obtains global indices from pointIndexHit and swaps them back
183 // to their original processor. Used to calculate local region
185 autoPtr<mapDistribute> calcLocalQueries
187 const List<pointIndexHit>&,
188 labelList& triangleIndex
194 label calcOverlappingProcs
197 const scalar radiusSqr,
201 autoPtr<mapDistribute> calcLocalQueries
203 const pointField& centres,
204 const scalarField& radiusSqr,
206 pointField& allCentres,
207 scalarField& allRadiusSqr,
208 labelList& allSegmentMap
212 // Surface redistribution
214 //- Finds new bounds based on an indepedent decomposition.
215 List<List<treeBoundBox> > independentlyDistributedBbs
220 //- Does any part of triangle overlap bb.
223 const List<treeBoundBox>& bb,
229 //- Find points used in subset
230 static void subsetMeshMap
233 const boolList& include,
234 const label nIncluded,
235 labelList& newToOldPoints,
236 labelList& oldToNewPoints,
237 labelList& newToOldFaces
240 //- Construct subsetted surface
241 static triSurface subsetMesh
244 const labelList& newToOldPoints,
245 const labelList& oldToNewPoints,
246 const labelList& newToOldFaces
249 //- Subset given marked faces
250 static triSurface subsetMesh
253 const boolList& include,
254 labelList& newToOldPoints,
255 labelList& newToOldFaces
258 //- Subset given marked faces
259 static triSurface subsetMesh
262 const labelList& newToOldFaces,
263 labelList& newToOldPoints
266 //- Find triangle otherF in allFaces.
267 static label findTriangle
269 const List<labelledTri>& allFaces,
270 const labelListList& allPointFaces,
271 const labelledTri& otherF
274 //- Merge triSurface (subTris, subPoints) into allTris, allPoints.
277 const scalar mergeDist,
278 const List<labelledTri>& subTris,
279 const pointField& subPoints,
281 List<labelledTri>& allTris,
282 pointField& allPoints,
284 labelList& faceConstructMap,
285 labelList& pointConstructMap
288 //- Distribute stored fields
290 void distributeFields(const mapDistribute& map);
293 //- Disallow default bitwise copy construct
294 distributedTriSurfaceMesh(const distributedTriSurfaceMesh&);
296 //- Disallow default bitwise assignment
297 void operator=(const distributedTriSurfaceMesh&);
302 //- Runtime type information
303 TypeName("distributedTriSurfaceMesh");
308 //- Construct from triSurface
309 distributedTriSurfaceMesh
313 const dictionary& dict
316 //- Construct read. Does findInstance to find io.local().
317 distributedTriSurfaceMesh(const IOobject& io);
319 //- Construct from dictionary (used by searchableSurface).
320 // Does read. Does findInstance to find io.local().
321 distributedTriSurfaceMesh
324 const dictionary& dict
330 virtual ~distributedTriSurfaceMesh();
338 //- Triangle indexing (demand driven)
339 const globalIndex& globalTris() const;
342 // searchableSurface implementation
344 //- Whether supports volume type below. I.e. whether is closed.
346 virtual bool hasVolumeType() const
351 //- Range of global indices that can be returned.
352 virtual label globalSize() const
354 return globalTris().size();
357 virtual void findNearest
359 const pointField& sample,
360 const scalarField& nearestDistSqr,
364 virtual void findLine
366 const pointField& start,
367 const pointField& end,
371 virtual void findLineAny
373 const pointField& start,
374 const pointField& end,
378 //- Get all intersections in order from start to end.
379 virtual void findLineAll
381 const pointField& start,
382 const pointField& end,
383 List<List<pointIndexHit> >&
386 //- From a set of points and indices get the region
387 virtual void getRegion
389 const List<pointIndexHit>&,
393 //- From a set of points and indices get the normal
394 virtual void getNormal
396 const List<pointIndexHit>&,
400 //- Determine type (inside/outside/mixed) for point. unknown if
401 // cannot be determined (e.g. non-manifold surface)
402 virtual void getVolumeType
408 //- Set bounds of surface. Bounds currently set as list of
409 // bounding boxes. Will do redistribution of surface to locally
410 // have all triangles overlapping bounds.
411 // Larger bounds: more triangles (memory), more fully local tests
413 // keepNonLocal = true : keep triangles that do not overlap
414 // any processor bounds.
415 // Should really be split into a routine to determine decomposition
416 // and one that does actual distribution but determining
417 // decomposition with duplicate triangle merging requires
418 // same amount as work as actual distribution.
419 virtual void distribute
421 const List<treeBoundBox>&,
422 const bool keepNonLocal,
423 autoPtr<mapDistribute>& faceMap,
424 autoPtr<mapDistribute>& pointMap
430 //- WIP. From a set of hits (points and
431 // indices) get the specified field. Misses do not get set.
432 virtual void getField(const List<pointIndexHit>&, labelList&) const;
434 //- Subset the part of surface that is overlapping bounds.
435 static triSurface overlappingSurface
438 const List<treeBoundBox>&,
439 labelList& subPointMap,
440 labelList& subFaceMap
443 //- Print some stats. Parallel aware version of
444 // triSurface::writeStats.
445 void writeStats(Ostream& os) const;
448 // regIOobject implementation
450 //- Write using given format, version and compression
451 virtual bool writeObject
453 IOstream::streamFormat fmt,
454 IOstream::versionNumber ver,
455 IOstream::compressionType cmp
461 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
463 } // End namespace Foam
465 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
468 # include "distributedTriSurfaceMeshTemplates.C"
471 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
475 // ************************************************************************* //