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-2020 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 public:
130 
131  // Generated Methods
132 
133  //- Copy construct
134  blockDescriptor(const blockDescriptor&) = default;
135 
136  //- No copy assignment
137  void operator=(const blockDescriptor&) = delete;
138 
139 
140  // Constructors
141 
142  //- Construct from components. Optional cellSet/zone name.
144  (
145  const cellShape& bshape,
146  const pointField& vertices,
147  const blockEdgeList& edges,
148  const blockFaceList& faces,
149  const labelVector& density,
151  const word& zoneName = word::null
152  );
153 
154  //- Construct from Istream
156  (
157  const dictionary& dict,
158  const label index,
159  const pointField& vertices,
160  const blockEdgeList& edges,
161  const blockFaceList& faces,
162  Istream& is
163  );
164 
165 
166  // Member Functions
167 
168  //- Reference to point field defining the block mesh
169  inline const pointField& vertices() const;
170 
171  //- Return reference to the list of curved faces
172  inline const blockFaceList& blockFaces() const;
173 
174  //- Return the block shape
175  inline const cellShape& blockShape() const;
176 
177  //- Return the mesh density (number of cells) in the i,j,k directions
178  inline const labelVector& density() const;
179 
180  //- Expansion ratios in all directions
181  const List<gradingDescriptors>& grading() const;
182 
183  //- Return the (optional) zone name
184  inline const word& zoneName() const;
185 
186  //- Curved-face labels for each block-face (-1 for flat faces)
187  inline const FixedList<label, 6>& curvedFaces() const;
188 
189  //- Number of curved faces in this block
190  inline label nCurvedFaces() const;
191 
192  //- Return block point for local label i
193  inline const point& blockPoint(const label i) const;
194 
195  //- Face vertex label offset for a particular i,j,k position
196  //- on hex face (0-5)
197  inline label facePointLabel
198  (
199  const direction facei,
200  const label i,
201  const label j
202  ) const;
203 
204  //- Return true if point i,j,k addresses a block vertex
205  inline bool vertex(const label i, const label j, const label k) const;
206 
207  //- Return true if point i,j,k addresses a block edge
208  inline bool edge(const label i, const label j, const label k) const;
209 
210  //- Calculate the points and weights for all edges.
211  // Return the number of curved edges
212  label edgesPointsWeights
213  (
214  pointField (&edgePoints)[12],
215  scalarList (&edgeWeights)[12]
216  ) const;
217 
218  //- Return true if point i,j,k addresses a block flat face or edge
219  inline bool flatFaceOrEdge
220  (
221  const label i,
222  const label j,
223  const label k
224  ) const;
225 
226  //- Return the list of face-points for all of the faces of the block
228 
229  //- Correct the location of the given face-points
230  // to lie on the faces of the block
232 
233  //- Write block index with dictionary lookup
234  static void write(Ostream&, const label blocki, const dictionary&);
235 
236  //- Return info proxy
237  inline InfoProxy<blockDescriptor> info() const
238  {
239  return *this;
240  }
241 };
242 
243 
244 //- Output Operator
245 Ostream& operator<<(Ostream& os, const blockDescriptor& bd);
246 
247 //- Info output
248 Ostream& operator<<(Ostream& os, const InfoProxy<blockDescriptor>& info);
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace Foam
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #include "blockDescriptorI.H"
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************************************************************* //
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: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::stringOps::expand
string expand(const std::string &s, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Definition: stringOps.C:720
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::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
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
Foam::blockDescriptor::correctFacePoints
void correctFacePoints(FixedList< pointField, 6 > &) const
Correct the location of the given face-points.
Definition: blockDescriptor.C:343
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:121
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:69
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::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::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::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:77
cellShape.H
Foam::blockDescriptor::info
InfoProxy< blockDescriptor > info() const
Return info proxy.
Definition: blockDescriptor.H:236
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