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 #include "wedgeMatcher.H"
00027 #include <OpenFOAM/primitiveMesh.H>
00028
00029
00030
00031
00032 const Foam::label Foam::wedgeMatcher::vertPerCell = 7;
00033 const Foam::label Foam::wedgeMatcher::facePerCell = 6;
00034 const Foam::label Foam::wedgeMatcher::maxVertPerFace = 4;
00035
00036
00037
00038
00039
00040 Foam::wedgeMatcher::wedgeMatcher()
00041 :
00042 cellMatcher
00043 (
00044 vertPerCell,
00045 facePerCell,
00046 maxVertPerFace,
00047 "wedge"
00048 )
00049 {}
00050
00051
00052
00053
00054 Foam::wedgeMatcher::~wedgeMatcher()
00055 {}
00056
00057
00058
00059
00060 bool Foam::wedgeMatcher::matchShape
00061 (
00062 const bool checkOnly,
00063 const faceList& faces,
00064 const labelList& owner,
00065 const label cellI,
00066 const labelList& myFaces
00067 )
00068 {
00069 if (!faceSizeMatch(faces, myFaces))
00070 {
00071 return false;
00072 }
00073
00074
00075 label numVert = calcLocalFaces(faces, myFaces);
00076
00077 if (numVert != vertPerCell)
00078 {
00079 return false;
00080 }
00081
00082
00083 calcEdgeAddressing(numVert);
00084
00085
00086 calcPointFaceIndex();
00087
00088
00089 vertLabels_.setSize(vertPerCell);
00090 faceLabels_.setSize(facePerCell);
00091
00092
00093
00094
00095
00096
00097 label face0I = -1;
00098 forAll(faceSize_, faceI)
00099 {
00100 if (faceSize_[faceI] == 3)
00101 {
00102 face0I = faceI;
00103 break;
00104 }
00105 }
00106
00107 const face& face0 = localFaces_[face0I];
00108
00109
00110 for(label face0vert0 = 0; face0vert0 < faceSize_[face0I]; face0vert0++)
00111 {
00112
00113
00114
00115
00116
00117 vertLabels_[0] = pointMap_[face0[face0vert0]];
00118 faceLabels_[0] = faceMap_[face0I];
00119
00120
00121
00122
00123
00124 label face0vert1 =
00125 nextVert
00126 (
00127 face0vert0,
00128 faceSize_[face0I],
00129 !(owner[faceMap_[face0I]] == cellI)
00130 );
00131 vertLabels_[1] = pointMap_[face0[face0vert1]];
00132
00133
00134
00135
00136
00137 label face4I =
00138 otherFace
00139 (
00140 numVert,
00141 face0[face0vert0],
00142 face0[face0vert1],
00143 face0I
00144 );
00145 const face& face4 = localFaces_[face4I];
00146
00147
00148
00149
00150
00151 if (faceSize_[face4I] != 4)
00152 {
00153
00154
00155 continue;
00156 }
00157
00158
00159 if (checkOnly)
00160 {
00161 return true;
00162 }
00163
00164 faceLabels_[4] = faceMap_[face4I];
00165
00166
00167 label face4vert0 = pointFaceIndex_[face0[face0vert0]][face4I];
00168
00169
00170
00171
00172
00173
00174 label face4vert3 =
00175 nextVert
00176 (
00177 face4vert0,
00178 faceSize_[face4I],
00179 !(owner[faceMap_[face4I]] == cellI)
00180 );
00181 vertLabels_[3] = pointMap_[face4[face4vert3]];
00182
00183
00184
00185
00186
00187
00188 label face2I =
00189 otherFace
00190 (
00191 numVert,
00192 face4[face4vert0],
00193 face4[face4vert3],
00194 face4I
00195 );
00196 const face& face2 = localFaces_[face2I];
00197
00198
00199
00200
00201
00202 if (faceSize_[face2I] != 3)
00203 {
00204
00205
00206 continue;
00207 }
00208 faceLabels_[2] = faceMap_[face2I];
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 label face2vert3 = pointFaceIndex_[face4[face4vert3]][face2I];
00220
00221
00222 label face2vert6 =
00223 nextVert
00224 (
00225 face2vert3,
00226 faceSize_[face2I],
00227 (owner[faceMap_[face2I]] == cellI)
00228 );
00229 vertLabels_[6] = pointMap_[face2[face2vert6]];
00230
00231
00232 label face1I =
00233 otherFace
00234 (
00235 numVert,
00236 face2[face2vert3],
00237 face2[face2vert6],
00238 face2I
00239 );
00240 faceLabels_[1] = faceMap_[face1I];
00241 const face& face1 = localFaces_[face1I];
00242
00243
00244
00245
00246
00247 label face1vert6 = pointFaceIndex_[face2[face2vert6]][face1I];
00248
00249
00250 label face1vert5 =
00251 nextVert
00252 (
00253 face1vert6,
00254 faceSize_[face1I],
00255 !(owner[faceMap_[face1I]] == cellI)
00256 );
00257 vertLabels_[5] = pointMap_[face1[face1vert5]];
00258
00259
00260 label face1vert4 =
00261 nextVert
00262 (
00263 face1vert5,
00264 faceSize_[face1I],
00265 !(owner[faceMap_[face1I]] == cellI)
00266 );
00267 vertLabels_[4] = pointMap_[face1[face1vert4]];
00268
00269
00270 label face0vert2 =
00271 nextVert
00272 (
00273 face0vert1,
00274 faceSize_[face0I],
00275 !(owner[faceMap_[face0I]] == cellI)
00276 );
00277 vertLabels_[2] = pointMap_[face0[face0vert2]];
00278
00279
00280
00281
00282
00283 label face3I =
00284 otherFace
00285 (
00286 numVert,
00287 face0[face0vert1],
00288 face0[face0vert2],
00289 face0I
00290 );
00291 faceLabels_[3] = faceMap_[face3I];
00292
00293
00294
00295
00296
00297
00298
00299
00300 label face5I =
00301 otherFace
00302 (
00303 numVert,
00304 face0[face0vert2],
00305 face0[face0vert0],
00306 face0I
00307 );
00308 faceLabels_[5] = faceMap_[face5I];
00309
00310
00311
00312
00313
00314
00315 return true;
00316 }
00317
00318
00319 return false;
00320 }
00321
00322
00323 Foam::label Foam::wedgeMatcher::faceHashValue() const
00324 {
00325 return 2*3 + 4*4;
00326 }
00327
00328
00329 bool Foam::wedgeMatcher::faceSizeMatch
00330 (
00331 const faceList& faces,
00332 const labelList& myFaces
00333 ) const
00334 {
00335 if (myFaces.size() != 6)
00336 {
00337 return false;
00338 }
00339
00340 label nTris = 0;
00341 label nQuads = 0;
00342
00343 forAll(myFaces, myFaceI)
00344 {
00345 label size = faces[myFaces[myFaceI]].size();
00346
00347 if (size == 3)
00348 {
00349 nTris++;
00350 }
00351 else if (size == 4)
00352 {
00353 nQuads++;
00354 }
00355 else
00356 {
00357 return false;
00358 }
00359 }
00360 if ((nTris == 2) && (nQuads == 4))
00361 {
00362 return true;
00363 }
00364 else
00365 {
00366 return false;
00367 }
00368 }
00369
00370
00371 bool Foam::wedgeMatcher::isA(const primitiveMesh& mesh, const label cellI)
00372 {
00373 return matchShape
00374 (
00375 true,
00376 mesh.faces(),
00377 mesh.faceOwner(),
00378 cellI,
00379 mesh.cells()[cellI]
00380 );
00381 }
00382
00383
00384 bool Foam::wedgeMatcher::isA(const faceList& faces)
00385 {
00386
00387 return matchShape
00388 (
00389 true,
00390 faces,
00391 labelList(faces.size(), 0),
00392 0,
00393 makeIdentity(faces.size())
00394 );
00395 }
00396
00397
00398 bool Foam::wedgeMatcher::matches
00399 (
00400 const primitiveMesh& mesh,
00401 const label cellI,
00402 cellShape& shape
00403 )
00404 {
00405 if
00406 (
00407 matchShape
00408 (
00409 false,
00410 mesh.faces(),
00411 mesh.faceOwner(),
00412 cellI,
00413 mesh.cells()[cellI]
00414 )
00415 )
00416 {
00417 shape = cellShape(model(), vertLabels());
00418
00419 return true;
00420 }
00421 else
00422 {
00423 return false;
00424 }
00425 }
00426
00427
00428