1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Create intermediate mesh files from SAMM files
27 \*---------------------------------------------------------------------------*/
31 #include "wallPolyPatch.H"
32 #include "cyclicPolyPatch.H"
33 #include "symmetryPolyPatch.H"
34 #include "preservePatchTypes.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 void sammMesh::readBoundary()
41 label nPatches=0, nFaces=0;
42 labelList nPatchFaces(1000);
44 label lineIndex, sammLabel;
45 label sammRegion, configNumber;
47 labelList pointLabels(4);
48 labelList pointLabelsTri(3);
50 labelList patchLabels(1000, -1);
53 patchTypes_.setSize(1000);
54 patchNames_.setSize(1000);
56 fileName boundaryFileName(casePrefix_ + ".bnd");
59 IFstream boundaryFile(boundaryFileName);
61 // Collect no. of faces (nFaces),
62 // no. of patches (nPatches)
63 // and for each of these patches the number of faces
64 // (nPatchFaces[patchLabel])
65 // and a conversion table from Samm regions to (Foam) patchLabels
67 if (boundaryFile.good())
69 forAll(nPatchFaces, faceLabel)
71 nPatchFaces[faceLabel] = 0;
74 while ((boundaryFile >> lineIndex).good())
79 for (int i=0; i<4; i++)
81 boundaryFile >> sammLabel;
84 boundaryFile >> sammRegion;
85 boundaryFile >> configNumber;
86 boundaryFile >> patchType;
88 // Build translation table to convert samm patch to foam patch
89 label patchLabel = patchLabels[sammRegion];
92 patchLabel = nPatches;
93 patchLabels[sammRegion] = patchLabel;
94 patchTypes_[patchLabel] = patchType;
95 patchNames_[patchLabel] = patchType + name(sammRegion);
99 Info<< "Samm region " << sammRegion
100 << " with type " << patchType
101 << " is now Foam patch " << patchLabel << endl;
105 nPatchFaces[patchLabel]++;
110 << "Setting size of shapePatchList to " << nPatches
113 nPatchFaces.setSize(nPatches);
114 patchTypes_.setSize(nPatches);
115 patchNames_.setSize(nPatches);
119 FatalErrorIn("void sammMesh::readBoundary()")
120 << "Cannot read file "
122 << abort(FatalError);
128 boundary_.setSize(nPatchFaces.size());
129 patchTypes_.setSize(nPatchFaces.size());
130 patchNames_.setSize(nPatchFaces.size());
132 // size the lists and reset the counters to be used again
133 forAll(boundary_, patchLabel)
135 boundary_[patchLabel].setSize(nPatchFaces[patchLabel]);
137 nPatchFaces[patchLabel] = 0;
140 IFstream boundaryFile(boundaryFileName);
142 for (label faceI=0; faceI<nFaces; faceI++)
144 boundaryFile >> lineIndex;
146 for (int i = 0; i < 4; i++)
148 boundaryFile >> sammLabel;
150 // convert Samm label to Foam point label
151 // through lookup-list starPointLabelLookup_
152 pointLabels[i] = starPointLabelLookup_[sammLabel];
154 if (pointLabels[i] < 0)
156 Info<< "Boundary file not consistent with vertex file\n"
157 << "Samm vertex number " << sammLabel
158 << " does not exist\n";
163 boundaryFile >> sammRegion;
164 label patchLabel = patchLabels[sammRegion];
166 boundaryFile >> configNumber;
167 boundaryFile >> patchType;
171 pointLabels[2] == pointLabels[3]
174 //Info<< "Converting collapsed quad into triangle"
175 // << " for face " << faceI
176 // << " in Samm boundary " << lineIndex << endl;
178 pointLabelsTri[0] = pointLabels[0];
179 pointLabelsTri[1] = pointLabels[1];
180 pointLabelsTri[2] = pointLabels[2];
182 boundary_[patchLabel][nPatchFaces[patchLabel]]
183 = face(pointLabelsTri);
187 boundary_[patchLabel][nPatchFaces[patchLabel]]
191 // increment counter of faces in current patch
192 nPatchFaces[patchLabel]++;
195 forAll(boundary_, patchLabel)
197 word patchType = patchTypes_[patchLabel];
199 if (patchType == "SYMP")
201 patchTypes_[patchLabel] = symmetryPolyPatch::typeName;
203 else if (patchType == "WALL")
205 patchTypes_[patchLabel] = wallPolyPatch::typeName;
207 else if (patchType == "CYCL")
209 // incorrect. should be cyclicPatch but this
210 // requires info on connected faces.
211 patchTypes_[patchLabel] = cyclicPolyPatch::typeName;
215 patchTypes_[patchLabel] = polyPatch::typeName;
218 Info<< "Foam patch " << patchLabel
219 << " is of type " << patchTypes_[patchLabel]
220 << " with name " << patchNames_[patchLabel] << endl;
225 FatalErrorIn("sammMesh::readBoundary()")
226 << "No boundary faces in file "
231 patchPhysicalTypes_.setSize(patchTypes_.size());
233 PtrList<dictionary> patchDicts;
239 polyMesh::meshSubDir,
246 forAll(patchDicts, patchI)
248 if (patchDicts.set(patchI))
250 const dictionary& dict = patchDicts[patchI];
251 dict.readIfPresent("type", patchTypes_[patchI]);
252 dict.readIfPresent("physicalType", patchPhysicalTypes_[patchI]);
258 // ************************************************************************* //