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 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  \verbatim
39  7 ---- 6
40  f5 |\ |\ f3
41  | | 4 ---- 5 \
42  | 3 |--- 2 | \
43  | \| \| f2
44  f4 0 ---- 1
45 
46  Z f0 ----- f1
47  | Y
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
95  cellShape blockShape_;
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  //- No copy assignment
130  void operator=(const blockDescriptor&) = delete;
131 
132 
133 public:
134 
135  // Constructors
136 
137  //- Construct from components. Optional cellSet/zone name.
139  (
140  const cellShape& bshape,
141  const pointField& vertices,
142  const blockEdgeList& edges,
143  const blockFaceList& faces,
144  const labelVector& density,
146  const word& zoneName = ""
147  );
148 
149  //- Construct from Istream
151  (
152  const dictionary& dict,
153  const label index,
154  const pointField& vertices,
155  const blockEdgeList& edges,
156  const blockFaceList& faces,
157  Istream& is
158  );
159 
160 
161  // Member Functions
162 
163  //- Reference to point field defining the block mesh
164  inline const pointField& vertices() const;
165 
166  //- Return reference to the list of curved faces
167  inline const blockFaceList& blockFaces() const;
168 
169  //- Return the block shape
170  inline const cellShape& blockShape() const;
171 
172  //- Return the mesh density (number of cells) in the i,j,k directions
173  inline const labelVector& density() const;
174 
175  //- Expansion ratios in all directions
176  const List<gradingDescriptors>& grading() const;
177 
178  //- Return the (optional) zone name
179  inline const word& zoneName() const;
180 
181  //- Curved-face labels for each block-face (-1 for flat faces)
182  inline const FixedList<label, 6>& curvedFaces() const;
183 
184  //- Number of curved faces in this block
185  inline label nCurvedFaces() const;
186 
187  //- Return block point for local label i
188  inline const point& blockPoint(const label i) const;
189 
190  //- Face vertex label offset for a particular i,j,k position
191  //- on hex face (0-5)
192  inline label facePointLabel
193  (
194  const direction facei,
195  const label i,
196  const label j
197  ) const;
198 
199  //- Return true if point i,j,k addresses a block vertex
200  inline bool vertex(const label i, const label j, const label k) const;
201 
202  //- Return true if point i,j,k addresses a block edge
203  inline bool edge(const label i, const label j, const label k) const;
204 
205  //- Calculate the points and weights for all edges.
206  // Return the number of curved edges
208  (
209  pointField (&edgePoints)[12],
210  scalarList (&edgeWeights)[12]
211  ) const;
212 
213  //- Return true if point i,j,k addresses a block flat face or edge
214  inline bool flatFaceOrEdge
215  (
216  const label i,
217  const label j,
218  const label k
219  ) const;
220 
221  //- Return the list of face-points for all of the faces of the block
223 
224  //- Correct the location of the given face-points
225  // to lie on the faces of the block
227 
228  //- Write block index with dictionary lookup
229  static void write(Ostream&, const label blocki, const dictionary&);
230 
231  //- Return info proxy
232  inline InfoProxy<blockDescriptor> info() const
233  {
234  return *this;
235  }
236 };
237 
238 
239 //- Output Operator
240 Ostream& operator<<(Ostream& os, const blockDescriptor& bd);
241 
242 //- Info output
243 Ostream& operator<<(Ostream& os, const InfoProxy<blockDescriptor>& info);
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 } // End namespace Foam
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 #include "blockDescriptorI.H"
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
Foam::blockDescriptor::blockPoint
const point & blockPoint(const label i) const
Return block point for local label i.
Definition: blockDescriptorI.H:81
Foam::blockDescriptor::vertices
const pointField & vertices() const
Reference to point field defining the block mesh.
Definition: blockDescriptorI.H:31
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::InfoProxy
A helper class for outputting values to Ostream.
Definition: InfoProxy.H:47
Foam::blockDescriptor::blockShape
const cellShape & blockShape() const
Return the block shape.
Definition: blockDescriptorI.H:43
InfoProxy.H
Foam::blockDescriptor::facePointLabel
label facePointLabel(const direction facei, const label i, const label j) const
Definition: blockDescriptorI.H:88
Foam::blockDescriptor::write
static void write(Ostream &, const label blocki, const dictionary &)
Write block index with dictionary lookup.
Definition: blockDescriptor.C:363
Foam::blockDescriptor::zoneName
const word & zoneName() const
Return the (optional) zone name.
Definition: blockDescriptorI.H:62
Foam::blockDescriptor::vertex
bool vertex(const label i, const label j, const label k) const
Return true if point i,j,k addresses a block vertex.
Definition: blockDescriptorI.H:125
Foam::blockDescriptor::nCurvedFaces
label nCurvedFaces() const
Number of curved faces in this block.
Definition: blockDescriptorI.H:75
scalarList.H
gradingDescriptors.H
Foam::blockDescriptor::curvedFaces
const FixedList< label, 6 > & curvedFaces() const
Curved-face labels for each block-face (-1 for flat faces)
Definition: blockDescriptorI.H:69
Foam::label
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:62
Foam::ijkMesh
A simple i-j-k (row-major order) to linear addressing for a rectilinear mesh. Since the underlying me...
Definition: ijkMesh.H:53
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
blockEdgeList.H
Foam::PtrList< blockEdge >
Foam::blockDescriptor::grading
const List< gradingDescriptors > & grading() const
Expansion ratios in all directions.
Definition: blockDescriptorI.H:56
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:287
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:121
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:151
stdFoam::end
constexpr auto end(C &c) -> decltype(c.end())
Return iterator to the end of the container c.
Definition: stdFoam.H:115
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:71
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::blockDescriptor::edge
bool edge(const label i, const label j, const label k) const
Return true if point i,j,k addresses a block edge.
Definition: blockDescriptorI.H:138
Foam::blockDescriptor::edgesPointsWeights
label edgesPointsWeights(pointField(&edgePoints)[12], scalarList(&edgeWeights)[12]) const
Calculate the points and weights for all edges.
Definition: blockDescriptorEdges.C:115
pointField.H
Foam::blockDescriptor::blockDescriptor
blockDescriptor(const cellShape &bshape, const pointField &vertices, const blockEdgeList &edges, const blockFaceList &faces, const labelVector &density, const UList< gradingDescriptors > &expand, const word &zoneName="")
Construct from components. Optional cellSet/zone name.
Definition: blockDescriptor.C:132
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: HashTable.H:102
Foam::stringOps::expand
string expand(const std::string &str, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Definition: stringOps.C:739
Foam::start
label ListType::const_reference const label start
Definition: ListOps.H:408
Foam::FixedList< label, 6 >
Foam::ijkAddressing::index
label index(const label i, const label j, const label k) const
Linear addressing index (offset) for an (i,j,k) position.
Definition: ijkAddressingI.H:131
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::direction
uint8_t direction
Definition: direction.H:47
cellShape.H
Foam::blockDescriptor::info
InfoProxy< blockDescriptor > info() const
Return info proxy.
Definition: blockDescriptor.H:231
Foam::blockDescriptor::density
const labelVector & density() const
Return the mesh density (number of cells) in the i,j,k directions.
Definition: blockDescriptorI.H:49
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
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
Foam::blockDescriptor::blockFaces
const blockFaceList & blockFaces() const
Return reference to the list of curved faces.
Definition: blockDescriptorI.H:37
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::blockDescriptor::correctFacePoints
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
Definition: blockDescriptor.C:343