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
00028
00029 #include "cellShapeRecognition.H"
00030 #include <OpenFOAM/labelList.H>
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037
00038
00039 cellShape extrudedQuadCellShape
00040 (
00041 const label cellIndex,
00042 const labelList& faceLabels,
00043 const faceList& faces,
00044 const labelList& owner,
00045 const labelList& neighbour,
00046 const label pointOffset,
00047 faceList& frontAndBackFaces
00048 )
00049 {
00050 const static cellModel* hexModelPtr_ = NULL;
00051
00052 if (!hexModelPtr_)
00053 {
00054 hexModelPtr_ = cellModeller::lookup("hex");
00055 }
00056
00057 const cellModel& hex = *hexModelPtr_;
00058
00059
00060 if (faceLabels.size() != 4)
00061 {
00062 FatalErrorIn
00063 (
00064 "extrudedQuadCellShape(const label cellIndex, "
00065 "const labelList& faceLabels, const faceList& faces, "
00066 "const labelList& owner, const labelList& neighbour, "
00067 "const label pointOffset, faceList& frontAndBackFaces)"
00068 ) << "Trying to create a quad with " << faceLabels.size() << " faces"
00069 << abort(FatalError);
00070 }
00071
00072
00073 labelListList localFaces(4);
00074
00075 forAll (faceLabels, faceI)
00076 {
00077 const label curFaceLabel = faceLabels[faceI];
00078
00079 const face& curFace = faces[curFaceLabel];
00080
00081 if (curFace.size() != 2)
00082 {
00083 FatalErrorIn
00084 (
00085 "extrudedQuadCellShape(const label cellIndex, "
00086 "const labelList& faceLabels, const faceList& faces, "
00087 "const labelList& owner, const labelList& neighbour, "
00088 "const label pointOffset, faceList& frontAndBackFaces)"
00089 ) << "face " << curFaceLabel
00090 << "does not have 2 vertices. Number of vertices: " << curFace
00091 << abort(FatalError);
00092 }
00093
00094 if (owner[curFaceLabel] == cellIndex)
00095 {
00096 localFaces[faceI] = curFace;
00097 }
00098 else if (neighbour[curFaceLabel] == cellIndex)
00099 {
00100
00101
00102
00103 localFaces[faceI].setSize(curFace.size());
00104
00105 forAllReverse(curFace, i)
00106 {
00107 localFaces[faceI][curFace.size() - i - 1] =
00108 curFace[i];
00109 }
00110 }
00111 else
00112 {
00113 FatalErrorIn
00114 (
00115 "extrudedQuadCellShape(const label cellIndex, "
00116 "const labelList& faceLabels, const faceList& faces, "
00117 "const labelList& owner, const labelList& neighbour, "
00118 "const label pointOffset, faceList& frontAndBackFaces)"
00119 ) << "face " << curFaceLabel
00120 << " does not belong to cell " << cellIndex
00121 << ". Face owner: " << owner[curFaceLabel] << " neighbour: "
00122 << neighbour[curFaceLabel]
00123 << abort(FatalError);
00124 }
00125 }
00126
00127
00128
00129
00130
00131 if
00132 (
00133 localFaces[0][0] != localFaces[1][1]
00134 && localFaces[0][1] != localFaces[1][0]
00135 )
00136 {
00137
00138 labelList missingPlaneFace(4);
00139
00140
00141 missingPlaneFace[0] = localFaces[0][0];
00142 missingPlaneFace[1] = localFaces[1][1];
00143 missingPlaneFace[2] = localFaces[1][0];
00144 missingPlaneFace[3] = localFaces[0][1];
00145
00146 frontAndBackFaces[2*cellIndex] = face(missingPlaneFace);
00147
00148
00149 missingPlaneFace[0] = localFaces[0][0] + pointOffset;
00150 missingPlaneFace[1] = localFaces[0][1] + pointOffset;
00151 missingPlaneFace[2] = localFaces[1][0] + pointOffset;
00152 missingPlaneFace[3] = localFaces[1][1] + pointOffset;
00153
00154 frontAndBackFaces[2*cellIndex + 1] = face(missingPlaneFace);
00155
00156
00157 labelList cellShapeLabels(8);
00158
00159 cellShapeLabels[0] = localFaces[0][0];
00160 cellShapeLabels[1] = localFaces[0][1];
00161 cellShapeLabels[2] = localFaces[1][0];
00162 cellShapeLabels[3] = localFaces[1][1];
00163
00164 cellShapeLabels[4] = localFaces[0][0] + pointOffset;
00165 cellShapeLabels[5] = localFaces[0][1] + pointOffset;
00166 cellShapeLabels[6] = localFaces[1][0] + pointOffset;
00167 cellShapeLabels[7] = localFaces[1][1] + pointOffset;
00168
00169
00170 return cellShape(hex, cellShapeLabels);
00171 }
00172 else if
00173 (
00174 localFaces[0][0] != localFaces[2][1]
00175 && localFaces[0][1] != localFaces[2][0]
00176 )
00177 {
00178
00179 labelList missingPlaneFace(4);
00180
00181
00182 missingPlaneFace[0] = localFaces[0][0];
00183 missingPlaneFace[1] = localFaces[2][1];
00184 missingPlaneFace[2] = localFaces[2][0];
00185 missingPlaneFace[3] = localFaces[0][1];
00186
00187 frontAndBackFaces[2*cellIndex] = face(missingPlaneFace);
00188
00189
00190 missingPlaneFace[0] = localFaces[0][0] + pointOffset;
00191 missingPlaneFace[1] = localFaces[0][1] + pointOffset;
00192 missingPlaneFace[2] = localFaces[2][0] + pointOffset;
00193 missingPlaneFace[3] = localFaces[2][1] + pointOffset;
00194
00195 frontAndBackFaces[2*cellIndex + 1] = face(missingPlaneFace);
00196
00197
00198 labelList cellShapeLabels(8);
00199
00200 cellShapeLabels[0] = localFaces[0][0];
00201 cellShapeLabels[1] = localFaces[0][1];
00202 cellShapeLabels[2] = localFaces[2][0];
00203 cellShapeLabels[3] = localFaces[2][1];
00204
00205 cellShapeLabels[4] = localFaces[0][0] + pointOffset;
00206 cellShapeLabels[5] = localFaces[0][1] + pointOffset;
00207 cellShapeLabels[6] = localFaces[2][0] + pointOffset;
00208 cellShapeLabels[7] = localFaces[2][1] + pointOffset;
00209
00210
00211 return cellShape(hex, cellShapeLabels);
00212 }
00213 else if
00214 (
00215 localFaces[0][0] != localFaces[3][1]
00216 && localFaces[0][1] != localFaces[3][0]
00217 )
00218 {
00219
00220 labelList missingPlaneFace(4);
00221
00222
00223 missingPlaneFace[0] = localFaces[0][0];
00224 missingPlaneFace[1] = localFaces[3][1];
00225 missingPlaneFace[2] = localFaces[3][0];
00226 missingPlaneFace[3] = localFaces[0][1];
00227
00228 frontAndBackFaces[2*cellIndex] = face(missingPlaneFace);
00229
00230
00231 missingPlaneFace[0] = localFaces[0][0] + pointOffset;
00232 missingPlaneFace[1] = localFaces[0][1] + pointOffset;
00233 missingPlaneFace[2] = localFaces[3][0] + pointOffset;
00234 missingPlaneFace[3] = localFaces[3][1] + pointOffset;
00235
00236 frontAndBackFaces[2*cellIndex + 1] = face(missingPlaneFace);
00237
00238
00239 labelList cellShapeLabels(8);
00240
00241 cellShapeLabels[0] = localFaces[0][0];
00242 cellShapeLabels[1] = localFaces[0][1];
00243 cellShapeLabels[2] = localFaces[3][0];
00244 cellShapeLabels[3] = localFaces[3][1];
00245
00246 cellShapeLabels[4] = localFaces[0][0] + pointOffset;
00247 cellShapeLabels[5] = localFaces[0][1] + pointOffset;
00248 cellShapeLabels[6] = localFaces[3][0] + pointOffset;
00249 cellShapeLabels[7] = localFaces[3][1] + pointOffset;
00250
00251
00252 return cellShape(hex, cellShapeLabels);
00253 }
00254 else
00255 {
00256 FatalErrorIn
00257 (
00258 "extrudedQuadCellShape(const label cellIndex, "
00259 "const labelList& faceLabels, const faceList& faces, "
00260 "const labelList& owner, const labelList& neighbour, "
00261 "const label pointOffset, faceList& frontAndBackFaces)"
00262 ) << "Problem with edge matching. Edges: " << localFaces
00263 << abort(FatalError);
00264 }
00265
00266
00267 return cellShape(hex, labelList(0));
00268 }
00269
00270
00271
00272
00273 }
00274
00275