initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / mesh / generation / blockMesh / blockMesh.C
blobebd8db02f2b151594f0d3c82bdb275b8d0855c10
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 Application
26     blockMesh
28 Description
29     Mesh generator
31 \*---------------------------------------------------------------------------*/
33 #include "blockMesh.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace Foam
40 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
42 // Construct from IOdictionary
43 blockMesh::blockMesh(IOdictionary& meshDescription)
45     topologyPtr_(createTopology(meshDescription)),
46     scale_(readScalar(meshDescription.lookup("convertToMeters"))),
47     blockOffsets_(createBlockOffsets()),
48     mergeList_(createMergeList()),
49     points_(createPoints()),
50     cells_(createCells()),
51     patches_(createPatches())
55 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
57 blockMesh::~blockMesh()
59     delete topologyPtr_;
63 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
65 const polyMesh& blockMesh::topology() const
67     if (!topologyPtr_)
68     {
69         FatalErrorIn("blockMesh::topology() const")
70             << "topologyPtr_ not allocated"
71             << exit(FatalError);
72     }
74     return *topologyPtr_;
78 const curvedEdgeList& blockMesh::edges() const
80     return edges_;
84 wordList blockMesh::patchNames() const
86     const polyPatchList& patchTopologies = topology().boundaryMesh();
87     wordList names(patchTopologies.size());
89     forAll (names, patchI)
90     {
91         names[patchI] = patchTopologies[patchI].name();
92     }
94     return names;
98 wordList blockMesh::patchTypes() const
100     const polyPatchList& patchTopologies = topology().boundaryMesh();
101     wordList types(patchTopologies.size());
103     forAll (types, patchI)
104     {
105         types[patchI] = patchTopologies[patchI].type();
106     }
108     return types;
112 wordList blockMesh::patchPhysicalTypes() const
114     const polyPatchList& patchTopologies = topology().boundaryMesh();
115     wordList physicalTypes(patchTopologies.size());
117     forAll (physicalTypes, patchI)
118     {
119         physicalTypes[patchI] = patchTopologies[patchI].physicalType();
120     }
122     return physicalTypes;
126 label blockMesh::numZonedBlocks() const
128     label num = 0;
130     forAll(*this, blockI)
131     {
132         if (operator[](blockI).blockDef().zoneName().size() > 0)
133         {
134             num++;
135         }
136     }
138     return num;
142 void blockMesh::writeTopology(Ostream& os) const
144     const pointField& pts = topology().points();
146     forAll(pts, pI)
147     {
148         const point& pt = pts[pI];
150         os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
151     }
153     const edgeList& edges = topology().edges();
155     forAll(edges, eI)
156     {
157         const edge& e = edges[eI];
159         os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl;
160     }
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 } // End namespace Foam
168 // ************************************************************************* //