surfZone.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "surfZone.H"
27 #include "dictionary.H"
28 #include "word.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 defineTypeNameAndDebug(surfZone, 0);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
43  size_(0),
44  start_(0)
45 {}
46 
47 
49 (
50  const word& name,
51  const label size,
52  const label start,
53  const label index,
54  const word& geometricType
55 )
56 :
57  surfZoneIdentifier(name, index, geometricType),
58  size_(size),
59  start_(start)
60 {}
61 
62 
64 :
66  size_(0),
67  start_(0)
68 {
69  word name(is);
70  dictionary dict(is);
71 
72  operator=(surfZone(name, dict, index));
73 }
74 
75 
77 (
78  const word& name,
79  const dictionary& dict,
80  const label index
81 )
82 :
83  surfZoneIdentifier(name, dict, index),
84  size_(dict.lookup<label>("nFaces")),
85  start_(dict.lookup<label>("startFace"))
86 {}
87 
88 
90 :
91  surfZoneIdentifier(zone, index),
92  size_(zone.size()),
93  start_(zone.start())
94 {}
95 
96 
97 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
98 
100 {
101  writeDict(os);
102 }
103 
104 
106 {
107  os << indent << name() << nl
109 
111  writeEntry(os, "nFaces", size());
112  writeEntry(os, "startFace", start());
113 
114  os << decrIndent << indent << token::END_BLOCK << endl;
115 }
116 
117 
118 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
119 
120 bool Foam::surfZone::operator!=(const surfZone& rhs) const
121 {
122  return !(*this == rhs);
123 }
124 
125 
126 bool Foam::surfZone::operator==(const surfZone& rhs) const
127 {
128  return
129  (
130  size() == rhs.size()
131  && start() == rhs.start()
132  && geometricType() == rhs.geometricType()
133  );
134 }
135 
136 
137 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
138 
140 {
141  zone = surfZone(is, 0);
142 
143  is.check("Istream& operator>>(Istream&, surfZone&)");
144  return is;
145 }
146 
147 
149 {
150  zone.write(os);
151  os.check("Ostream& operator<<(Ostream&, const surfZone&");
152  return os;
153 }
154 
155 
156 // ************************************************************************* //
bool operator==(const surfZone &) const
compare.
Definition: surfZone.C:126
dictionary dict
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:59
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
An identifier for a surface zone on a meshed surface.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
const word & name() const
Return name.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A surface zone on a MeshedSurface.
Definition: surfZone.H:62
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const word & geometricType() const
Return the geometric type of the zone.
label size() const
Return size of this zone in the face list.
Definition: surfZone.H:141
surfZone()
Construct null.
Definition: surfZone.C:40
void writeDict(Ostream &) const
Write dictionary.
Definition: surfZone.C:105
surfZoneIdentifier()
Construct null.
Base class for zones.
Definition: zone.H:57
A class for handling words, derived from string.
Definition: word.H:59
Istream & operator>>(Istream &, directionInfo &)
void write(Ostream &) const
Write surfZoneIdentifier as a dictionary.
bool operator!=(const surfZone &) const
Definition: surfZone.C:120
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
defineTypeNameAndDebug(combustionModel, 0)
void write(Ostream &) const
Write.
Definition: surfZone.C:99
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
label start() const
Return start label of this zone in the face list.
Definition: surfZone.H:129
Ostream & operator<<(Ostream &, const ensightPart &)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844