|
|
|
faceCoupleInfo.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00024 00025 Class 00026 faceCoupleInfo 00027 00028 Description 00029 Container for information needed to couple to meshes. When constructed from 00030 two meshes and a geometric tolerance finds the corresponding boundary faces. 00031 00032 The information it keeps is the set of faces&points (cutFaces, cutPoints) 00033 that should replace a set of faces on the master (masterPatch) and 00034 a set of faces on the slave (slavePatch) 00035 00036 00037 Uses same tolerance to match faces and points on matched faces since 00038 they both originate from the same points and the tolerance usually 00039 comes from writing these points with limited precision (6 by default) 00040 00041 1) Perfect match: 00042 - one-to-one match for faces and points. 00043 - the cut is always the 'most connected' of the master and slave so 00044 multiple master or slave points might point to the same cut point. 00045 00046 e.g. master: 00047 +--+ 00048 | | 00049 | | 00050 +--+ 00051 +--+ 00052 | | 00053 | | 00054 +--+ 00055 slave: 00056 +--+ 00057 | | 00058 | | 00059 +--+ 00060 +--+ 00061 | | 00062 | | 00063 +--+ 00064 adding both together creates a singly connected 2x2 cavity so suddenly 00065 the duplicate master points and the duplicate slave points all become 00066 a single cut point. 00067 00068 00069 2) Subdivision match: 00070 - Can be constructed from slave being subdivision of master with the 00071 polyPatch constructor. 00072 - Does not include above shared-point detection! 00073 00074 Notes on multiple slave faces per master: 00075 00076 As long as 00077 - all master edges are present in slave 00078 - slave can have extra edges/points/faces BUT all subfaces have to have 00079 at least one point on a maste face. 00080 00081 So master: 00082 +-------+ 00083 | | 00084 | | 00085 | | 00086 | | 00087 | | 00088 | | 00089 | | 00090 +-------+ 00091 00092 slave: 00093 +---+---+ 00094 |\ | /| 00095 | \ | / | 00096 | \|/ | 00097 +---+---+ 00098 | /|\ | 00099 | / | \ | 00100 |/ | \| 00101 +---+---+ 00102 00103 is ok. 00104 00105 For this kind of matching the order is: 00106 - match cutpoint to masterpoint 00107 - find those cutEdges that align with a master edge. This gives two sets 00108 of cut edges: those that have a master equivalent ('border edges') and 00109 those that don't ('internal edges'). The border edges now divide the 00110 cutFaces into regions with the same masterFace correspondence. 00111 - find cutFaces that are fully determined by the border edges they use. 00112 - all cutFaces that are connected through an internal edge have the same 00113 master face. 00114 00115 00116 Note: matching refined faces onto master is a bit dodgy and will probably 00117 only work for unwarped faces. Also it will fail if e.g. face is split 00118 into 3x3 since then middle face has no point/edge in common with master. 00119 (problem is in face matching (findSlavesCoveringMaster), probably 00120 point/edge matching might just work) 00121 00122 00123 SourceFiles 00124 faceCoupleInfo.C 00125 00126 00127 \*---------------------------------------------------------------------------*/ 00128 00129 #ifndef faceCoupleInfo_H 00130 #define faceCoupleInfo_H 00131 00132 #include "pointField.H" 00133 #include "indirectPrimitivePatch.H" 00134 #include "primitiveFacePatch.H" 00135 00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00137 00138 namespace Foam 00139 { 00140 00141 typedef HashTable<labelList, edge, Hash<edge> > edgeLookup; 00142 00143 00144 // Class forward declarations 00145 class face; 00146 class primitiveMesh; 00147 class polyPatch; 00148 class polyMesh; 00149 00150 /*---------------------------------------------------------------------------*\ 00151 Class faceCoupleInfo Declaration 00152 \*---------------------------------------------------------------------------*/ 00153 00154 class faceCoupleInfo 00155 { 00156 // Private data 00157 00158 //- Angle matching tolerance. 00159 static const scalar angleTol_; 00160 00161 //- Master patch 00162 autoPtr<indirectPrimitivePatch> masterPatchPtr_; 00163 00164 //- Slave patch 00165 autoPtr<indirectPrimitivePatch> slavePatchPtr_; 00166 00167 00168 //- Description of cut. 00169 // - Cut is the matching area between the slave 00170 // and the master. 00171 // - cut is the finest of master and slave. It can never be 00172 // coarser than either one of them. (so face addressing we keep is 00173 // cut-to-master and cut-to-slave) 00174 // - multiple master or slave points can end up becoming one cut point 00175 // (so point addressing we keep is master-to-cut and slave-to-cut) 00176 00177 // Cut consists of faces and points (note: could be expressed as some 00178 // kind of PrimitivePatch which holds points instead of reference to 00179 // them) 00180 // Orientation of cutFaces should be same as masterFaces! 00181 pointField cutPoints_; 00182 autoPtr<primitiveFacePatch> cutFacesPtr_; 00183 00184 //- Additional point coupling information. Is between points on 00185 // boundary of both meshes. 00186 00187 // Addressing to/from cut 00188 00189 //- master 00190 labelList cutToMasterFaces_; 00191 labelList masterToCutPoints_; 00192 00193 //- slave 00194 labelList cutToSlaveFaces_; 00195 labelList slaveToCutPoints_; 00196 00197 //- For edges originating from splitting of edges: 00198 // given the two endpoints of the unsplit edge give the list 00199 // of inbetween vertices 00200 edgeLookup cutEdgeToPoints_; 00201 00202 00203 // Private Member Functions 00204 00205 // Debugging 00206 00207 //- Calculate face centres from (subset of) faces. 00208 template<template<class> class FaceList> 00209 static pointField calcFaceCentres 00210 ( 00211 const FaceList<face>&, 00212 const pointField&, 00213 const label start, 00214 const label size 00215 ); 00216 00217 //- Write edges 00218 static void writeOBJ 00219 ( 00220 const fileName& fName, 00221 const edgeList& edges, 00222 const pointField& points, 00223 const bool compact = true 00224 ); 00225 00226 //- Write edges 00227 static void writeOBJ 00228 ( 00229 const fileName& fName, 00230 const pointField& points0, 00231 const pointField& points1 00232 ); 00233 00234 //- Write connections between corresponding points and faces 00235 // as .obj files. 00236 void writePointsFaces() const; 00237 00238 //- Write connections between corresponding edges as .obj files. 00239 void writeEdges(const labelList&, const labelList&) const; 00240 00241 00242 // Edge handling/matching 00243 00244 //- Find corresponding edges on patch when having only a map for 00245 // the points. 00246 labelList findMappedEdges 00247 ( 00248 const edgeList& edges, 00249 const labelList& pointMap, 00250 const indirectPrimitivePatch& 00251 ); 00252 00253 //- Check if edge on slavePatch corresponds to an edge between faces 00254 // in two different polyPatches on the mesh. 00255 bool regionEdge(const polyMesh&, const label slaveEdgeI) const; 00256 00257 //- Finds edge connected to point most aligned with master edge. 00258 label mostAlignedCutEdge 00259 ( 00260 const bool report, 00261 const polyMesh& slaveMesh, 00262 const bool patchDivision, 00263 const labelList& cutToMasterEdges, 00264 const labelList& cutToSlaveEdges, 00265 const label pointI, 00266 const label edgeStart, 00267 const label edgeEnd 00268 ) const; 00269 00270 //- From (many-to-one) map of cut edges to master edges determine 00271 // points inbetween. I.e. just string up the edges. Stores this 00272 // all on cutEdgeToPoints_ 00273 void setCutEdgeToPoints(const labelList& cutToMasterEdges); 00274 00275 // Face matching 00276 00277 //- Matches two faces.Determines rotation for f1 to match up 00278 // with f0, i.e. the index in f0 of 00279 // the first point of f1. 00280 static label matchFaces 00281 ( 00282 const scalar absTol, 00283 const pointField& points0, 00284 const face& f0, 00285 const pointField& points1, 00286 const face& f1, 00287 const bool sameOrientation 00288 ); 00289 00290 //- Matches points on patch to points on cut. 00291 static bool matchPointsThroughFaces 00292 ( 00293 const scalar absTol, 00294 const pointField& cutPoints, 00295 const faceList& cutFaces, 00296 const pointField& patchPoints, 00297 const faceList& patchFaces, 00298 const bool sameOrientation, 00299 00300 labelList& patchToCutPoints, // patch to (uncompacted) cut points 00301 labelList& cutToCompact, // compaction list 00302 labelList& compactToCut // compaction list 00303 ); 00304 00305 //- Returns max distance to masterF of any point on cutF. 00306 static scalar maxDistance 00307 ( 00308 const face& cutF, 00309 const pointField& cutPoints, 00310 const face& masterF, 00311 const pointField& masterPoints 00312 ); 00313 00314 //- Finds matching (boundary)face centres. 00315 // Since faces identical uses geometric match on face centres. 00316 static void findPerfectMatchingFaces 00317 ( 00318 const primitiveMesh& mesh0, 00319 const primitiveMesh& mesh1, 00320 const scalar absTol, 00321 00322 labelList& mesh0Faces, 00323 labelList& mesh1Faces 00324 ); 00325 00326 //- Find matching (boundary)faces. Matching if slave is on top of 00327 // master face (slaves is subdivision of master) 00328 static void findSlavesCoveringMaster 00329 ( 00330 const primitiveMesh& mesh0, 00331 const primitiveMesh& mesh1, 00332 const scalar absTol, 00333 00334 labelList& mesh0Faces, 00335 labelList& mesh1Faces 00336 ); 00337 00338 //- Grow cutToMasterFace across 'internal' edges. 00339 label growCutFaces(const labelList&, Map<labelList>&); 00340 00341 void checkMatch(const labelList& cutToMasterEdges) const; 00342 00343 //- Gets a list of cutFaces (that use a master edge) and the 00344 // candidate master faces. 00345 // Checks among these master faces if there is only one remaining 00346 // unmatched one. 00347 label matchEdgeFaces(const labelList&, Map<labelList>& candidates); 00348 00349 //- Gets a list of cutFaces (that use a master edge) and the 00350 // candidate master faces. 00351 // Finds most aligned master face. 00352 label geometricMatchEdgeFaces(Map<labelList>& candidates); 00353 00354 //- Used by perfectPointMatch. Determine match from cut points to 00355 // slave points (for perfect matching faces) 00356 void perfectSlavePointMatch(const scalar absTol); 00357 00358 //- Find point and edge correspondence for perfect matching faces 00359 void perfectPointMatch(const scalar absTol, const bool); 00360 00361 //- Find point and edge correspondence for slaves being subdivision of 00362 // master. 00363 void subDivisionMatch 00364 ( 00365 const polyMesh& slaveMesh, 00366 const bool patchDivision, 00367 const scalar absTol 00368 ); 00369 00370 public: 00371 00372 //- Runtime type information 00373 ClassName("faceCoupleInfo"); 00374 00375 00376 // Constructors 00377 00378 //- Construct from two meshes and absolute tolerance. 00379 // Finds out matches geometrically. No checking for nonsense match. 00380 // Tolerance is absolute one so use with care. 00381 // perfectMatch : each point/edge/face has corresponding point on other 00382 // side 00383 // if this is false then assumes slave is subdivision. 00384 // Matching then will work only for non-warped faces 00385 // since does nearest-to-face comparison with absTol. 00386 faceCoupleInfo 00387 ( 00388 const polyMesh& mesh0, 00389 const polyMesh& mesh1, 00390 const scalar absTol, 00391 const bool perfectMatch 00392 ); 00393 00394 //- Construct from meshes and subset of mesh faces 00395 // (i.e. indirectPrimitivePatch addressing) 00396 // All faces in patch are considered matched (but don't have to be 00397 // ordered) 00398 // perfectMatch : each point/edge/face has corresponding point on other 00399 // side 00400 // orderedFaces : faces in patch are ordered (so masterAddressing[i] 00401 // matches slaveAddressing[i]) 00402 // patchDivision: faces in slave mesh that originate from the 00403 // same master face have the same patch. Used by some triangulation 00404 // methods. 00405 faceCoupleInfo 00406 ( 00407 const polyMesh& masterMesh, 00408 const labelList& masterAddressing, 00409 const polyMesh& slaveMesh, 00410 const labelList& slaveAddressing, 00411 const scalar absTol, 00412 const bool perfectMatch, 00413 const bool orderedFaces, 00414 const bool patchDivision 00415 ); 00416 00417 00418 // Destructor 00419 00420 ~faceCoupleInfo(); 00421 00422 00423 00424 // Member Functions 00425 00426 //- Utility functions 00427 00428 //- Get patch face labels 00429 static labelList faceLabels(const polyPatch&); 00430 00431 //- Create Map from List 00432 static Map<label> makeMap(const labelList&); 00433 static Map<labelList> makeMap(const labelListList&); 00434 00435 00436 // Access 00437 00438 //- Addressing engine for coupled faces on mesh0 00439 const indirectPrimitivePatch& masterPatch() const 00440 { 00441 return masterPatchPtr_(); 00442 } 00443 00444 //- Addressing engine for coupled faces on mesh1 00445 const indirectPrimitivePatch& slavePatch() const 00446 { 00447 return slavePatchPtr_(); 00448 } 00449 00450 //- Addressing engine for combined set of faces. 00451 const primitiveFacePatch& cutFaces() const 00452 { 00453 return cutFacesPtr_(); 00454 } 00455 00456 //- Points for combined set of faces. 00457 const pointField& cutPoints() const 00458 { 00459 return cutPoints_; 00460 } 00461 00462 00463 // Addressing from meshes to cut and vice versa. 00464 00465 //- Master face for every face on cut. Will always be at least 00466 // one but there might be multiple cut faces pointing to the same 00467 // master 00468 const labelList& cutToMasterFaces() const 00469 { 00470 return cutToMasterFaces_; 00471 } 00472 const labelList& masterToCutPoints() const 00473 { 00474 return masterToCutPoints_; 00475 } 00476 00477 const labelList& cutToSlaveFaces() const 00478 { 00479 return cutToSlaveFaces_; 00480 } 00481 const labelList& slaveToCutPoints() const 00482 { 00483 return slaveToCutPoints_; 00484 } 00485 00486 //- From two cut points (original edge) to list of inserted 00487 // points 00488 const edgeLookup& cutEdgeToPoints() const 00489 { 00490 return cutEdgeToPoints_; 00491 } 00492 00493 }; 00494 00495 00496 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00497 00498 } // End namespace Foam 00499 00500 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00501 00502 #ifdef NoRepository 00503 # include "faceCoupleInfoTemplates.C" 00504 #endif 00505 00506 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00507 00508 #endif 00509 00510 // ************************************************************************* // |