RemoteDataI.H
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) 2022 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 "RemoteData.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 :
33  remote(),
34  data()
35 {}
36 
37 
38 template<class Type>
40 (
41  const label p,
42  const label e,
43  const Type& d
44 )
45 :
46  remote(p, e),
47  data(d)
48 {}
49 
50 
51 template<class Type>
53 {
54  is >> *this;
55 }
56 
57 
58 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
59 
60 template<class Type>
62 (
64  const RemoteData<Type>& y
65 ) const
66 {
67  if (y.proci != -1)
68  {
69  if (x.proci == -1)
70  {
71  x = y;
72  }
73  else if (y.data < x.data)
74  {
75  x = y;
76  }
77  }
78 }
79 
80 
81 template<class Type>
83 (
85  const RemoteData<Type>& y
86 ) const
87 {
88  if (y.proci != -1)
89  {
90  if (x.proci == -1)
91  {
92  x = y;
93  }
94  else if (y.data.first() < x.data.first())
95  {
96  x = y;
97  }
98  }
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
103 
104 template<class Type>
105 inline bool Foam::operator==
106 (
107  const RemoteData<Type>& a,
108  const RemoteData<Type>& b
109 )
110 {
111  return
112  static_cast<const remote&>(a) == static_cast<const remote&>(b)
113  && a.data == b.data;
114 }
115 
116 
117 template<class Type>
118 inline bool Foam::operator!=
119 (
120  const RemoteData<Type>& a,
121  const RemoteData<Type>& b
122 )
123 {
124  return !(a == b);
125 }
126 
127 
128 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
129 
130 template<class Type>
131 inline Foam::Ostream& Foam::operator<<(Ostream& os, const RemoteData<Type>& p)
132 {
133  return os << static_cast<const remote&>(p) << token::SPACE << p.data;
134 }
135 
136 
137 template<class Type>
138 inline Foam::Istream& Foam::operator>>(Istream& is, RemoteData<Type>& p)
139 {
140  return is >> static_cast<remote&>(p) >> p.data;
141 }
142 
143 
144 // ************************************************************************* //
scalar y
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Struct for keeping processor, element (cell, face, point) and a piece of data. Used for finding minim...
Definition: RemoteData.H:65
RemoteData()
Construct null.
Definition: RemoteDataI.H:31
Type data
Data.
Definition: RemoteData.H:71
T * data()
Return a pointer to the first data element,.
Definition: UListI.H:149
Database for solution and other reduced data.
Definition: data.H:54
Struct for keeping processor, element (cell, face, point) index.
Definition: remote.H:57
volScalarField & b
Definition: createFields.H:27
const doubleScalar e
Definition: doubleScalar.H:105
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
Istream & operator>>(Istream &, directionInfo &)
Ostream & operator<<(Ostream &, const ensightPart &)
volScalarField & p