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 // ************************************************************************* //
Foam::surfZoneIdentifier::write
void write(Ostream &os) const
Definition: surfZoneIdentifier.C:95
Foam::surfZone::start
label start() const
Definition: surfZone.H:124
Foam::surfZone::surfZone
surfZone()
Definition: surfZone.C:27
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::zone
Base class for mesh zones.
Definition: zone.H:59
Foam::surfZone::write
void write(Ostream &os) const
Definition: surfZone.C:81
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:223
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Definition: Ostream.C:84
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:100
Foam::surfZoneIdentifier::index
label index() const
Definition: surfZoneIdentifier.H:161
Foam::surfZoneIdentifier
Identifies a surface patch/zone by name and index, with optional geometric type.
Definition: surfZoneIdentifier.H:55
Foam::operator!=
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:235
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Definition: boundaryPatch.C:76
Foam::constant::physicoChemical::b
const dimensionedScalar b
Definition: createFields.H:27
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
surfZone.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Definition: Ostream.C:102
Foam::IOstream::check
virtual bool check(const char *operation) const
Definition: IOstream.C:51
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
Foam::surfZone::size
label size() const
Definition: surfZone.H:136
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Ostream::write
virtual bool write(const token &tok)=0
Foam::surfZoneIdentifier::geometricType
const word & geometricType() const
Definition: surfZoneIdentifier.H:149
Foam::surfZone
A surface zone on a MeshedSurface.
Definition: surfZone.H:52
dictionary.H
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:302
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::surfZoneIdentifier::name
const word & name() const
Definition: surfZoneIdentifier.H:137
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52