surfZoneIdentifier.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 OpenFOAM Foundation
9  Copyright (C) 2016-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 "surfZoneIdentifier.H"
30 #include "dictionary.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 :
37 {}
38 
39 
41 :
42  name_(),
43  index_(index),
44  geometricType_()
45 {}
46 
47 
49 (
50  const word& name,
51  const label index
52 )
53 :
54  name_(name),
55  index_(index),
56  geometricType_()
57 {}
58 
59 
61 (
62  const word& name,
63  const label index,
64  const word& geometricType
65 )
66 :
67  name_(name),
68  index_(index),
69  geometricType_(geometricType)
70 {}
71 
72 
74 (
75  const word& name,
76  const dictionary& dict,
77  const label index
78 )
79 :
80  name_(name),
81  index_(index),
82  geometricType_()
83 {
84  dict.readIfPresent("geometricType", geometricType_);
85 }
86 
87 
89 (
90  const surfZoneIdentifier& ident,
91  const label index
92 )
93 :
94  name_(ident.name_),
95  index_(index),
96  geometricType_(ident.geometricType_)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 {
104  if (!geometricType_.empty())
105  {
106  os.writeEntry("geometricType", geometricType_);
107  }
108 }
109 
110 
111 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
112 
113 bool Foam::operator==
114 (
115  const surfZoneIdentifier& a,
116  const surfZoneIdentifier& b
117 )
118 {
119  return
120  (
121  (a.index() == b.index())
122  && (a.name() == b.name())
123  && (a.geometricType() == b.geometricType())
124  );
125 }
126 
127 
128 bool Foam::operator!=
129 (
130  const surfZoneIdentifier& a,
131  const surfZoneIdentifier& b
132 )
133 {
134  return !(a == b);
135 }
136 
137 
138 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
139 
141 {
142  // Also read "" for empty words
143  obj.name() = word::validate(token(is).stringToken());
144  obj.geometricType() = word::validate(token(is).stringToken());
145 
146  return is;
147 }
148 
149 
151 {
152  // Force unconditional line-breaks on list output.
153  // We otherwise risk extremely unreadable entries
154  os << nl;
155 
156  // Empty words are double-quoted so they are treated as 'string'
157  // and not simply lost
158 
159  os.writeQuoted(obj.name(), obj.name().empty()) << token::SPACE;
160  os.writeQuoted(obj.geometricType(), obj.geometricType().empty());
161 
163  return os;
164 }
165 
166 
167 // ************************************************************************* //
Foam::surfZoneIdentifier::write
void write(Ostream &os) const
Definition: surfZoneIdentifier.C:102
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::OBJstream::writeQuoted
virtual Ostream & writeQuoted(const std::string &str, const bool quoted=true)
Write std::string surrounded by quotes.
Definition: OBJstream.C:108
Foam::dimensioned::name
const word & name() const
Return const reference to name.
Definition: dimensionedType.C:406
Foam::word::validate
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Definition: word.C:45
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::token
A token holds an item read from Istream.
Definition: token.H:68
Foam::surfZoneIdentifier::index
label index() const
The index of this patch/zone in the surface mesh.
Definition: surfZoneIdentifier.H:165
surfZoneIdentifier.H
Foam::surfZoneIdentifier
Identifies a surface patch/zone by name and index, with optional geometric type.
Definition: surfZoneIdentifier.H:59
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
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::surfZoneIdentifier::surfZoneIdentifier
surfZoneIdentifier()
Default construct. Uses name="", index=0.
Definition: surfZoneIdentifier.C:34
Foam::surfZoneIdentifier::geometricType
const word & geometricType() const
The geometric type of the patch/zone.
Definition: surfZoneIdentifier.H:153
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::token::SPACE
Space [isspace].
Definition: token.H:125
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::surfZoneIdentifier::name
const word & name() const
The patch/zone name.
Definition: surfZoneIdentifier.H:141
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