initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / applications / utilities / mesh / generation / blockMesh / blockMesh.C
blob640971ada099b069f25467cf1bb6f97a199bd754
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 Application
26     blockMesh
28 Description
29     Mesh generator
31 \*---------------------------------------------------------------------------*/
33 #include "blockMesh.H"
36 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
38 // Construct from IOdictionary
39 Foam::blockMesh::blockMesh(IOdictionary& meshDescription)
41     topologyPtr_(createTopology(meshDescription)),
42     blockOffsets_(createBlockOffsets()),
43     mergeList_(createMergeList()),
44     points_(createPoints(meshDescription)),
45     cells_(createCells()),
46     patches_(createPatches())
50 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
52 Foam::blockMesh::~blockMesh()
54     delete topologyPtr_;
58 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
60 const Foam::polyMesh& Foam::blockMesh::topology() const
62     if (!topologyPtr_)
63     {
64         FatalErrorIn("blockMesh::topology() const")
65             << "topologyPtr_ not allocated"
66             << exit(FatalError);
67     }
69     return *topologyPtr_;
73 Foam::wordList Foam::blockMesh::patchNames() const
75     const polyPatchList& patchTopologies = topology().boundaryMesh();
76     wordList names(patchTopologies.size());
78     forAll (names, patchI)
79     {
80         names[patchI] = patchTopologies[patchI].name();
81     }
83     return names;
87 Foam::wordList Foam::blockMesh::patchTypes() const
89     const polyPatchList& patchTopologies = topology().boundaryMesh();
90     wordList types(patchTopologies.size());
92     forAll (types, patchI)
93     {
94         types[patchI] = patchTopologies[patchI].type();
95     }
97     return types;
101 Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
103     const polyPatchList& patchTopologies = topology().boundaryMesh();
104     wordList physicalTypes(patchTopologies.size());
106     forAll (physicalTypes, patchI)
107     {
108         physicalTypes[patchI] = patchTopologies[patchI].physicalType();
109     }
111     return physicalTypes;
115 Foam::label Foam::blockMesh::numZonedBlocks() const
117     label num = 0;
119     forAll(*this, blockI)
120     {
121         if (operator[](blockI).blockDef().zoneName().size())
122         {
123             num++;
124         }
125     }
127     return num;
131 void Foam::blockMesh::writeTopology(Ostream& os) const
133     const pointField& pts = topology().points();
135     forAll(pts, pI)
136     {
137         const point& pt = pts[pI];
139         os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
140     }
142     const edgeList& edges = topology().edges();
144     forAll(edges, eI)
145     {
146         const edge& e = edges[eI];
148         os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl;
149     }
152 // ************************************************************************* //