block.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-2016 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::block
29
30Description
31 Creates a single block of cells from point coordinates, numbers of
32 cells in each direction and an expansion ratio.
33
34Note
35 The cells for filling the block are demand-driven.
36
37SourceFiles
38 block.C
39 blockCreate.C
40
41\*---------------------------------------------------------------------------*/
42
43#ifndef block_H
44#define block_H
45
46#include "blockDescriptor.H"
47#include "cellShapeList.H"
48#include "hexCell.H"
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52namespace Foam
53{
54
55/*---------------------------------------------------------------------------*\
56 Class block Declaration
57\*---------------------------------------------------------------------------*/
59class block
60:
61 public blockDescriptor
62{
63 // Private Data
64
65 //- List of points
66 pointField points_;
67
68 //- The cells (hex)
69 List<hexCell> blockCells_;
70
71 //- Boundary patches
72 FixedList<List<FixedList<label, 4>>, 6> blockPatches_;
73
74
75 // Private Member Functions
76
77 //- Create vertices for cells filling the block
78 void createPoints();
79
80 //- Create cells
81 void createCells();
82
83 //- Create boundary patch faces for the block
84 void createBoundary();
85
86 //- Add boundary faces for the shape face to the output list at
87 //- the iterator location
88 template<class OutputIterator>
89 OutputIterator addBoundaryFaces
90 (
91 const direction shapeFacei,
92 OutputIterator iter
93 ) const;
94
95
96 //- No copy construct
97 block(const block&) = delete;
98
99 //- No copy assignment
100 void operator=(const block&) = delete;
101
102
103public:
104
105 //- Runtime type information
106 TypeName("block");
107
108
109 // Declare run-time constructor selection tables
112 (
113 autoPtr,
114 block,
115 Istream,
116 (
117 const dictionary& dict,
118 const label index,
119 const pointField& vertices,
120 const blockEdgeList& edges,
121 const blockFaceList& faces,
122 Istream& is
123 ),
124 (dict, index, vertices, edges, faces, is)
125 );
126
127
128 // Constructors
129
130 //- Construct from components. Optional zone name.
131 block
132 (
133 const cellShape& bshape,
134 const pointField& vertices,
135 const blockEdgeList& edges,
136 const blockFaceList& faces,
137 const labelVector& density,
138 const UList<gradingDescriptors>& expand
140 const word& zoneName = ""
141 );
142
143 //- Construct from components with Istream
144 block
145 (
146 const dictionary& dict,
147 const label index,
148 const pointField& vertices,
149 const blockEdgeList& edges,
150 const blockFaceList& faces,
151 Istream& is
152 );
153
154 //- Construct from a block definition
155 block(const blockDescriptor& blockDesc);
156
157 //- Clone
158 autoPtr<block> clone() const
159 {
161 return nullptr;
162 }
163
164 //- New function which constructs and returns pointer to a block
165 static autoPtr<block> New
166 (
167 const dictionary& dict,
168 const label index,
169 const pointField& points,
170 const blockEdgeList& edges,
171 const blockFaceList& faces,
172 Istream&
173 );
174
175 //- Class used for the read-construction of
176 // PtrLists of blocks
177 class iNew
178 {
179 const dictionary& dict_;
180 const pointField& points_;
181 const blockEdgeList& edges_;
182 const blockFaceList& faces_;
183 mutable label index_;
184
185 public:
187 iNew
188 (
189 const dictionary& dict,
190 const pointField& points,
191 const blockEdgeList& edges,
192 const blockFaceList& faces
193 )
194 :
195 dict_(dict),
196 points_(points),
197 edges_(edges),
198 faces_(faces),
199 index_(0)
200 {}
203 {
204 return block::New(dict_, index_++, points_, edges_, faces_, is);
205 }
206 };
207
208
209 //- Destructor
210 virtual ~block() = default;
211
212
213 // Member Functions
214
215 // Access
216
217 //- The points for filling the block
218 inline const pointField& points() const noexcept;
219
220 //- The hex cells for filling the block
221 inline const List<hexCell>& cells() const;
222
223 //- The boundary patch faces for the block
224 inline const FixedList<List<FixedList<label, 4>>, 6>&
226
227
228 // Mesh Components
229
230 //- The (hex) cell shapes for filling the block.
231 cellShapeList shapes() const;
232};
233
234
235//- Ostream Operator
236Ostream& operator<<(Ostream& os, const block& blk);
237
238
239// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240
241} // End namespace Foam
242
243// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244
245#include "blockI.H"
246
247// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248
249#endif
250
251// ************************************************************************* //
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: FixedList.H:81
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
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Takes the description of the block and the list of curved edges and creates a list of points on edges...
const pointField & vertices() const noexcept
Reference to point field defining the block mesh.
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.
Class used for the read-construction of.
Definition: block.H:177
autoPtr< block > operator()(Istream &is) const
Definition: block.H:201
iNew(const dictionary &dict, const pointField &points, const blockEdgeList &edges, const blockFaceList &faces)
Definition: block.H:187
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:61
autoPtr< block > clone() const
Clone.
Definition: block.H:157
const pointField & points() const noexcept
The points for filling the block.
Definition: blockI.H:31
virtual ~block()=default
Destructor.
TypeName("block")
Runtime type information.
const FixedList< List< FixedList< label, 4 > >, 6 > & boundaryPatches() const noexcept
The boundary patch faces for the block.
Definition: blockI.H:49
static autoPtr< block > New(const dictionary &dict, const label index, const pointField &points, const blockEdgeList &edges, const blockFaceList &faces, Istream &)
New function which constructs and returns pointer to a block.
Definition: block.C:100
declareRunTimeSelectionTable(autoPtr, block, Istream,(const dictionary &dict, const label index, const pointField &vertices, const blockEdgeList &edges, const blockFaceList &faces, Istream &is),(dict, index, vertices, edges, faces, is))
cellShapeList shapes() const
The (hex) cell shapes for filling the block.
Definition: blockCreate.C:556
const List< hexCell > & cells() const
The hex cells for filling the block.
Definition: blockI.H:37
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
A hexahedral cell primitive.
Definition: hexCell.H:63
label index(const label i, const label j, const label k) const
Linear addressing index (offset) for an (i,j,k) position.
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:56
const direction noexcept
Definition: Scalar.H:223
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73