hexBlock.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2015 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Description
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #ifndef hexBlock_H
31 #define hexBlock_H
32 
33 #include "labelList.H"
34 #include "pointField.H"
35 #include "faceList.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 /*---------------------------------------------------------------------------*\
43  Class hexBlock Declaration
44 \*---------------------------------------------------------------------------*/
45 
46 class hexBlock
47 {
48  // Private data
49 
50  //- Handedness of the block
51  enum handed
52  {
53  noPoints,
54  right,
55  left
56  };
57 
58  //- Number of point in each direction
59  label xDim_;
60  label yDim_;
61  label zDim_;
62 
63  //- Handedness of the block
64  handed blockHandedness_;
65 
66  //- List of points
67  pointField points_;
68 
69 
70  // Private Member Functions
71 
72  //- No copy construct
73  hexBlock(const hexBlock&) = delete;
74 
75  //- No copy assignment
76  void operator=(const hexBlock&) = delete;
77 
78  //- Vertex addressing inside the block
79  inline label vtxLabel(label i, label j, label k) const;
80 
81  //- Calculate handedness of block
82  void setHandedness();
83 
84 public:
85 
86  // Constructors
87 
88  //- Construct from components
89  hexBlock
90  (
91  const label nx,
92  const label ny,
93  const label nz
94  );
95 
96  // Member Functions
97 
98  //- Number of points
99  label xDim() const
100  {
101  return xDim_;
102  }
103 
104  label yDim() const
105  {
106  return yDim_;
107  }
108 
109  label zDim() const
110  {
111  return zDim_;
112  }
113 
114  label nBlockPoints() const
115  {
116  return (xDim_ + 1)*(yDim_ + 1)*(zDim_ + 1);
117  }
118 
119  label nBlockCells() const
120  {
121  return xDim_*yDim_*zDim_;
122  }
123 
124  //- Return block points
125  const pointField& points() const
126  {
127  if (blockHandedness_ == noPoints)
128  {
130  << "points not read in yet"
131  << abort(FatalError);
132  }
133 
134  return points_;
135  }
136 
137  //- Return block cells
138  labelListList blockCells() const;
139 
140  //- Return block patch faces given direction and range limits
141  // From the cfx manual: direction
142  // 0 = solid (3-D patch),
143  // 1 = high i, 2 = high j, 3 = high k
144  // 4 = low i, 5 = low j, 6 = low k
145  faceList patchFaces(label direc, const labelList& range) const;
146 
147 
148  //- Read block points either with or without blanking after every block.
149  // If twoDThickness > 0 reads (half) the points and extrudes the
150  // points in z direction.
151  void readPoints
152  (
153  const bool readBlank,
154  const scalar twoDThicknes,
155  Istream&
156  );
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::hexBlock::yDim
label yDim() const
Definition: hexBlock.H:104
Foam::hexBlock::blockCells
labelListList blockCells() const
Return block cells.
Foam::hexBlock::nBlockPoints
label nBlockPoints() const
Definition: hexBlock.H:114
faceList.H
Foam::hexBlock::patchFaces
faceList patchFaces(label direc, const labelList &range) const
Return block patch faces given direction and range limits.
Foam::hexBlock::points
const pointField & points() const
Return block points.
Definition: hexBlock.H:125
labelList.H
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::hexBlock::zDim
label zDim() const
Definition: hexBlock.H:109
Foam::FatalError
error FatalError
Foam::hexBlock::xDim
label xDim() const
Number of points.
Definition: hexBlock.H:99
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
pointField.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
range
scalar range
Definition: LISASMDCalcMethod1.H:12
Foam::List< labelList >
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::hexBlock::nBlockCells
label nBlockCells() const
Definition: hexBlock.H:119
Foam::hexBlock::readPoints
void readPoints(Istream &)
Read block points.