}
+ /**
+ * Check if the bit at position @p n in @p number is set.
+ */
+ inline static bool
+ get_bit(const char number, const unsigned int n)
+ {
+ // source:
+ // https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit
+ // "Checking a bit"
+ return (number >> n) & 1U;
+ }
+
+
+
+ /**
+ * Set the bit at position @p n in @p number to value @p x.
+ */
+ inline static void
+ set_bit(char &number, const unsigned int n, const bool x)
+ {
+ // source:
+ // https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit
+ // "Changing the nth bit to x"
+ number ^= (-x ^ number) & (1UL << n);
+ }
+
+
+
template <int dim, int spacedim>
inline static bool
face_flip(const TriaAccessor<3, dim, spacedim> &accessor,
AssertIndexRange(face, GeometryInfo<3>::faces_per_cell);
Assert(accessor.present_index * GeometryInfo<3>::faces_per_cell + face <
accessor.tria->levels[accessor.present_level]
- ->cells.face_flips.size(),
+ ->cells.face_orientations.size(),
ExcInternalError());
- return (
- accessor.tria->levels[accessor.present_level]->cells.face_flips
- [accessor.present_index * GeometryInfo<3>::faces_per_cell + face]);
+ return get_bit(
+ accessor.tria->levels[accessor.present_level]->cells.face_orientations
+ [accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
+ 1 /*=flip_bit*/);
}
AssertIndexRange(face, GeometryInfo<3>::faces_per_cell);
Assert(accessor.present_index * GeometryInfo<3>::faces_per_cell + face <
accessor.tria->levels[accessor.present_level]
- ->cells.face_rotations.size(),
+ ->cells.face_orientations.size(),
ExcInternalError());
- return (
- accessor.tria->levels[accessor.present_level]->cells.face_rotations
- [accessor.present_index * GeometryInfo<3>::faces_per_cell + face]);
+ return get_bit(
+ accessor.tria->levels[accessor.present_level]->cells.face_orientations
+ [accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
+ 2 /*=rotation_bit*/);
}
/**
accessor.tria->levels[accessor.present_level]
->cells.face_orientations.size(),
ExcInternalError());
- accessor.tria->levels[accessor.present_level]->cells.face_orientations
- [accessor.present_index * GeometryInfo<3>::faces_per_cell + face] =
- value;
+ set_bit(
+ accessor.tria->levels[accessor.present_level]->cells.face_orientations
+ [accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
+ 0 /*=orientation_bit*/,
+ value);
}
AssertIndexRange(face, GeometryInfo<3>::faces_per_cell);
Assert(accessor.present_index * GeometryInfo<3>::faces_per_cell + face <
accessor.tria->levels[accessor.present_level]
- ->cells.face_flips.size(),
+ ->cells.face_orientations.size(),
ExcInternalError());
- accessor.tria->levels[accessor.present_level]->cells.face_flips
- [accessor.present_index * GeometryInfo<3>::faces_per_cell + face] =
- value;
+ set_bit(
+ accessor.tria->levels[accessor.present_level]->cells.face_orientations
+ [accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
+ 1 /*=flip_bit*/,
+ value);
}
AssertIndexRange(face, GeometryInfo<3>::faces_per_cell);
Assert(accessor.present_index * GeometryInfo<3>::faces_per_cell + face <
accessor.tria->levels[accessor.present_level]
- ->cells.face_rotations.size(),
+ ->cells.face_orientations.size(),
ExcInternalError());
- accessor.tria->levels[accessor.present_level]->cells.face_rotations
- [accessor.present_index * GeometryInfo<3>::faces_per_cell + face] =
- value;
+ set_bit(
+ accessor.tria->levels[accessor.present_level]->cells.face_orientations
+ [accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
+ 2 /*=rotation_bit*/,
+ value);
}
/**
*
* In effect, this field has <code>6*n_cells</code> elements, being the
* number of cells times the six faces each has.
- */
- std::vector<bool> face_orientations;
-
- /**
+ *
* flip = rotation by 180 degrees
- */
- std::vector<bool> face_flips;
-
- /**
+ *
* rotation by 90 degrees
*/
- std::vector<bool> face_rotations;
+ std::vector<char> face_orientations;
/**
* Assert that enough space is allocated to accommodate
* In effect, this field has <code>4*n_quads</code> elements, being the
* number of quads times the four lines each has.
*/
- std::vector<bool> line_orientations;
+ std::vector<char> line_orientations;
/**
* Assert that enough space is allocated to accommodate
{
this->TriaObjects<TriaObject<3>>::serialize(ar, version);
- ar &face_orientations &face_flips &face_rotations;
+ ar &face_orientations;
}
GeometryInfo<3>::faces_per_cell);
AssertIndexRange(face, GeometryInfo<3>::faces_per_cell);
- return face_orientations[cell * GeometryInfo<3>::faces_per_cell + face];
+ return face_orientations[cell * GeometryInfo<3>::faces_per_cell + face] &
+ 1;
}
//----------------------------------------------------------------------//
TriaObjectsQuad3D::face_orientation(const unsigned int cell,
const unsigned int face) const
{
- return line_orientations[cell * GeometryInfo<2>::faces_per_cell + face];
+ return line_orientations[cell * GeometryInfo<2>::faces_per_cell + face] &
+ 1;
}
refinement_cases.insert(refinement_cases.end(),
new_size - refinement_cases.size(),
RefinementCase<3>::no_refinement);
-
- face_flips.reserve(new_size * GeometryInfo<3>::faces_per_cell);
- face_flips.insert(face_flips.end(),
- new_size * GeometryInfo<3>::faces_per_cell -
- face_flips.size(),
- false);
- face_rotations.reserve(new_size * GeometryInfo<3>::faces_per_cell);
- face_rotations.insert(face_rotations.end(),
- new_size * GeometryInfo<3>::faces_per_cell -
- face_rotations.size(),
- false);
}
next_free_single = next_free_pair = 0;
}
face_orientations.size(),
ExcMemoryInexact(cells.size() * GeometryInfo<3>::faces_per_cell,
face_orientations.size()));
- Assert(cells.size() * GeometryInfo<3>::faces_per_cell ==
- face_flips.size(),
- ExcMemoryInexact(cells.size() * GeometryInfo<3>::faces_per_cell,
- face_flips.size()));
- Assert(cells.size() * GeometryInfo<3>::faces_per_cell ==
- face_rotations.size(),
- ExcMemoryInexact(cells.size() * GeometryInfo<3>::faces_per_cell,
- face_rotations.size()));
}
{
TriaObjects<TriaObject<3>>::clear();
face_orientations.clear();
- face_flips.clear();
- face_rotations.clear();
}
TriaObjectsHex::memory_consumption() const
{
return (MemoryConsumption::memory_consumption(face_orientations) +
- MemoryConsumption::memory_consumption(face_flips) +
- MemoryConsumption::memory_consumption(face_rotations) +
TriaObjects<TriaObject<3>>::memory_consumption());
}