Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / utilities / mesh / conversion / cfx4ToFoam / block.C
blob1bb776c57f35666c9e939136b88597510b89b97b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by
13     the Free Software Foundation, either version 3 of the License, or
14     (at your option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "error.H"
27 #include "block.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 namespace Foam
34 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
37 label block::vtxLabel(label a, label b, label c)
39     return (a + b*(BlockDef.xDim() + 1)
40             + c*(BlockDef.xDim() + 1)*(BlockDef.yDim() + 1));
43 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
45 // from description
46 block::block(const blockDescriptor& definition)
48     BlockDef(definition),
49     Vertices
50     (
51         ((BlockDef.xDim() + 1)*(BlockDef.yDim() + 1)*(BlockDef.zDim() + 1))
52     ),
53     Cells
54     (
55         (BlockDef.xDim()*BlockDef.yDim()*BlockDef.zDim())
56     ),
57     BoundaryPatches(6)
59     // create points
60     blockPoints();
62     // generate internal cells
63     blockCells();
65     // generate boundary patches
66     blockBoundary();
69 // as copy
70 block::block(const block& original)
72     BlockDef(original.blockDef()),
73     Vertices(original.points()),
74     Cells(original.cells()),
75     BoundaryPatches(original.boundaryPatches())
79 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
81 block::~block()
85 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
88 const blockDescriptor& block::blockDef() const
90     return BlockDef;
93 const pointField& block::points() const
95     return Vertices;
98 const labelListList& block::cells() const
100     return Cells;
103 const labelListListList& block::boundaryPatches() const
105     return BoundaryPatches;
109 // * * * * * * * * * * * * * * * IOstream Operators  * * * * * * * * * * * * //
111 Ostream& operator<<(Ostream& os, const block& b)
113     os  << b.Vertices << nl
114         << b.Cells << nl
115         << b.BoundaryPatches << endl;
117     return os;
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 } // End namespace Foam
125 // ************************************************************************* //