patchIdentifier.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-2013 OpenFOAM Foundation
9  Copyright (C) 2020-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 "patchIdentifier.H"
30 #include "dictionary.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 :
36  name_(),
37  index_(0)
38 {}
39 
40 
42 (
43  const word& name,
44  const label index
45 )
46 :
47  name_(name),
48  index_(index)
49 {}
50 
51 
53 (
54  const word& name,
55  const label index,
56  const word& physicalType,
57  const wordList& inGroups
58 )
59 :
60  name_(name),
61  index_(index),
62  physicalType_(physicalType),
63  inGroups_(inGroups)
64 {}
65 
66 
68 (
69  const word& name,
70  const dictionary& dict,
71  const label index
72 )
73 :
74  patchIdentifier(name, index)
75 {
76  dict.readIfPresent("physicalType", physicalType_);
77  dict.readIfPresent("inGroups", inGroups_);
78 }
79 
80 
82 (
83  const patchIdentifier& ident,
84  const label index
85 )
86 :
87  name_(ident.name_),
88  index_(index),
89  physicalType_(ident.physicalType_),
90  inGroups_(ident.inGroups_)
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
97 {
98  if (!physicalType_.empty())
99  {
100  os.writeEntry("physicalType", physicalType_);
101  }
102 
103  if (!inGroups_.empty())
104  {
105  os.writeKeyword("inGroups");
106  // Flat output of list
107  inGroups_.writeList(os, 0) << token::END_STATEMENT << nl;
108  }
109 }
110 
111 
112 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
113 
115 {
116  ident.write(os);
118  return os;
119 }
120 
121 
122 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::patchIdentifier
Identifies a patch by name and index, with optional physical type and group information.
Definition: patchIdentifier.H:55
Foam::token::END_STATEMENT
End entry [isseparator].
Definition: token.H:154
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::patchIdentifier::patchIdentifier
patchIdentifier()
Default construct. Uses name="", index=0.
Definition: patchIdentifier.C:34
Foam::Ostream::writeKeyword
virtual Ostream & writeKeyword(const keyType &kw)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:57
patchIdentifier.H
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List< word >
dictionary.H
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:295
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::patchIdentifier::write
void write(Ostream &os) const
Definition: patchIdentifier.C:96
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:405