Loading...
Searching...
No Matches
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 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
72namespace Foam
73{
74
75// Forward Declarations
76class blockDescriptor;
77
79
81
83/*---------------------------------------------------------------------------*\
84 Class blockDescriptor Declaration
85\*---------------------------------------------------------------------------*/
86
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
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,
138 const gradingDescriptors& expand
139 ) const;
140
141 void findCurvedFaces(const label blockIndex = -1);
142
143public:
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,
164 const UList<gradingDescriptors>& expand
166 const word& zoneName = word::null
167 );
168
169 //- Construct from Istream
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
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
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
267 void correctFacePoints(FixedList<pointField, 6>&) const;
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// ************************************************************************* //
label k
A 1D vector of objects of type <T> with a fixed length <N>.
Definition FixedList.H:73
A helper class for outputting values to Ostream.
Definition InfoProxy.H:49
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:72
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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:89
static const UList< T > & null() noexcept
Return a null UList (reference to a nullObject). Behaves like an empty UList.
Definition UList.H:225
Takes the description of the block and the list of curved edges and creates a list of points on edges...
bool edge(const label i, const label j, const label k) const
True if point i,j,k addresses a block edge.
label nCurvedFaces() const noexcept
Number of curved faces in this block.
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.
InfoProxy< blockDescriptor > info() const noexcept
Return info proxy, used to print information to a stream.
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.
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
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
Face vertex label offset for a particular i,j,k position on hex face (0-5).
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
Calculate points and weights for specified edge, using the specified number of divisions and grading.
void operator=(const blockDescriptor &)=delete
No copy assignment.
An analytical geometric cellShape.
Definition cellShape.H:71
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
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:62
List of gradingDescriptor for the sections of a block with additional IO functionality.
ijkMesh()
Construct zero-sized.
Definition ijkMeshI.H:23
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
const pointField & points
Namespace for OpenFOAM.
Vector< label > labelVector
Vector of labels.
Definition labelVector.H:47
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
uint8_t direction
Definition direction.H:49
vector point
Point is a vector.
Definition point.H:37
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
const direction noexcept
Definition scalarImpl.H:265
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
vectorField pointField
pointField is a vectorField.
List< scalar > scalarList
List of scalar.
Definition scalarList.H:32
dictionary dict