FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "surfZone.H"
29 #include <OpenFOAM/dictionary.H>
30 #include <OpenFOAM/word.H>
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
35 
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 :
42  size_(0),
43  start_(0)
44 {}
45 
46 
48 (
49  const word& name,
50  const label size,
51  const label start,
52  const label index,
53  const word& geometricType
54 )
55 :
56  surfZoneIdentifier(name, index, geometricType),
57  size_(size),
58  start_(start)
59 {}
60 
61 
62 Foam::surfZone::surfZone(Istream& is, const label index)
63 :
65  size_(0),
66  start_(0)
67 {
68  word name(is);
69  dictionary dict(is);
70 
71  operator=(surfZone(name, dict, index));
72 }
73 
74 
76 (
77  const word& name,
78  const dictionary& dict,
79  const label index
80 )
81 :
82  surfZoneIdentifier(name, dict, index),
83  size_(readLabel(dict.lookup("nFaces"))),
84  start_(readLabel(dict.lookup("startFace")))
85 {}
86 
87 
89 :
90  surfZoneIdentifier(zone, zone.index()),
91  size_(zone.size()),
92  start_(zone.start())
93 {}
94 
95 
96 Foam::surfZone::surfZone(const surfZone& zone, const label index)
97 :
98  surfZoneIdentifier(zone, index),
99  size_(zone.size()),
100  start_(zone.start())
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
107 {
108  writeDict(os);
109 }
110 
111 
113 {
114  os << indent << name() << nl
116 
118  os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl;
119  os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl;
120 
121  os << decrIndent << indent << token::END_BLOCK << endl;
122 }
123 
124 
125 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
126 
127 bool Foam::surfZone::operator!=(const surfZone& rhs) const
128 {
129  return !(*this == rhs);
130 }
131 
132 
133 bool Foam::surfZone::operator==(const surfZone& rhs) const
134 {
135  return
136  (
137  size() == rhs.size()
138  && start() == rhs.start()
139  && geometricType() == rhs.geometricType()
140  );
141 }
142 
143 
144 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
145 
147 {
148  zone = surfZone(is, 0);
149 
150  is.check("Istream& operator>>(Istream&, surfZone&)");
151  return is;
152 }
153 
154 
156 {
157  zone.write(os);
158  os.check("Ostream& operator<<(Ostream&, const surfZone&");
159  return os;
160 }
161 
162 
163 // ************************ vim: set sw=4 sts=4 et: ************************ //