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-2022 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 public:
134 
135  // Constructors
136 
137  //- Construct from components. Optional cellSet/zone name.
139  (
140  const cellShape&,
141  const pointField& vertices,
142  const blockEdgeList&,
143  const blockFaceList&,
144  const Vector<label>& density,
146  const word& zoneName = ""
147  );
148 
149  //- Construct from Istream
151  (
152  const dictionary& dict,
153  const label index,
154  const pointField& vertices,
155  const blockEdgeList&,
156  const blockFaceList&,
157  Istream&
158  );
159 
160  //- Copy construct
161  blockDescriptor(const blockDescriptor&) = default;
162 
163 
164  // Member Functions
165 
166  //- Reference to point field defining the block mesh
167  inline const pointField& vertices() const;
168 
169  //- Return reference to the list of curved faces
170  inline const blockFaceList& faces() const;
171 
172  //- Return the block shape
173  inline const cellShape& blockShape() const;
174 
175  //- Return the mesh density (number of cells) in the i,j,k directions
176  inline const Vector<label>& density() const;
177 
178  //- Return the (optional) zone name
179  inline const word& zoneName() const;
180 
181  //- Return the number of points
182  inline label nPoints() const;
183 
184  //- Return the number of cells
185  inline label nCells() const;
186 
187  //- Curved-face labels for each block-face (-1 for flat faces)
188  inline const FixedList<label, 6>& curvedFaces() const;
189 
190  //- Number of curved faces in this block
191  inline label nCurvedFaces() const;
192 
193  //- Return block point for local label i
194  inline const point& blockPoint(const label i) const;
195 
196  //- Vertex label offset for a particular i,j,k position
197  inline label pointLabel
198  (
199  const label i,
200  const label j,
201  const label k
202  ) const;
203 
204  //- Face vertex label offset for a particular i,j,k position
205  inline label facePointLabel
206  (
207  const label facei,
208  const label i,
209  const label j
210  ) const;
211 
212  //- Return true if point i,j,k addresses a block vertex
213  inline bool vertex(const label i, const label j, const label k) const;
214 
215  //- Return true if point i,j,k addresses a block edge
216  inline bool edge(const label i, const label j, const label k) const;
217 
218  //- Calculate the points and weights for all edges.
219  // Return the number of curved edges
221  (
222  pointField (&edgePoints)[12],
223  scalarList (&edgeWeights)[12]
224  ) const;
225 
226  //- Return true if point i,j,k addresses a block flat face or edge
227  inline bool flatFaceOrEdge
228  (
229  const label i,
230  const label j,
231  const label k
232  ) const;
233 
234  //- Return the list of face-points for all of the faces of the block
236 
237  //- Correct the location of the given face-points
238  // to lie on the faces of the block
240 
241  //- Write block index with dictionary lookup
242  static void write(Ostream&, const label blocki, const dictionary&);
243 
244 
245  // Member Operators
246 
247  //- Disallow default bitwise assignment
248  void operator=(const blockDescriptor&) = delete;
249 
250 
251  // IOstream Operators
252 
253  friend Ostream& operator<<(Ostream&, const blockDescriptor&);
254 };
255 
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 } // End namespace Foam
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #include "blockDescriptorI.H"
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #endif
268 
269 // ************************************************************************* //
label k
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:74
Takes the description of the block and the list of curved edges and creates a list of points on edges...
const FixedList< label, 6 > & curvedFaces() const
Curved-face labels for each block-face (-1 for flat faces)
bool edge(const label i, const label j, const label k) const
Return true if point i,j,k addresses a block edge.
const cellShape & blockShape() const
Return the block shape.
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.
const word & zoneName() const
Return the (optional) zone name.
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.
const blockFaceList & faces() const
Return reference to the list of curved faces.
const point & blockPoint(const label i) const
Return block point for local label i.
label edgesPointsWeights(pointField(&edgePoints)[12], scalarList(&edgeWeights)[12]) const
Calculate the points and weights for all edges.
label facePointLabel(const label facei, const label i, const label j) const
Face vertex label offset for a particular i,j,k position.
const pointField & vertices() const
Reference to point field defining the block mesh.
bool vertex(const label i, const label j, const label k) const
Return true if point i,j,k addresses a block vertex.
label pointLabel(const label i, const label j, const label k) const
Vertex label offset for a particular i,j,k position.
label nCells() const
Return the number of cells.
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
const Vector< label > & density() const
Return the mesh density (number of cells) in the i,j,k directions.
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
label nPoints() const
Return the number of points.
friend Ostream & operator<<(Ostream &, const blockDescriptor &)
FixedList< pointField, 6 > facePoints(const pointField &points) const
Return the list of face-points for all of the faces of the block.
label nCurvedFaces() const
Number of curved faces in this block.
void operator=(const blockDescriptor &)=delete
Disallow default bitwise assignment.
An analytical geometric cellShape.
Definition: cellShape.H:72
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A class for handling words, derived from string.
Definition: word.H:62
const pointField & points
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:69
Namespace for OpenFOAM.
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
Ostream & operator<<(Ostream &, const ensightPart &)
dictionary dict