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-2019 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 Class
25  Foam::hexBlock
26 
27 Description
28  Hex block definition used in the cfx converter.
29 
30 SourceFiles
31  hexBlock.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef hexBlock_H
36 #define hexBlock_H
37 
38 #include "labelList.H"
39 #include "pointField.H"
40 #include "faceList.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class hexBlock Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class hexBlock
52 {
53  // Private Data
54 
55  //- Handedness of the block
56  enum handed
57  {
58  noPoints,
59  right,
60  left
61  };
62 
63  //- Number of point in each direction
64  label xDim_;
65  label yDim_;
66  label zDim_;
67 
68  //- Handedness of the block
69  handed blockHandedness_;
70 
71  //- List of points
72  pointField points_;
73 
74 
75  // Private Member Functions
76 
77  //- Vertex addressing inside the block
78  inline label vtxLabel(label i, label j, label k) const;
79 
80 
81 public:
82 
83  // Constructors
84 
85  //- Construct from components
86  hexBlock(const label nx, const label ny, const label nz);
87 
88  //- Disallow default bitwise copy construction
89  hexBlock(const hexBlock&) = delete;
90 
91 
92  // Member Functions
93 
94  //- Number of points
95  label xDim() const
96  {
97  return xDim_;
98  }
99 
100  label yDim() const
101  {
102  return yDim_;
103  }
105  label zDim() const
106  {
107  return zDim_;
108  }
110  label nBlockPoints() const
111  {
112  return (xDim_ + 1)*(yDim_ + 1)*(zDim_ + 1);
113  }
115  label nBlockCells() const
116  {
117  return xDim_*yDim_*zDim_;
118  }
119 
120  //- Return block points
121  const pointField& points() const
122  {
123  if (blockHandedness_ == noPoints)
124  {
126  << "points not read in yet"
127  << abort(FatalError);
128  }
129 
130  return points_;
131  }
132 
133  //- Return block cells
134  labelListList blockCells() const;
135 
136  //- Return block patch faces given direction and range limits
137  // From the cfx manual: direction
138  // 0 = solid (3-D patch),
139  // 1 = high i, 2 = high j, 3 = high k
140  // 4 = low i, 5 = low j, 6 = low k
141  faceList patchFaces(label direc, const labelList& range) const;
142 
143 
144  //- Read block points
145  void readPoints(Istream&);
146 
147 
148  // Member Operators
149 
150  //- Disallow default bitwise assignment
151  void operator=(const hexBlock&) = delete;
152 };
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 } // End namespace Foam
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 #endif
162 
163 // ************************************************************************* //
label xDim() const
Number of points.
Definition: hexBlock.H:94
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
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:114
label nBlockPoints() const
Definition: hexBlock.H:109
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label yDim() const
Definition: hexBlock.H:99
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:120
label zDim() const
Definition: hexBlock.H:104
Hex block definition used in the cfx converter.
Definition: hexBlock.H:50
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.