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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2012 OpenFOAM Foundation
9  Copyright (C) 2018-2020 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 "surfZone.H"
30 #include "dictionary.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 :
37  size_(0),
38  start_(0)
39 {}
40 
41 
42 Foam::surfZone::surfZone(const word& name, const label size)
43 :
45  size_(size),
46  start_(0)
47 {}
48 
49 
51 (
52  const word& name,
53  const label size,
54  const label start,
55  const label index,
56  const word& geometricType
57 )
58 :
59  surfZoneIdentifier(name, index, geometricType),
60  size_(size),
61  start_(start)
62 {}
63 
64 
66 (
67  const word& name,
68  const dictionary& dict,
69  const label index
70 )
71 :
72  surfZoneIdentifier(name, dict, index),
73  size_(dict.get<label>("nFaces")),
74  start_(dict.get<label>("startFace"))
75 {}
76 
77 
78 Foam::surfZone::surfZone(const surfZone& zone, const label index)
79 :
80  surfZone(zone)
81 {
82  surfZoneIdentifier::index() = index;
83 }
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
88 void Foam::surfZone::write(Ostream& os) const
89 {
90  os.beginBlock(name());
91 
93  os.writeEntry("nFaces", size());
94  os.writeEntry("startFace", start());
95 
96  os.endBlock();
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
101 
102 bool Foam::operator==(const surfZone& a, const surfZone& b)
103 {
104  return
105  (
106  a.size() == b.size()
107  && a.start() == b.start()
108  && a.geometricType() == b.geometricType()
109  );
110 }
111 
112 
113 bool Foam::operator!=(const surfZone& a, const surfZone& b)
114 {
115  return !(a == b);
116 }
117 
118 
119 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
120 
121 Foam::Istream& Foam::operator>>(Istream& is, surfZone& obj)
122 {
123  const word name(is);
124  const dictionary dict(is);
125 
126  // Could also leave index untouched?
127  obj = surfZone(name, dict, 0);
128 
129  is.check(FUNCTION_NAME);
130  return is;
131 }
132 
133 
134 Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& obj)
135 {
136  obj.write(os);
137 
139  return os;
140 }
141 
142 
143 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dictionary dict
Identifies a surface patch/zone by name and index, with optional geometric type.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:45
const word & name() const
The patch/zone 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:52
label size() const
The size of this zone in the face list.
Definition: surfZone.H:162
surfZone()
Default construct, with zero start, size, index.
Definition: surfZone.C:27
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Base class for mesh zones.
Definition: zone.H:59
A class for handling words, derived from Foam::string.
Definition: word.H:63
Istream & operator>>(Istream &, directionInfo &)
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void write(Ostream &os) const
Write (geometricType) dictionary entry (without surrounding braces)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
label start() const
The start label of this zone in the face list.
Definition: surfZone.H:146
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:297
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
void write(Ostream &os) const
Write dictionary, includes surrounding braces.
Definition: surfZone.C:81