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 | Copyright (C) 2011-2015 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  //- Disallow default bitwise copy construct
78  hexBlock(const hexBlock&);
79 
80  //- Disallow default bitwise assignment
81  void operator=(const hexBlock&);
82 
83  //- Vertex addressing inside the block
84  inline label vtxLabel(label i, label j, label k) const;
85 
86 
87 public:
88 
89  // Constructors
90 
91  //- Construct from components
92  hexBlock(const label nx, const label ny, const label nz);
93 
94  // Member Functions
95 
96  //- Number of points
97  label xDim() const
98  {
99  return xDim_;
100  }
102  label yDim() const
103  {
104  return yDim_;
105  }
107  label zDim() const
108  {
109  return zDim_;
110  }
112  label nBlockPoints() const
113  {
114  return (xDim_ + 1)*(yDim_ + 1)*(zDim_ + 1);
115  }
117  label nBlockCells() const
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
147  void readPoints(Istream&);
148 };
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 } // End namespace Foam
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 #endif
158 
159 // ************************************************************************* //
label xDim() const
Number of points.
Definition: hexBlock.H:96
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.
scalar range
label nBlockCells() const
Definition: hexBlock.H:116
label nBlockPoints() const
Definition: hexBlock.H:111
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label yDim() const
Definition: hexBlock.H:101
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:122
label zDim() const
Definition: hexBlock.H:106
Hex block definition used in the cfx converter.
Definition: hexBlock.H:50
void readPoints(Istream &)
Read block points.
Namespace for OpenFOAM.
labelListList blockCells() const
Return block cells.