OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     blockMesh
00027 
00028 Description
00029     Mesh generator
00030 
00031 \*---------------------------------------------------------------------------*/
00032 
00033 #include "blockMesh.H"
00034 
00035 
00036 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00037 
00038 // Construct from IOdictionary
00039 Foam::blockMesh::blockMesh(IOdictionary& meshDescription)
00040 :
00041     topologyPtr_(createTopology(meshDescription)),
00042     blockOffsets_(createBlockOffsets()),
00043     mergeList_(createMergeList()),
00044     points_(createPoints(meshDescription)),
00045     cells_(createCells()),
00046     patches_(createPatches())
00047 {}
00048 
00049 
00050 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00051 
00052 Foam::blockMesh::~blockMesh()
00053 {
00054     delete topologyPtr_;
00055 }
00056 
00057 
00058 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00059 
00060 const Foam::polyMesh& Foam::blockMesh::topology() const
00061 {
00062     if (!topologyPtr_)
00063     {
00064         FatalErrorIn("blockMesh::topology() const")
00065             << "topologyPtr_ not allocated"
00066             << exit(FatalError);
00067     }
00068 
00069     return *topologyPtr_;
00070 }
00071 
00072 
00073 Foam::wordList Foam::blockMesh::patchNames() const
00074 {
00075     const polyPatchList& patchTopologies = topology().boundaryMesh();
00076     wordList names(patchTopologies.size());
00077 
00078     forAll (names, patchI)
00079     {
00080         names[patchI] = patchTopologies[patchI].name();
00081     }
00082 
00083     return names;
00084 }
00085 
00086 
00087 Foam::wordList Foam::blockMesh::patchTypes() const
00088 {
00089     const polyPatchList& patchTopologies = topology().boundaryMesh();
00090     wordList types(patchTopologies.size());
00091 
00092     forAll (types, patchI)
00093     {
00094         types[patchI] = patchTopologies[patchI].type();
00095     }
00096 
00097     return types;
00098 }
00099 
00100 
00101 Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
00102 {
00103     const polyPatchList& patchTopologies = topology().boundaryMesh();
00104     wordList physicalTypes(patchTopologies.size());
00105 
00106     forAll (physicalTypes, patchI)
00107     {
00108         physicalTypes[patchI] = patchTopologies[patchI].physicalType();
00109     }
00110 
00111     return physicalTypes;
00112 }
00113 
00114 
00115 Foam::label Foam::blockMesh::numZonedBlocks() const
00116 {
00117     label num = 0;
00118 
00119     forAll(*this, blockI)
00120     {
00121         if (operator[](blockI).blockDef().zoneName().size())
00122         {
00123             num++;
00124         }
00125     }
00126 
00127     return num;
00128 }
00129 
00130 
00131 void Foam::blockMesh::writeTopology(Ostream& os) const
00132 {
00133     const pointField& pts = topology().points();
00134 
00135     forAll(pts, pI)
00136     {
00137         const point& pt = pts[pI];
00138 
00139         os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
00140     }
00141 
00142     const edgeList& edges = topology().edges();
00143 
00144     forAll(edges, eI)
00145     {
00146         const edge& e = edges[eI];
00147 
00148         os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl;
00149     }
00150 }
00151 
00152 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd