1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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,
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
169 fileName meshDir = mesh.objectRegistry::path()/mesh.meshDir();
171 // remove some directories and files - this should be easier
172 mesh.removeFiles(mesh.instance());
173 if (dir(meshDir/"sets"))
175 rmDir(meshDir/"sets");
178 Info<< "Writing polyMesh" << endl;
182 IOstream::currentVersion,
183 IOstream::UNCOMPRESSED
189 void Foam::meshReader::clearExtraStorage()
192 baffleFaces_.clear();
193 boundaryIds_.clear();
196 deleteDemandDrivenData(pointCellsPtr_);
200 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
202 Foam::meshReader::meshReader
204 const fileName& fileOrPrefix,
205 const scalar scaleFactor
208 pointCellsPtr_(NULL),
216 geometryFile_(fileOrPrefix),
217 scaleFactor_(scaleFactor),
223 patchPhysicalTypes_(0),
231 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
233 Foam::meshReader::~meshReader()
235 deleteDemandDrivenData(pointCellsPtr_);
239 // ************************************************************************* //