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 "starMesh.H"
00030 #include <OpenFOAM/polyPatch.H>
00031
00032
00033
00034 void starMesh::createPolyBoundary()
00035 {
00036 label nBoundaryFacesFound = 0;
00037
00038 polyBoundaryPatchStartIndices_.setSize(boundary_.size());
00039
00040 label nCreatedFaces = nInternalFaces_;
00041
00042 const labelListList& PointCells = pointCells();
00043
00044 forAll (boundary_, patchI)
00045 {
00046 const faceList& curShapePatch = boundary_[patchI];
00047
00048 polyBoundaryPatchStartIndices_[patchI] = nCreatedFaces;
00049
00050 forAll (curShapePatch, faceI)
00051 {
00052 bool found = false;
00053
00054 const face& curFace = curShapePatch[faceI];
00055
00056 meshFaces_[nCreatedFaces] = curFace;
00057
00058
00059
00060 const labelList& facePoints = curFace;
00061
00062 forAll(facePoints, pointI)
00063 {
00064 const labelList& facePointCells =
00065 PointCells[facePoints[pointI]];
00066
00067 forAll(facePointCells, cellI)
00068 {
00069 const faceList& curCellFaces =
00070 cellFaces_[facePointCells[cellI]];
00071
00072 forAll(curCellFaces, cellFaceI)
00073 {
00074 if (curCellFaces[cellFaceI] == curFace)
00075 {
00076
00077 found = true;
00078
00079
00080 if
00081 (
00082 cellPolys_[facePointCells[cellI]][cellFaceI]
00083 != -1
00084 )
00085 {
00086 if
00087 (
00088 cellPolys_[facePointCells[cellI]][cellFaceI]
00089 > nInternalFaces_
00090 )
00091 {
00092 Info
00093 << "void starMesh::createPolyBoundary()"
00094 << ": Problem with face: " << curFace
00095 << "\nProbably multiple definitions "
00096 << "of a single boundary face. " << endl
00097 << "Other boundary face: "
00098 << curCellFaces[cellFaceI]
00099 << endl;
00100
00101 Info << "PROSTAR Command: vset,news,vlis";
00102 forAll (curCellFaces[cellFaceI], spI)
00103 {
00104
00105
00106 if
00107 (
00108 curCellFaces[cellFaceI][spI] > -1
00109 && curCellFaces[cellFaceI][spI]
00110 < starPointID_.size()
00111 )
00112 {
00113 Info
00114 << ","
00115 << starPointID_
00116 [curCellFaces[cellFaceI][spI]];
00117 }
00118 else
00119 {
00120 Info << ",???";
00121 }
00122 }
00123 Info << " $ bset,add,vset,all" << endl;
00124 }
00125 else
00126 {
00127 Info
00128 << "void starMesh::createPolyBoundary()"
00129 << ": Problem with face: " << curFace
00130 << "\nProbably trying to define a "
00131 << "boundary face on a previously "
00132 << "matched internal face. " << endl
00133 << "Internal face: "
00134 << curCellFaces[cellFaceI]
00135 << endl;
00136
00137 Info << "PROSTAR Command: vset,news,vlis";
00138 forAll (curCellFaces[cellFaceI], spI)
00139 {
00140
00141
00142 if
00143 (
00144 curCellFaces[cellFaceI][spI] > -1
00145 && curCellFaces[cellFaceI][spI]
00146 < starPointID_.size()
00147 )
00148 {
00149 Info
00150 << ","
00151 << starPointID_
00152 [curCellFaces[cellFaceI][spI]];
00153 }
00154 else
00155 {
00156 Info << ",???";
00157 }
00158 }
00159 Info << " $ bset,add,vset,all" << endl;
00160
00161 }
00162 }
00163
00164 cellPolys_[facePointCells[cellI]][cellFaceI] =
00165 nCreatedFaces;
00166
00167 nBoundaryFacesFound++;
00168 }
00169 if (found) break;
00170 }
00171 if (found) break;
00172 }
00173 if (found) break;
00174 }
00175
00176 nCreatedFaces++;
00177 }
00178 }
00179
00180
00181 label nMissingFaceFound = 0;
00182
00183 forAll (cellPolys_, cellI)
00184 {
00185 const labelList& curFaces = cellPolys_[cellI];
00186
00187 forAll (curFaces, faceI)
00188 {
00189 if (curFaces[faceI] < 0)
00190 {
00191 const face& missingFace = cellFaces_[cellI][faceI];
00192
00193 Info << "starMesh::createPolyBoundary() : "
00194 << "missing face found in cell " << cellI
00195 << ".\nType: " << cellShapes_[cellI].model().name()
00196 << ". STAR cell number: " << starCellID_[cellI]
00197 << ". Face: " << missingFace << endl;
00198
00199 nMissingFaceFound++;
00200
00201 Info << "PROSTAR Command: vset,news,vlis";
00202 forAll (missingFace, spI)
00203 {
00204
00205 if
00206 (
00207 missingFace[spI] > -1
00208 && missingFace[spI] < starPointID_.size()
00209 )
00210 {
00211 Info << "," << starPointID_[missingFace[spI]];
00212 }
00213 else
00214 {
00215 Info << ",???";
00216 }
00217 }
00218 Info << " $ bset,add,vset,all" << endl;
00219 }
00220 }
00221 }
00222
00223 if (nMissingFaceFound > 0)
00224 {
00225 Info << "Number of unmatched faces: " << nMissingFaceFound << endl;
00226 }
00227
00228
00229 meshFaces_.setSize(nCreatedFaces);
00230
00231
00232
00233 labelList markupFaces(meshFaces_.size(), 0);
00234
00235 forAll (cellPolys_, cellI)
00236 {
00237 const labelList& curFaces = cellPolys_[cellI];
00238
00239 forAll (curFaces, faceI)
00240 {
00241 markupFaces[curFaces[faceI]]++;
00242 }
00243 }
00244
00245 for (label i = nInternalFaces_; i < markupFaces.size(); i++)
00246 {
00247 markupFaces[i]++;
00248 }
00249
00250 label nProblemFacesFound = 0;
00251
00252 forAll (markupFaces, faceI)
00253 {
00254 if (markupFaces[faceI] != 2)
00255 {
00256 const face& problemFace = meshFaces_[faceI];
00257
00258 Info << "starMesh::createPolyBoundary() : "
00259 << "problem with face " << faceI << ": addressed "
00260 << markupFaces[faceI] << " times (should be 2!). Face: "
00261 << problemFace << endl;
00262
00263 nProblemFacesFound++;
00264
00265 Info << "PROSTAR Command: vset,news,vlis";
00266 forAll (problemFace, spI)
00267 {
00268
00269 if
00270 (
00271 problemFace[spI] > -1
00272 && problemFace[spI] < starPointID_.size()
00273 )
00274 {
00275 Info << "," << starPointID_[problemFace[spI]];
00276 }
00277 else
00278 {
00279 Info << ",???";
00280 }
00281 }
00282 Info << " $ bset,add,vset,all" << endl;
00283 }
00284 }
00285
00286 if (nProblemFacesFound > 0)
00287 {
00288 Info << "Number of incorrectly matched faces: "
00289 << nProblemFacesFound << endl;
00290 }
00291
00292 Info << "Number of boundary faces: " << nBoundaryFacesFound << endl;
00293 Info << "Total number of faces: " << nCreatedFaces << endl;
00294 }
00295
00296
00297 List<polyPatch*> starMesh::polyBoundaryPatches(const polyMesh& pMesh)
00298 {
00299 List<polyPatch*> p(boundary_.size());
00300
00301 forAll (boundary_, patchI)
00302 {
00303 p[patchI] = polyPatch::New
00304 (
00305 patchTypes_[patchI],
00306 patchNames_[patchI],
00307 boundary_[patchI].size(),
00308 polyBoundaryPatchStartIndices_[patchI],
00309 patchI,
00310 pMesh.boundaryMesh()
00311 ).ptr();
00312 }
00313
00314 return p;
00315 }
00316
00317
00318