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 "sammMesh.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 sammMesh::readBoundary()
00041 {
00042 label nPatches=0, nFaces=0;
00043 labelList nPatchFaces(1000);
00044
00045 label lineIndex, sammLabel;
00046 label sammRegion, 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 >> sammLabel;
00083 }
00084
00085 boundaryFile >> sammRegion;
00086 boundaryFile >> configNumber;
00087 boundaryFile >> patchType;
00088
00089
00090 label patchLabel = patchLabels[sammRegion];
00091 if (patchLabel == -1)
00092 {
00093 patchLabel = nPatches;
00094 patchLabels[sammRegion] = patchLabel;
00095 patchTypes_[patchLabel] = patchType;
00096 patchNames_[patchLabel] = patchType + name(sammRegion);
00097
00098 nPatches++;
00099
00100 Info<< "Samm region " << sammRegion
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 shapePatchList to " << nPatches
00112 << nl << endl;
00113
00114 nPatchFaces.setSize(nPatches);
00115 patchTypes_.setSize(nPatches);
00116 patchNames_.setSize(nPatches);
00117 }
00118 else
00119 {
00120 FatalErrorIn("void sammMesh::readBoundary()")
00121 << "Cannot read file "
00122 << boundaryFileName
00123 << abort(FatalError);
00124 }
00125 }
00126
00127 if (nPatches > 0)
00128 {
00129 boundary_.setSize(nPatchFaces.size());
00130 patchTypes_.setSize(nPatchFaces.size());
00131 patchNames_.setSize(nPatchFaces.size());
00132
00133
00134 forAll(boundary_, patchLabel)
00135 {
00136 boundary_[patchLabel].setSize(nPatchFaces[patchLabel]);
00137
00138 nPatchFaces[patchLabel] = 0;
00139 }
00140
00141 IFstream boundaryFile(boundaryFileName);
00142
00143 for (label faceI=0; faceI<nFaces; faceI++)
00144 {
00145 boundaryFile >> lineIndex;
00146
00147 for (int i = 0; i < 4; i++)
00148 {
00149 boundaryFile >> sammLabel;
00150
00151
00152
00153 pointLabels[i] = starPointLabelLookup_[sammLabel];
00154
00155 if (pointLabels[i] < 0)
00156 {
00157 Info<< "Boundary file not consistent with vertex file\n"
00158 << "Samm vertex number " << sammLabel
00159 << " does not exist\n";
00160 }
00161
00162 }
00163
00164 boundaryFile >> sammRegion;
00165 label patchLabel = patchLabels[sammRegion];
00166
00167 boundaryFile >> configNumber;
00168 boundaryFile >> patchType;
00169
00170 if
00171 (
00172 pointLabels[2] == pointLabels[3]
00173 )
00174 {
00175
00176
00177
00178
00179 pointLabelsTri[0] = pointLabels[0];
00180 pointLabelsTri[1] = pointLabels[1];
00181 pointLabelsTri[2] = pointLabels[2];
00182
00183 boundary_[patchLabel][nPatchFaces[patchLabel]]
00184 = face(pointLabelsTri);
00185 }
00186 else
00187 {
00188 boundary_[patchLabel][nPatchFaces[patchLabel]]
00189 = face(pointLabels);
00190 }
00191
00192
00193 nPatchFaces[patchLabel]++;
00194 }
00195
00196 forAll(boundary_, patchLabel)
00197 {
00198 word patchType = patchTypes_[patchLabel];
00199
00200 if (patchType == "SYMP")
00201 {
00202 patchTypes_[patchLabel] = symmetryPolyPatch::typeName;
00203 }
00204 else if (patchType == "WALL")
00205 {
00206 patchTypes_[patchLabel] = wallPolyPatch::typeName;
00207 }
00208 else if (patchType == "CYCL")
00209 {
00210
00211
00212 patchTypes_[patchLabel] = cyclicPolyPatch::typeName;
00213 }
00214 else
00215 {
00216 patchTypes_[patchLabel] = polyPatch::typeName;
00217 }
00218
00219 Info<< "Foam patch " << patchLabel
00220 << " is of type " << patchTypes_[patchLabel]
00221 << " with name " << patchNames_[patchLabel] << endl;
00222 }
00223 }
00224 else
00225 {
00226 FatalErrorIn("sammMesh::readBoundary()")
00227 << "No boundary faces in file "
00228 << boundaryFileName
00229 << endl;
00230 }
00231
00232 patchPhysicalTypes_.setSize(patchTypes_.size());
00233
00234 preservePatchTypes
00235 (
00236 runTime_,
00237 runTime_.constant(),
00238 polyMesh::defaultRegion,
00239 patchNames_,
00240 patchTypes_,
00241 defaultFacesName_,
00242 defaultFacesType_,
00243 patchPhysicalTypes_
00244 );
00245 }
00246
00247
00248
Copyright © 2000-2009 OpenCFD Ltd