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-------------------------------------------------------------------------------
11License
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
33namespace Foam
34{
37}
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
42(
43 const cellShape& bshape,
44 const pointField& vertices,
45 const blockEdgeList& edges,
46 const blockFaceList& faces,
47 const labelVector& density,
48 const UList<gradingDescriptors>& expand,
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
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
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// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
Definition: Istream.C:70
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Takes the description of the block and the list of curved edges and creates a list of points on edges...
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:61
An analytical geometric cellShape.
Definition: cellShape.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A token holds an item read from Istream.
Definition: token.H:69
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
pointField vertices(const blockVertexList &bvl)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
volScalarField & b
Definition: createFields.H:27