From b7658eff686df98f04f5a24fc14025bac89a5015 Mon Sep 17 00:00:00 2001 From: David Wells Date: Tue, 2 Aug 2016 22:39:17 -0400 Subject: [PATCH] Redo the hp make_flux_sparsity_pattern logic. This now the same as the non-hp version, which was changed in 9b037871bb. In brief: this function uses the total ordering of cells instead of user flags to figure out when a face may be skipped. --- source/dofs/dof_tools_sparsity.cc | 42 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/source/dofs/dof_tools_sparsity.cc b/source/dofs/dof_tools_sparsity.cc index 2eb8c011d6..1ac28b71b6 100644 --- a/source/dofs/dof_tools_sparsity.cc +++ b/source/dofs/dof_tools_sparsity.cc @@ -1024,8 +1024,6 @@ namespace DoFTools { const typename dealii::hp::DoFHandler::face_iterator cell_face = cell->face(face); - if (cell_face->user_flag_set ()) - continue; const bool periodic_neighbor = cell->has_periodic_neighbor (face); @@ -1048,15 +1046,37 @@ namespace DoFTools typename dealii::hp::DoFHandler::level_cell_iterator neighbor = cell->neighbor_or_periodic_neighbor(face); - // Refinement edges are taken care of by coarser cells - if ((!periodic_neighbor && cell->neighbor_is_coarser(face)) || - (periodic_neighbor && cell->periodic_neighbor_is_coarser(face))) + // Like the non-hp case: If the cells are on the same + // level (and both are active, locally-owned cells) then + // only add to the sparsity pattern if the current cell + // is 'greater' in the total ordering. + if (neighbor->level () == cell->level () + && + neighbor->index () > cell->index () + && + neighbor->active () + && + neighbor->is_locally_owned ()) continue; - - const unsigned int - neighbor_face = periodic_neighbor? - cell->periodic_neighbor_of_periodic_neighbor(face): - cell->neighbor_of_neighbor(face); + // Again, like the non-hp case: If we are more refined + // then the neighbor, then we will automatically find + // the active neighbor cell when we call 'neighbor + // (face)' above. The opposite is not true; if the + // neighbor is more refined then the call 'neighbor + // (face)' will *not* return an active cell. Hence, + // only add things to the sparsity pattern if (when the + // levels are different) the neighbor is coarser than + // the current cell. + // + // Like above, do not use this optimization if the + // neighbor is not locally owned. + if (neighbor->level () != cell->level () + && + ((!periodic_neighbor && !cell->neighbor_is_coarser (face)) + ||(periodic_neighbor && !cell->periodic_neighbor_is_coarser (face))) + && + neighbor->is_locally_owned ()) + continue; // (the neighbor is finer) if (cell_face->has_children()) { @@ -1114,7 +1134,6 @@ namespace DoFTools } } } - sub_neighbor->face(neighbor_face)->set_user_flag (); } } else @@ -1162,7 +1181,6 @@ namespace DoFTools } } } - neighbor->face(neighbor_face)->set_user_flag (); } } } -- 2.39.5