Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic cleanup 2 #16281

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 18 additions & 48 deletions source/dofs/dof_tools_constraints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2376,6 +2376,11 @@ namespace DoFTools
ExcMessage("first_vector_components is nonempty, so matrix must "
"be a rotation matrix exactly of size spacedim"));

const unsigned char combined_orientation =
::dealii::internal::combined_face_orientation(face_orientation,
face_rotation,
face_flip);

#ifdef DEBUG
if (!face_1->has_children())
{
Expand Down Expand Up @@ -2426,43 +2431,10 @@ namespace DoFTools
}
#endif

// A lookup table on how to go through the child faces depending on the
// orientation:

static const int lookup_table_2d[2][2] = {
// flip:
{0, 1}, // false
{1, 0}, // true
};

static const int lookup_table_3d[2][2][2][4] = {
// orientation flip rotation
{
{
{0, 2, 1, 3}, // false false false
{2, 3, 0, 1}, // false false true
},
{
{3, 1, 2, 0}, // false true false
{1, 0, 3, 2}, // false true true
},
},
{
{
{0, 1, 2, 3}, // true false false
{1, 3, 0, 2}, // true false true
},
{
{3, 2, 1, 0}, // true true false
{2, 0, 3, 1}, // true true true
},
},
};

if (face_1->has_children() && face_2->has_children())
{
// In the case that both faces have children, we loop over all children
// and apply make_periodicty_constrains recursively:
// and apply make_periodicity_constraints() recursively:

Assert(face_1->n_children() ==
GeometryInfo<dim>::max_children_per_face &&
Expand All @@ -2473,20 +2445,18 @@ namespace DoFTools
for (unsigned int i = 0; i < GeometryInfo<dim>::max_children_per_face;
++i)
{
// Lookup the index for the second face
unsigned int j;
switch (dim)
{
case 2:
j = lookup_table_2d[face_flip][i];
break;
case 3:
j = lookup_table_3d[face_orientation][face_flip]
[face_rotation][i];
break;
default:
AssertThrow(false, ExcNotImplemented());
}
// We need to access the subface indices without knowing the face
// number. Hence, we pick the lowest-value face: i.e., face 2 in 2D
// has subfaces {0, 1} and face 4 in 3D has subfaces {0, 1, 2, 3}.
const unsigned int face_no = dim == 2 ? 2 : 4;

// Lookup the index for the second face. Like the assertions above,
// this is only presently valid for hypercube meshes.
const auto reference_cell = ReferenceCells::get_hypercube<dim>();
const unsigned int j =
reference_cell.child_cell_on_face(face_no,
i,
combined_orientation);

make_periodicity_constraints(face_1->child(i),
face_2->child(j),
Expand Down
3 changes: 2 additions & 1 deletion source/grid/grid_tools_dof_handlers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,8 @@ namespace GridTools
const unsigned int size_new = matched_pairs.size();
for (unsigned int i = size_old; i < size_new; ++i)
{
Assert(matched_pairs[i].orientation == 1,
Assert(matched_pairs[i].orientation ==
ReferenceCell::default_combined_face_orientation(),
ExcMessage(
"Found a face match with non standard orientation. "
"This function is only suitable for meshes with cells "
Expand Down