rheolef
6.3
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
nfem
geo_element
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
4
#include "rheolef/compiler.h"
5
6
namespace
rheolef {
7
8
class
geo_element_indirect
{
9
public
:
10
11
12
typedef
size_t
size_type
;
13
typedef
short
int
orientation_type
;
// for sign (+1,-1)
14
typedef
short
int
shift_type
;
// for face [0:4[ shift
15
16
17
geo_element_indirect
()
18
:
_all
(std::numeric_limits<
size_type
>::
max
()) {}
19
geo_element_indirect
(
orientation_type
orient,
size_type
ige,
size_type
shift
= 0)
20
:
_all
(std::numeric_limits<
size_type
>::
max
())
21
{
set
(orient, ige,
shift
); }
22
23
24
size_type
index
()
const
{
return
_all
&
index_mask
; }
25
orientation_type
orientation
()
const
{
return
(
_all
&
orient_mask
) ? -1 : 1; }
26
shift_type
shift
()
const
{
return
(
_all
&
shift_mask
) >>
shift_position
; }
27
28
29
void
set_orientation
(
orientation_type
orient) {
30
_all
= (
_all
& (~
orient_mask
));
31
if
(orient < 0)
_all
=
_all
|
orient_mask
;
32
}
33
void
set_shift
(
size_type
shift
) {
34
_all
= (
_all
& (~
shift_mask
));
35
_all
=
_all
| (
shift_mask
& (shift <<
shift_position
));
36
}
37
void
set_index
(
size_type
ige) {
38
_all
= (
_all
& (~
index_mask
));
39
_all
=
_all
| (
index_mask
& ige);
40
}
41
void
set
(
orientation_type
orient,
size_type
ige,
size_type
shift
= 0) {
42
set_orientation
(orient);
43
set_index
(ige);
44
set_shift
(
shift
);
45
}
46
47
// i/o:
48
49
void
dump
(std::ostream& out = std::clog)
const
{
50
for
(
int
i = 8*
sizeof
(
size_type
) - 1; i >= 0; i--) {
51
size_type
bit = (
_all
& (
size_type
(1) << i)) >> i;
52
out << bit;
53
if
(i % 8 == 0 && i != 0) out <<
" "
;
54
}
55
}
56
template
<
class
Archive>
57
void
serialize
(Archive& ar,
const
unsigned
int
version) { ar &
_all
; }
58
59
protected
:
60
61
62
static
const
size_type
orient_position
= 8*
sizeof
(
size_type
)-1;
63
static
const
size_type
orient_mask
= (
size_type
(1) <<
orient_position
);
64
65
static
const
size_type
shift_position
= 8*
sizeof
(
size_type
)-4;
66
static
const
size_type
shift_mask
= (
size_type
(1) <<
shift_position
) |
67
(
size_type
(1) << (
shift_position
+1)) |
68
(
size_type
(1) << (
shift_position
+2));
69
70
71
static
const
size_type
index_mask
= ~(
orient_mask
|
shift_mask
);
72
73
74
size_type
_all
;
75
};
76
// i/o:
77
std::istream&
operator>>
(std::istream& is,
geo_element_indirect
& x);
78
std::ostream&
operator<<
(std::ostream& os,
const
geo_element_indirect
& x);
79
80
}
// namespace rheolef
81
82
#ifdef _RHEOLEF_HAVE_MPI
83
#include "rheolef/distributed.h"
84
namespace
boost {
85
namespace
mpi {
86
template
<>
struct
is_mpi_datatype<rheolef::geo_element_indirect> : mpl::true_ { };
87
}
// namespace mpi
88
}
// namespace boost
89
#endif // _RHEOLEF_HAVE_MPI
90
91
#endif // _RHEOLEF_GEO_ELEMENT_INDIRECT_H
92