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