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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::blockDescriptor
29 
30 Description
31  Takes the description of the block and the list of curved edges and
32  creates a list of points on edges together with the weighting factors
33 
34  For a given block, the correspondence between the ordering of vertex labels
35  and face labels is shown below. For vertex numbering in the sequence 0 to 7
36  (block, centre): faces 0 (f0) and 1 are left and right, respectively; faces
37  2 and 3 are front and back; and faces 4 and 5 are bottom and top:
38 
39  \verbatim
40  7 ---- 6
41  f5 |\ :\ f3
42  | | 4 ---- 5 \
43  | 3.|....2 | \
44  | \| \| f2
45  f4 0 ---- 1
46  Y Z
47  \ | f0 ------ f1
48  \|
49  o--- X
50  \endverbatim
51 
52 SourceFiles
53  blockDescriptor.C
54  blockDescriptorEdges.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef Foam_blockDescriptor_H
59 #define Foam_blockDescriptor_H
60 
61 #include "ijkMesh.H"
62 #include "cellShape.H"
63 #include "pointField.H"
64 #include "scalarList.H"
65 #include "blockEdgeList.H"
66 #include "blockFaceList.H"
67 #include "gradingDescriptors.H"
68 #include "InfoProxy.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 
75 // Forward Declarations
76 class blockDescriptor;
77 
78 Ostream& operator<<(Ostream&, const blockDescriptor&);
79 
80 Ostream& operator<<(Ostream&, const InfoProxy<blockDescriptor>&);
81 
82 
83 /*---------------------------------------------------------------------------*\
84  Class blockDescriptor Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 class blockDescriptor
88 :
89  public ijkMesh
90 {
91  // Private Data
92 
93  //- Reference to point field defining the block mesh
94  const pointField& vertices_;
95 
96  //- Reference to a list of block edges
97  const blockEdgeList& blockEdges_;
98 
99  //- Reference to the list of curved faces
100  const blockFaceList& blockFaces_;
101 
102  //- Block shape. Likely only hex is supportable
103  cellShape blockShape_;
104 
105  //- Expansion ratios in all directions
106  List<gradingDescriptors> expand_;
107 
108  //- The block index in the originating list (-1 for unknown)
109  label index_;
110 
111  //- Name of the zone (empty word if none)
112  word zoneName_;
113 
114  //- Curved-face labels for each block-face (-1 for flat faces)
115  FixedList<label, 6> curvedFaces_;
116 
117  //- Number of curved faces in this block
118  label nCurvedFaces_;
119 
120 
121  // Private Member Functions
122 
123  //- Assign edge grading.
124  // \return false for unsupported specification
125  bool assignGradings(const UList<gradingDescriptors>& ratios);
126 
127  //- Check block has outward-pointing faces
128  void check(const Istream& is);
129 
130  //- Calculate the points and weights for the specified hex edge.
131  // Return the number of curved edges (0-1)
132  int calcEdgePointsWeights
133  (
134  pointField& edgePoints,
135  scalarList& edgeWeights,
136  const Foam::edge& cellModelEdge,
137  const label nDiv,
139  ) const;
140 
141  void findCurvedFaces(const label blockIndex = -1);
142 
143 public:
144 
145  // Generated Methods
146 
147  //- Copy construct
148  blockDescriptor(const blockDescriptor&) = default;
149 
150  //- No copy assignment
151  void operator=(const blockDescriptor&) = delete;
152 
153 
154  // Constructors
155 
156  //- Construct from components. Optional zone name.
158  (
159  const cellShape& bshape,
160  const pointField& vertices,
161  const blockEdgeList& edges,
162  const blockFaceList& faces,
163  const labelVector& density,
166  const word& zoneName = word::null
167  );
168 
169  //- Construct from Istream
171  (
172  const dictionary& dict,
173  const label blockIndex,
174  const pointField& vertices,
175  const blockEdgeList& edges,
176  const blockFaceList& faces,
177  Istream& is
178  );
179 
180 
181  // Member Functions
182 
183  //- Reference to point field defining the block mesh
184  inline const pointField& vertices() const noexcept;
185 
186  //- Return reference to the list of curved faces
187  inline const blockFaceList& blockFaces() const noexcept;
188 
189  //- Return the block shape
190  inline const cellShape& blockShape() const noexcept;
191 
192  //- The mesh density (number of cells) in the i,j,k directions
193  inline const labelVector& density() const noexcept;
194 
195  //- Expansion ratios in all directions
196  inline const List<gradingDescriptors>& grading() const noexcept;
197 
198  //- Return the (optional) zone name
199  inline const word& zoneName() const noexcept;
200 
201  //- Curved-face labels for each block-face (-1 for flat faces)
202  inline const FixedList<label, 6>& curvedFaces() const noexcept;
203 
204  //- Number of curved faces in this block
205  inline label nCurvedFaces() const noexcept;
206 
207  //- Return block point for local label i
208  inline const point& blockPoint(const label i) const;
209 
210  //- Face vertex label offset for a particular i,j,k position
211  //- on hex face (0-5)
212  inline label facePointLabel
213  (
214  const direction facei,
215  const label i,
216  const label j
217  ) const;
218 
219  //- True if point i,j,k addresses a block vertex
220  inline bool vertex(const label i, const label j, const label k) const;
221 
222  //- True if point i,j,k addresses a block edge
223  inline bool edge(const label i, const label j, const label k) const;
224 
225  //- Calculate the points and weights for all edges.
226  // \return the number of curved edges (0-12)
228  (
229  pointField (&edgesPoints)[12],
230  scalarList (&edgesWeights)[12]
231  ) const;
232 
233  //- Calculate points and weights for specified edge,
234  //- using the specified number of divisions and grading
235  // \return True if the edge is curved
236  bool edgePointsWeights
237  (
238  const label edgei,
239  pointField& edgePoints,
240  scalarList& edgeWeights,
241  const label nDiv,
243  ) const;
244 
245  //- Calculate points and weights for specified edge.
246  // \return True if the edge is curved
247  bool edgePointsWeights
248  (
249  const label edgei,
250  pointField& edgePoints,
251  scalarList& edgeWeights
252  ) const;
253 
254  //- Return true if point i,j,k addresses a block flat face or edge
255  inline bool flatFaceOrEdge
256  (
257  const label i,
258  const label j,
259  const label k
260  ) const;
261 
262  //- Return the list of face-points for all of the faces of the block
264 
265  //- Correct the location of the given face-points
266  // to lie on the faces of the block
268 
269  //- Write block index with dictionary lookup
270  static void write(Ostream&, const label blocki, const dictionary&);
271 
272  //- Return info proxy,
273  //- used to print information to a stream
274  InfoProxy<blockDescriptor> info() const noexcept { return *this; }
275 };
276 
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 } // End namespace Foam
281 
282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
283 
284 #include "blockDescriptorI.H"
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
dictionary dict
uint8_t direction
Definition: direction.H:46
bool vertex(const label i, const label j, const label k) const
True if point i,j,k addresses a block vertex.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
An analytical geometric cellShape.
Definition: cellShape.H:68
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...
const blockFaceList & blockFaces() const noexcept
Return reference to the list of curved faces.
label facePointLabel(const direction facei, const label i, const label j) const
Face vertex label offset for a particular i,j,k position on hex face (0-5)
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.
int edgesPointsWeights(pointField(&edgesPoints)[12], scalarList(&edgesWeights)[12]) const
Calculate the points and weights for all edges.
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
label nCurvedFaces() const noexcept
Number of curved faces in this block.
const point & blockPoint(const label i) const
Return block point for local label i.
bool edgePointsWeights(const label edgei, pointField &edgePoints, scalarList &edgeWeights, const label nDiv, const gradingDescriptors &gd=gradingDescriptors()) const
Calculate points and weights for specified edge, using the specified number of divisions and grading...
blockDescriptor(const blockDescriptor &)=default
Copy construct.
const pointField & points
const cellShape & blockShape() const noexcept
Return the block shape.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
Definition: edge.H:59
const List< gradingDescriptors > & grading() const noexcept
Expansion ratios in all directions.
A class for handling words, derived from Foam::string.
Definition: word.H:63
InfoProxy< blockDescriptor > info() const noexcept
Return info proxy, used to print information to a stream.
const word & zoneName() const noexcept
Return the (optional) zone name.
const pointField & vertices() const noexcept
Reference to point field defining the block mesh.
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.
static const word null
An empty word.
Definition: word.H:84
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:105
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
const labelVector & density() const noexcept
The mesh density (number of cells) in the i,j,k directions.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
void operator=(const blockDescriptor &)=delete
No copy assignment.
A simple i-j-k (row-major order) to linear addressing for a rectilinear mesh. Since the underlying me...
Definition: ijkMesh.H:53
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
const FixedList< label, 6 > & curvedFaces() const noexcept
Curved-face labels for each block-face (-1 for flat faces)
List of gradingDescriptor for the sections of a block with additional IO functionality.
bool edge(const label i, const label j, const label k) const
True if point i,j,k addresses a block edge.
Namespace for OpenFOAM.
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping and return the expanded string.
Definition: stringOps.C:705