1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "meshReader.H"
30 #include "emptyPolyPatch.H"
31 #include "cellModeller.H"
32 #include "demandDrivenData.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 const Foam::cellModel* Foam::meshReader::unknownModel = Foam::cellModeller::
42 const Foam::cellModel* Foam::meshReader::tetModel = Foam::cellModeller::
48 const Foam::cellModel* Foam::meshReader::pyrModel = Foam::cellModeller::
54 const Foam::cellModel* Foam::meshReader::prismModel = Foam::cellModeller::
60 const Foam::cellModel* Foam::meshReader::hexModel = Foam::cellModeller::
67 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
69 void Foam::meshReader::addCellZones(polyMesh& mesh) const
71 cellTable_.addCellZones(mesh, cellTableId_);
72 warnDuplicates("cellZones", mesh.cellZones().names());
76 void Foam::meshReader::addFaceZones(polyMesh& mesh) const
78 label nZone = monitoringSets_.size();
79 mesh.faceZones().setSize(nZone);
89 HashTable<List<label>, word, string::hash>::const_iterator
90 iter = monitoringSets_.begin();
91 iter != monitoringSets_.end();
95 Info<< "faceZone " << nZone
96 << " (size: " << iter().size() << ") name: "
97 << iter.key() << endl;
106 List<bool>(iter().size(), false),
114 mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE;
115 warnDuplicates("faceZones", mesh.faceZones().names());
119 Foam::autoPtr<Foam::polyMesh> Foam::meshReader::mesh
121 const objectRegistry& registry
126 Info<< "Creating a polyMesh" << endl;
129 Info<< "Number of internal faces: " << nInternalFaces_ << endl;
131 createPolyBoundary();
134 autoPtr<polyMesh> mesh
140 polyMesh::defaultRegion,
145 xferMove(meshFaces_),
150 // adding patches also checks the mesh
151 mesh().addPatches(polyBoundaryPatches(mesh));
153 warnDuplicates("boundaries", mesh().boundaryMesh().names());
155 addCellZones(mesh());
156 addFaceZones(mesh());
162 void Foam::meshReader::writeMesh
164 const polyMesh& mesh,
165 IOstream::streamFormat fmt
170 Info<< "Writing polyMesh" << endl;
174 IOstream::currentVersion,
175 IOstream::UNCOMPRESSED
181 void Foam::meshReader::clearExtraStorage()
184 baffleFaces_.clear();
185 boundaryIds_.clear();
188 deleteDemandDrivenData(pointCellsPtr_);
192 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
194 Foam::meshReader::meshReader
196 const fileName& fileOrPrefix,
197 const scalar scaleFactor
200 pointCellsPtr_(NULL),
208 geometryFile_(fileOrPrefix),
209 scaleFactor_(scaleFactor),
215 patchPhysicalTypes_(0),
223 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
225 Foam::meshReader::~meshReader()
227 deleteDemandDrivenData(pointCellsPtr_);
231 // ************************************************************************* //