block.C
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 \*---------------------------------------------------------------------------*/
28 
29 #include "block.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
37 }
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
41 Foam::block::block
42 (
43  const cellShape& bshape,
44  const pointField& vertices,
45  const blockEdgeList& edges,
46  const blockFaceList& faces,
47  const labelVector& density,
49  const word& zoneName
50 )
51 :
52  blockDescriptor(bshape, vertices, edges, faces, density, expand, zoneName),
53  points_(),
54  blockCells_(),
55  blockPatches_()
56 {
57  // Always need points, and demand-driven data leaves dangling addressing?
58  createPoints();
59  createBoundary();
60 }
61 
62 
63 Foam::block::block
64 (
65  const dictionary& dict,
66  const label index,
67  const pointField& vertices,
68  const blockEdgeList& edges,
69  const blockFaceList& faces,
70  Istream& is
71 )
72 :
73  blockDescriptor(dict, index, vertices, edges, faces, is),
74  points_(),
75  blockCells_(),
76  blockPatches_()
77 {
78  // Always need points, and demand-driven data leaves dangling addressing?
79  createPoints();
80  createBoundary();
81 }
82 
83 
84 Foam::block::block(const blockDescriptor& blockDesc)
85 :
86  blockDescriptor(blockDesc),
87  points_(),
88  blockCells_(),
89  blockPatches_()
90 {
91  // Always need points, and demand-driven data leaves dangling addressing?
92  createPoints();
93  createBoundary();
94 }
95 
96 
97 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
98 
100 (
101  const dictionary& dict,
102  const label index,
103  const pointField& points,
104  const blockEdgeList& edges,
105  const blockFaceList& faces,
106  Istream& is
107 )
108 {
109  DebugInFunction << "Constructing block" << endl;
110 
111  const word blockOrCellShapeType(is);
112 
113  auto* ctorPtr = IstreamConstructorTable(blockOrCellShapeType);
114 
115  if (!ctorPtr)
116  {
117  is.putBack(token(blockOrCellShapeType));
118  return autoPtr<block>::New(dict, index, points, edges, faces, is);
119  }
121  return autoPtr<block>(ctorPtr(dict, index, points, edges, faces, is));
122 }
123 
124 
125 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
126 
127 Foam::Ostream& Foam::operator<<(Ostream& os, const block& b)
128 {
129  os << b.points() << nl
130  << b.cells() << nl
131  << b.boundaryPatches() << endl;
132 
133  return os;
134 }
135 
136 
137 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
An analytical geometric cellShape.
Definition: cellShape.H:68
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...
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
A token holds an item read from Istream.
Definition: token.H:65
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
pointField vertices(const blockVertexList &bvl)
void putBack(const token &tok)
Put back a token (copy). Only a single put back is permitted.
Definition: Istream.C:71
const pointField & points
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
A class for handling words, derived from Foam::string.
Definition: word.H:63
#define DebugInFunction
Report an information message using Foam::Info.
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:105
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
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:93
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
Namespace for OpenFOAM.
string expand(const std::string &s, const HashTable< string > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping and return the expanded string.
Definition: stringOps.C:705