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

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