labelledScalar.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  labelledScalar
26 
27 Description
28  A class containing point label and its coordinates. It is used for
29  exchanging data over processors
30 
31 SourceFiles
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef labelledScalar_H
36 #define labelledScalar_H
37 
38 #include "label.H"
39 #include "scalar.H"
40 #include "contiguous.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class labelledScalar Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 class labelledScalar
52 {
53  // Private data
54  //- label
55  label sLabel_;
56 
57  //- value
58  scalar value_;
59 
60  public:
61 
62  // Constructors
63  //- Null construct
65  :
66  sLabel_(-1),
67  value_(0.0)
68  {}
69 
70  //- Construct from label and value
71  labelledScalar(const label sl, const scalar s)
72  :
73  sLabel_(sl),
74  value_(s)
75  {}
76 
77  // Destructor
79  {}
80 
81  // Member functions
82  //- return scalar label
83  inline label scalarLabel() const
84  {
85  return sLabel_;
86  }
87 
88  //- return the value
89  inline const scalar& value() const
90  {
91  return value_;
92  }
93 
94  // Member operators
95 
96  inline void operator=(const labelledScalar& ls)
97  {
98  sLabel_ = ls.sLabel_;
99  value_ = ls.value_;
100  }
101 
102  inline bool operator==(const labelledScalar& ls) const
103  {
104  if( sLabel_ == ls.sLabel_ )
105  return true;
106 
107  return false;
108  }
109 
110  inline bool operator<(const labelledScalar& ls) const
111  {
112  if( value_ < ls.value_ )
113  return true;
114 
115  return false;
116  }
117 
118  inline bool operator<=(const labelledScalar& ls) const
119  {
120  if( value_ <= ls.value_ )
121  return true;
122 
123  return false;
124  }
125 
126  inline bool operator>(const labelledScalar& ls) const
127  {
128  if( value_ > ls.value_ )
129  return true;
130 
131  return false;
132  }
133 
134  inline bool operator>=(const labelledScalar& ls) const
135  {
136  if( value_ >= ls.value_ )
137  return true;
138 
139  return false;
140  }
141 
142  inline bool operator!=(const labelledScalar& ls) const
143  {
144  return !this->operator==(ls);
145  }
146 
147  // Friend operators
148  friend Ostream& operator<<(Ostream& os, const labelledScalar& ls)
149  {
150  os << token::BEGIN_LIST;
151  os << ls.sLabel_ << token::SPACE;
152  os << ls.value_ << token::END_LIST;
153 
154  // Check state of Ostream
155  os.check("operator<<(Ostream&, const labelledScalar&");
156 
157  return os;
158  }
159 
160  friend Istream& operator>>(Istream& is, labelledScalar& ls)
161  {
162  // Read beginning of labelledScalar
163  is.readBegin("labelledScalar");
164 
165  is >> ls.sLabel_;
166  is >> ls.value_;
167 
168  // Read end of labelledScalar
169  is.readEnd("labelledScalar");
170 
171  // Check state of Istream
172  is.check("operator>>(Istream&, labelledScalar");
173 
174  return is;
175  }
176 };
177 
178 //- Specify data associated with labelledScalar type is contiguous
179 template<>
180 inline bool contiguous<labelledScalar>() {return true;}
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 } // End namespace Foam
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 #endif
189 
190 // ************************************************************************* //
Foam::labelledScalar::labelledScalar
labelledScalar()
Null construct.
Definition: labelledScalar.H:63
Foam::Istream::readEnd
Istream & readEnd(const char *funcName)
Definition: Istream.C:105
Foam::labelledScalar::operator=
void operator=(const labelledScalar &ls)
Definition: labelledScalar.H:95
Foam::contiguous< labelledScalar >
bool contiguous< labelledScalar >()
Specify data associated with labelledScalar type is contiguous.
Definition: labelledScalar.H:179
Foam::labelledScalar::operator>>
friend Istream & operator>>(Istream &is, labelledScalar &ls)
Definition: labelledScalar.H:159
Foam::labelledScalar::operator<=
bool operator<=(const labelledScalar &ls) const
Definition: labelledScalar.H:117
Foam::labelledScalar::scalarLabel
label scalarLabel() const
return scalar label
Definition: labelledScalar.H:82
Foam::labelledScalar::value
const scalar & value() const
return the value
Definition: labelledScalar.H:88
Foam::labelledScalar::operator!=
bool operator!=(const labelledScalar &ls) const
Definition: labelledScalar.H:141
Foam::labelledScalar::labelledScalar
labelledScalar(const label sl, const scalar s)
Construct from label and value.
Definition: labelledScalar.H:70
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::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::labelledScalar::operator<
bool operator<(const labelledScalar &ls) const
Definition: labelledScalar.H:109
Foam::labelledScalar::operator>
bool operator>(const labelledScalar &ls) const
Definition: labelledScalar.H:125
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
scalar.H
Foam::labelledScalar::sLabel_
label sLabel_
label
Definition: labelledScalar.H:54
Foam::labelledScalar::operator>=
bool operator>=(const labelledScalar &ls) const
Definition: labelledScalar.H:133
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
s
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::labelledScalar
Definition: labelledScalar.H:50
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
label.H
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::labelledScalar::operator==
bool operator==(const labelledScalar &ls) const
Definition: labelledScalar.H:101
Foam::labelledScalar::~labelledScalar
~labelledScalar()
Definition: labelledScalar.H:77
Foam::labelledScalar::operator<<
friend Ostream & operator<<(Ostream &os, const labelledScalar &ls)
Definition: labelledScalar.H:147
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Istream::readBegin
Istream & readBegin(const char *funcName)
Definition: Istream.C:88
Foam::labelledScalar::value_
scalar value_
value
Definition: labelledScalar.H:57
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
Foam::token::SPACE
@ SPACE
Definition: token.H:95