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-2025 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>
52 inline Foam::RemoteData<Type>::RemoteData(const label e, const Type& d)
53 :
54  remote(e),
55  data(d)
56 {}
57 
58 
59 template<class Type>
61 {
62  is >> *this;
63 }
64 
65 
66 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
67 
68 template<class Type>
70 (
71  const RemoteData<Type>& a,
72  const RemoteData<Type>& b
73 ) const
74 {
75  if (b.proci != -1 && (a.proci == -1 || a.proci < b.proci))
76  {
77  return b;
78  }
79  else
80  {
81  return a;
82  }
83 }
84 
85 
86 template<class Type>
88 (
90  const RemoteData<Type>& b
91 ) const
92 {
93  if (b.proci != -1 && (a.proci == -1 || a.proci < b.proci))
94  {
95  a = b;
96  }
97 }
98 
99 
100 template<class Type>
102 (
103  RemoteData<Type>& a,
104  const RemoteData<Type>& b
105 ) const
106 {
107  if (b.proci != -1 && (a.proci == -1 || b.data < a.data))
108  {
109  a = b;
110  }
111 }
112 
113 
114 template<class Type>
116 (
117  RemoteData<Type>& a,
118  const RemoteData<Type>& b
119 ) const
120 {
121  if (b.proci != -1 && (a.proci == -1 || b.data > a.data))
122  {
123  a = b;
124  }
125 }
126 
127 
128 template<class Type>
130 (
131  RemoteData<Type>& a,
132  const RemoteData<Type>& b
133 ) const
134 {
135  if (b.proci != -1 && (a.proci == -1 || b.data.first() < a.data.first()))
136  {
137  a = b;
138  }
139 }
140 
141 
142 template<class Type>
144 (
145  RemoteData<Type>& a,
146  const RemoteData<Type>& b
147 ) const
148 {
149  if (b.proci != -1 && (a.proci == -1 || b.data.first() > a.data.first()))
150  {
151  a = b;
152  }
153 }
154 
155 
156 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
157 
158 template<class Type>
159 inline bool Foam::operator==
160 (
161  const RemoteData<Type>& a,
162  const RemoteData<Type>& b
163 )
164 {
165  return
166  static_cast<const remote&>(a) == static_cast<const remote&>(b)
167  && a.data == b.data;
168 }
169 
170 
171 template<class Type>
172 inline bool Foam::operator!=
173 (
174  const RemoteData<Type>& a,
175  const RemoteData<Type>& b
176 )
177 {
178  return !(a == b);
179 }
180 
181 
182 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
183 
184 template<class Type>
185 inline Foam::Ostream& Foam::operator<<(Ostream& os, const RemoteData<Type>& p)
186 {
187  return os << static_cast<const remote&>(p) << token::SPACE << p.data;
188 }
189 
190 
191 template<class Type>
192 inline Foam::Istream& Foam::operator>>(Istream& is, RemoteData<Type>& p)
193 {
194  return is >> static_cast<remote&>(p) >> p.data;
195 }
196 
197 
198 // ************************************************************************* //
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:75
Struct for keeping processor, element (cell, face, point) index.
Definition: remote.H:57
label proci
Processor index.
Definition: remote.H:67
volScalarField & b
Definition: createFields.H:27
const doubleScalar e
Definition: doubleScalar.H:106
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 &, pistonPointEdgeData &)
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
volScalarField & p