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-2024 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>& b
65 ) const
66 {
67  if (b.proci != -1 && (a.proci == -1 || b.data < a.data))
68  {
69  a = b;
70  }
71 }
72 
73 
74 template<class Type>
76 (
78  const RemoteData<Type>& b
79 ) const
80 {
81  if (b.proci != -1 && (a.proci == -1 || b.data.first() < a.data.first()))
82  {
83  a = b;
84  }
85 }
86 
87 
88 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
89 
90 template<class Type>
91 inline bool Foam::operator==
92 (
93  const RemoteData<Type>& a,
94  const RemoteData<Type>& b
95 )
96 {
97  return
98  static_cast<const remote&>(a) == static_cast<const remote&>(b)
99  && a.data == b.data;
100 }
101 
102 
103 template<class Type>
104 inline bool Foam::operator!=
105 (
106  const RemoteData<Type>& a,
107  const RemoteData<Type>& b
108 )
109 {
110  return !(a == b);
111 }
112 
113 
114 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
115 
116 template<class Type>
117 inline Foam::Ostream& Foam::operator<<(Ostream& os, const RemoteData<Type>& p)
118 {
119  return os << static_cast<const remote&>(p) << token::SPACE << p.data;
120 }
121 
122 
123 template<class Type>
124 inline Foam::Istream& Foam::operator>>(Istream& is, RemoteData<Type>& p)
125 {
126  return is >> static_cast<remote&>(p) >> p.data;
127 }
128 
129 
130 // ************************************************************************* //
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
T * data()
Return a pointer to the first data element,.
Definition: UListI.H:149
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:25
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