parMapperHelper.H
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  parMapperHelper
26 
27 Description
28  A class containing point coordinates, moving distance,
29  global label of the mapped point and projected patch. It is used for
30  exchanging data over processors
31 
32 SourceFiles
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef parMapperHelper_H
37 #define parMapperHelper_H
38 
39 #include "label.H"
40 #include "point.H"
41 #include "contiguous.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class parMapperHelper Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class parMapperHelper
53 {
54  // Private data
56  scalar movingDist_;
58  label patch_;
59 
60  public:
61 
62  // Constructors
63  explicit inline parMapperHelper()
64  :
65  p_(),
66  movingDist_(),
67  globalLabel_(-1),
68  patch_(-1)
69  {};
70 
71  explicit inline parMapperHelper
72  (
73  const point& p,
74  const scalar& movingDst,
75  const label globalLabel,
76  const label patchLabel
77  )
78  :
79  p_(p),
80  movingDist_(movingDst),
82  patch_(patchLabel)
83  {}
84 
85  // Destructor
87  {};
88 
89  // Member functions
90  //- return point coordinates
91  inline const point& coordinates() const
92  {
93  return p_;
94  }
95 
96  //- return moving distance
97  inline const scalar& movingDistance() const
98  {
99  return movingDist_;
100  }
101 
102  //- return global label
103  inline label globalLabel() const
104  {
105  return globalLabel_;
106  }
107 
108  //- return patch the point is mapped to
109  inline label pointPatch() const
110  {
111  return patch_;
112  }
113 
114  // Operators
115 
116  inline void operator=(const parMapperHelper& h)
117  {
118  p_ = h.p_;
119  movingDist_ = h.movingDist_;
120  globalLabel_ = h.globalLabel_;
121  patch_ = h.patch_;
122  }
123 
124  inline bool operator!=(const parMapperHelper& h) const
125  {
126  if( globalLabel_ != h.globalLabel_ )
127  return true;
128 
129  return false;
130  }
131 
132  // Friend operators
133  friend Ostream& operator<<(Ostream& os, const parMapperHelper& h)
134  {
135  os << token::BEGIN_LIST;
136  os << h.p_ << token::SPACE;
137  os << h.movingDist_ << token::SPACE;
138  os << h.globalLabel_ << token::SPACE;
139  os << h.patch_ << token::END_LIST;
140 
141  // Check state of Ostream
142  os.check("operator<<(Ostream&, const parMapperHelper&");
143  return os;
144  }
145 
147  {
148  // Read beginning of parMapperHelper
149  is.readBegin("parMapperHelper");
150 
151  is >> h.p_;
152  is >> h.movingDist_;
153  is >> h.globalLabel_;
154  is >> h.patch_;
155 
156  // Read end of parMapperHelper
157  is.readEnd("parMapperHelper");
158 
159  // Check state of Istream
160  is.check("operator>>(Istream&, parMapperHelper");
161 
162  return is;
163  }
164 };
165 
166 //- Specify data associated with parMapperHelper type is contiguous
167 template<>
168 inline bool contiguous<parMapperHelper>() {return true;}
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
Foam::parMapperHelper::operator=
void operator=(const parMapperHelper &h)
Definition: parMapperHelper.H:115
Foam::Istream::readEnd
Istream & readEnd(const char *funcName)
Definition: Istream.C:105
Foam::parMapperHelper::globalLabel
label globalLabel() const
return global label
Definition: parMapperHelper.H:102
Foam::parMapperHelper
Definition: parMapperHelper.H:51
p
p
Definition: pEqn.H:62
point.H
Foam::parMapperHelper::operator!=
bool operator!=(const parMapperHelper &h) const
Definition: parMapperHelper.H:123
Foam::parMapperHelper::movingDist_
scalar movingDist_
Definition: parMapperHelper.H:55
Foam::parMapperHelper::p_
point p_
Definition: parMapperHelper.H:54
Foam::parMapperHelper::operator<<
friend Ostream & operator<<(Ostream &os, const parMapperHelper &h)
Definition: parMapperHelper.H:132
Foam::parMapperHelper::globalLabel_
label globalLabel_
Definition: parMapperHelper.H:56
Foam::parMapperHelper::movingDistance
const scalar & movingDistance() const
return moving distance
Definition: parMapperHelper.H:96
Foam::label
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
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::constant::universal::h
const dimensionedScalar h
Planck constant.
Definition: createFields.H:6
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
Foam::parMapperHelper::operator>>
friend Istream & operator>>(Istream &is, parMapperHelper &h)
Definition: parMapperHelper.H:145
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::parMapperHelper::pointPatch
label pointPatch() const
return patch the point is mapped to
Definition: parMapperHelper.H:108
Foam::parMapperHelper::coordinates
const point & coordinates() const
return point coordinates
Definition: parMapperHelper.H:90
Foam::contiguous< parMapperHelper >
bool contiguous< parMapperHelper >()
Specify data associated with parMapperHelper type is contiguous.
Definition: parMapperHelper.H:167
Foam::token::BEGIN_LIST
@ BEGIN_LIST
Definition: token.H:100
Foam::Vector< scalar >
label.H
contiguous.H
Template function to specify if the data of a type are contiguous.
Foam::parMapperHelper::~parMapperHelper
~parMapperHelper()
Definition: parMapperHelper.H:85
Foam::parMapperHelper::parMapperHelper
parMapperHelper()
Definition: parMapperHelper.H:62
Foam::parMapperHelper::patch_
label patch_
Definition: parMapperHelper.H:57
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::Istream::readBegin
Istream & readBegin(const char *funcName)
Definition: Istream.C:88
Foam::token::END_LIST
@ END_LIST
Definition: token.H:101
Foam::token::SPACE
@ SPACE
Definition: token.H:95