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 -------------------------------------------------------------------------------
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 "blockDescriptor.H"
47 #include "cellShapeList.H"
48 #include "hexCell.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<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 
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 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,
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:
186 
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  {}
201 
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>&
225  boundaryPatches() const noexcept;
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
236 Ostream& 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 // ************************************************************************* //
Foam::block::boundaryPatches
const FixedList< List< FixedList< label, 4 > >, 6 > & boundaryPatches() const noexcept
The boundary patch faces for the block.
Definition: blockI.H:49
Foam::block::clone
autoPtr< block > clone() const
Clone.
Definition: block.H:157
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::block::shapes
cellShapeList shapes() const
The (hex) cell shapes for filling the block.
Definition: blockCreate.C:556
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::blockDescriptor::zoneName
const word & zoneName() const noexcept
Return the (optional) zone name.
Definition: blockDescriptorI.H:66
Foam::block::iNew::operator()
autoPtr< block > operator()(Istream &is) const
Definition: block.H:201
cellShapeList.H
Foam::blockDescriptor::vertices
const pointField & vertices() const noexcept
Reference to point field defining the block mesh.
Definition: blockDescriptorI.H:32
Foam::block::TypeName
TypeName("block")
Runtime type information.
blockDescriptor.H
Foam::block::cells
const List< hexCell > & cells() const
The hex cells for filling the block.
Definition: blockI.H:37
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::block::points
const pointField & points() const noexcept
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::blockDescriptor::density
const labelVector & density() const noexcept
The mesh density (number of cells) in the i,j,k directions.
Definition: blockDescriptorI.H:53
Foam::block::~block
virtual ~block()=default
Destructor.
Foam::PtrList< blockEdge >
hexCell.H
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::cellShape
An analytical geometric cellShape.
Definition: cellShape.H:69
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
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:187
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: BitOps.H:63
Foam::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
Foam::hexCell
A hexahedral cell primitive.
Definition: hexCell.H:60
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:52
Foam::block::iNew
Class used for the read-construction of.
Definition: block.H:176
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::stringOps::expand
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Definition: stringOps.C:718
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