BUG: PointEdgeWave : n cyclics bool instead of label
[OpenFOAM-1.6.x.git] / src / conversion / meshReader / meshReader.C
blob0bb5ea612dcf14d9b97d4034cc021f0bc7ad55bf
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 \*---------------------------------------------------------------------------*/
27 #include "meshReader.H"
28 #include "Time.H"
29 #include "polyMesh.H"
30 #include "faceSet.H"
31 #include "emptyPolyPatch.H"
32 #include "cellModeller.H"
33 #include "demandDrivenData.H"
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 const Foam::cellModel* Foam::meshReader::unknownModel = Foam::cellModeller::
38 lookup
40     "unknown"
43 const Foam::cellModel* Foam::meshReader::tetModel = Foam::cellModeller::
44 lookup
46     "tet"
49 const Foam::cellModel* Foam::meshReader::pyrModel = Foam::cellModeller::
50 lookup
52     "pyr"
55 const Foam::cellModel* Foam::meshReader::prismModel = Foam::cellModeller::
56 lookup
58     "prism"
61 const Foam::cellModel* Foam::meshReader::hexModel = Foam::cellModeller::
62 lookup
64     "hex"
68 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
70 void Foam::meshReader::addCellZones(polyMesh& mesh) const
72     cellTable_.addCellZones(mesh, cellTableId_);
73     warnDuplicates("cellZones", mesh.cellZones().names());
77 void Foam::meshReader::addFaceZones(polyMesh& mesh) const
79     label nZone = monitoringSets_.size();
80     mesh.faceZones().setSize(nZone);
82     if (!nZone)
83     {
84         return;
85     }
87     nZone = 0;
88     for
89     (
90         HashTable<List<label>, word, string::hash>::const_iterator
91         iter = monitoringSets_.begin();
92         iter != monitoringSets_.end();
93         ++iter
94     )
95     {
96         Info<< "faceZone " << nZone
97             << " (size: " << iter().size() << ") name: "
98             << iter.key() << endl;
100         mesh.faceZones().set
101         (
102             nZone,
103             new faceZone
104             (
105                 iter.key(),
106                 iter(),
107                 List<bool>(iter().size(), false),
108                 nZone,
109                 mesh.faceZones()
110             )
111         );
113         nZone++;
114     }
115     mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
116     warnDuplicates("faceZones", mesh.faceZones().names());
120 Foam::autoPtr<Foam::polyMesh> Foam::meshReader::mesh
122     const objectRegistry& registry
125     readGeometry();
127     Info<< "Creating a polyMesh" << endl;
128     createPolyCells();
130     Info<< "Number of internal faces: " << nInternalFaces_ << endl;
132     createPolyBoundary();
133     clearExtraStorage();
135     autoPtr<polyMesh> mesh
136     (
137         new polyMesh
138         (
139             IOobject
140             (
141                 polyMesh::defaultRegion,
142                 "constant",
143                 registry
144             ),
145             xferMove(points_),
146             xferMove(meshFaces_),
147             xferMove(cellPolys_)
148         )
149     );
151     // adding patches also checks the mesh
152     mesh().addPatches(polyBoundaryPatches(mesh));
154     warnDuplicates("boundaries", mesh().boundaryMesh().names());
156     addCellZones(mesh());
157     addFaceZones(mesh());
159     return mesh;
163 void Foam::meshReader::writeMesh
165     const polyMesh& mesh,
166     IOstream::streamFormat fmt
167 ) const
169     mesh.removeFiles();
171     Info<< "Writing polyMesh" << endl;
172     mesh.writeObject
173     (
174         fmt,
175         IOstream::currentVersion,
176         IOstream::UNCOMPRESSED
177     );
178     writeAux(mesh);
182 void Foam::meshReader::clearExtraStorage()
184     cellFaces_.clear();
185     baffleFaces_.clear();
186     boundaryIds_.clear();
187     baffleIds_.clear();
189     deleteDemandDrivenData(pointCellsPtr_);
193 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
195 Foam::meshReader::meshReader
197     const fileName& fileOrPrefix,
198     const scalar scaleFactor
200     :
201     pointCellsPtr_(NULL),
202     nInternalFaces_(0),
203     patchStarts_(0),
204     patchSizes_(0),
205     interfaces_(0),
206     baffleIds_(0),
207     meshFaces_(0),
208     cellPolys_(0),
209     geometryFile_(fileOrPrefix),
210     scaleFactor_(scaleFactor),
211     points_(0),
212     origCellId_(0),
213     boundaryIds_(0),
214     patchTypes_(0),
215     patchNames_(0),
216     patchPhysicalTypes_(0),
217     cellFaces_(0),
218     baffleFaces_(0),
219     cellTableId_(0),
220     cellTable_()
224 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
226 Foam::meshReader::~meshReader()
228     deleteDemandDrivenData(pointCellsPtr_);
232 // ************************************************************************* //