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 {
35  defineTypeNameAndDebug(block, 0);
36  defineRunTimeSelectionTable(block, Istream);
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  }
120 
121  return autoPtr<block>(ctorPtr(dict, index, points, edges, faces, is));
122 }
123 
124 
125 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
126 
128 {
129  os << b.points() << nl
130  << b.cells() << nl
131  << b.boundaryPatches() << endl;
132 
133  return os;
134 }
135 
136 
137 // ************************************************************************* //
Foam::autoPtr::New
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
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::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::token
A token holds an item read from Istream.
Definition: token.H:68
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
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
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
Foam::PtrList< blockEdge >
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
Foam::vertices
pointField vertices(const blockVertexList &bvl)
Definition: blockVertexList.H:49
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::nl
constexpr char nl
Definition: Ostream.H:404
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::Istream::putBack
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
Definition: Istream.C:70
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
points
const pointField & points
Definition: gmvOutputHeader.H:1
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
block.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)