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 "starMesh.H"
00030 #include <OpenFOAM/Time.H>
00031 #include <OpenFOAM/wallPolyPatch.H>
00032 #include <OpenFOAM/cyclicPolyPatch.H>
00033 #include <OpenFOAM/symmetryPolyPatch.H>
00034 #include <OpenFOAM/preservePatchTypes.H>
00035 #include <OpenFOAM/IFstream.H>
00036
00037
00038
00039 void starMesh::readBoundary()
00040 {
00041 label nPatches=0, nFaces=0;
00042 labelList nPatchFaces(1000);
00043
00044 label lineIndex, starLabel;
00045 label starRegion, configNumber;
00046
00047 labelList pointLabels(4);
00048 labelList pointLabelsTri(3);
00049
00050 labelList patchLabels(1000, -1);
00051
00052 word patchType;
00053 patchTypes_.setSize(1000);
00054 patchNames_.setSize(1000);
00055
00056 fileName boundaryFileName(casePrefix_ + ".bnd");
00057
00058 {
00059 IFstream boundaryFile(boundaryFileName);
00060
00061
00062
00063
00064
00065
00066
00067 if (boundaryFile.good())
00068 {
00069 forAll(nPatchFaces, faceLabel)
00070 {
00071 nPatchFaces[faceLabel] = 0;
00072 }
00073
00074 while ((boundaryFile >> lineIndex).good())
00075 {
00076 nFaces++;
00077
00078
00079 for (int i=0; i<4; i++)
00080 {
00081 boundaryFile >> starLabel;
00082 }
00083
00084 boundaryFile >> starRegion;
00085 boundaryFile >> configNumber;
00086 boundaryFile >> patchType;
00087
00088
00089 label patchLabel = patchLabels[starRegion];
00090 if (patchLabel == -1)
00091 {
00092 patchLabel = nPatches;
00093 patchLabels[starRegion] = patchLabel;
00094 patchTypes_[patchLabel] = patchType;
00095 patchNames_[patchLabel] = patchType + name(starRegion);
00096
00097 nPatches++;
00098
00099 Info<< "Star region " << starRegion
00100 << " with type " << patchType
00101 << " is now Foam patch " << patchLabel << endl;
00102
00103 }
00104
00105 nPatchFaces[patchLabel]++;
00106 }
00107
00108
00109 Info<< nl
00110 << "Setting size of boundary to " << nPatches
00111 << nl << endl;
00112
00113 nPatchFaces.setSize(nPatches);
00114 }
00115 else
00116 {
00117 FatalErrorIn("starMesh::readBoundary()")
00118 << "Cannot read file "
00119 << boundaryFileName
00120 << abort(FatalError);
00121 }
00122 }
00123
00124 if (nPatches > 0)
00125 {
00126 boundary_.setSize(nPatchFaces.size());
00127 patchTypes_.setSize(nPatchFaces.size());
00128 patchNames_.setSize(nPatchFaces.size());
00129
00130
00131 forAll(boundary_, patchLabel)
00132 {
00133 boundary_[patchLabel].setSize(nPatchFaces[patchLabel]);
00134
00135 nPatchFaces[patchLabel] = 0;
00136 }
00137
00138 IFstream boundaryFile(boundaryFileName);
00139
00140 for (label faceI=0; faceI<nFaces; faceI++)
00141 {
00142 boundaryFile >> lineIndex;
00143
00144 for (int i = 0; i < 4; i++)
00145 {
00146 boundaryFile >> starLabel;
00147
00148
00149
00150 pointLabels[i] = starPointLabelLookup_[starLabel];
00151
00152 if (pointLabels[i] < 0)
00153 {
00154 Info<< "Boundary file not consistent with vertex file\n"
00155 << "Star vertex number " << starLabel
00156 << " does not exist\n";
00157 }
00158
00159 }
00160
00161 boundaryFile >> starRegion;
00162 label patchLabel = patchLabels[starRegion];
00163
00164 boundaryFile >> configNumber;
00165 boundaryFile >> patchType;
00166
00167 if
00168 (
00169 pointLabels[2] == pointLabels[3]
00170 )
00171 {
00172
00173
00174
00175
00176 pointLabelsTri[0] = pointLabels[0];
00177 pointLabelsTri[1] = pointLabels[1];
00178 pointLabelsTri[2] = pointLabels[2];
00179
00180 boundary_[patchLabel][nPatchFaces[patchLabel]]
00181 = face(pointLabelsTri);
00182 }
00183 else
00184 {
00185 boundary_[patchLabel][nPatchFaces[patchLabel]]
00186 = face(pointLabels);
00187 }
00188
00189
00190 nPatchFaces[patchLabel]++;
00191 }
00192
00193 forAll(boundary_, patchLabel)
00194 {
00195 word patchType = patchTypes_[patchLabel];
00196
00197 if (patchType == "SYMP")
00198 {
00199 patchTypes_[patchLabel] = symmetryPolyPatch::typeName;
00200 }
00201 else if (patchType == "WALL")
00202 {
00203 patchTypes_[patchLabel] = wallPolyPatch::typeName;
00204 }
00205 else if (patchType == "CYCL")
00206 {
00207
00208
00209 patchTypes_[patchLabel] = cyclicPolyPatch::typeName;
00210 }
00211 else
00212 {
00213 patchTypes_[patchLabel] = polyPatch::typeName;
00214 }
00215
00216 Info<< "Foam patch " << patchLabel
00217 << " is of type " << patchTypes_[patchLabel]
00218 << " with name " << patchNames_[patchLabel] << endl;
00219 }
00220 }
00221 else
00222 {
00223 WarningIn("void starMesh::readBoundary()")
00224 << "no boundary faces in file "
00225 << boundaryFileName
00226 << endl;
00227 }
00228
00229 patchPhysicalTypes_.setSize(patchTypes_.size());
00230
00231 preservePatchTypes
00232 (
00233 runTime_,
00234 runTime_.constant(),
00235 polyMesh::defaultRegion,
00236 patchNames_,
00237 patchTypes_,
00238 defaultFacesName_,
00239 defaultFacesType_,
00240 patchPhysicalTypes_
00241 );
00242 }
00243
00244
00245