FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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