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 #include "PrimitivePatch.H"
00031 #include "Map.H"
00032 #include "ListOps.H"
00033
00034
00035
00036
00037 template
00038 <
00039 class Face,
00040 template<class> class FaceList,
00041 class PointField,
00042 class PointType
00043 >
00044
00045 void
00046 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00047 visitPointRegion
00048 (
00049 const label pointI,
00050 const labelList& pFaces,
00051 const label startFaceI,
00052 const label startEdgeI,
00053 boolList& pFacesHad
00054 ) const
00055 {
00056 label index = findIndex(pFaces, startFaceI);
00057
00058 if (!pFacesHad[index])
00059 {
00060
00061 pFacesHad[index] = true;
00062
00063
00064 const labelList& fEdges = faceEdges()[startFaceI];
00065
00066 label nextEdgeI = -1;
00067
00068 forAll(fEdges, i)
00069 {
00070 label edgeI = fEdges[i];
00071
00072 const edge& e = edges()[edgeI];
00073
00074 if (edgeI != startEdgeI && (e[0] == pointI || e[1] == pointI))
00075 {
00076 nextEdgeI = edgeI;
00077
00078 break;
00079 }
00080 }
00081
00082 if (nextEdgeI == -1)
00083 {
00084 FatalErrorIn
00085 (
00086 "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00087 "visitPointRegion"
00088 ) << "Problem: cannot find edge out of " << fEdges
00089 << "on face " << startFaceI << " that uses point " << pointI
00090 << " and is not edge " << startEdgeI << abort(FatalError);
00091 }
00092
00093
00094 const labelList& eFaces = edgeFaces()[nextEdgeI];
00095
00096 forAll(eFaces, i)
00097 {
00098 if (eFaces[i] != startFaceI)
00099 {
00100 visitPointRegion
00101 (
00102 pointI,
00103 pFaces,
00104 eFaces[i],
00105 nextEdgeI,
00106 pFacesHad
00107 );
00108 }
00109 }
00110 }
00111 }
00112
00113
00114
00115
00116 template
00117 <
00118 class Face,
00119 template<class> class FaceList,
00120 class PointField,
00121 class PointType
00122 >
00123
00124 typename Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
00125 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00126 surfaceType() const
00127 {
00128 if (debug)
00129 {
00130 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00131 "surfaceType() : "
00132 "calculating patch topology"
00133 << endl;
00134 }
00135
00136 const labelListList& edgeFcs = edgeFaces();
00137
00138 surfaceTopo pType = MANIFOLD;
00139
00140 forAll(edgeFcs, edgeI)
00141 {
00142 label nNbrs = edgeFcs[edgeI].size();
00143
00144 if (nNbrs < 1 || nNbrs > 2)
00145 {
00146 pType = ILLEGAL;
00147
00148
00149 return pType;
00150 }
00151 else if (nNbrs == 1)
00152 {
00153
00154 pType = OPEN;
00155 }
00156 }
00157
00158 if (debug)
00159 {
00160 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00161 "surfaceType() : "
00162 "finished calculating patch topology"
00163 << endl;
00164 }
00165
00166 return pType;
00167 }
00168
00169
00170 template
00171 <
00172 class Face,
00173 template<class> class FaceList,
00174 class PointField,
00175 class PointType
00176 >
00177
00178 bool
00179 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00180 checkTopology
00181 (
00182 const bool report,
00183 labelHashSet* setPtr
00184 ) const
00185 {
00186 if (debug)
00187 {
00188 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00189 "checkTopology(const bool, labelHashSet&) : "
00190 "checking patch topology"
00191 << endl;
00192 }
00193
00194
00195
00196 const labelListList& edgeFcs = edgeFaces();
00197
00198 surfaceTopo surfaceType = MANIFOLD;
00199
00200 forAll(edgeFcs, edgeI)
00201 {
00202 label nNbrs = edgeFcs[edgeI].size();
00203
00204 if (nNbrs < 1 || nNbrs > 2)
00205 {
00206 surfaceType = ILLEGAL;
00207
00208 if (report)
00209 {
00210 Info<< "Edge " << edgeI << " with vertices:" << edges()[edgeI]
00211 << " has " << nNbrs << " face neighbours"
00212 << endl;
00213 }
00214
00215 if (setPtr)
00216 {
00217 const edge& e = edges()[edgeI];
00218
00219 setPtr->insert(meshPoints()[e.start()]);
00220 setPtr->insert(meshPoints()[e.end()]);
00221 }
00222 }
00223 else if (nNbrs == 1)
00224 {
00225 surfaceType = OPEN;
00226 }
00227 }
00228
00229 if (debug)
00230 {
00231 Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
00232 "checkTopology(const bool, labelHashSet&) : "
00233 "finished checking patch topology"
00234 << endl;
00235 }
00236
00237 return surfaceType == ILLEGAL;
00238 }
00239
00240
00241 template
00242 <
00243 class Face,
00244 template<class> class FaceList,
00245 class PointField,
00246 class PointType
00247 >
00248
00249 bool
00250 Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
00251 checkPointManifold
00252 (
00253 const bool report,
00254 labelHashSet* setPtr
00255 ) const
00256 {
00257 const labelListList& pf = pointFaces();
00258 const labelListList& pe = pointEdges();
00259 const labelListList& ef = edgeFaces();
00260 const labelList& mp = meshPoints();
00261
00262 bool foundError = false;
00263
00264 forAll(pf, pointI)
00265 {
00266 const labelList& pFaces = pf[pointI];
00267
00268
00269 boolList pFacesHad(pFaces.size(), false);
00270
00271
00272 const labelList& pEdges = pe[pointI];
00273 label startEdgeI = pEdges[0];
00274
00275 const labelList& eFaces = ef[startEdgeI];
00276
00277 forAll(eFaces, i)
00278 {
00279
00280
00281 this->visitPointRegion
00282 (
00283 pointI,
00284 pFaces,
00285 eFaces[i],
00286 startEdgeI,
00287 pFacesHad
00288 );
00289 }
00290
00291
00292
00293
00294 label unset = findIndex(pFacesHad, false);
00295
00296 if (unset != -1)
00297 {
00298 foundError = true;
00299
00300 label meshPointI = mp[pointI];
00301
00302 if (setPtr)
00303 {
00304 setPtr->insert(meshPointI);
00305 }
00306
00307 if (report)
00308 {
00309 Info<< "Point " << meshPointI
00310 << " uses faces which are not connected through an edge"
00311 << nl
00312 << "This means that the surface formed by this patched"
00313 << " is multiply connected at this point" << nl
00314 << "Connected (patch) faces:" << nl;
00315
00316 forAll(pFacesHad, i)
00317 {
00318 if (pFacesHad[i])
00319 {
00320 Info<< " " << pFaces[i] << endl;
00321 }
00322 }
00323
00324 Info<< nl << "Unconnected (patch) faces:" << nl;
00325 forAll(pFacesHad, i)
00326 {
00327 if (!pFacesHad[i])
00328 {
00329 Info<< " " << pFaces[i] << endl;
00330 }
00331 }
00332 }
00333 }
00334 }
00335
00336 return foundError;
00337 }
00338
00339
00340