Rheolef  7.1
an efficient C++ finite element environment
geo_element_indirect.h
Go to the documentation of this file.
1 #ifndef _RHEOLEF_GEO_ELEMENT_INDIRECT_H
2 #define _RHEOLEF_GEO_ELEMENT_INDIRECT_H
3 
24 #include "rheolef/compiler_mpi.h"
25 
26 namespace rheolef {
27 
28 // =====================================================================
29 // geo_element_indirect = index + orient + face shift
30 // =====================================================================
31 // TODO: compact the sign bit and size_t in a long int
33 public:
34 
35 // typedefs:
36 
37  typedef size_t size_type;
38  typedef short int orientation_type; // for sign (+1,-1)
39  typedef short int shift_type; // for face [0:4[ shift
40 
41 // allocators:
42 
44  : _all(std::numeric_limits<size_type>::max()) {}
46  : _all(std::numeric_limits<size_type>::max())
47  { set (orient, ige, shift); }
48 
49 // accessors:
50 
51  size_type index() const { return _all & index_mask; }
52  orientation_type orientation() const { return (_all & orient_mask) ? -1 : 1; }
53  shift_type shift() const { return (_all & shift_mask) >> shift_position; }
54 
55 // modifiers:
56 
58  _all = (_all & (~orient_mask));
59  if (orient < 0) _all = _all | orient_mask;
60  }
62  _all = (_all & (~shift_mask));
64  }
65  void set_index (size_type ige) {
66  _all = (_all & (~index_mask));
67  _all = _all | (index_mask & ige);
68  }
69  void set (orientation_type orient, size_type ige, size_type shift = 0) {
70  set_orientation (orient);
71  set_index (ige);
72  set_shift (shift);
73  }
74 
75 // i/o:
76 
77  void dump(std::ostream& out = std::clog) const {
78  for (int i = 8*sizeof(size_type) - 1; i >= 0; i--) {
79  size_type bit = (_all & (size_type(1) << i)) >> i;
80  out << bit;
81  if (i % 8 == 0 && i != 0) out << " ";
82  }
83  }
84  template<class Archive>
85  void serialize (Archive& ar, const unsigned int version) { ar & _all; }
86 
87 protected:
88 
89 // implementation:
90 
91  // left bit(0) = first left bit: orientation
92  static const size_type orient_position = 8*sizeof(size_type)-1;
94 
95  // left bits(1:3) = face shift (for 3d faces)
96  static const size_type shift_position = 8*sizeof(size_type)-4;
97  static const size_type shift_mask = (size_type(1) << shift_position) |
98  (size_type(1) << (shift_position+1)) |
99  (size_type(1) << (shift_position+2));
100 
101 
102  // others right bits = index of the subgeo (face or edge)
104 
105 // data:
106 
108 };
109 // i/o:
110 std::istream& operator>> (std::istream& is, geo_element_indirect& x);
111 std::ostream& operator<< (std::ostream& os, const geo_element_indirect& x);
112 
113 } // namespace rheolef
114 
115 #ifdef _RHEOLEF_HAVE_MPI
116 #include "rheolef/compiler.h"
117 // =====================================================================
118 // Some serializable types, have a fixed amount of data stored at fixed field positions.
119 // When this is the case, boost::mpi can optimize their serialization and transmission to avoid extraneous
120 // copy operations.
121 // To enable this optimization, we specialize the type trait is_mpi_datatype, e.g.:
122 namespace boost {
123  namespace mpi {
124  template <> struct is_mpi_datatype<rheolef::geo_element_indirect> : mpl::true_ { };
125  } // namespace mpi
126 } // namespace boost
127 #endif // _RHEOLEF_HAVE_MPI
128 
129 #endif // _RHEOLEF_GEO_ELEMENT_INDIRECT_H
rheolef::geo_element_indirect::orientation
orientation_type orientation() const
Definition: geo_element_indirect.h:52
rheolef::geo_element_indirect::set
void set(orientation_type orient, size_type ige, size_type shift=0)
Definition: geo_element_indirect.h:69
rheolef::io::out
@ out
Definition: rheostream.h:167
rheolef::geo_element_indirect::set_orientation
void set_orientation(orientation_type orient)
Definition: geo_element_indirect.h:57
rheolef::geo_element_indirect::shift_type
short int shift_type
Definition: geo_element_indirect.h:39
rheolef::geo_element_indirect::shift_position
static const size_type shift_position
Definition: geo_element_indirect.h:96
rheolef::geo_element_indirect::index
size_type index() const
Definition: geo_element_indirect.h:51
rheolef::geo_element_indirect::shift
shift_type shift() const
Definition: geo_element_indirect.h:53
boost
Definition: mpi_pair_datatype.h:46
rheolef-config.version
version
Definition: rheolef-config.in:126
rheolef::geo_element_indirect
Definition: geo_element_indirect.h:32
rheolef::geo_element_indirect::index_mask
static const size_type index_mask
Definition: geo_element_indirect.h:103
rheolef::geo_element_indirect::geo_element_indirect
geo_element_indirect(orientation_type orient, size_type ige, size_type shift=0)
Definition: geo_element_indirect.h:45
boost::mpi
Definition: mpi_pair_datatype.h:47
rheolef::geo_element_indirect::orientation_type
short int orientation_type
Definition: geo_element_indirect.h:38
rheolef::geo_element_indirect::set_shift
void set_shift(size_type shift)
Definition: geo_element_indirect.h:61
rheolef::geo_element_indirect::geo_element_indirect
geo_element_indirect()
Definition: geo_element_indirect.h:43
rheolef::geo_element_indirect::serialize
void serialize(Archive &ar, const unsigned int version)
Definition: geo_element_indirect.h:85
rheolef::operator>>
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::geo_element_indirect::dump
void dump(std::ostream &out=std::clog) const
Definition: geo_element_indirect.h:77
rheolef::geo_element_indirect::orient_mask
static const size_type orient_mask
Definition: geo_element_indirect.h:93
rheolef::geo_element_indirect::orient_position
static const size_type orient_position
Definition: geo_element_indirect.h:92
rheolef::geo_element_indirect::shift_mask
static const size_type shift_mask
Definition: geo_element_indirect.h:97
rheolef::geo_element_indirect::size_type
size_t size_type
Definition: geo_element_indirect.h:37
rheolef::geo_element_indirect::_all
size_type _all
Definition: geo_element_indirect.h:107
rheolef::geo_element_indirect::set_index
void set_index(size_type ige)
Definition: geo_element_indirect.h:65
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
rheolef::std
Definition: vec_expr_v2.h:391