surfacePatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 {
35 }
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 :
41  geometricSurfacePatch("", "", -1),
42  size_(0),
43  start_(0)
44 {}
45 
46 
48 (
49  const word& geometricType,
50  const word& name,
51  const label size,
52  const label start,
53  const label index
54 )
55 :
56  geometricSurfacePatch(geometricType, name, index),
57  size_(size),
58  start_(start)
59 {}
60 
61 
63 :
64  geometricSurfacePatch(is, index),
65  size_(0),
66  start_(0)
67 {
68  size_ = readLabel(is);
69  start_ = readLabel(is);
70 }
71 
72 
74 (
75  const word& name,
76  const dictionary& dict,
77  const label index
78 )
79 :
81  size_(dict.lookup<label>("nFaces")),
82  start_(dict.lookup<label>("startFace"))
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  os << nl
91  << static_cast<const geometricSurfacePatch&>(*this) << endl
92  << size() << tab << start();
93 }
94 
96 {
97  os << nl << name() << nl << token::BEGIN_BLOCK << nl;
98 
100 
101  os << " nFaces " << size() << ';' << nl
102  << " startFace " << start() << ';' << nl
103  << token::END_BLOCK << endl;
104 }
105 
106 
107 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
108 
110 {
111  return !(*this == p);
112 }
113 
114 
116 {
117  return
118  (
119  (geometricType() == p.geometricType())
120  && (size() == p.size())
121  && (start() == p.start())
122  );
123 }
124 
125 
126 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
127 
129 {
130  p.write(os);
131  os.check("Ostream& operator<<(Ostream& f, const surfacePatch& p");
132  return os;
133 }
134 
135 
136 // ************************************************************************* //
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
The geometricSurfacePatch is like patchIdentifier but for surfaces. Holds type, name and index.
void writeDict(Ostream &) const
Write dictionary.
virtual bool write(const bool write=true) const
Write using setting from DB.
'Patch' on surface as subset of triSurface.
Definition: surfacePatch.H:61
void write(Ostream &) const
Write.
Definition: surfacePatch.C:88
surfacePatch()
Construct null.
Definition: surfacePatch.C:39
void writeDict(Ostream &) const
Write dictionary.
Definition: surfacePatch.C:95
bool operator==(const surfacePatch &) const
compare.
Definition: surfacePatch.C:115
bool operator!=(const surfacePatch &) const
Definition: surfacePatch.C:109
@ BEGIN_BLOCK
Definition: token.H:113
@ END_BLOCK
Definition: token.H:114
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
static const char tab
Definition: Ostream.H:265
defineTypeNameAndDebug(combustionModel, 0)
label readLabel(Istream &is)
Definition: label.H:64
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
static const char nl
Definition: Ostream.H:266
dictionary dict
volScalarField & p