remoteI.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 "remote.H"
27 #include "Pstream.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  proci(-1),
34  elementi(-1)
35 {}
36 
37 
38 inline Foam::remote::remote(const label p, const label e)
39 :
40  proci(p),
41  elementi(e)
42 {}
43 
44 
46 :
47  proci(Pstream::myProcNo()),
48  elementi(e)
49 {}
50 
51 
53 {
54  is >> *this;
55 }
56 
57 
58 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
59 
60 inline Foam::remote Foam::remote::firstProcOp::operator()
61 (
62  const remote& a,
63  const remote& b
64 ) const
65 {
66  if (b.proci != -1 && (a.proci == -1 || a.proci < b.proci))
67  {
68  return b;
69  }
70  else
71  {
72  return a;
73  }
74 }
75 
76 
77 inline void Foam::remote::firstProcEqOp::operator()
78 (
79  remote& a,
80  const remote& b
81 ) const
82 {
83  if (b.proci != -1 && (a.proci == -1 || a.proci < b.proci))
84  {
85  a = b;
86  }
87 }
88 
89 
90 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
91 
92 inline bool Foam::operator==(const remote& a, const remote& b)
93 {
94  return a.proci == b.proci && a.elementi == b.elementi;
95 }
96 
97 
98 inline bool Foam::operator!=(const remote& a, const remote& b)
99 {
100  return !(a == b);
101 }
102 
103 
104 // * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
105 
107 {
108  return os << p.proci << token::SPACE << p.elementi;
109 }
110 
111 
113 {
114  return is >> p.proci >> p.elementi;
115 }
116 
117 
118 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
119 
120 namespace Foam
121 {
122 
123 template<class Cmpt>
124 class Tensor;
125 
126 inline remote transform(const Tensor<scalar>&, const remote& p)
127 {
128  return p;
129 }
130 
131 }
132 
133 
134 // ************************************************************************* //
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
Inter-processor communications stream.
Definition: Pstream.H:56
Struct for keeping processor, element (cell, face, point) index.
Definition: remote.H:57
remote()
Construct null.
Definition: remoteI.H:31
label elementi
Element index.
Definition: remote.H:70
label proci
Processor index.
Definition: remote.H:67
volScalarField & b
Definition: createFields.H:27
Namespace for OpenFOAM.
bool operator!=(const particle &, const particle &)
Definition: particle.C:424
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
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Istream & operator>>(Istream &, pistonPointEdgeData &)
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:501
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
volScalarField & p