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 
114 Foam::Ostream& Foam::operator<<(Ostream& os, const patchIdentifier& ident)
115 {
116  ident.write(os);
118  return os;
119 }
120 
121 
122 // ************************************************************************* //
dictionary dict
void write(Ostream &os) const
Write (physicalType, inGroups) dictionary entries (without surrounding braces)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
Identifies a patch by name and index, with optional physical type and group information.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:420
End entry [isseparator].
Definition: token.H:157
patchIdentifier()
Default construct. Uses name="", index=0.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
Definition: UListIO.C:72
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76