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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::blockDescriptor
29
30Description
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
52SourceFiles
53 blockDescriptor.C
54 blockDescriptorEdges.C
55
56\*---------------------------------------------------------------------------*/
57
58#ifndef blockDescriptor_H
59#define 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
72namespace Foam
73{
74
75/*---------------------------------------------------------------------------*\
76 Class blockDescriptor Declaration
77\*---------------------------------------------------------------------------*/
80:
81 public ijkMesh
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& blockEdges_;
90
91 //- Reference to the list of curved faces
92 const blockFaceList& blockFaces_;
93
94 //- Block shape. Likely only hex is supportable
95 cellShape blockShape_;
96
97 //- Expansion ratios in all directions
99
100 //- The block index in the originating list (-1 for unknown)
101 label index_;
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 //- Assign edge grading.
116 // \return false for unsupported specification
117 bool assignGradings(const UList<gradingDescriptors>& ratios);
118
119 //- Check block has outward-pointing faces
120 void check(const Istream& is);
121
122 //- Calculate the points and weights for the specified hex edge.
123 // Return the number of curved edges (0-1)
124 int calcEdgePointsWeights
125 (
126 pointField& edgePoints,
127 scalarList& edgeWeights,
128 const Foam::edge& cellModelEdge,
129 const label nDiv,
130 const gradingDescriptors& expand
131 ) const;
132
133 void findCurvedFaces(const label blockIndex = -1);
134
135public:
136
137 // Generated Methods
138
139 //- Copy construct
140 blockDescriptor(const blockDescriptor&) = default;
141
142 //- No copy assignment
143 void operator=(const blockDescriptor&) = delete;
144
145
146 // Constructors
147
148 //- Construct from components. Optional zone name.
150 (
151 const cellShape& bshape,
152 const pointField& vertices,
153 const blockEdgeList& edges,
154 const blockFaceList& faces,
155 const labelVector& density,
156 const UList<gradingDescriptors>& expand
158 const word& zoneName = word::null
159 );
160
161 //- Construct from Istream
163 (
164 const dictionary& dict,
165 const label blockIndex,
166 const pointField& vertices,
167 const blockEdgeList& edges,
168 const blockFaceList& faces,
169 Istream& is
170 );
171
172
173 // Member Functions
174
175 //- Reference to point field defining the block mesh
176 inline const pointField& vertices() const noexcept;
177
178 //- Return reference to the list of curved faces
179 inline const blockFaceList& blockFaces() const noexcept;
180
181 //- Return the block shape
182 inline const cellShape& blockShape() const noexcept;
183
184 //- The mesh density (number of cells) in the i,j,k directions
185 inline const labelVector& density() const noexcept;
186
187 //- Expansion ratios in all directions
188 inline const List<gradingDescriptors>& grading() const noexcept;
189
190 //- Return the (optional) zone name
191 inline const word& zoneName() const noexcept;
192
193 //- Curved-face labels for each block-face (-1 for flat faces)
194 inline const FixedList<label, 6>& curvedFaces() const noexcept;
195
196 //- Number of curved faces in this block
197 inline label nCurvedFaces() const noexcept;
198
199 //- Return block point for local label i
200 inline const point& blockPoint(const label i) const;
201
202 //- Face vertex label offset for a particular i,j,k position
203 //- on hex face (0-5)
204 inline label facePointLabel
205 (
206 const direction facei,
207 const label i,
208 const label j
209 ) const;
210
211 //- True if point i,j,k addresses a block vertex
212 inline bool vertex(const label i, const label j, const label k) const;
213
214 //- True if point i,j,k addresses a block edge
215 inline bool edge(const label i, const label j, const label k) const;
216
217 //- Calculate the points and weights for all edges.
218 // \return the number of curved edges (0-12)
220 (
221 pointField (&edgesPoints)[12],
222 scalarList (&edgesWeights)[12]
223 ) const;
224
225 //- Calculate points and weights for specified edge,
226 //- using the specified number of divisions and grading
227 // \return True if the edge is curved
229 (
230 const label edgei,
231 pointField& edgePoints,
232 scalarList& edgeWeights,
233 const label nDiv,
235 ) const;
236
237 //- Calculate points and weights for specified edge.
238 // \return True if the edge is curved
240 (
241 const label edgei,
242 pointField& edgePoints,
243 scalarList& edgeWeights
244 ) const;
245
246 //- Return true if point i,j,k addresses a block flat face or edge
247 inline bool flatFaceOrEdge
248 (
249 const label i,
250 const label j,
251 const label k
252 ) const;
253
254 //- Return the list of face-points for all of the faces of the block
256
257 //- Correct the location of the given face-points
258 // to lie on the faces of the block
259 void correctFacePoints(FixedList<pointField, 6>&) const;
260
261 //- Write block index with dictionary lookup
262 static void write(Ostream&, const label blocki, const dictionary&);
263
264 //- Return info proxy
266 {
267 return *this;
268 }
269};
270
271
272//- Output Operator
273Ostream& operator<<(Ostream& os, const blockDescriptor& bd);
274
275//- Info output
276Ostream& operator<<(Ostream& os, const InfoProxy<blockDescriptor>& info);
277
278
279// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280
281} // End namespace Foam
282
283// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284
285#include "blockDescriptorI.H"
286
287// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288
289#endif
290
291// ************************************************************************* //
label k
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:52
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
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:94
Takes the description of the block and the list of curved edges and creates a list of points on edges...
label nCurvedFaces() const noexcept
Number of curved faces in this block.
InfoProxy< blockDescriptor > info() const
Return info proxy.
const pointField & vertices() const noexcept
Reference to point field defining the block mesh.
blockDescriptor(const blockDescriptor &)=default
Copy construct.
const List< gradingDescriptors > & grading() const noexcept
Expansion ratios in all directions.
const FixedList< label, 6 > & curvedFaces() const noexcept
Curved-face labels for each block-face (-1 for flat faces)
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 point & blockPoint(const label i) const
Return block point for local label i.
bool vertex(const label i, const label j, const label k) const
True if point i,j,k addresses a block vertex.
int edgesPointsWeights(pointField(&edgesPoints)[12], scalarList(&edgesWeights)[12]) const
Calculate the points and weights for all edges.
label facePointLabel(const direction facei, const label i, const label j) const
const cellShape & blockShape() const noexcept
Return the block shape.
const labelVector & density() const noexcept
The mesh density (number of cells) in the i,j,k directions.
const word & zoneName() const noexcept
Return the (optional) zone name.
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
FixedList< pointField, 6 > facePoints(const pointField &points) const
Return the list of face-points for all of the faces of the block.
const blockFaceList & blockFaces() const noexcept
Return reference to the list of curved faces.
bool edgePointsWeights(const label edgei, pointField &edgePoints, scalarList &edgeWeights, const label nDiv, const gradingDescriptors &gd=gradingDescriptors()) const
void operator=(const blockDescriptor &)=delete
No copy assignment.
An analytical geometric cellShape.
Definition: cellShape.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:66
List of gradingDescriptor for the sections of a block with additional IO functionality.
A simple i-j-k (row-major order) to linear addressing for a rectilinear mesh. Since the underlying me...
Definition: ijkMesh.H:60
A class for handling words, derived from Foam::string.
Definition: word.H:68
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
uint8_t direction
Definition: direction.H:56
const direction noexcept
Definition: Scalar.H:223
runTime write()
dictionary dict