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 
00029 #include <OpenFOAM/error.H>
00030 
00031 #include "block.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00039 
00040 
00041 label block::vtxLabel(label a, label b, label c)
00042 {
00043     return (a + b*(BlockDef.xDim() + 1)
00044             + c*(BlockDef.xDim() + 1)*(BlockDef.yDim() + 1));
00045 }
00046 
00047 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00048 
00049 // from description
00050 block::block(const blockDescriptor& definition)
00051 :
00052     BlockDef(definition),
00053     Vertices
00054     (
00055         ((BlockDef.xDim() + 1)*(BlockDef.yDim() + 1)*(BlockDef.zDim() + 1))
00056     ),
00057     Cells
00058     (
00059         (BlockDef.xDim()*BlockDef.yDim()*BlockDef.zDim())
00060     ),
00061     BoundaryPatches(6)
00062 {
00063     // create points
00064     blockPoints();
00065 
00066     // generate internal cells
00067     blockCells();
00068 
00069     // generate boundary patches
00070     blockBoundary();
00071 }
00072 
00073 // as copy
00074 block::block(const block& original)
00075 :
00076     BlockDef(original.blockDef()),
00077     Vertices(original.points()),
00078     Cells(original.cells()),
00079     BoundaryPatches(original.boundaryPatches())
00080 {}
00081 
00082 
00083 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00084 
00085 block::~block()
00086 {}
00087 
00088 
00089 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00090 
00091 
00092 const blockDescriptor& block::blockDef() const
00093 {
00094     return BlockDef;
00095 }
00096 
00097 const pointField& block::points() const
00098 {
00099     return Vertices;
00100 }
00101 
00102 const labelListList& block::cells() const
00103 {
00104     return Cells;
00105 }
00106 
00107 const labelListListList& block::boundaryPatches() const
00108 {
00109     return BoundaryPatches;
00110 }
00111 
00112 
00113 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
00114 
00115 Ostream& operator<<(Ostream& os, const block& b)
00116 {
00117     os << b.Vertices << nl
00118        << b.Cells << nl
00119        << b.BoundaryPatches << endl;
00120 
00121     return os;
00122 }
00123 
00124 
00125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00126 
00127 } // End namespace Foam
00128 
00129 // ************************ vim: set sw=4 sts=4 et: ************************ //
00130 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines