block.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::block
26 
27 Description
28  Creates a single block of cells from point coordinates, numbers of
29  cells in each direction and an expansion ratio.
30 
31  Note:
32  The vertices and cells for filling the block are demand-driven.
33 
34 SourceFiles
35  block.C
36  blockCreate.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef block_H
41 #define block_H
42 
43 #include "pointField.H"
44 #include "labelList.H"
45 
46 #include "blockDescriptor.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 class Istream;
54 class Ostream;
55 
56 // Forward declaration of friend functions and operators
57 class block;
58 Ostream& operator<<(Ostream&, const block&);
59 
60 /*---------------------------------------------------------------------------*\
61  Class block Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 class block
65 :
66  public blockDescriptor
67 {
68  // Private Data
69 
70  //- List of points
71  pointField points_;
72 
73  //- Boundary patches
74  FixedList<List<FixedList<label, 4>>, 6> boundaryPatches_;
75 
76 
77  // Private Member Functions
78 
79  //- Creates vertices for cells filling the block
80  void createPoints();
81 
82  //- Creates boundary patch faces for the block
83  void createBoundary();
84 
85 
86 public:
87 
88  //- Runtime type information
89  TypeName("block");
90 
91 
92  // Declare run-time constructor selection tables
93 
95  (
96  autoPtr,
97  block,
98  Istream,
99  (
100  const dictionary& dict,
101  const label index,
102  const pointField& vertices,
103  const blockEdgeList& edges,
104  const blockFaceList& faces,
105  Istream& is
106  ),
107  (dict, index, vertices, edges, faces, is)
108  );
109 
110 
111  // Constructors
112 
113  //- Construct from components with Istream
114  block
115  (
116  const dictionary& dict,
117  const label index,
118  const pointField& vertices,
119  const blockEdgeList& edges,
120  const blockFaceList& faces,
121  Istream& is
122  );
123 
124  //- Construct from a block definition
125  block(const blockDescriptor&);
126 
127  //- Disallow default bitwise copy construction
128  block(const block&) = delete;
129 
130  //- Clone
131  autoPtr<block> clone() const
132  {
134  return autoPtr<block>(nullptr);
135  }
136 
137  //- New function which constructs and returns pointer to a block
138  static autoPtr<block> New
139  (
140  const dictionary& dict,
141  const label index,
142  const pointField& points,
143  const blockEdgeList& edges,
144  const blockFaceList& faces,
145  Istream&
146  );
147 
148  //- Class used for the read-construction of
149  // PtrLists of blocks
150  class iNew
151  {
152  const dictionary& dict_;
153  const pointField& points_;
154  const blockEdgeList& edges_;
155  const blockFaceList& faces_;
156  mutable label index_;
157 
158  public:
159 
160  iNew
161  (
162  const dictionary& dict,
163  const pointField& points,
164  const blockEdgeList& edges,
165  const blockFaceList& faces
166  )
167  :
168  dict_(dict),
169  points_(points),
170  edges_(edges),
171  faces_(faces),
172  index_(0)
173  {}
174 
176  {
177  return block::New(dict_, index_++, points_, edges_, faces_, is);
178  }
179  };
180 
181 
182  //- Destructor
183  virtual ~block()
184  {}
185 
186 
187  // Member Functions
188 
189  // Access
190 
191  //- Return the points for filling the block
192  inline const pointField& points() const;
193 
194  //- Return the cells for filling the block
196 
197  //- Return the boundary patch faces for the block
198  inline const FixedList<List<FixedList<label, 4>>, 6>&
199  boundaryPatches() const;
200 
201 
202  // Member Operators
203 
204  //- Disallow default bitwise assignment
205  void operator=(const block&) = delete;
206 
207 
208  // Ostream Operator
209 
210  friend Ostream& operator<<(Ostream&, const block&);
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #include "blockI.H"
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:78
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:91
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Takes the description of the block and the list of curved edges and creates a list of points on edges...
const blockFaceList & faces() const
Return reference to the list of curved faces.
const pointField & vertices() const
Reference to point field defining the block mesh.
Class used for the read-construction of.
Definition: block.H:150
iNew(const dictionary &dict, const pointField &points, const blockEdgeList &edges, const blockFaceList &faces)
Definition: block.H:160
autoPtr< block > operator()(Istream &is) const
Definition: block.H:174
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:66
friend Ostream & operator<<(Ostream &, const block &)
List< FixedList< label, 8 > > cells() const
Return the cells for filling the block.
Definition: blockCreate.C:349
virtual ~block()
Destructor.
Definition: block.H:182
block(const dictionary &dict, const label index, const pointField &vertices, const blockEdgeList &edges, const blockFaceList &faces, Istream &is)
Construct from components with Istream.
Definition: block.C:39
TypeName("block")
Runtime type information.
const FixedList< List< FixedList< label, 4 > >, 6 > & boundaryPatches() const
Return the boundary patch faces for the block.
Definition: blockI.H:35
autoPtr< block > clone() const
Clone.
Definition: block.H:130
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:65
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))
const pointField & points() const
Return the points for filling the block.
Definition: blockI.H:28
void operator=(const block &)=delete
Disallow default bitwise assignment.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
Namespace for OpenFOAM.
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:59
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
dictionary dict