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