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