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 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 "blockVertex.H"
30 #include "pointVertex.H"
31 #include "blockMeshTools.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(blockVertex, 0);
38  defineRunTimeSelectionTable(blockVertex, Istream);
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 {}
46 
47 
49 {
51  return nullptr;
52 }
53 
54 
56 (
57  const dictionary& dict,
58  const label index,
59  const searchableSurfaces& geometry,
60  Istream& is
61 )
62 {
63  DebugInFunction << "Constructing blockVertex" << endl;
64 
65  token firstToken(is);
66 
67  if (firstToken.isPunctuation() && firstToken.pToken() == token::BEGIN_LIST)
68  {
69  // Putback the opening bracket
70  is.putBack(firstToken);
71 
73  (
74  new blockVertices::pointVertex(dict, index, geometry, is)
75  );
76  }
77  else if (firstToken.isWord())
78  {
79  const word faceType(firstToken.wordToken());
80 
81  auto cstrIter = IstreamConstructorTablePtr_->cfind(faceType);
82 
83  if (!cstrIter.found())
84  {
86  (
87  dict,
88  "blockVertex",
89  faceType,
90  *IstreamConstructorTablePtr_
91  ) << abort(FatalIOError);
92  }
93 
94  return autoPtr<blockVertex>(cstrIter()(dict, index, geometry, is));
95  }
96 
98  << "incorrect first token, expected <word> or '(', found "
99  << firstToken.info()
100  << exit(FatalIOError);
101 
102  return nullptr;
103 }
104 
105 
107 {
108  const dictionary* varDictPtr = dict.findDict("namedVertices");
109  if (varDictPtr)
110  {
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 // ************************************************************************* //
Foam::dictionary::findDict
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
Definition: dictionary.C:503
Foam::val
label ListType::const_reference val
Definition: ListOps.H:407
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::blockVertex::New
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:56
pointVertex.H
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::token
A token holds an item read from Istream.
Definition: token.H:69
Foam::blockMeshTools::write
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
Definition: blockMeshTools.C:88
Foam::token::pToken
punctuationToken pToken() const
Return punctuation character.
Definition: tokenI.H:428
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:419
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:380
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::token::info
InfoProxy< token > info() const
Return info proxy for printing token information to a stream.
Definition: token.H:513
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:356
Foam::blockVertex::blockVertex
blockVertex()
Construct null.
Definition: blockVertex.C:44
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
blockVertex.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::token::isWord
bool isWord() const
Token is WORD.
Definition: tokenI.H:552
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::token::wordToken
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:558
Foam::blockVertex::read
static label read(Istream &, const dictionary &)
Read vertex index with optional name lookup.
Definition: blockVertex.C:106
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::autoPtr< Foam::blockVertex >
blockMeshTools.H
Foam::readLabel
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:70
Foam::Istream::putBack
void putBack(const token &tok)
Put back token.
Definition: Istream.C:53
Foam::searchableSurfaces
Container for searchableSurfaces. The collection is specified as a dictionary. For example,...
Definition: searchableSurfaces.H:92
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:375
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::blockVertex::write
static void write(Ostream &, const label, const dictionary &)
Write vertex index with optional name backsubstitution.
Definition: blockVertex.C:118
Foam::token::isPunctuation
bool isPunctuation() const
Token is PUNCTUATION.
Definition: tokenI.H:422
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:117
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::blockVertices::pointVertex
Definition: pointVertex.H:52
Foam::blockVertex::clone
virtual autoPtr< blockVertex > clone() const
Clone function.
Definition: blockVertex.C:48