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 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 
72 namespace Foam
73 {
74 
75 /*---------------------------------------------------------------------------*\
76  Class blockDescriptor Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 class blockDescriptor
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,
131  ) const;
132 
133  void findCurvedFaces(const label blockIndex = -1);
134 
135 public:
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,
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
228  bool edgePointsWeights
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
239  bool edgePointsWeights
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
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
273 Ostream& operator<<(Ostream& os, const blockDescriptor& bd);
274 
275 //- Info output
276 Ostream& 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 // ************************************************************************* //
Foam::blockDescriptor::operator=
void operator=(const blockDescriptor &)=delete
No copy assignment.
Foam::blockDescriptor::blockPoint
const point & blockPoint(const label i) const
Return block point for local label i.
Definition: blockDescriptorI.H:85
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:47
Foam::blockDescriptor::curvedFaces
const FixedList< label, 6 > & curvedFaces() const noexcept
Curved-face labels for each block-face (-1 for flat faces)
Definition: blockDescriptorI.H:73
Foam::blockDescriptor::grading
const List< gradingDescriptors > & grading() const noexcept
Expansion ratios in all directions.
Definition: blockDescriptorI.H:60
Foam::blockDescriptor::zoneName
const word & zoneName() const noexcept
Return the (optional) zone name.
Definition: blockDescriptorI.H:66
InfoProxy.H
Foam::blockDescriptor::facePointLabel
label facePointLabel(const direction facei, const label i, const label j) const
Definition: blockDescriptorI.H:92
Foam::blockDescriptor::edgePointsWeights
bool edgePointsWeights(const label edgei, pointField &edgePoints, scalarList &edgeWeights, const label nDiv, const gradingDescriptors &gd=gradingDescriptors()) const
Definition: blockDescriptorEdges.C:154
Foam::blockDescriptor::write
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
Definition: blockDescriptor.C:402
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:63
Foam::blockDescriptor::blockFaces
const blockFaceList & blockFaces() const noexcept
Return reference to the list of curved faces.
Definition: blockDescriptorI.H:39
Foam::blockDescriptor::vertex
bool vertex(const label i, const label j, const label k) const
True if point i,j,k addresses a block vertex.
Definition: blockDescriptorI.H:129
Foam::blockDescriptor::vertices
const pointField & vertices() const noexcept
Reference to point field defining the block mesh.
Definition: blockDescriptorI.H:32
Foam::gradingDescriptors
List of gradingDescriptor for the sections of a block with additional IO functionality.
Definition: gradingDescriptors.H:58
scalarList.H
gradingDescriptors.H
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::blockDescriptor::edgesPointsWeights
int edgesPointsWeights(pointField(&edgesPoints)[12], scalarList(&edgesWeights)[12]) const
Calculate the points and weights for all edges.
Definition: blockDescriptorEdges.C:129
Foam::ijkMesh
A simple i-j-k (row-major order) to linear addressing for a rectilinear mesh. Since the underlying me...
Definition: ijkMesh.H:57
blockDescriptorI.H
Foam::Field< vector >
ijkMesh.H
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::blockDescriptor::density
const labelVector & density() const noexcept
The mesh density (number of cells) in the i,j,k directions.
Definition: blockDescriptorI.H:53
blockEdgeList.H
Foam::PtrList< blockEdge >
blockFaceList.H
Foam::blockDescriptor::facePoints
FixedList< pointField, 6 > facePoints(const pointField &points) const
Return the list of face-points for all of the faces of the block.
Definition: blockDescriptor.C:326
Foam::blockDescriptor::correctFacePoints
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
Definition: blockDescriptor.C:382
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::blockDescriptor::flatFaceOrEdge
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.
Definition: blockDescriptorI.H:155
os
OBJstream os(runTime.globalPath()/outputName)
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:69
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::blockDescriptor::nCurvedFaces
label nCurvedFaces() const noexcept
Number of curved faces in this block.
Definition: blockDescriptorI.H:79
Foam::blockDescriptor::edge
bool edge(const label i, const label j, const label k) const
True if point i,j,k addresses a block edge.
Definition: blockDescriptorI.H:142
pointField.H
Foam::Vector< label >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::FixedList< label, 6 >
Foam::UList
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:103
points
const pointField & points
Definition: gmvOutputHeader.H:1
k
label k
Boltzmann constant.
Definition: LISASMDCalcMethod2.H:41
Foam::blockDescriptor::blockDescriptor
blockDescriptor(const blockDescriptor &)=default
Copy construct.
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::word::null
static const word null
An empty word.
Definition: word.H:80
Foam::blockDescriptor::blockShape
const cellShape & blockShape() const noexcept
Return the block shape.
Definition: blockDescriptorI.H:46
cellShape.H
Foam::blockDescriptor::info
InfoProxy< blockDescriptor > info() const
Return info proxy.
Definition: blockDescriptor.H:264
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::stringOps::expand
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Definition: stringOps.C:718
Foam::blockDescriptor
Takes the description of the block and the list of curved edges and creates a list of points on edges...
Definition: blockDescriptor.H:78