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