#include <deal.II/base/array_view.h>
#include <deal.II/base/geometry_info.h>
#include <deal.II/base/tensor.h>
+#include <deal.II/base/utilities.h>
DEAL_II_NAMESPACE_OPEN
namespace internal
{
- /**
- * Check if the bit at position @p n in @p number is set.
- */
- inline static bool
- get_bit(const unsigned char number, const unsigned int n)
- {
- AssertIndexRange(n, 8);
-
- // 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(unsigned char &number, const unsigned int n, const bool x)
- {
- AssertIndexRange(n, 8);
-
- // source:
- // https://stackoverflow.com/questions/47981/how-do-you-set-clear-and-toggle-a-single-bit
- // "Changing the nth bit to x"
- number ^= (-static_cast<unsigned char>(x) ^ number) & (1U << n);
- }
-
/**
* A namespace for geometric information on reference cells.
*/
return GeometryInfo<dim>::face_to_cell_lines(
face,
line,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
unsigned int
return GeometryInfo<dim>::face_to_cell_vertices(
face,
vertex,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
};
{
return GeometryInfo<3>::standard_to_real_face_line(
line,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
else // TRI
{
{
return GeometryInfo<3>::standard_to_real_face_vertex(
vertex,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
else // Tri
{
{
return GeometryInfo<3>::standard_to_real_face_line(
line,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
else // TRI
{
{
return GeometryInfo<3>::standard_to_real_face_vertex(
vertex,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
else // TRI
{
return GeometryInfo<3>::standard_to_real_face_line(
line,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
bool
{false, false}},
{{true, false}, {false, true}}}};
- const bool face_orientation = get_bit(face_orientation_raw, 0);
- const bool face_flip = get_bit(face_orientation_raw, 2);
- const bool face_rotation = get_bit(face_orientation_raw, 1);
+ const bool face_orientation =
+ Utilities::get_bit(face_orientation_raw, 0);
+ const bool face_flip = Utilities::get_bit(face_orientation_raw, 2);
+ const bool face_rotation = Utilities::get_bit(face_orientation_raw, 1);
return (
static_cast<bool>(line_orientation) ==
return GeometryInfo<3>::standard_to_real_face_vertex(
vertex,
- get_bit(face_orientation, 0),
- get_bit(face_orientation, 2),
- get_bit(face_orientation, 1));
+ Utilities::get_bit(face_orientation, 0),
+ Utilities::get_bit(face_orientation, 2),
+ Utilities::get_bit(face_orientation, 1));
}
dealii::ReferenceCell
face_orientation(const TriaAccessor<3, 3, 3> &accessor,
const unsigned int face)
{
- return internal::get_bit(
+ return Utilities::get_bit(
accessor.tria->levels[accessor.present_level]->face_orientations
[accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
0 /*=orientation_bit*/);
->face_orientations.size(),
ExcInternalError());
- return internal::get_bit(
+ return Utilities::get_bit(
accessor.tria->levels[accessor.present_level]->face_orientations
[accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
2 /*=flip_bit*/);
->face_orientations.size(),
ExcInternalError());
- return internal::get_bit(
+ return Utilities::get_bit(
accessor.tria->levels[accessor.present_level]->face_orientations
[accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
1 /*=rotation_bit*/);
accessor.tria->levels[accessor.present_level]
->face_orientations.size(),
ExcInternalError());
- internal::set_bit(
+ Utilities::set_bit(
accessor.tria->levels[accessor.present_level]->face_orientations
[accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
0 /*=orientation_bit*/,
->face_orientations.size(),
ExcInternalError());
- internal::set_bit(
+ Utilities::set_bit(
accessor.tria->levels[accessor.present_level]->face_orientations
[accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
2 /*=flip_bit*/,
->face_orientations.size(),
ExcInternalError());
- internal::set_bit(
+ Utilities::set_bit(
accessor.tria->levels[accessor.present_level]->face_orientations
[accessor.present_index * GeometryInfo<3>::faces_per_cell + face],
1 /*=rotation_bit*/,