labelledPointScalar.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  labelledPointScalar
26 
27 Description
28  A class containing a label, coordinates and scalar. It is used for
29  exchanging data over processors
30 
31 SourceFiles
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef labelledPointScalar_H
36 #define labelledPointScalar_H
37 
38 #include "label.H"
39 #include "point.H"
40 #include "contiguous.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class labelledPointScalar Declaration
49 \*---------------------------------------------------------------------------*/
50 
52 {
53  // Private data
54  //- point label
55  label pLabel_;
56 
57  //- point coordinates
58  point coords_;
59 
60  //- scalar data
61  scalar weight_;
62 
63  public:
64 
65  // Constructors
66  //- Null construct
68  :
69  pLabel_(-1),
71  weight_(0.0)
72  {}
73 
74  //- Construct from point and label
75  labelledPointScalar(const label pl, const point& p, const scalar s)
76  :
77  pLabel_(pl),
78  coords_(p),
79  weight_(s)
80  {}
81 
82  // Destructor
84  {}
85 
86  // Member functions
87  //- return point label
88  inline label pointLabel() const
89  {
90  return pLabel_;
91  }
92 
93  inline label& pointLabel()
94  {
95  return pLabel_;
96  }
97 
98  //- return point coordinates
99  inline const point& coordinates() const
100  {
101  return coords_;
102  }
103 
104  inline point& coordinates()
105  {
106  return coords_;
107  }
108 
109  //- return scalar value
110  inline const scalar& scalarValue() const
111  {
112  return weight_;
113  }
114 
115  inline scalar& scalarValue()
116  {
117  return weight_;
118  }
119 
120  // Member operators
121 
122  inline void operator=(const labelledPointScalar& lps)
123  {
124  pLabel_ = lps.pLabel_;
125  coords_ = lps.coords_;
126  weight_ = lps.weight_;
127  }
128 
129  inline bool operator==(const labelledPointScalar& lps) const
130  {
131  if( pLabel_ == lps.pLabel_ )
132  return true;
133 
134  return false;
135  }
136 
137  inline bool operator!=(const labelledPointScalar& lps) const
138  {
139  return !this->operator==(lps);
140  }
141 
142  // Friend operators
143  friend Ostream& operator<<(Ostream& os, const labelledPointScalar& lps)
144  {
145  os << token::BEGIN_LIST;
146  os << lps.pLabel_ << token::SPACE;
147  os << lps.coords_ << token::SPACE;
148  os << lps.weight_ << token::END_LIST;
149 
150  // Check state of Ostream
151  os.check("operator<<(Ostream&, const labelledPointScalarS&");
152 
153  return os;
154  }
155 
156  friend Istream& operator>>(Istream& is, labelledPointScalar& lps)
157  {
158  // Read beginning of labelledPointScalar
159  is.readBegin("labelledPointScalar");
160 
161  is >> lps.pLabel_;
162  is >> lps.coords_;
163  is >> lps.weight_;
164 
165  // Read end of labelledPointScalar
166  is.readEnd("labelledPointScalar");
167 
168  // Check state of Istream
169  is.check("operator>>(Istream&, labelledPointScalar");
170 
171  return is;
172  }
173 };
174 
175 //- Specify data associated with labelledPointScalar type is contiguous
176 template<>
177 inline bool contiguous<labelledPointScalar>() {return true;}
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
Foam::Istream::readEnd
Istream & readEnd(const char *funcName)
Definition: Istream.C:105
Foam::labelledPointScalar::scalarValue
const scalar & scalarValue() const
return scalar value
Definition: labelledPointScalar.H:109
Foam::labelledPointScalar::labelledPointScalar
labelledPointScalar()
Null construct.
Definition: labelledPointScalar.H:66
p
p
Definition: pEqn.H:62
Foam::labelledPointScalar::weight_
scalar weight_
scalar data
Definition: labelledPointScalar.H:60
point.H
Foam::labelledPointScalar::coordinates
const point & coordinates() const
return point coordinates
Definition: labelledPointScalar.H:98
Foam::labelledPointScalar::operator==
bool operator==(const labelledPointScalar &lps) const
Definition: labelledPointScalar.H:128
Foam::labelledPointScalar::coordinates
point & coordinates()
Definition: labelledPointScalar.H:103
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::labelledPointScalar::pLabel_
label pLabel_
point label
Definition: labelledPointScalar.H:54
Foam::labelledPointScalar::~labelledPointScalar
~labelledPointScalar()
Definition: labelledPointScalar.H:82
Foam::labelledPointScalar
Definition: labelledPointScalar.H:50
Foam::labelledPointScalar::scalarValue
scalar & scalarValue()
Definition: labelledPointScalar.H:114
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
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::labelledPointScalar::operator<<
friend Ostream & operator<<(Ostream &os, const labelledPointScalar &lps)
Definition: labelledPointScalar.H:142
Foam::labelledPointScalar::labelledPointScalar
labelledPointScalar(const label pl, const point &p, const scalar s)
Construct from point and label.
Definition: labelledPointScalar.H:74
Foam::labelledPointScalar::operator!=
bool operator!=(const labelledPointScalar &lps) const
Definition: labelledPointScalar.H:136
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
Foam::Vector< scalar >
label.H
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::labelledPointScalar::pointLabel
label pointLabel() const
return point label
Definition: labelledPointScalar.H:87
Foam::labelledPointScalar::operator>>
friend Istream & operator>>(Istream &is, labelledPointScalar &lps)
Definition: labelledPointScalar.H:155
Foam::labelledPointScalar::coords_
point coords_
point coordinates
Definition: labelledPointScalar.H:57
Foam::labelledPointScalar::operator=
void operator=(const labelledPointScalar &lps)
Definition: labelledPointScalar.H:121
Foam::contiguous< labelledPointScalar >
bool contiguous< labelledPointScalar >()
Specify data associated with labelledPointScalar type is contiguous.
Definition: labelledPointScalar.H:176
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::labelledPointScalar::pointLabel
label & pointLabel()
Definition: labelledPointScalar.H:92
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
Foam::token::SPACE
@ SPACE
Definition: token.H:95
Foam::zero
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:47