blockDescriptor.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-2016 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 the 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  f0 ----- f1
44  \endverbatim
45 
46 SourceFiles
47  blockDescriptor.C
48  blockDescriptorEdges.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef blockDescriptor_H
53 #define blockDescriptor_H
54 
55 #include "cellShape.H"
56 #include "pointField.H"
57 #include "scalarList.H"
58 #include "blockEdgeList.H"
59 #include "blockFaceList.H"
60 #include "gradingDescriptors.H"
61 
62 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
63 
64 namespace Foam
65 {
66 
67 class Istream;
68 class Ostream;
69 
70 // Forward declaration of friend functions and operators
71 class blockDescriptor;
72 Ostream& operator<<(Ostream&, const blockDescriptor&);
73 
74 /*---------------------------------------------------------------------------*\
75  Class blockDescriptor Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 class blockDescriptor
79 {
80  // Private data
81 
82  //- Reference to point field defining the block mesh
83  const pointField& vertices_;
84 
85  //- Reference to a list of block edges
86  const blockEdgeList& edges_;
87 
88  //- Reference to the list of curved faces
89  const blockFaceList& faces_;
90 
91  //- Block shape
92  cellShape blockShape_;
93 
94  //- The number of cells in the i,j,k directions
95  Vector<label> density_;
96 
97  //- Expansion ratios in all directions
99 
100  //- Name of the zone (empty word if none)
101  word zoneName_;
102 
103  //- Curved-face labels for each block-face (-1 for flat faces)
104  FixedList<label, 6> curvedFaces_;
105 
106  //- Number of curved faces in this block
107  label nCurvedFaces_;
108 
109 
110  // Private Member Functions
111 
112  //- Check block has outward-pointing faces
113  void check(const Istream& is);
114 
115  //- Calculate the points and weights for the specified edge.
116  // Return the number of curved edges
117  label edgePointsWeights
118  (
119  pointField (&edgePoints)[12],
120  scalarList (&edgeWeights)[12],
121  const label edgei,
122  const label start,
123  const label end,
124  const label dim
125  ) const;
126 
127  void findCurvedFaces();
128 
129 
130  // Private Member Functions
131 
132  //- Disallow default bitwise assignment
133  void operator=(const blockDescriptor&);
134 
135 
136 public:
137 
138  // Constructors
139 
140  //- Construct from components. Optional cellSet/zone name.
142  (
143  const cellShape&,
144  const pointField& vertices,
145  const blockEdgeList&,
146  const blockFaceList&,
147  const Vector<label>& density,
149  const word& zoneName = ""
150  );
151 
152  //- Construct from Istream
154  (
155  const dictionary& dict,
156  const label index,
157  const pointField& vertices,
158  const blockEdgeList&,
159  const blockFaceList&,
160  Istream&
161  );
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  // IOstream Operators
246 
247  friend Ostream& operator<<(Ostream&, const blockDescriptor&);
248 };
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace Foam
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #include "blockDescriptorI.H"
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************************************************************* //
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 occurences 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.