Merge branch 'upstream/OpenFOAM' into master
[freefoam.git] / applications / utilities / mesh / conversion / cfx4ToFoam / hexBlock.H
blob978604ad872274656be7af5349bcce910bca8617
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::hexBlock
28 Description
29     Hex block definition used in the cfx converter.
31 SourceFiles
32     hexBlock.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef hexBlock_H
37 #define hexBlock_H
39 #include <OpenFOAM/labelList.H>
40 #include <OpenFOAM/pointField.H>
41 #include <OpenFOAM/faceList.H>
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                            Class hexBlock Declaration
50 \*---------------------------------------------------------------------------*/
52 class hexBlock
54     // Private data
56         //- Handedness of the block
57         enum handed
58         {
59             noPoints,
60             right,
61             left
62         };
64         //- Number of point in each direction
65         label xDim_;
66         label yDim_;
67         label zDim_;
69         //- Handedness of the block
70         handed blockHandedness_;
72         //- List of points
73         pointField points_;
76     // Private Member Functions
78         //- Disallow default bitwise copy construct
79         hexBlock(const hexBlock&);
81         //- Disallow default bitwise assignment
82         void operator=(const hexBlock&);
84         //- Vertex addressing inside the block
85         inline label vtxLabel(label i, label j, label k) const;
88 public:
90     // Constructors
92         //- Construct from components
93         hexBlock(const label nx, const label ny, const label nz);
95     // Member Functions
97         //- Number of points
98         label xDim() const
99         {
100             return xDim_;
101         }
103         label yDim() const
104         {
105             return yDim_;
106         }
108         label zDim() const
109         {
110             return zDim_;
111         }
113         label nBlockPoints() const
114         {
115             return (xDim_ + 1)*(yDim_ + 1)*(zDim_ + 1);
116         }
118         label nBlockCells() const
119         {
120             return xDim_*yDim_*zDim_;
121         }
123         //- Return block points
124         const pointField& points() const
125         {
126             if (blockHandedness_ == noPoints)
127             {
128                 FatalErrorIn("hexBlock::points() const")
129                     << "points not read in yet"
130                     << abort(FatalError);
131             }
133             return points_;
134         }
136         //- Return block cells
137         labelListList blockCells() const;
139         //- Return block patch faces given direction and range limits
140         // From the cfx manual: direction
141         // 0 = solid (3-D patch),
142         // 1 = high i, 2 = high j, 3 = high k
143         // 4 = low i, 5 = low j, 6 = low k
144         faceList patchFaces(label direc, const labelList& range) const;
147         //- Read block points
148         void readPoints(Istream&);
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 } // End namespace Foam
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 #endif
160 // ************************ vim: set sw=4 sts=4 et: ************************ //