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