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
25 \*---------------------------------------------------------------------------*/
27 #include "meshReader.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::
43 const Foam::cellModel* Foam::meshReader::tetModel = Foam::cellModeller::
49 const Foam::cellModel* Foam::meshReader::pyrModel = Foam::cellModeller::
55 const Foam::cellModel* Foam::meshReader::prismModel = Foam::cellModeller::
61 const Foam::cellModel* Foam::meshReader::hexModel = Foam::cellModeller::
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);
90 HashTable<List<label>, word, string::hash>::const_iterator
91 iter = monitoringSets_.begin();
92 iter != monitoringSets_.end();
96 Info<< "faceZone " << nZone
97 << " (size: " << iter().size() << ") name: "
98 << iter.key() << endl;
107 List<bool>(iter().size(), false),
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
127 Info<< "Creating a polyMesh" << endl;
130 Info<< "Number of internal faces: " << nInternalFaces_ << endl;
132 createPolyBoundary();
135 autoPtr<polyMesh> mesh
141 polyMesh::defaultRegion,
146 xferMove(meshFaces_),
151 // adding patches also checks the mesh
152 mesh().addPatches(polyBoundaryPatches(mesh));
154 warnDuplicates("boundaries", mesh().boundaryMesh().names());
156 addCellZones(mesh());
157 addFaceZones(mesh());
163 void Foam::meshReader::writeMesh
165 const polyMesh& mesh,
166 IOstream::streamFormat fmt
171 Info<< "Writing polyMesh" << endl;
175 IOstream::currentVersion,
176 IOstream::UNCOMPRESSED
182 void Foam::meshReader::clearExtraStorage()
185 baffleFaces_.clear();
186 boundaryIds_.clear();
189 deleteDemandDrivenData(pointCellsPtr_);
193 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
195 Foam::meshReader::meshReader
197 const fileName& fileOrPrefix,
198 const scalar scaleFactor
201 pointCellsPtr_(NULL),
209 geometryFile_(fileOrPrefix),
210 scaleFactor_(scaleFactor),
216 patchPhysicalTypes_(0),
224 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
226 Foam::meshReader::~meshReader()
228 deleteDemandDrivenData(pointCellsPtr_);
232 // ************************************************************************* //