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 #include <OpenFOAM/cellModeller.H>
00032
00033
00034
00035 namespace Foam
00036 {
00037
00038
00039
00040 cellShape extrudedTriangleCellShape
00041 (
00042 const label cellIndex,
00043 const labelList& faceLabels,
00044 const faceList& faces,
00045 const labelList& owner,
00046 const labelList& neighbour,
00047 const label pointOffset,
00048 faceList& frontAndBackFaces
00049 )
00050 {
00051 const static cellModel* prismModelPtr_ = NULL;
00052
00053 if (!prismModelPtr_)
00054 {
00055 prismModelPtr_ = cellModeller::lookup("prism");
00056 }
00057
00058 const cellModel& prism = *prismModelPtr_;
00059
00060
00061 if (faceLabels.size() != 3)
00062 {
00063 FatalErrorIn
00064 (
00065 "extrudedTriangleCellShape(const label cellIndex, "
00066 "const labelList& faceLabels, const faceList& faces, "
00067 "const labelList& owner, const labelList& neighbour, "
00068 "const label pointOffset, faceList& frontAndBackFaces)"
00069 ) << "Trying to create a triangle with " << faceLabels.size()
00070 << " faces"
00071 << abort(FatalError);
00072 }
00073
00074
00075 labelListList localFaces(3);
00076
00077 forAll (faceLabels, faceI)
00078 {
00079 const label curFaceLabel = faceLabels[faceI];
00080
00081 const face& curFace = faces[curFaceLabel];
00082
00083 if (curFace.size() != 2)
00084 {
00085 FatalErrorIn
00086 (
00087 "extrudedTriangleCellShape(const label cellIndex, "
00088 "const labelList& faceLabels, const faceList& faces, "
00089 "const labelList& owner, const labelList& neighbour, "
00090 "const label pointOffset, faceList& frontAndBackFaces)"
00091 ) << "face " << curFaceLabel
00092 << "does not have 2 vertices. Number of vertices: " << curFace
00093 << abort(FatalError);
00094 }
00095
00096 if (owner[curFaceLabel] == cellIndex)
00097 {
00098 localFaces[faceI] = curFace;
00099 }
00100 else if (neighbour[curFaceLabel] == cellIndex)
00101 {
00102
00103
00104
00105 localFaces[faceI].setSize(curFace.size());
00106
00107 forAllReverse(curFace, i)
00108 {
00109 localFaces[faceI][curFace.size() - i - 1] =
00110 curFace[i];
00111 }
00112 }
00113 else
00114 {
00115 FatalErrorIn
00116 (
00117 "extrudedTriangleCellShape(const label cellIndex, "
00118 "const labelList& faceLabels, const faceList& faces, "
00119 "const labelList& owner, const labelList& neighbour, "
00120 "const label pointOffset, faceList& frontAndBackFaces)"
00121 ) << "face " << curFaceLabel
00122 << " does not belong to cell " << cellIndex
00123 << ". Face owner: " << owner[curFaceLabel] << " neighbour: "
00124 << neighbour[curFaceLabel]
00125 << abort(FatalError);
00126 }
00127 }
00128
00129
00130 if (localFaces[0][1] == localFaces[1][0])
00131 {
00132
00133 labelList missingPlaneFace(3);
00134
00135
00136 missingPlaneFace[0] = localFaces[0][0];
00137 missingPlaneFace[1] = localFaces[1][1];
00138 missingPlaneFace[2] = localFaces[0][1];
00139
00140 frontAndBackFaces[2*cellIndex] = face(missingPlaneFace);
00141
00142
00143 missingPlaneFace[0] = localFaces[0][0] + pointOffset;
00144 missingPlaneFace[1] = localFaces[0][1] + pointOffset;
00145 missingPlaneFace[2] = localFaces[1][1] + pointOffset;
00146
00147 frontAndBackFaces[2*cellIndex + 1] = face(missingPlaneFace);
00148
00149
00150 labelList cellShapeLabels(6);
00151
00152 cellShapeLabels[0] = localFaces[0][0];
00153 cellShapeLabels[1] = localFaces[0][1];
00154 cellShapeLabels[2] = localFaces[1][1];
00155
00156 cellShapeLabels[3] = localFaces[0][0] + pointOffset;
00157 cellShapeLabels[4] = localFaces[0][1] + pointOffset;
00158 cellShapeLabels[5] = localFaces[1][1] + pointOffset;
00159
00160 return cellShape(prism, cellShapeLabels);
00161 }
00162 else if (localFaces[0][1] == localFaces[2][0])
00163 {
00164
00165 labelList missingPlaneFace(3);
00166
00167
00168 missingPlaneFace[0] = localFaces[0][0];
00169 missingPlaneFace[1] = localFaces[2][1];
00170 missingPlaneFace[2] = localFaces[0][1];
00171
00172 frontAndBackFaces[2*cellIndex] = face(missingPlaneFace);
00173
00174
00175 missingPlaneFace[0] = localFaces[0][0] + pointOffset;
00176 missingPlaneFace[1] = localFaces[0][1] + pointOffset;
00177 missingPlaneFace[2] = localFaces[2][1] + pointOffset;
00178
00179 frontAndBackFaces[2*cellIndex + 1] = face(missingPlaneFace);
00180
00181
00182 labelList cellShapeLabels(6);
00183
00184 cellShapeLabels[0] = localFaces[0][0];
00185 cellShapeLabels[1] = localFaces[0][1];
00186 cellShapeLabels[2] = localFaces[2][1];
00187
00188 cellShapeLabels[3] = localFaces[0][0] + pointOffset;
00189 cellShapeLabels[4] = localFaces[0][1] + pointOffset;
00190 cellShapeLabels[5] = localFaces[2][1] + pointOffset;
00191
00192 return cellShape(prism, cellShapeLabels);
00193 }
00194 else
00195 {
00196 FatalErrorIn
00197 (
00198 "extrudedTriangleCellShape(const label cellIndex, "
00199 "const labelList& faceLabels, const faceList& faces, "
00200 "const labelList& owner, const labelList& neighbour, "
00201 "const label pointOffset, faceList& frontAndBackFaces)"
00202 ) << "Problem with edge matching. Edges: " << localFaces
00203 << abort(FatalError);
00204 }
00205
00206
00207 return cellShape(prism, labelList(0));
00208 }
00209
00210
00211
00212
00213 }
00214
00215