Loading...
Searching...
No Matches
blockVertex.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) 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 "blockVertex.H"
30#include "pointVertex.H"
32
33// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34
35namespace Foam
36{
42// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43
45{
47 return nullptr;
48}
49
50
52(
53 const dictionary& dict,
54 const label index,
55 const searchableSurfaces& geometry,
56 Istream& is
57)
58{
59 DebugInFunction << "Constructing blockVertex" << endl;
60
61 token firstToken(is);
62
63 if (firstToken.isPunctuation(token::BEGIN_LIST))
64 {
65 // Putback the opening bracket
66 is.putBack(firstToken);
67
69 (
70 new blockVertices::pointVertex(dict, index, geometry, is)
71 );
72 }
73 else if (firstToken.isWord())
74 {
75 const word faceType(firstToken.wordToken());
76
77 auto* ctorPtr = IstreamConstructorTable(faceType);
78
79 if (!ctorPtr)
80 {
82 (
83 dict,
84 "blockVertex",
85 faceType,
86 *IstreamConstructorTablePtr_
87 ) << abort(FatalIOError);
88 }
89
90 return autoPtr<blockVertex>(ctorPtr(dict, index, geometry, is));
91 }
92
94 << "incorrect first token, expected <word> or '(', found "
95 << firstToken.info() << nl
97
98 return nullptr;
99}
100
101
102Foam::label Foam::blockVertex::read
103(
104 Istream& is,
105 const dictionary& dict
106)
107{
108 const dictionary* varDictPtr = dict.findDict("namedVertices");
109 if (varDictPtr)
111 return blockMeshTools::read(is, *varDictPtr);
112 }
113 return readLabel(is);
114}
115
116
118(
119 Ostream& os,
120 const label val,
121 const dictionary& d
122)
123{
124 const dictionary* varDictPtr = d.findDict("namedVertices");
125 if (varDictPtr)
126 {
127 blockMeshTools::write(os, val, *varDictPtr);
128 }
129 else
130 {
131 os << val;
132 }
133}
134
135
136// ************************************************************************* //
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
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Define a block vertex.
Definition blockVertex.H:48
static void write(Ostream &, const label, const dictionary &)
Write vertex index with optional name backsubstitution.
static label read(Istream &, const dictionary &)
Read vertex index with optional name lookup.
Definition blockVertex.C:96
blockVertex() noexcept=default
Default construct.
virtual autoPtr< blockVertex > clone() const
Clone function.
Definition blockVertex.C:37
static autoPtr< blockVertex > New(const dictionary &dict, const label index, const searchableSurfaces &geometry, Istream &)
New function which constructs and returns pointer to a blockVertex.
Definition blockVertex.C:45
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
A token holds an item read from Istream.
Definition token.H:70
bool isPunctuation() const noexcept
Token is PUNCTUATION.
Definition tokenI.H:650
@ BEGIN_LIST
Begin list [isseparator].
Definition token.H:174
const word & wordToken() const
Return const reference to the word contents.
Definition tokenI.H:1022
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE).
Definition tokenI.H:1004
InfoProxy< token > info() const noexcept
Return info proxy, for printing token information to a stream.
Definition token.H:1253
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
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition error.H:688
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
OBJstream os(runTime.globalPath()/outputName)
#define DebugInFunction
Report an information message using Foam::Info.
void write(Ostream &, const label val, const dictionary &)
Write with dictionary lookup.
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Namespace for OpenFOAM.
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition label.H:63
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict