surfZone.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 | Copyright (C) 2011-2012 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_(readLabel(dict.lookup("nFaces"))),
85  start_(readLabel(dict.lookup("startFace")))
86 {}
87 
88 
90 :
91  surfZoneIdentifier(zone, zone.index()),
92  size_(zone.size()),
93  start_(zone.start())
94 {}
95 
96 
98 :
99  surfZoneIdentifier(zone, index),
100  size_(zone.size()),
101  start_(zone.start())
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
108 {
109  writeDict(os);
110 }
111 
112 
114 {
115  os << indent << name() << nl
117 
119  os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
120  os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
121 
122  os << decrIndent << indent << token::END_BLOCK << endl;
123 }
124 
125 
126 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
127 
128 bool Foam::surfZone::operator!=(const surfZone& rhs) const
129 {
130  return !(*this == rhs);
131 }
132 
133 
134 bool Foam::surfZone::operator==(const surfZone& rhs) const
135 {
136  return
137  (
138  size() == rhs.size()
139  && start() == rhs.start()
140  && geometricType() == rhs.geometricType()
141  );
142 }
143 
144 
145 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
146 
148 {
149  zone = surfZone(is, 0);
150 
151  is.check("Istream& operator>>(Istream&, surfZone&)");
152  return is;
153 }
154 
155 
157 {
158  zone.write(os);
159  os.check("Ostream& operator<<(Ostream&, const surfZone&");
160  return os;
161 }
162 
163 
164 // ************************************************************************* //
void write(Ostream &) const
Write.
Definition: surfZone.C:107
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:223
An identifier for a surface zone on a meshed surface.
const word & name() const
Return name.
const word & geometricType() const
Return the geometric type of the zone.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
surfZone()
Construct null.
Definition: surfZone.C:40
bool operator!=(const surfZone &) const
Definition: surfZone.C:128
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 &)
label readLabel(Istream &is)
Definition: label.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
defineTypeNameAndDebug(combustionModel, 0)
label start() const
Return start label of this zone in the face list.
Definition: surfZone.H:132
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:237
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
label size() const
Return size of this zone in the face list.
Definition: surfZone.H:144
Ostream & operator<<(Ostream &, const ensightPart &)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:230
void writeDict(Ostream &) const
Write dictionary.
Definition: surfZone.C:113
void write(Ostream &) const
Write surfZoneIdentifier as a dictionary.
Namespace for OpenFOAM.
bool operator==(const surfZone &) const
compare.
Definition: surfZone.C:134
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451