00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef distributedTriSurfaceMesh_H
00049 #define distributedTriSurfaceMesh_H
00050
00051 #include "triSurfaceMesh.H"
00052 #include <OpenFOAM/IOdictionary.H>
00053 #include <OpenFOAM/Pair.H>
00054 #include <OpenFOAM/globalIndex.H>
00055
00056
00057
00058 namespace Foam
00059 {
00060
00061 class mapDistribute;
00062 class decompositionMethod;
00063
00064
00065 typedef Pair<point> segment;
00066 template<>
00067 inline bool contiguous<segment>() {return contiguous<point>();}
00068
00069
00070
00071
00072
00073
00074 class distributedTriSurfaceMesh
00075 :
00076 public triSurfaceMesh
00077 {
00078 public:
00079
00080
00081
00082 enum distributionType
00083 {
00084 FOLLOW = 0,
00085 INDEPENDENT = 1,
00086 FROZEN = 2
00087 };
00088
00089 static const NamedEnum<distributionType, 3> distributionTypeNames_;
00090
00091 private:
00092
00093
00094
00095
00096 scalar mergeDist_;
00097
00098
00099 autoPtr<decompositionMethod> decomposer_;
00100
00101
00102 IOdictionary dict_;
00103
00104
00105 List<List<treeBoundBox> > procBb_;
00106
00107
00108 mutable autoPtr<globalIndex> globalTris_;
00109
00110
00111 distributionType distType_;
00112
00113
00114
00115
00116
00117
00118
00119 bool read();
00120
00121
00122
00123
00124 static bool isLocal
00125 (
00126 const List<treeBoundBox>& myBbs,
00127 const point& start,
00128 const point& end
00129 );
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 void distributeSegment
00148 (
00149 const label,
00150 const point& start,
00151 const point& end,
00152
00153 DynamicList<segment>&,
00154 DynamicList<label>&,
00155 List<DynamicList<label> >&
00156 ) const;
00157
00158
00159
00160 autoPtr<mapDistribute> distributeSegments
00161 (
00162 const pointField& start,
00163 const pointField& end,
00164
00165 List<segment>& allSegments,
00166 List<label>& allSegmentMap
00167 ) const;
00168
00169
00170 void findLine
00171 (
00172 const bool nearestIntersection,
00173 const pointField& start,
00174 const pointField& end,
00175 List<pointIndexHit>& info
00176 ) const;
00177
00178
00179
00180
00181
00182
00183
00184 autoPtr<mapDistribute> calcLocalQueries
00185 (
00186 const List<pointIndexHit>&,
00187 labelList& triangleIndex
00188 ) const;
00189
00190
00191
00192
00193 label calcOverlappingProcs
00194 (
00195 const point& centre,
00196 const scalar radiusSqr,
00197 boolList& overlaps
00198 ) const;
00199
00200 autoPtr<mapDistribute> calcLocalQueries
00201 (
00202 const pointField& centres,
00203 const scalarField& radiusSqr,
00204
00205 pointField& allCentres,
00206 scalarField& allRadiusSqr,
00207 labelList& allSegmentMap
00208 ) const;
00209
00210
00211
00212
00213
00214 List<List<treeBoundBox> > independentlyDistributedBbs
00215 (
00216 const triSurface&
00217 );
00218
00219
00220 static bool overlaps
00221 (
00222 const List<treeBoundBox>& bb,
00223 const point& p0,
00224 const point& p1,
00225 const point& p2
00226 );
00227
00228
00229 static void subsetMeshMap
00230 (
00231 const triSurface& s,
00232 const boolList& include,
00233 const label nIncluded,
00234 labelList& newToOldPoints,
00235 labelList& oldToNewPoints,
00236 labelList& newToOldFaces
00237 );
00238
00239
00240 static triSurface subsetMesh
00241 (
00242 const triSurface& s,
00243 const labelList& newToOldPoints,
00244 const labelList& oldToNewPoints,
00245 const labelList& newToOldFaces
00246 );
00247
00248
00249 static triSurface subsetMesh
00250 (
00251 const triSurface& s,
00252 const boolList& include,
00253 labelList& newToOldPoints,
00254 labelList& newToOldFaces
00255 );
00256
00257
00258 static triSurface subsetMesh
00259 (
00260 const triSurface& s,
00261 const labelList& newToOldFaces,
00262 labelList& newToOldPoints
00263 );
00264
00265
00266 static label findTriangle
00267 (
00268 const List<labelledTri>& allFaces,
00269 const labelListList& allPointFaces,
00270 const labelledTri& otherF
00271 );
00272
00273
00274 static void merge
00275 (
00276 const scalar mergeDist,
00277 const List<labelledTri>& subTris,
00278 const pointField& subPoints,
00279
00280 List<labelledTri>& allTris,
00281 pointField& allPoints,
00282
00283 labelList& faceConstructMap,
00284 labelList& pointConstructMap
00285 );
00286
00287
00288 template<class Type>
00289 void distributeFields(const mapDistribute& map);
00290
00291
00292
00293 distributedTriSurfaceMesh(const distributedTriSurfaceMesh&);
00294
00295
00296 void operator=(const distributedTriSurfaceMesh&);
00297
00298
00299 public:
00300
00301
00302 TypeName("distributedTriSurfaceMesh");
00303
00304
00305
00306
00307
00308 distributedTriSurfaceMesh
00309 (
00310 const IOobject&,
00311 const triSurface&,
00312 const dictionary& dict
00313 );
00314
00315
00316 distributedTriSurfaceMesh(const IOobject& io);
00317
00318
00319
00320 distributedTriSurfaceMesh
00321 (
00322 const IOobject& io,
00323 const dictionary& dict
00324 );
00325
00326
00327
00328
00329 virtual ~distributedTriSurfaceMesh();
00330
00331
00332 void clearOut();
00333
00334
00335
00336
00337
00338 const globalIndex& globalTris() const;
00339
00340
00341
00342
00343
00344
00345 virtual bool hasVolumeType() const
00346 {
00347 return false;
00348 }
00349
00350
00351 virtual label globalSize() const
00352 {
00353 return globalTris().size();
00354 }
00355
00356 virtual void findNearest
00357 (
00358 const pointField& sample,
00359 const scalarField& nearestDistSqr,
00360 List<pointIndexHit>&
00361 ) const;
00362
00363 virtual void findLine
00364 (
00365 const pointField& start,
00366 const pointField& end,
00367 List<pointIndexHit>&
00368 ) const;
00369
00370 virtual void findLineAny
00371 (
00372 const pointField& start,
00373 const pointField& end,
00374 List<pointIndexHit>&
00375 ) const;
00376
00377
00378 virtual void findLineAll
00379 (
00380 const pointField& start,
00381 const pointField& end,
00382 List<List<pointIndexHit> >&
00383 ) const;
00384
00385
00386 virtual void getRegion
00387 (
00388 const List<pointIndexHit>&,
00389 labelList& region
00390 ) const;
00391
00392
00393 virtual void getNormal
00394 (
00395 const List<pointIndexHit>&,
00396 vectorField& normal
00397 ) const;
00398
00399
00400
00401 virtual void getVolumeType
00402 (
00403 const pointField&,
00404 List<volumeType>&
00405 ) const;
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418 virtual void distribute
00419 (
00420 const List<treeBoundBox>&,
00421 const bool keepNonLocal,
00422 autoPtr<mapDistribute>& faceMap,
00423 autoPtr<mapDistribute>& pointMap
00424 );
00425
00426
00427
00428
00429
00430
00431 virtual void getField(const List<pointIndexHit>&, labelList&) const;
00432
00433
00434 static triSurface overlappingSurface
00435 (
00436 const triSurface&,
00437 const List<treeBoundBox>&,
00438 labelList& subPointMap,
00439 labelList& subFaceMap
00440 );
00441
00442
00443
00444 void writeStats(Ostream& os) const;
00445
00446
00447
00448
00449
00450 virtual bool writeObject
00451 (
00452 IOstream::streamFormat fmt,
00453 IOstream::versionNumber ver,
00454 IOstream::compressionType cmp
00455 ) const;
00456
00457 };
00458
00459
00460
00461
00462 }
00463
00464
00465
00466 #ifdef NoRepository
00467 # include "distributedTriSurfaceMeshTemplates.C"
00468 #endif
00469
00470
00471
00472 #endif
00473
00474