blockDescriptor.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-2018 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::blockDescriptor
26 
27 Description
28  Takes the description of the block and the list of curved edges and
29  creates a list of points on edges together with the weighting factors
30 
31  For a given block, the correspondence between the ordering of vertex labels
32  and face labels is shown below. For vertex numbering in the sequence 0 to 7
33  (block, centre): faces 0 (f0) and 1 are left and right, respectively; faces
34  2 and 3 are front and back; and faces 4 and 5 are bottom and top:
35  \verbatim
36  7 ---- 6
37  f5 |\ |\ f3
38  | | 4 ---- 5 \
39  | 3 |--- 2 | \
40  | \| \| f2
41  f4 0 ---- 1
42 
43  Z f0 ----- f1
44  | Y
45  | /
46  O --- X
47  \endverbatim
48 
49 SourceFiles
50  blockDescriptor.C
51  blockDescriptorEdges.C
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #ifndef blockDescriptor_H
56 #define blockDescriptor_H
57 
58 #include "cellShape.H"
59 #include "pointField.H"
60 #include "scalarList.H"
61 #include "blockEdgeList.H"
62 #include "blockFaceList.H"
63 #include "gradingDescriptors.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 class Istream;
71 class Ostream;
72 
73 // Forward declaration of friend functions and operators
74 class blockDescriptor;
75 Ostream& operator<<(Ostream&, const blockDescriptor&);
76 
77 /*---------------------------------------------------------------------------*\
78  Class blockDescriptor Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 class blockDescriptor
82 {
83  // Private data
84 
85  //- Reference to point field defining the block mesh
86  const pointField& vertices_;
87 
88  //- Reference to a list of block edges
89  const blockEdgeList& edges_;
90 
91  //- Reference to the list of curved faces
92  const blockFaceList& faces_;
93 
94  //- Block shape
95  cellShape blockShape_;
96 
97  //- The number of cells in the i,j,k directions
98  Vector<label> density_;
99 
100  //- Expansion ratios in all directions
101  List<gradingDescriptors> expand_;
102 
103  //- Name of the zone (empty word if none)
104  word zoneName_;
105 
106  //- Curved-face labels for each block-face (-1 for flat faces)
107  FixedList<label, 6> curvedFaces_;
108 
109  //- Number of curved faces in this block
110  label nCurvedFaces_;
111 
112 
113  // Private Member Functions
114 
115  //- Check block has outward-pointing faces
116  void check(const Istream& is);
117 
118  //- Calculate the points and weights for the specified edge.
119  // Return the number of curved edges
120  label edgePointsWeights
121  (
122  pointField (&edgePoints)[12],
123  scalarList (&edgeWeights)[12],
124  const label edgei,
125  const label start,
126  const label end,
127  const label dim
128  ) const;
129 
130  void findCurvedFaces();
131 
132 
133  // Private Member Functions
134 
135  //- Disallow default bitwise assignment
136  void operator=(const blockDescriptor&);
137 
138 
139 public:
140 
141  // Constructors
142 
143  //- Construct from components. Optional cellSet/zone name.
145  (
146  const cellShape&,
147  const pointField& vertices,
148  const blockEdgeList&,
149  const blockFaceList&,
150  const Vector<label>& density,
152  const word& zoneName = ""
153  );
154 
155  //- Construct from Istream
157  (
158  const dictionary& dict,
159  const label index,
160  const pointField& vertices,
161  const blockEdgeList&,
162  const blockFaceList&,
163  Istream&
164  );
165 
166 
167  // Member Functions
168 
169  //- Reference to point field defining the block mesh
170  inline const pointField& vertices() const;
171 
172  //- Return reference to the list of curved faces
173  inline const blockFaceList& faces() const;
174 
175  //- Return the block shape
176  inline const cellShape& blockShape() const;
177 
178  //- Return the mesh density (number of cells) in the i,j,k directions
179  inline const Vector<label>& density() const;
180 
181  //- Return the (optional) zone name
182  inline const word& zoneName() const;
183 
184  //- Return the number of points
185  inline label nPoints() const;
186 
187  //- Return the number of cells
188  inline label nCells() const;
189 
190  //- Curved-face labels for each block-face (-1 for flat faces)
191  inline const FixedList<label, 6>& curvedFaces() const;
192 
193  //- Number of curved faces in this block
194  inline label nCurvedFaces() const;
195 
196  //- Return block point for local label i
197  inline const point& blockPoint(const label i) const;
198 
199  //- Vertex label offset for a particular i,j,k position
200  inline label pointLabel
201  (
202  const label i,
203  const label j,
204  const label k
205  ) const;
206 
207  //- Face vertex label offset for a particular i,j,k position
208  inline label facePointLabel
209  (
210  const label facei,
211  const label i,
212  const label j
213  ) const;
214 
215  //- Return true if point i,j,k addresses a block vertex
216  inline bool vertex(const label i, const label j, const label k) const;
217 
218  //- Return true if point i,j,k addresses a block edge
219  inline bool edge(const label i, const label j, const label k) const;
220 
221  //- Calculate the points and weights for all edges.
222  // Return the number of curved edges
224  (
225  pointField (&edgePoints)[12],
226  scalarList (&edgeWeights)[12]
227  ) const;
228 
229  //- Return true if point i,j,k addresses a block flat face or edge
230  inline bool flatFaceOrEdge
231  (
232  const label i,
233  const label j,
234  const label k
235  ) const;
236 
237  //- Return the list of face-points for all of the faces of the block
239 
240  //- Correct the location of the given face-points
241  // to lie on the faces of the block
243 
244  //- Write block index with dictionary lookup
245  static void write(Ostream&, const label blocki, const dictionary&);
246 
247 
248  // IOstream Operators
249 
250  friend Ostream& operator<<(Ostream&, const blockDescriptor&);
251 };
252 
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 } // End namespace Foam
257 
258 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 
260 #include "blockDescriptorI.H"
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
label edgesPointsWeights(pointField(&edgePoints)[12], scalarList(&edgeWeights)[12]) const
Calculate the points and weights for all edges.
dictionary dict
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping.
Definition: stringOps.C:75
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
bool vertex(const label i, const label j, const label k) const
Return true if point i,j,k addresses a block vertex.
friend Ostream & operator<<(Ostream &, const blockDescriptor &)
const Vector< label > & density() const
Return the mesh density (number of cells) in the i,j,k directions.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
label nCells() const
Return the number of cells.
An analytical geometric cellShape.
Definition: cellShape.H:69
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Takes the description of the block and the list of curved edges and creates a list of points on edges...
label k
Boltzmann constant.
FixedList< pointField, 6 > facePoints(const pointField &points) const
Return the list of face-points for all of the faces of the block.
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
const cellShape & blockShape() const
Return the block shape.
const point & blockPoint(const label i) const
Return block point for local label i.
blockDescriptor(const cellShape &, const pointField &vertices, const blockEdgeList &, const blockFaceList &, const Vector< label > &density, const UList< gradingDescriptors > &expand, const word &zoneName="")
Construct from components. Optional cellSet/zone name.
label facePointLabel(const label facei, const label i, const label j) const
Face vertex label offset for a particular i,j,k position.
const FixedList< label, 6 > & curvedFaces() const
Curved-face labels for each block-face (-1 for flat faces)
const pointField & points
A class for handling words, derived from string.
Definition: word.H:59
bool flatFaceOrEdge(const label i, const label j, const label k) const
Return true if point i,j,k addresses a block flat face or edge.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:61
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
label nCurvedFaces() const
Number of curved faces in this block.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
label nPoints() const
Return the number of points.
const pointField & vertices() const
Reference to point field defining the block mesh.
Ostream & operator<<(Ostream &, const ensightPart &)
label pointLabel(const label i, const label j, const label k) const
Vertex label offset for a particular i,j,k position.
const word & zoneName() const
Return the (optional) zone name.
bool edge(const label i, const label j, const label k) const
Return true if point i,j,k addresses a block edge.
const blockFaceList & faces() const
Return reference to the list of curved faces.
Namespace for OpenFOAM.