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

block.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 Description
00025 
00026 \*---------------------------------------------------------------------------*/
00027 
00028 #include <OpenFOAM/error.H>
00029 #include "block.H"
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 namespace Foam
00034 {
00035 
00036 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00037 
00038 
00039 label block::vtxLabel(label a, label b, label c)
00040 {
00041     return (a + b*(blockDef_.n().x() + 1)
00042             + c*(blockDef_.n().x() + 1)*(blockDef_.n().y() + 1));
00043 }
00044 
00045 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00046 
00047 // Construct from description
00048 block::block(const blockDescriptor& definition)
00049 :
00050     blockDef_(definition),
00051     vertices_
00052     (
00053         ((blockDef_.n().x() + 1)*(blockDef_.n().y() + 1)*(blockDef_.n().z() + 1))
00054     ),
00055     cells_
00056     (
00057         (blockDef_.n().x()*blockDef_.n().y()*blockDef_.n().z())
00058     ),
00059     boundaryPatches_(6)
00060 {
00061     // create points
00062     blockPoints();
00063 
00064     // generate internal cells
00065     blockCells();
00066 
00067     // generate boundary patches
00068     blockBoundary();
00069 }
00070 
00071 
00072 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00073 
00074 
00075 const blockDescriptor& block::blockDef() const
00076 {
00077     return blockDef_;
00078 }
00079 
00080 const pointField& block::points() const
00081 {
00082     return vertices_;
00083 }
00084 
00085 const labelListList& block::cells() const
00086 {
00087     return cells_;
00088 }
00089 
00090 const labelListListList& block::boundaryPatches() const
00091 {
00092     return boundaryPatches_;
00093 }
00094 
00095 
00096 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00097 
00098 Ostream& operator<<(Ostream& os, const block& b)
00099 {
00100     os << b.vertices_ << nl
00101        << b.cells_ << nl
00102        << b.boundaryPatches_ << endl;
00103 
00104     return os;
00105 }
00106 
00107 
00108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00109 
00110 } // End namespace Foam
00111 
00112 // ************************ vim: set sw=4 sts=4 et: ************************ //
00113 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines