FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

blockMesh.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Application
00025     blockMesh
00026 
00027 Description
00028     Mesh generator
00029 
00030 \*---------------------------------------------------------------------------*/
00031 
00032 #include "blockMesh.H"
00033 
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 // Construct from IOdictionary
00038 Foam::blockMesh::blockMesh(IOdictionary& meshDescription)
00039 :
00040     topologyPtr_(createTopology(meshDescription)),
00041     blockOffsets_(createBlockOffsets()),
00042     mergeList_(createMergeList()),
00043     points_(createPoints(meshDescription)),
00044     cells_(createCells()),
00045     patches_(createPatches())
00046 {}
00047 
00048 
00049 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00050 
00051 Foam::blockMesh::~blockMesh()
00052 {
00053     delete topologyPtr_;
00054 }
00055 
00056 
00057 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00058 
00059 const Foam::polyMesh& Foam::blockMesh::topology() const
00060 {
00061     if (!topologyPtr_)
00062     {
00063         FatalErrorIn("blockMesh::topology() const")
00064             << "topologyPtr_ not allocated"
00065             << exit(FatalError);
00066     }
00067 
00068     return *topologyPtr_;
00069 }
00070 
00071 
00072 Foam::wordList Foam::blockMesh::patchNames() const
00073 {
00074     const polyPatchList& patchTopologies = topology().boundaryMesh();
00075     wordList names(patchTopologies.size());
00076 
00077     forAll (names, patchI)
00078     {
00079         names[patchI] = patchTopologies[patchI].name();
00080     }
00081 
00082     return names;
00083 }
00084 
00085 
00086 Foam::wordList Foam::blockMesh::patchTypes() const
00087 {
00088     const polyPatchList& patchTopologies = topology().boundaryMesh();
00089     wordList types(patchTopologies.size());
00090 
00091     forAll (types, patchI)
00092     {
00093         types[patchI] = patchTopologies[patchI].type();
00094     }
00095 
00096     return types;
00097 }
00098 
00099 
00100 Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
00101 {
00102     const polyPatchList& patchTopologies = topology().boundaryMesh();
00103     wordList physicalTypes(patchTopologies.size());
00104 
00105     forAll (physicalTypes, patchI)
00106     {
00107         physicalTypes[patchI] = patchTopologies[patchI].physicalType();
00108     }
00109 
00110     return physicalTypes;
00111 }
00112 
00113 
00114 Foam::label Foam::blockMesh::numZonedBlocks() const
00115 {
00116     label num = 0;
00117 
00118     forAll(*this, blockI)
00119     {
00120         if (operator[](blockI).blockDef().zoneName().size())
00121         {
00122             num++;
00123         }
00124     }
00125 
00126     return num;
00127 }
00128 
00129 
00130 void Foam::blockMesh::writeTopology(Ostream& os) const
00131 {
00132     const pointField& pts = topology().points();
00133 
00134     forAll(pts, pI)
00135     {
00136         const point& pt = pts[pI];
00137 
00138         os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
00139     }
00140 
00141     const edgeList& edges = topology().edges();
00142 
00143     forAll(edges, eI)
00144     {
00145         const edge& e = edges[eI];
00146 
00147         os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl;
00148     }
00149 }
00150 
00151 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines