Loading...
Searching...
No Matches
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\*---------------------------------------------------------------------------*/
29#include "block.H"
30
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
35 defineTypeNameAndDebug(block, 0);
37}
38
39// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40
41Foam::block::block
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_()
57 // Always need points, and demand-driven data leaves dangling addressing?
58 createPoints();
59 createBoundary();
60}
61
62
63Foam::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_()
78 // Always need points, and demand-driven data leaves dangling addressing?
79 createPoints();
80 createBoundary();
81}
82
83
84Foam::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
127Foam::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// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
void putBack(const token &tok)
Put back a token (copy). Only a single put back is permitted.
Definition Istream.C:71
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
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:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition autoPtr.H:178
Takes the description of the block and the list of curved edges and creates a list of points on edges...
const pointField & vertices() const noexcept
Reference to point field defining the block mesh.
blockDescriptor(const blockDescriptor &)=default
Copy construct.
const labelVector & density() const noexcept
The mesh density (number of cells) in the i,j,k directions.
const word & zoneName() const noexcept
Return the (optional) zone name.
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition block.H:57
const pointField & points() const noexcept
The points for filling the block.
Definition blockI.H:24
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
An analytical geometric cellShape.
Definition cellShape.H:71
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
label index(const label i, const label j, const label k) const
Linear addressing index (offset) for an (i,j,k) position.
A token holds an item read from Istream.
Definition token.H:70
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
OBJstream os(runTime.globalPath()/outputName)
const pointField & points
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for OpenFOAM.
Vector< label > labelVector
Vector of labels.
Definition labelVector.H:47
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
pointField vertices(const blockVertexList &bvl)
PtrList< blockFace > blockFaceList
A PtrList of blockFaces.
PtrList< blockEdge > blockEdgeList
A PtrList of blockEdges.
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
volScalarField & b