1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Create intermediate mesh files from SAMM files
28 \*---------------------------------------------------------------------------*/
32 #include "wallPolyPatch.H"
33 #include "cyclicPolyPatch.H"
34 #include "symmetryPolyPatch.H"
35 #include "preservePatchTypes.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 void sammMesh::readBoundary()
42 label nPatches=0, nFaces=0;
43 labelList nPatchFaces(1000);
45 label lineIndex, sammLabel;
46 label sammRegion, configNumber;
48 labelList pointLabels(4);
49 labelList pointLabelsTri(3);
51 labelList patchLabels(1000, -1);
54 patchTypes_.setSize(1000);
55 patchNames_.setSize(1000);
57 fileName boundaryFileName(casePrefix_ + ".bnd");
60 IFstream boundaryFile(boundaryFileName);
62 // Collect no. of faces (nFaces),
63 // no. of patches (nPatches)
64 // and for each of these patches the number of faces
65 // (nPatchFaces[patchLabel])
66 // and a conversion table from Samm regions to (Foam) patchLabels
68 if (boundaryFile.good())
70 forAll(nPatchFaces, faceLabel)
72 nPatchFaces[faceLabel] = 0;
75 while ((boundaryFile >> lineIndex).good())
80 for (int i=0; i<4; i++)
82 boundaryFile >> sammLabel;
85 boundaryFile >> sammRegion;
86 boundaryFile >> configNumber;
87 boundaryFile >> patchType;
89 // Build translation table to convert samm patch to foam patch
90 label patchLabel = patchLabels[sammRegion];
93 patchLabel = nPatches;
94 patchLabels[sammRegion] = patchLabel;
95 patchTypes_[patchLabel] = patchType;
96 patchNames_[patchLabel] = patchType + name(sammRegion);
100 Info<< "Samm region " << sammRegion
101 << " with type " << patchType
102 << " is now Foam patch " << patchLabel << endl;
106 nPatchFaces[patchLabel]++;
111 << "Setting size of shapePatchList to " << nPatches
114 nPatchFaces.setSize(nPatches);
115 patchTypes_.setSize(nPatches);
116 patchNames_.setSize(nPatches);
120 FatalErrorIn("void sammMesh::readBoundary()")
121 << "Cannot read file "
123 << abort(FatalError);
129 boundary_.setSize(nPatchFaces.size());
130 patchTypes_.setSize(nPatchFaces.size());
131 patchNames_.setSize(nPatchFaces.size());
133 // size the lists and reset the counters to be used again
134 forAll(boundary_, patchLabel)
136 boundary_[patchLabel].setSize(nPatchFaces[patchLabel]);
138 nPatchFaces[patchLabel] = 0;
141 IFstream boundaryFile(boundaryFileName);
143 for (label faceI=0; faceI<nFaces; faceI++)
145 boundaryFile >> lineIndex;
147 for (int i = 0; i < 4; i++)
149 boundaryFile >> sammLabel;
151 // convert Samm label to Foam point label
152 // through lookup-list starPointLabelLookup_
153 pointLabels[i] = starPointLabelLookup_[sammLabel];
155 if (pointLabels[i] < 0)
157 Info<< "Boundary file not consistent with vertex file\n"
158 << "Samm vertex number " << sammLabel
159 << " does not exist\n";
164 boundaryFile >> sammRegion;
165 label patchLabel = patchLabels[sammRegion];
167 boundaryFile >> configNumber;
168 boundaryFile >> patchType;
172 pointLabels[2] == pointLabels[3]
175 //Info<< "Converting collapsed quad into triangle"
176 // << " for face " << faceI
177 // << " in Samm boundary " << lineIndex << endl;
179 pointLabelsTri[0] = pointLabels[0];
180 pointLabelsTri[1] = pointLabels[1];
181 pointLabelsTri[2] = pointLabels[2];
183 boundary_[patchLabel][nPatchFaces[patchLabel]]
184 = face(pointLabelsTri);
188 boundary_[patchLabel][nPatchFaces[patchLabel]]
192 // increment counter of faces in current patch
193 nPatchFaces[patchLabel]++;
196 forAll(boundary_, patchLabel)
198 word patchType = patchTypes_[patchLabel];
200 if (patchType == "SYMP")
202 patchTypes_[patchLabel] = symmetryPolyPatch::typeName;
204 else if (patchType == "WALL")
206 patchTypes_[patchLabel] = wallPolyPatch::typeName;
208 else if (patchType == "CYCL")
210 // incorrect. should be cyclicPatch but this
211 // requires info on connected faces.
212 patchTypes_[patchLabel] = cyclicPolyPatch::typeName;
216 patchTypes_[patchLabel] = polyPatch::typeName;
219 Info<< "Foam patch " << patchLabel
220 << " is of type " << patchTypes_[patchLabel]
221 << " with name " << patchNames_[patchLabel] << endl;
226 FatalErrorIn("sammMesh::readBoundary()")
227 << "No boundary faces in file "
232 patchPhysicalTypes_.setSize(patchTypes_.size());
238 polyMesh::defaultRegion,
248 // ************************************************************************* //