tetMatcher.C
Go to the documentation of this file.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 #include "tetMatcher.H"
00028 #include "cellMatcher.H"
00029 #include "primitiveMesh.H"
00030 #include "primitiveMesh.H"
00031 #include "cellModeller.H"
00032
00033
00034
00035 const Foam::label Foam::tetMatcher::vertPerCell = 4;
00036 const Foam::label Foam::tetMatcher::facePerCell = 4;
00037 const Foam::label Foam::tetMatcher::maxVertPerFace = 3;
00038
00039
00040
00041
00042
00043 Foam::tetMatcher::tetMatcher()
00044 :
00045 cellMatcher
00046 (
00047 vertPerCell,
00048 facePerCell,
00049 maxVertPerFace,
00050 "tet"
00051 )
00052 {}
00053
00054
00055
00056
00057 Foam::tetMatcher::~tetMatcher()
00058 {}
00059
00060
00061
00062
00063
00064 bool Foam::tetMatcher::matchShape
00065 (
00066 const bool checkOnly,
00067 const faceList& faces,
00068 const labelList& owner,
00069 const label cellI,
00070 const labelList& myFaces
00071 )
00072 {
00073 if (!faceSizeMatch(faces, myFaces))
00074 {
00075 return false;
00076 }
00077
00078
00079 if (checkOnly)
00080 {
00081 return true;
00082 }
00083
00084
00085 label numVert = calcLocalFaces(faces, myFaces);
00086
00087 if (numVert != vertPerCell)
00088 {
00089 return false;
00090 }
00091
00092
00093 calcEdgeAddressing(numVert);
00094
00095
00096 calcPointFaceIndex();
00097
00098
00099 vertLabels_.setSize(vertPerCell);
00100 faceLabels_.setSize(facePerCell);
00101
00102
00103
00104
00105
00106 label face3I = 0;
00107 const face& face3 = localFaces_[face3I];
00108 label face3vert0 = 0;
00109
00110
00111
00112
00113
00114
00115 vertLabels_[0] = pointMap_[face3[face3vert0]];
00116 faceLabels_[3] = faceMap_[face3I];
00117
00118
00119 label face3vert1 =
00120 nextVert
00121 (
00122 face3vert0,
00123 faceSize_[face3I],
00124 !(owner[faceMap_[face3I]] == cellI)
00125 );
00126 vertLabels_[1] = pointMap_[face3[face3vert1]];
00127
00128
00129 label face3vert2 =
00130 nextVert
00131 (
00132 face3vert1,
00133 faceSize_[face3I],
00134 !(owner[faceMap_[face3I]] == cellI)
00135 );
00136 vertLabels_[2] = pointMap_[face3[face3vert2]];
00137
00138
00139 label face2I =
00140 otherFace
00141 (
00142 numVert,
00143 face3[face3vert0],
00144 face3[face3vert1],
00145 face3I
00146 );
00147 faceLabels_[2] = faceMap_[face2I];
00148
00149
00150 label face0I =
00151 otherFace
00152 (
00153 numVert,
00154 face3[face3vert1],
00155 face3[face3vert2],
00156 face3I
00157 );
00158 faceLabels_[0] = faceMap_[face0I];
00159
00160
00161 label face1I =
00162 otherFace
00163 (
00164 numVert,
00165 face3[face3vert2],
00166 face3[face3vert0],
00167 face3I
00168 );
00169 faceLabels_[1] = faceMap_[face1I];
00170 const face& face1 = localFaces_[face1I];
00171
00172
00173 label face1vert0 = pointFaceIndex_[face3[face3vert0]][face1I];
00174
00175
00176 label face1vert3 =
00177 nextVert
00178 (
00179 face1vert0,
00180 faceSize_[face1I],
00181 (owner[faceMap_[face1I]] == cellI)
00182 );
00183 vertLabels_[3] = pointMap_[face1[face1vert3]];
00184
00185 return true;
00186 }
00187
00188
00189 Foam::label Foam::tetMatcher::faceHashValue() const
00190 {
00191 return 4*3;
00192 }
00193
00194
00195 bool Foam::tetMatcher::faceSizeMatch
00196 (
00197 const faceList& faces,
00198 const labelList& myFaces
00199 ) const
00200 {
00201 if (myFaces.size() != 4)
00202 {
00203 return false;
00204 }
00205
00206 forAll(myFaces, myFaceI)
00207 {
00208 label size = faces[myFaces[myFaceI]].size();
00209
00210 if (size != 3)
00211 {
00212 return false;
00213 }
00214 }
00215 return true;
00216 }
00217
00218
00219 bool Foam::tetMatcher::isA(const primitiveMesh& mesh, const label cellI)
00220 {
00221 return matchShape
00222 (
00223 true,
00224 mesh.faces(),
00225 mesh.faceOwner(),
00226 cellI,
00227 mesh.cells()[cellI]
00228 );
00229 }
00230
00231
00232 bool Foam::tetMatcher::isA(const faceList& faces)
00233 {
00234
00235 return matchShape
00236 (
00237 true,
00238 faces,
00239 labelList(faces.size(), 0),
00240 0,
00241 makeIdentity(faces.size())
00242 );
00243 }
00244
00245
00246 bool Foam::tetMatcher::matches
00247 (
00248 const primitiveMesh& mesh,
00249 const label cellI,
00250 cellShape& shape
00251 )
00252 {
00253 if
00254 (
00255 matchShape
00256 (
00257 false,
00258 mesh.faces(),
00259 mesh.faceOwner(),
00260 cellI,
00261 mesh.cells()[cellI]
00262 )
00263 )
00264 {
00265 shape = cellShape(model(), vertLabels());
00266
00267 return true;
00268 }
00269 else
00270 {
00271 return false;
00272 }
00273 }
00274
00275
00276
Copyright © 2000-2009 OpenCFD Ltd