Forward compatibility: flex
[foam-extend-3.2.git] / src / mesh / cfMesh / utilities / helperClasses / parallelHelpers / labelledPointScalar / labelledPointScalar.H
blob857018db738a9386961eda3045df88fdaa47b308
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.
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.
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.
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/>.
24 Class
25     labelledPointScalar
27 Description
28     A class containing a label, coordinates and scalar. It is used for
29     exchanging data over processors
31 SourceFiles
33 \*---------------------------------------------------------------------------*/
35 #ifndef labelledPointScalar_H
36 #define labelledPointScalar_H
38 #include "label.H"
39 #include "point.H"
40 #include "contiguous.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 /*---------------------------------------------------------------------------*\
48                     Class labelledPointScalar Declaration
49 \*---------------------------------------------------------------------------*/
51 class labelledPointScalar
53     // Private data
54         //- point label
55         label pLabel_;
57         //- point coordinates
58         point coords_;
60         //- scalar data
61         scalar weight_;
63     public:
65     // Constructors
66         //- Null construct
67         labelledPointScalar()
68         :
69             pLabel_(-1),
70             coords_(vector::zero),
71             weight_(0.0)
72         {}
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         {}
82     // Destructor
83         ~labelledPointScalar()
84         {}
86     // Member functions
87         //- return point label
88         inline label pointLabel() const
89         {
90             return pLabel_;
91         }
93         inline label& pointLabel()
94         {
95             return pLabel_;
96         }
98         //- return point coordinates
99         inline const point& coordinates() const
100         {
101             return coords_;
102         }
104         inline point& coordinates()
105         {
106             return coords_;
107         }
109         //- return scalar value
110         inline const scalar& scalarValue() const
111         {
112             return weight_;
113         }
115         inline scalar& scalarValue()
116         {
117             return weight_;
118         }
120     // Member operators
122         inline void operator=(const labelledPointScalar& lps)
123         {
124             pLabel_ = lps.pLabel_;
125             coords_ = lps.coords_;
126             weight_ = lps.weight_;
127         }
129         inline bool operator==(const labelledPointScalar& lps) const
130         {
131             if( pLabel_ == lps.pLabel_ )
132                 return true;
134             return false;
135         }
137         inline bool operator!=(const labelledPointScalar& lps) const
138         {
139             return !this->operator==(lps);
140         }
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;
150             // Check state of Ostream
151             os.check("operator<<(Ostream&, const labelledPointScalarS&");
153             return os;
154         }
156         friend Istream& operator>>(Istream& is, labelledPointScalar& lps)
157         {
158             // Read beginning of labelledPointScalar
159             is.readBegin("labelledPointScalar");
161             is >> lps.pLabel_;
162             is >> lps.coords_;
163             is >> lps.weight_;
165             // Read end of labelledPointScalar
166             is.readEnd("labelledPointScalar");
168             // Check state of Istream
169             is.check("operator>>(Istream&, labelledPointScalar");
171             return is;
172         }
175 //- Specify data associated with labelledPointScalar type is contiguous
176 template<>
177 inline bool contiguous<labelledPointScalar>() {return true;}
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 } // End namespace Foam
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 #endif
187 // ************************************************************************* //