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-2018 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  //- Disallow default bitwise copy construct
86  block(const block&);
87 
88  //- Disallow default bitwise assignment
89  void operator=(const block&);
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("block");
96 
97 
98  // Declare run-time constructor selection tables
99 
101  (
102  autoPtr,
103  block,
104  Istream,
105  (
106  const dictionary& dict,
107  const label index,
108  const pointField& vertices,
109  const blockEdgeList& edges,
110  const blockFaceList& faces,
111  Istream& is
112  ),
113  (dict, index, vertices, edges, faces, is)
114  );
115 
116 
117  // Constructors
118 
119  //- Construct from components with Istream
120  block
121  (
122  const dictionary& dict,
123  const label index,
124  const pointField& vertices,
125  const blockEdgeList& edges,
126  const blockFaceList& faces,
127  Istream& is
128  );
129 
130  //- Construct from a block definition
131  block(const blockDescriptor&);
132 
133  //- Clone
134  autoPtr<block> clone() const
135  {
137  return autoPtr<block>(nullptr);
138  }
139 
140  //- New function which constructs and returns pointer to a block
141  static autoPtr<block> New
142  (
143  const dictionary& dict,
144  const label index,
145  const pointField& points,
146  const blockEdgeList& edges,
147  const blockFaceList& faces,
148  Istream&
149  );
150 
151  //- Class used for the read-construction of
152  // PtrLists of blocks
153  class iNew
154  {
155  const dictionary& dict_;
156  const pointField& points_;
157  const blockEdgeList& edges_;
158  const blockFaceList& faces_;
159  mutable label index_;
160 
161  public:
162 
164  (
165  const dictionary& dict,
166  const pointField& points,
167  const blockEdgeList& edges,
168  const blockFaceList& faces
169  )
170  :
171  dict_(dict),
172  points_(points),
173  edges_(edges),
174  faces_(faces),
175  index_(0)
176  {}
179  {
180  return block::New(dict_, index_++, points_, edges_, faces_, is);
181  }
182  };
183 
184 
185  //- Destructor
186  virtual ~block()
187  {}
188 
189 
190  // Member Functions
191 
192  // Access
193 
194  //- Return the points for filling the block
195  inline const pointField& points() const;
196 
197  //- Return the cells for filling the block
199 
200  //- Return the boundary patch faces for the block
201  inline const FixedList<List<FixedList<label, 4>>, 6>&
202  boundaryPatches() const;
203 
204 
205  // Ostream Operator
206 
207  friend Ostream& operator<<(Ostream&, const block&);
208 };
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 #include "blockI.H"
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #endif
221 
222 // ************************************************************************* //
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))
dictionary dict
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
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:54
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:60
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Takes the description of the block and the list of curved edges and creates a list of points on edges...
List< FixedList< label, 8 > > cells() const
Return the cells for filling the block.
Definition: blockCreate.C:349
Class used for the read-construction of.
Definition: block.H:152
autoPtr< block > clone() const
Clone.
Definition: block.H:133
friend Ostream & operator<<(Ostream &, const block &)
autoPtr< block > operator()(Istream &is) const
Definition: block.H:177
iNew(const dictionary &dict, const pointField &points, const blockEdgeList &edges, const blockFaceList &faces)
Definition: block.H:163
TypeName("block")
Runtime type information.
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:63
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const pointField & vertices() const
Reference to point field defining the block mesh.
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
virtual ~block()
Destructor.
Definition: block.H:185
Ostream & operator<<(Ostream &, const ensightPart &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const FixedList< List< FixedList< label, 4 > >, 6 > & boundaryPatches() const
Return the boundary patch faces for the block.
Definition: blockI.H:35
const pointField & points() const
Return the points for filling the block.
Definition: blockI.H:28
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
const blockFaceList & faces() const
Return reference to the list of curved faces.
Namespace for OpenFOAM.