bitTransfer.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 
22 #ifndef __bitTransfer_hpp__
23 #define __bitTransfer_hpp__
24 
25 
26 #include "types.hpp"
27 #include "Vectors.hpp"
28 
29 namespace pFlow
30 {
31 
32 // a simple functor that transfers 3 integers into a long variable and
33 // transfer the long to 3 integers
34 
36 {
37 protected:
38 
39  static const int numBits_ = 21;
40  static const int numBits2_ = 2 * numBits_;
41  static const unsigned long mask1_ = 0x000000000001FFFFF;
42  static const unsigned long mask2_ = 0x0000003FFFFE00000;
43  static const unsigned long mask3_ = 0x07FFFFC0000000000;
44 
45 public:
46 
48 
49  inline unsigned long operator()(const unit3& int3 )
50  {
51  return
52  static_cast<long>(int3.x()) |
53  static_cast<long>(int3.y()) << numBits_ |
54  static_cast<long>(int3.z()) << numBits2_;
55  }
56 
57  inline unit3 operator() (const unsigned long& ul )
58  {
59  return unit3
60  (
61  ul & mask1_,
62  (ul & mask2_)>> numBits_,
63  (ul & mask3_)>> numBits2_
64  );
65  }
66 };
67 
68 }
69 
70 
71 #endif
types.hpp
Vectors.hpp
pFlow
Definition: demComponent.hpp:28
pFlow::bitTransfer
Definition: bitTransfer.hpp:35
pFlow::bitTransfer::mask3_
static const unsigned long mask3_
Definition: bitTransfer.hpp:43
pFlow::bitTransfer::numBits2_
static const int numBits2_
Definition: bitTransfer.hpp:40
pFlow::bitTransfer::numBits_
static const int numBits_
Definition: bitTransfer.hpp:39
pFlow::bitTransfer::mask2_
static const unsigned long mask2_
Definition: bitTransfer.hpp:42
pFlow::bitTransfer::operator()
unsigned long operator()(const unit3 &int3)
Definition: bitTransfer.hpp:49
pFlow::bitTransfer::mask1_
static const unsigned long mask1_
Definition: bitTransfer.hpp:41
pFlow::bitTransfer::bitTransfer
bitTransfer()
Definition: bitTransfer.hpp:47