32 template<std::size_t PBITS,
39 static constexpr std::size_t FLAGS_UNMASK =
40 ~(((std::size_t(1) << FBITS) - std::size_t(1)) << 59);
42 static_assert(PBITS + EBITS + FBITS + GBITS + 4 == 128,
43 "invalid id bit configuration");
46 static_assert(
sizeof(std::size_t) * CHAR_BIT >= 64,
47 "need std::size_t >= 64 bit");
53 : dimension_(
id.dimension_), domain_(
id.domain_), partition_(
id.partition_),
54 entity_(
id.entity_), flags_(
id.flags_), global_(
id.global_) {}
56 explicit id_(
const std::size_t local_id)
57 : dimension_(0), domain_(0), partition_(0), entity_(local_id), flags_(0),
60 template<std::
size_t D, std::
size_t M>
61 static id_ make(
const std::size_t local_id,
62 const std::size_t partition_id = 0,
63 const std::size_t flags = 0,
64 const std::size_t global = 0) {
66 global_id.dimension_ = D;
67 global_id.domain_ = M;
68 global_id.partition_ = partition_id;
69 global_id.entity_ = local_id;
70 global_id.global_ = global;
71 global_id.flags_ = flags;
76 template<std::
size_t M>
77 static id_ make(
const std::size_t dim,
78 const std::size_t local_id,
79 const std::size_t partition_id = 0,
80 const std::size_t flags = 0,
81 const std::size_t global = 0) {
83 global_id.dimension_ = dim;
84 global_id.domain_ = M;
85 global_id.partition_ = partition_id;
86 global_id.entity_ = local_id;
87 global_id.global_ = global;
88 global_id.flags_ = flags;
93 static id_ make(
const std::size_t dim,
94 const std::size_t local_id,
95 const std::size_t partition_id = 0,
96 const std::size_t flags = 0,
97 const std::size_t global = 0,
98 const std::size_t domain = 0) {
100 global_id.dimension_ = dim;
101 global_id.domain_ = domain;
102 global_id.partition_ = partition_id;
103 global_id.entity_ = local_id;
104 global_id.global_ = global;
105 global_id.flags_ = flags;
118 std::size_t global_id()
const {
119 constexpr std::size_t unmask = ~((std::size_t(1) << EBITS) - 1);
120 return static_cast<std::size_t
>((local_id() & unmask) | global_);
123 void set_global(
const std::size_t global) {
127 std::size_t global()
const {
131 void set_partition(
const std::size_t partition) {
132 partition_ = partition;
135 id_ & operator=(
id_ &&) =
default;
137 id_ & operator=(
const id_ &
id) {
138 dimension_ =
id.dimension_;
139 domain_ =
id.domain_;
140 partition_ =
id.partition_;
141 entity_ =
id.entity_;
142 global_ =
id.global_;
148 std::size_t dimension()
const {
152 std::size_t domain()
const {
156 std::size_t partition()
const {
160 std::size_t entity()
const {
164 std::size_t index_space_index()
const {
168 std::size_t flags()
const {
172 void set_flags(
const std::size_t flags) {
173 assert(flags < 1 << FBITS &&
"flag bits exceeded");
177 bool operator<(
const id_ &
id)
const {
178 return local_id() <
id.local_id();
181 bool operator==(
const id_ &
id)
const {
182 return (local_id() & FLAGS_UNMASK) == (
id.local_id() & FLAGS_UNMASK);
185 bool operator!=(
const id_ &
id)
const {
186 return !(local_id() ==
id.local_id());
190 std::size_t dimension_ : 2;
191 std::size_t domain_ : 2;
192 std::size_t partition_ : PBITS;
193 std::size_t entity_ : EBITS;
194 std::size_t flags_ : FBITS;
195 std::size_t global_ : GBITS;
203 inline std::ostream &
205 return ostr << uint64_t(x >> 64) <<
":" << uint64_t(x);
Definition: uint128.hh:57
std::ostream & operator<<(std::ostream &ostr, const filling_curve< D, T, DER > &k)
output for filling_curve using output_ function defined in the class
Definition: filling_curve.hh:206
Definition: control.hh:31