1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Foam::distributedTriSurfaceMesh
28 IOoject and searching on distributed triSurface. All processor hold
29 (possibly overlapping) part of the overall surface. All queries are
30 distributed to the processor that can answer it and the result sent back.
32 Can work in three modes:
33 - follow : makes sure each processor has all the triangles inside the
34 externally provided bounding box (usually the mesh bounding box).
35 Guarantees minimum amount of communication since mesh-local queries
36 should be answerable without any comms.
37 - independent : surface is decomposed according to the triangle centres
38 so the decomposition might be radically different from the mesh
39 decomposition. Guarantees best memory balance but at the expense of
44 distributedTriSurfaceMesh.C
46 \*---------------------------------------------------------------------------*/
48 #ifndef distributedTriSurfaceMesh_H
49 #define distributedTriSurfaceMesh_H
51 #include "triSurfaceMesh.H"
52 #include "IOdictionary.H"
54 #include "globalIndex.H"
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 class decompositionMethod;
65 typedef Pair<point> segment;
67 inline bool contiguous<segment>() {return contiguous<point>();}
70 /*---------------------------------------------------------------------------*\
71 Class distributedTriSurfaceMesh Declaration
72 \*---------------------------------------------------------------------------*/
74 class distributedTriSurfaceMesh
89 static const NamedEnum<distributionType, 3> distributionTypeNames_;
93 // Private member data
98 //- Decomposition used when independently decomposing surface.
99 autoPtr<decompositionMethod> decomposer_;
101 //- Bounding box settings
104 //- bounding boxes of all processors
105 List<List<treeBoundBox> > procBb_;
107 //- Global triangle numbering
108 mutable autoPtr<globalIndex> globalTris_;
110 //- The distribution type.
111 distributionType distType_;
114 // Private Member Functions
118 //- Read my additional data
126 const List<treeBoundBox>& myBbs,
131 //- Split segment into subsegments overlapping the processor
133 //void Foam::distributedTriSurfaceMesh::splitSegment
135 // const label segmentI,
136 // const point& start,
138 // const treeBoundBox& bb,
140 // DynamicList<segment>& allSegments,
141 // dynamicLabelList& allSegmentMap,
142 // dynamicLabelList sendMap
145 //- Distribute segments into overlapping processor
146 // bounding boxes. Sort per processor.
147 void distributeSegment
153 DynamicList<segment>&,
155 List<dynamicLabelList >&
158 //- Divide edges into local and remote segments. Construct map to
159 // distribute and collect data.
160 autoPtr<mapDistribute> distributeSegments
162 const pointField& start,
163 const pointField& end,
165 List<segment>& allSegments,
166 List<label>& allSegmentMap
169 //- Split edges, distribute, test and collect.
172 const bool nearestIntersection,
173 const pointField& start,
174 const pointField& end,
175 List<pointIndexHit>& info
181 //- Obtains global indices from pointIndexHit and swaps them back
182 // to their original processor. Used to calculate local region
184 autoPtr<mapDistribute> calcLocalQueries
186 const List<pointIndexHit>&,
187 labelList& triangleIndex
193 label calcOverlappingProcs
196 const scalar radiusSqr,
200 autoPtr<mapDistribute> calcLocalQueries
202 const pointField& centres,
203 const scalarField& radiusSqr,
205 pointField& allCentres,
206 scalarField& allRadiusSqr,
207 labelList& allSegmentMap
211 // Surface redistribution
213 //- Finds new bounds based on an indepedent decomposition.
214 List<List<treeBoundBox> > independentlyDistributedBbs
219 //- Does any part of triangle overlap bb.
222 const List<treeBoundBox>& bb,
228 //- Find points used in subset
229 static void subsetMeshMap
232 const boolList& include,
233 const label nIncluded,
234 labelList& newToOldPoints,
235 labelList& oldToNewPoints,
236 labelList& newToOldFaces
239 //- Construct subsetted surface
240 static triSurface subsetMesh
243 const labelList& newToOldPoints,
244 const labelList& oldToNewPoints,
245 const labelList& newToOldFaces
248 //- Subset given marked faces
249 static triSurface subsetMesh
252 const boolList& include,
253 labelList& newToOldPoints,
254 labelList& newToOldFaces
257 //- Subset given marked faces
258 static triSurface subsetMesh
261 const labelList& newToOldFaces,
262 labelList& newToOldPoints
265 //- Find triangle otherF in allFaces.
266 static label findTriangle
268 const List<labelledTri>& allFaces,
269 const labelListList& allPointFaces,
270 const labelledTri& otherF
273 //- Merge triSurface (subTris, subPoints) into allTris, allPoints.
276 const scalar mergeDist,
277 const List<labelledTri>& subTris,
278 const pointField& subPoints,
280 List<labelledTri>& allTris,
281 pointField& allPoints,
283 labelList& faceConstructMap,
284 labelList& pointConstructMap
287 //- Distribute stored fields
289 void distributeFields(const mapDistribute& map);
292 //- Disallow default bitwise copy construct
293 distributedTriSurfaceMesh(const distributedTriSurfaceMesh&);
295 //- Disallow default bitwise assignment
296 void operator=(const distributedTriSurfaceMesh&);
301 //- Runtime type information
302 TypeName("distributedTriSurfaceMesh");
307 //- Construct from triSurface
308 distributedTriSurfaceMesh
312 const dictionary& dict
315 //- Construct read. Does findInstance to find io.local().
316 distributedTriSurfaceMesh(const IOobject& io);
318 //- Construct from dictionary (used by searchableSurface).
319 // Does read. Does findInstance to find io.local().
320 distributedTriSurfaceMesh
323 const dictionary& dict
329 virtual ~distributedTriSurfaceMesh();
337 //- Triangle indexing (demand driven)
338 const globalIndex& globalTris() const;
341 // searchableSurface implementation
343 //- Whether supports volume type below. I.e. whether is closed.
345 virtual bool hasVolumeType() const
350 //- Range of global indices that can be returned.
351 virtual label globalSize() const
353 return globalTris().size();
356 virtual void findNearest
358 const pointField& sample,
359 const scalarField& nearestDistSqr,
363 virtual void findLine
365 const pointField& start,
366 const pointField& end,
370 virtual void findLineAny
372 const pointField& start,
373 const pointField& end,
377 //- Get all intersections in order from start to end.
378 virtual void findLineAll
380 const pointField& start,
381 const pointField& end,
382 List<List<pointIndexHit> >&
385 //- From a set of points and indices get the region
386 virtual void getRegion
388 const List<pointIndexHit>&,
392 //- From a set of points and indices get the normal
393 virtual void getNormal
395 const List<pointIndexHit>&,
399 //- Determine type (inside/outside/mixed) for point. unknown if
400 // cannot be determined (e.g. non-manifold surface)
401 virtual void getVolumeType
407 //- Set bounds of surface. Bounds currently set as list of
408 // bounding boxes. Will do redistribution of surface to locally
409 // have all triangles overlapping bounds.
410 // Larger bounds: more triangles (memory), more fully local tests
412 // keepNonLocal = true : keep triangles that do not overlap
413 // any processor bounds.
414 // Should really be split into a routine to determine decomposition
415 // and one that does actual distribution but determining
416 // decomposition with duplicate triangle merging requires
417 // same amount as work as actual distribution.
418 virtual void distribute
420 const List<treeBoundBox>&,
421 const bool keepNonLocal,
422 autoPtr<mapDistribute>& faceMap,
423 autoPtr<mapDistribute>& pointMap
429 //- WIP. From a set of hits (points and
430 // indices) get the specified field. Misses do not get set.
431 virtual void getField(const List<pointIndexHit>&, labelList&) const;
433 //- Subset the part of surface that is overlapping bounds.
434 static triSurface overlappingSurface
437 const List<treeBoundBox>&,
438 labelList& subPointMap,
439 labelList& subFaceMap
442 //- Print some stats. Parallel aware version of
443 // triSurface::writeStats.
444 void writeStats(Ostream& os) const;
447 // regIOobject implementation
449 //- Write using given format, version and compression
450 virtual bool writeObject
452 IOstream::streamFormat fmt,
453 IOstream::versionNumber ver,
454 IOstream::compressionType cmp
460 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
462 } // End namespace Foam
464 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
467 # include "distributedTriSurfaceMeshTemplates.C"
470 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
474 // ************************************************************************* //