surfacePatch.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 "surfacePatch.H"
27 #include "dictionary.H"
28 #include "word.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 defineTypeNameAndDebug(surfacePatch, 0);
35 }
36 
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 // Construct null
42 :
43  geometricSurfacePatch("", "", -1),
44  size_(0),
45  start_(0)
46 {}
47 
48 
49 
50 // Construct from components
52 (
53  const word& geometricType,
54  const word& name,
55  const label size,
56  const label start,
57  const label index
58 )
59 :
60  geometricSurfacePatch(geometricType, name, index),
61  size_(size),
62  start_(start)
63 {}
64 
65 
66 // Construct from Istream
68 :
69  geometricSurfacePatch(is, index),
70  size_(0),
71  start_(0)
72 {
73  size_ = readLabel(is);
74  start_ = readLabel(is);
75 }
76 
77 // Construct from dictionary
79 (
80  const word& name,
81  const dictionary& dict,
82  const label index
83 )
84 :
85  geometricSurfacePatch(name, dict, index),
86  size_(readLabel(dict.lookup("nFaces"))),
87  start_(readLabel(dict.lookup("startFace")))
88 {}
89 
90 
91 // Construct as copy
93 :
95  size_(sp.size()),
96  start_(sp.start())
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 {
104  os << nl
105  << static_cast<const geometricSurfacePatch&>(*this) << endl
106  << size() << tab << start();
107 }
108 
110 {
111  os << nl << name() << nl << token::BEGIN_BLOCK << nl;
112 
114 
115  os << " nFaces " << size() << ';' << nl
116  << " startFace " << start() << ';' << nl
117  << token::END_BLOCK << endl;
118 }
119 
120 
121 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
122 
124 {
125  return !(*this == p);
126 }
127 
128 
130 {
131  return
132  (
133  (geometricType() == p.geometricType())
134  && (size() == p.size())
135  && (start() == p.start())
136  );
137 }
138 
139 
140 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
141 
143 {
144  p.write(os);
145  os.check("Ostream& operator<<(Ostream& f, const surfacePatch& p");
146  return os;
147 }
148 
149 
150 // ************************************************************************* //
bool operator!=(const surfacePatch &) const
Definition: surfacePatch.C:123
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
const word & geometricType() const
Return the type of the patch.
static const char tab
Definition: Ostream.H:261
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
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
geometricSurfacePatch()
Construct null.
&#39;Patch&#39; on surface as subset of triSurface.
Definition: surfacePatch.H:58
A class for handling words, derived from string.
Definition: word.H:59
bool operator==(const surfacePatch &) const
compare.
Definition: surfacePatch.C:129
void writeDict(Ostream &) const
Write dictionary.
Definition: surfacePatch.C:109
surfacePatch()
Construct null.
Definition: surfacePatch.C:41
const word & name() const
Return name.
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 patch in the polyMesh face list.
Definition: surfacePatch.H:109
void writeDict(Ostream &) const
Write dictionary.
Ostream & operator<<(Ostream &, const ensightPart &)
The geometricSurfacePatch is like patchIdentifier but for surfaces. Holds type, name and index...
label size() const
Return size of this patch in the polyMesh face list.
Definition: surfacePatch.H:121
volScalarField & p
void write(Ostream &) const
Write.
Definition: surfacePatch.C:102
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451