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-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::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 
161  // Member Functions
162 
163  //- Reference to point field defining the block mesh
164  inline const pointField& vertices() const;
165 
166  //- Return reference to the list of curved faces
167  inline const blockFaceList& faces() const;
168 
169  //- Return the block shape
170  inline const cellShape& blockShape() const;
171 
172  //- Return the mesh density (number of cells) in the i,j,k directions
173  inline const Vector<label>& density() const;
174 
175  //- Return the (optional) zone name
176  inline const word& zoneName() const;
177 
178  //- Return the number of points
179  inline label nPoints() const;
180 
181  //- Return the number of cells
182  inline label nCells() const;
183 
184  //- Curved-face labels for each block-face (-1 for flat faces)
185  inline const FixedList<label, 6>& curvedFaces() const;
186 
187  //- Number of curved faces in this block
188  inline label nCurvedFaces() const;
189 
190  //- Return block point for local label i
191  inline const point& blockPoint(const label i) const;
192 
193  //- Vertex label offset for a particular i,j,k position
194  inline label pointLabel
195  (
196  const label i,
197  const label j,
198  const label k
199  ) const;
200 
201  //- Face vertex label offset for a particular i,j,k position
202  inline label facePointLabel
203  (
204  const label facei,
205  const label i,
206  const label j
207  ) const;
208 
209  //- Return true if point i,j,k addresses a block vertex
210  inline bool vertex(const label i, const label j, const label k) const;
211 
212  //- Return true if point i,j,k addresses a block edge
213  inline bool edge(const label i, const label j, const label k) const;
214 
215  //- Calculate the points and weights for all edges.
216  // Return the number of curved edges
218  (
219  pointField (&edgePoints)[12],
220  scalarList (&edgeWeights)[12]
221  ) const;
222 
223  //- Return true if point i,j,k addresses a block flat face or edge
224  inline bool flatFaceOrEdge
225  (
226  const label i,
227  const label j,
228  const label k
229  ) const;
230 
231  //- Return the list of face-points for all of the faces of the block
233 
234  //- Correct the location of the given face-points
235  // to lie on the faces of the block
237 
238  //- Write block index with dictionary lookup
239  static void write(Ostream&, const label blocki, const dictionary&);
240 
241 
242  // Member Operators
243 
244  //- Disallow default bitwise assignment
245  void operator=(const blockDescriptor&) = delete;
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:69
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:156
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
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:60
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:54
label nPoints() const
Return the number of points.
void operator=(const blockDescriptor &)=delete
Disallow default bitwise assignment.
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.