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

hexBlock.H

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 #ifndef hexBlock_H
00030 #define hexBlock_H
00031 
00032 #include "labelList.H"
00033 #include "pointField.H"
00034 #include "faceList.H"
00035 
00036 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00037 
00038 namespace Foam
00039 {
00040 
00041 /*---------------------------------------------------------------------------*\
00042                            Class hexBlock Declaration
00043 \*---------------------------------------------------------------------------*/
00044 
00045 class hexBlock
00046 {
00047     // Private data
00048 
00049         //- Handedness of the block
00050         enum handed
00051         {
00052             noPoints,
00053             right,
00054             left
00055         };
00056 
00057         //- Number of point in each direction
00058         label xDim_;
00059         label yDim_;
00060         label zDim_;
00061 
00062         //- Handedness of the block
00063         handed blockHandedness_;
00064 
00065         //- List of points
00066         pointField points_;
00067 
00068 
00069     // Private Member Functions
00070 
00071         //- Disallow default bitwise copy construct
00072         hexBlock(const hexBlock&);
00073 
00074         //- Disallow default bitwise assignment
00075         void operator=(const hexBlock&);
00076 
00077         //- Vertex addressing inside the block
00078         inline label vtxLabel(label i, label j, label k) const;
00079 
00080         //- Calculate handedness of block
00081         void setHandedness();
00082 
00083 public:
00084 
00085     // Constructors
00086 
00087         //- Construct from components
00088         hexBlock
00089         (
00090             const label nx,
00091             const label ny,
00092             const label nz
00093         );
00094 
00095     // Member Functions
00096 
00097         //- Number of points
00098         label xDim() const
00099         {
00100             return xDim_;
00101         }
00102 
00103         label yDim() const
00104         {
00105             return yDim_;
00106         }
00107 
00108         label zDim() const
00109         {
00110             return zDim_;
00111         }
00112 
00113         label nBlockPoints() const
00114         {
00115             return (xDim_ + 1)*(yDim_ + 1)*(zDim_ + 1);
00116         }
00117 
00118         label nBlockCells() const
00119         {
00120             return xDim_*yDim_*zDim_;
00121         }
00122 
00123         //- Return block points
00124         const pointField& points() const
00125         {
00126             if (blockHandedness_ == noPoints)
00127             {
00128                 FatalErrorIn("hexBlock::points() const")
00129                     << "points not read in yet"
00130                     << abort(FatalError);
00131             }
00132 
00133             return points_;
00134         }
00135 
00136         //- Return block cells
00137         labelListList blockCells() const;
00138 
00139         //- Return block patch faces given direction and range limits
00140         // From the cfx manual: direction
00141         // 0 = solid (3-D patch),
00142         // 1 = high i, 2 = high j, 3 = high k
00143         // 4 = low i, 5 = low j, 6 = low k
00144         faceList patchFaces(label direc, const labelList& range) const;
00145 
00146 
00147         //- Read block points either with or without blanking after every block.
00148         //  If twoDThickness > 0 reads (half) the points and extrudes the
00149         //  points in z direction.
00150         void readPoints
00151         (
00152             const bool readBlank,
00153             const scalar twoDThicknes,
00154             Istream&
00155         );
00156 };
00157 
00158 
00159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00160 
00161 } // End namespace Foam
00162 
00163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00164 
00165 #endif
00166 
00167 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd