Skip to content

Commit

Permalink
Merge pull request #16388 from drwells/adjust-line-dof-index-combined…
Browse files Browse the repository at this point in the history
…-orientation

Use the combined orientation in another FiniteElement function.
  • Loading branch information
bangerth committed Dec 28, 2023
2 parents 588c295 + 5c5d009 commit f287dfd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
9 changes: 5 additions & 4 deletions doc/news/changes/incompatibilities/20231221DavidWells
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Changed: FiniteElement::adjust_quad_dof_index_for_face_orientation() and
FiniteElement::face_to_cell_index() now use the standardized
<tt>combined_orientation</tt> orientation encoding as input arguments rather
than three booleans.
Changed: FiniteElement::adjust_quad_dof_index_for_face_orientation(),
FiniteElement::face_to_cell_index(), and
FiniteElement::adjust_line_dof_index_for_line_orientation() now use the
standardized <tt>combined_orientation</tt> orientation encoding as input
arguments rather than one or three booleans.
<br>
(David Wells, 2023/12/21)
16 changes: 9 additions & 7 deletions include/deal.II/fe/fe.h
Original file line number Diff line number Diff line change
Expand Up @@ -1524,15 +1524,17 @@ class FiniteElement : public Subscriptor, public FiniteElementData<dim>
ReferenceCell::default_combined_face_orientation()) const;

/**
* For lines with non-standard line_orientation in 3d, the dofs on lines
* have to be permuted in order to be combined with the correct shape
* functions. Given a local dof @p index on a line, return the local index,
* if the line has non-standard line_orientation. In 2d and 1d there is no
* need for permutation, so the given index is simply returned.
* Given a local dof @p index on a line and the orientation @p
* combined_orientation of that line, return the local dof which accounts for
* @p combined_orientation.
*
* @note In both 1d and all-quadrilateral meshes in 2d all lines have the
* standard orientation.
*/
unsigned int
adjust_line_dof_index_for_line_orientation(const unsigned int index,
const bool line_orientation) const;
adjust_line_dof_index_for_line_orientation(
const unsigned int index,
const unsigned char combined_orientation) const;

/**
* Return in which of the vector components of this finite element the @p
Expand Down
15 changes: 9 additions & 6 deletions include/deal.II/grid/tria_accessor.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ namespace internal
* cell->line_orientation(), 1d specialization
*/
template <int dim, int spacedim>
static std::array<unsigned int, 1>
static std::array<unsigned char, 1>
get_line_orientations_of_cell(const TriaAccessor<1, dim, spacedim> &)
{
Assert(false, ExcInternalError());
Expand All @@ -1118,14 +1118,17 @@ namespace internal
* cell->line_orientation(), 2d specialization
*/
template <int dim, int spacedim>
static std::array<bool, 4>
static std::array<unsigned char, 4>
get_line_orientations_of_cell(const TriaAccessor<2, dim, spacedim> &cell)
{
// For 2d cells the access cell->line_orientation() is already
// efficient
std::array<bool, 4> line_orientations = {};
std::array<unsigned char, 4> line_orientations = {};
for (const unsigned int line : cell.line_indices())
line_orientations[line] = cell.line_orientation(line);
line_orientations[line] =
cell.line_orientation(line) == true ?
ReferenceCell::default_combined_face_orientation() :
ReferenceCell::reversed_combined_line_orientation();
return line_orientations;
}

Expand All @@ -1136,10 +1139,10 @@ namespace internal
* cell->line_orientation(), 3d specialization
*/
template <int dim, int spacedim>
static std::array<bool, 12>
static std::array<unsigned char, 12>
get_line_orientations_of_cell(const TriaAccessor<3, dim, spacedim> &cell)
{
std::array<bool, 12> line_orientations = {};
std::array<unsigned char, 12> line_orientations = {};

// For hexahedra, the classical access via quads -> lines is too
// inefficient. Unroll this code here to allow the compiler to inline
Expand Down
12 changes: 9 additions & 3 deletions source/fe/fe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -683,14 +683,19 @@ FiniteElement<dim, spacedim>::adjust_quad_dof_index_for_face_orientation(
template <int dim, int spacedim>
unsigned int
FiniteElement<dim, spacedim>::adjust_line_dof_index_for_line_orientation(
const unsigned int index,
const bool line_orientation) const
const unsigned int index,
const unsigned char combined_orientation) const
{
// We orient quads (and 1D meshes are always oriented) so always skip those
// cases
//
// TODO - we may want to change this in the future: see also the notes in
// face_to_cell_index()
Assert(combined_orientation ==
ReferenceCell::default_combined_face_orientation() ||
combined_orientation ==
ReferenceCell::reversed_combined_line_orientation(),
ExcInternalError());
if (this->reference_cell() == ReferenceCells::Line ||
this->reference_cell() == ReferenceCells::Quadrilateral)
return index;
Expand All @@ -699,7 +704,8 @@ FiniteElement<dim, spacedim>::adjust_line_dof_index_for_line_orientation(
Assert(adjust_line_dof_index_for_line_orientation_table.size() ==
this->n_dofs_per_line(),
ExcInternalError());
if (line_orientation)
if (combined_orientation ==
ReferenceCell::default_combined_face_orientation())
return index;
else
return index + adjust_line_dof_index_for_line_orientation_table[index];
Expand Down

0 comments on commit f287dfd

Please sign in to comment.