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