Loading...
Searching...
No Matches
geometricSurfacePatch.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) 2017-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
30#include "dictionary.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
35:
36 name_("patch"),
37 index_(0)
38{}
39
40
50 const word& name,
51 const label index
53:
54 name_(name),
55 index_(index)
56{}
57
58
60(
61 const word& name,
62 const label index,
63 const word& geometricType
64)
66 name_(name),
67 index_(index),
68 geometricType_(geometricType)
69{}
70
71
73(
74 const word& name,
75 const dictionary& dict,
76 const label index
77)
80{
81 dict.readIfPresent("geometricType", geometricType_);
82}
83
84
86(
87 const surfZoneIdentifier& ident
88)
90 geometricSurfacePatch(ident.name(), ident.index(), ident.geometricType())
91{}
92
93
94// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95
97{
98 if (!geometricType_.empty())
99 {
100 os.writeEntry("geometricType", geometricType_);
101 }
102}
103
104
105// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
106
107bool Foam::operator==
108(
109 const geometricSurfacePatch& a,
111)
112{
113 return
115 (a.name() == b.name())
116 && (a.geometricType() == b.geometricType())
117 );
118}
119
120
121bool Foam::operator!=
122(
123 const geometricSurfacePatch& a,
124 const geometricSurfacePatch& b
125)
127 return !(a == b);
128}
129
130
131// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
132
133Foam::Istream& Foam::operator>>(Istream& is, geometricSurfacePatch& obj)
134{
135 // Also read "" for empty words
136 obj.name() = word::validate(token(is).stringToken());
137 obj.geometricType() = word::validate(token(is).stringToken());
138
139 return is;
140}
141
142
143Foam::Ostream& Foam::operator<<(Ostream& os, const geometricSurfacePatch& obj)
144{
145 // Force unconditional line-breaks on list output.
146 // We otherwise risk extremely unreadable entries
147 os << nl;
148
149 // Empty words are double-quoted so they are treated as 'string'
150 // and not simply lost
151
152 os.writeQuoted(obj.name(), obj.name().empty()) << token::SPACE;
153 os.writeQuoted(obj.geometricType(), obj.geometricType().empty());
154
155 // Equivalent for OpenFOAM-1912 and earlier:
156 // if (obj.geometricType().empty())
157 // {
158 // os << emptyType;
159 // }
160 // else
161 // {
162 // os << obj.geometricType();
163 // }
164
165 os.check(FUNCTION_NAME);
166 return os;
167}
168
169
170// ************************************************************************* //
virtual const fileName & name() const
The name of the stream.
Definition IOstream.C:33
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Identifies a surface patch/zone by name and index, with geometric type.
geometricSurfacePatch()
Default construct. Uses name="patch", index=0, type="".
const word & geometricType() const noexcept
The geometric type of the patch/zone.
void write(Ostream &os) const
Write (geometricType) dictionary entry (without surrounding braces).
label index() const noexcept
The index of this patch/zone in the surface mesh.
const word & name() const noexcept
The patch/zone name.
geometricSurfacePatch(const geometricSurfacePatch &)=default
Copy construct.
Identifies a surface patch/zone by name and index, with optional geometric type.
A token holds an item read from Istream.
Definition token.H:70
@ SPACE
Space [isspace].
Definition token.H:144
A class for handling words, derived from Foam::string.
Definition word.H:66
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
Definition word.C:39
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
volScalarField & b