initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / mesh / conversion / plot3dToFoam / hexBlock.H
blob9cd6f409c60632122f2c5d53e3509be418262c69
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 Description
27 \*---------------------------------------------------------------------------*/
29 #ifndef hexBlock_H
30 #define hexBlock_H
32 #include "labelList.H"
33 #include "pointField.H"
34 #include "faceList.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 namespace Foam
41 /*---------------------------------------------------------------------------*\
42                            Class hexBlock Declaration
43 \*---------------------------------------------------------------------------*/
45 class hexBlock
47     // Private data
49         //- Handedness of the block
50         enum handed
51         {
52             noPoints,
53             right,
54             left
55         };
57         //- Number of point in each direction
58         label xDim_;
59         label yDim_;
60         label zDim_;
62         //- Handedness of the block
63         handed blockHandedness_;
65         //- List of points
66         pointField points_;
69     // Private Member Functions
71         //- Disallow default bitwise copy construct
72         hexBlock(const hexBlock&);
74         //- Disallow default bitwise assignment
75         void operator=(const hexBlock&);
77         //- Vertex addressing inside the block
78         inline label vtxLabel(label i, label j, label k) const;
80         //- Calculate handedness of block
81         void setHandedness();
83 public:
85     // Constructors
87         //- Construct from components
88         hexBlock
89         (
90             const label nx,
91             const label ny,
92             const label nz
93         );
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 either with or without blanking after every block.
148         //  If twoDThickness > 0 reads (half) the points and extrudes the
149         //  points in z direction.
150         void readPoints
151         (
152             const bool readBlank,
153             const scalar twoDThicknes,
154             Istream&
155         );
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 } // End namespace Foam
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 #endif
167 // ************************************************************************* //