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 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::block
29 
30 Description
31  Creates a single block of cells from point coordinates, numbers of
32  cells in each direction and an expansion ratio.
33 
34 Note
35  The cells for filling the block are demand-driven.
36 
37 SourceFiles
38  block.C
39  blockCreate.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef block_H
44 #define block_H
45 
46 #include "pointField.H"
47 #include "faceList.H"
48 #include "blockDescriptor.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class block Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class block
60 :
61  public blockDescriptor
62 {
63  // Private Data
64 
65  //- List of points
66  pointField points_;
67 
68  //- The cells (hex)
69  List<FixedList<label, 8>> 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 
103 public:
104 
105  //- Runtime type information
106  TypeName("block");
107 
108 
109  // Declare run-time constructor selection tables
110 
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 cellSet/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,
139  const word& zoneName = ""
140  );
141 
142  //- Construct from components with Istream
143  block
144  (
145  const dictionary& dict,
146  const label index,
147  const pointField& vertices,
148  const blockEdgeList& edges,
149  const blockFaceList& faces,
150  Istream& is
151  );
152 
153  //- Construct from a block definition
154  block(const blockDescriptor& blockDesc);
155 
156  //- Clone
157  autoPtr<block> clone() const
158  {
160  return nullptr;
161  }
162 
163  //- New function which constructs and returns pointer to a block
164  static autoPtr<block> New
165  (
166  const dictionary& dict,
167  const label index,
168  const pointField& points,
169  const blockEdgeList& edges,
170  const blockFaceList& faces,
171  Istream&
172  );
173 
174  //- Class used for the read-construction of
175  // PtrLists of blocks
176  class iNew
177  {
178  const dictionary& dict_;
179  const pointField& points_;
180  const blockEdgeList& edges_;
181  const blockFaceList& faces_;
182  mutable label index_;
183 
184  public:
185 
187  (
188  const dictionary& dict,
189  const pointField& points,
190  const blockEdgeList& edges,
191  const blockFaceList& faces
192  )
193  :
194  dict_(dict),
195  points_(points),
196  edges_(edges),
197  faces_(faces),
198  index_(0)
199  {}
200 
202  {
203  return block::New(dict_, index_++, points_, edges_, faces_, is);
204  }
205  };
206 
207 
208  //- Destructor
209  virtual ~block() = default;
210 
211 
212  // Member Functions
213 
214  // Access
215 
216  //- The points for filling the block
217  inline const pointField& points() const;
218 
219  //- The cells for filling the block
220  inline const List<FixedList<label, 8>>& cells() const;
221 
222  //- The boundary patch faces for the block
223  inline const FixedList<List<FixedList<label, 4>>, 6>&
224  boundaryPatches() const;
225 };
226 
227 
228 //- Ostream Operator
229 Ostream& operator<<(Ostream& os, const block& blk);
230 
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 } // End namespace Foam
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #include "blockI.H"
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
243 
244 // ************************************************************************* //
Foam::block::clone
autoPtr< block > clone() const
Clone.
Definition: block.H:156
Foam::block
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:58
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::block::iNew::operator()
autoPtr< block > operator()(Istream &is) const
Definition: block.H:200
Foam::blockDescriptor::zoneName
const word & zoneName() const
Return the (optional) zone name.
Definition: blockDescriptorI.H:62
Foam::block::TypeName
TypeName("block")
Runtime type information.
faceList.H
blockDescriptor.H
blockI.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::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:436
Foam::block::points
const pointField & points() const
The points for filling the block.
Definition: blockI.H:31
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::block::~block
virtual ~block()=default
Destructor.
Foam::PtrList< blockEdge >
Foam::block::declareRunTimeSelectionTable
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))
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::block::boundaryPatches
const FixedList< List< FixedList< label, 4 > >, 6 > & boundaryPatches() const
The boundary patch faces for the block.
Definition: blockI.H:50
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:71
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
pointField.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::block::iNew::iNew
iNew(const dictionary &dict, const pointField &points, const blockEdgeList &edges, const blockFaceList &faces)
Definition: block.H:186
Foam::block::cells
const List< FixedList< label, 8 > > & cells() const
The cells for filling the block.
Definition: blockI.H:38
Foam::block::New
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
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::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
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
Foam::direction
uint8_t direction
Definition: direction.H:47
Foam::block::iNew
Class used for the read-construction of.
Definition: block.H:175
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::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