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
67 Foam::surfacePatch::surfacePatch(Istream& is, const label index)
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 :
94  geometricSurfacePatch(sp),
95  size_(sp.size()),
96  start_(sp.start())
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
102 void Foam::surfacePatch::write(Ostream& os) const
103 {
104  os << nl
105  << static_cast<const geometricSurfacePatch&>(*this) << endl
106  << size() << tab << start();
107 }
108 
109 void Foam::surfacePatch::writeDict(Ostream& os) const
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 
123 bool Foam::surfacePatch::operator!=(const surfacePatch& p) const
124 {
125  return !(*this == p);
126 }
127 
128 
129 bool Foam::surfacePatch::operator==(const surfacePatch& p) const
130 {
131  return
132  (
133  (geometricType() == p.geometricType())
134  && (size() == p.size())
135  && (start() == p.start())
136  );
137 }
138 
139 
140 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
141 
142 Foam::Ostream& Foam::operator<<(Ostream& os, const surfacePatch& p)
143 {
144  p.write(os);
145  os.check("Ostream& operator<<(Ostream& f, const surfacePatch& p");
146  return os;
147 }
148 
149 
150 // ************************************************************************* //
p
p
Definition: pEqn.H:62
Foam::geometricSurfacePatch::writeDict
void writeDict(Ostream &) const
Write dictionary.
Definition: geometricSurfacePatch.C:112
Foam::surfacePatch::size_
label size_
size of this patch in the triSurface face list
Definition: surfacePatch.H:58
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::surfacePatch::writeDict
void writeDict(Ostream &) const
Write dictionary.
Definition: surfacePatch.C:109
Foam::surfacePatch::write
void write(Ostream &) const
Write.
Definition: surfacePatch.C:102
Foam::label
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
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::surfacePatch
'Patch' on surface as subset of triSurface.
Definition: surfacePatch.H:51
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::surfacePatch::operator!=
bool operator!=(const surfacePatch &) const
Definition: surfacePatch.C:123
Foam::tab
static const char tab
Definition: Ostream.H:259
Foam::token::END_BLOCK
@ END_BLOCK
Definition: token.H:105
dictionary.H
surfacePatch.H
Foam::readLabel
label readLabel(Istream &is)
Definition: label.H:64
Foam::token::BEGIN_BLOCK
@ BEGIN_BLOCK
Definition: token.H:104
Foam::surfacePatch::start_
label start_
Start label of this patch in the triSurface face list.
Definition: surfacePatch.H:61
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
word.H
Foam::surfacePatch::surfacePatch
surfacePatch()
Construct null.
Definition: surfacePatch.C:41
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress
Foam::surfacePatch::operator==
bool operator==(const surfacePatch &) const
compare.
Definition: surfacePatch.C:129