From 9318c4022cfa011027cc51d9fa33d32ad7ebce33 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 20 Jun 2017 07:22:52 -0600 Subject: [PATCH] Check whether a function call makes sense at the place where the function is called. This is instead of returning early in the function. Check that the arguments are indeed valid within the function. --- source/dofs/dof_handler_policy.cc | 41 ++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index c105f5b648..4cd55706a0 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -537,6 +537,9 @@ namespace internal const unsigned int level, const bool check_validity) { + Assert (level::MGVertexDoFs>::iterator i=dof_handler.mg_vertex_dofs.begin(); i!=dof_handler.mg_vertex_dofs.end(); @@ -642,8 +645,8 @@ namespace internal const unsigned int level, const bool check_validity) { - if (level>=dof_handler.get_triangulation().n_levels()) - return; + Assert (level::MGVertexDoFs>::iterator i=dof_handler.mg_vertex_dofs.begin(); i!=dof_handler.mg_vertex_dofs.end(); ++i) @@ -791,8 +794,9 @@ namespace internal const unsigned int level, const bool check_validity) { - if (level>=dof_handler.get_triangulation().n_levels()) - return; + Assert (level::MGVertexDoFs>::iterator i=dof_handler.mg_vertex_dofs.begin(); i!=dof_handler.mg_vertex_dofs.end(); ++i) // if the present vertex lives on the present level @@ -2268,15 +2272,23 @@ namespace internal const unsigned int n_cpus = Utilities::MPI::n_mpi_processes (tr->get_communicator()); - unsigned int n_levels = Utilities::MPI::max(dof_handler.get_triangulation().n_levels(), tr->get_communicator()); - + // loop over all levels that exist globally (across all + // processors), even if the current processor does not in fact + // have any cells on that level or if the local part of the + // Triangulation has fewer levels. we need to do this because + // we need to communicate across all processors on all levels + const unsigned int n_levels = Utilities::MPI::max(dof_handler.get_triangulation().n_levels(), + tr->get_communicator()); for (unsigned int level = 0; level < n_levels; ++level) { NumberCache &number_cache = number_caches[level]; //* 1. distribute on own subdomain const unsigned int n_initial_local_dofs = - Implementation::distribute_dofs_on_level(0, tr->locally_owned_subdomain(), dof_handler, level); + Implementation::distribute_dofs_on_level(0, + tr->locally_owned_subdomain(), + dof_handler, + level); //* 2. iterate over ghostcells and kill dofs that are not // owned by us @@ -2284,7 +2296,7 @@ namespace internal for (dealii::types::global_dof_index i=0; in_levels()) + if (level < tr->n_levels()) { std::vector local_dof_indices; @@ -2345,9 +2357,16 @@ namespace internal // now re-enumerate all dofs to this shifted and condensed // numbering form. we renumber some dofs as invalid, so - // choose the nocheck-version. - Implementation::renumber_mg_dofs (renumbering, IndexSet(0), - dof_handler, level, false); + // choose the nocheck-version of the function + // + // of course there is nothing for us to renumber if the + // level we are currently dealing with doesn't even exist + // within the current triangulation, so skip renumbering + // in that case + if (level < tr->n_levels()) + Implementation::renumber_mg_dofs (renumbering, IndexSet(0), + dof_handler, level, + false); // now a little bit of housekeeping number_cache.n_global_dofs -- 2.39.5