From d80f1e3bb20b0c248324a4f7753c06cd1b6f5908 Mon Sep 17 00:00:00 2001 From: bangerth Date: Sun, 26 Jan 2014 19:36:28 +0000 Subject: [PATCH] Disallow calling certain functions that have to do with active_fe_index on cells that are not in fact active. Fix the various places where we used to do so (and which probably produced something that made not much sense). git-svn-id: https://svn.dealii.org/trunk@32318 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/hp/get_interpolated_dof_values_01.cc | 18 +++++++++++++++--- ...get_interpolated_dof_values_01.debug.output | 12 +++++++++--- tests/hp/set_dof_values_by_interpolation_01.cc | 18 +++++++++++++++--- ...dof_values_by_interpolation_01.debug.output | 6 ++++++ 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/tests/hp/get_interpolated_dof_values_01.cc b/tests/hp/get_interpolated_dof_values_01.cc index 4eb4a8673a..3e1d9cdd70 100644 --- a/tests/hp/get_interpolated_dof_values_01.cc +++ b/tests/hp/get_interpolated_dof_values_01.cc @@ -69,9 +69,21 @@ void test () // try to interpolate from the active cell onto the coarsest cell, // which is definitely not active. this can't work, so expect an - // exception + // exception for both the call to cell->get_fe() and the call to + // cell->get_interpolated_dof_values typename hp::DoFHandler::cell_iterator cell=dof_handler.begin(0); - Vector local (cell->get_fe().dofs_per_cell); + + unsigned int dofs_per_cell = 4; + try + { + dofs_per_cell = cell->get_fe().dofs_per_cell; + } + catch (const ExceptionBase &e) + { + deallog << "Yes, exception 1!" << std::endl; + deallog << e.get_exc_name() << std::endl; + } + Vector local (dofs_per_cell); try { @@ -79,7 +91,7 @@ void test () } catch (const ExceptionBase &e) { - deallog << "Yes, exception!" << std::endl; + deallog << "Yes, exception 2!" << std::endl; deallog << e.get_exc_name() << std::endl; } } diff --git a/tests/hp/get_interpolated_dof_values_01.debug.output b/tests/hp/get_interpolated_dof_values_01.debug.output index ba7953b18d..41ebc1842e 100644 --- a/tests/hp/get_interpolated_dof_values_01.debug.output +++ b/tests/hp/get_interpolated_dof_values_01.debug.output @@ -1,7 +1,13 @@ -DEAL::Yes, exception! +DEAL::Yes, exception 1! +DEAL::ExcMessage ("In hp::DoFHandler objects, finite elements are only associated " "with active cells. Consequently, you can not ask for the " "active finite element on cells with children.") +DEAL::Yes, exception 2! DEAL::ExcMessage ("You cannot call this function on non-active cells " "of hp::DoFHandler objects unless you provide an explicit " "finite element index because they do not have naturally " "associated finite element spaces associated: degrees " "of freedom are only distributed on active cells for which " "the active_fe_index has been set.") -DEAL::Yes, exception! +DEAL::Yes, exception 1! +DEAL::ExcMessage ("In hp::DoFHandler objects, finite elements are only associated " "with active cells. Consequently, you can not ask for the " "active finite element on cells with children.") +DEAL::Yes, exception 2! DEAL::ExcMessage ("You cannot call this function on non-active cells " "of hp::DoFHandler objects unless you provide an explicit " "finite element index because they do not have naturally " "associated finite element spaces associated: degrees " "of freedom are only distributed on active cells for which " "the active_fe_index has been set.") -DEAL::Yes, exception! +DEAL::Yes, exception 1! +DEAL::ExcMessage ("In hp::DoFHandler objects, finite elements are only associated " "with active cells. Consequently, you can not ask for the " "active finite element on cells with children.") +DEAL::Yes, exception 2! DEAL::ExcMessage ("You cannot call this function on non-active cells " "of hp::DoFHandler objects unless you provide an explicit " "finite element index because they do not have naturally " "associated finite element spaces associated: degrees " "of freedom are only distributed on active cells for which " "the active_fe_index has been set.") diff --git a/tests/hp/set_dof_values_by_interpolation_01.cc b/tests/hp/set_dof_values_by_interpolation_01.cc index 676afac53f..0fa4497cca 100644 --- a/tests/hp/set_dof_values_by_interpolation_01.cc +++ b/tests/hp/set_dof_values_by_interpolation_01.cc @@ -69,13 +69,25 @@ void test () // try to interpolate from the active cell onto the coarsest cell, // which is definitely not active. this can't work, so expect an - // exception + // exception for both the call to cell->get_fe() and the call to + // cell->get_interpolated_dof_values typename hp::DoFHandler::cell_iterator cell=dof_handler.begin(0); - Vector local (cell->get_fe().dofs_per_cell); + unsigned int dofs_per_cell = 4; try { - cell->get_interpolated_dof_values (solution, local); + dofs_per_cell = cell->get_fe().dofs_per_cell; + } + catch (const ExceptionBase &e) + { + deallog << "Yes, exception 1!" << std::endl; + deallog << e.get_exc_name() << std::endl; + } + Vector local (dofs_per_cell); + + try + { + cell->set_dof_values_by_interpolation (local, solution); } catch (const ExceptionBase &e) { diff --git a/tests/hp/set_dof_values_by_interpolation_01.debug.output b/tests/hp/set_dof_values_by_interpolation_01.debug.output index ba7953b18d..57dc42ca78 100644 --- a/tests/hp/set_dof_values_by_interpolation_01.debug.output +++ b/tests/hp/set_dof_values_by_interpolation_01.debug.output @@ -1,7 +1,13 @@ +DEAL::Yes, exception 1! +DEAL::ExcMessage ("In hp::DoFHandler objects, finite elements are only associated " "with active cells. Consequently, you can not ask for the " "active finite element on cells with children.") DEAL::Yes, exception! DEAL::ExcMessage ("You cannot call this function on non-active cells " "of hp::DoFHandler objects unless you provide an explicit " "finite element index because they do not have naturally " "associated finite element spaces associated: degrees " "of freedom are only distributed on active cells for which " "the active_fe_index has been set.") +DEAL::Yes, exception 1! +DEAL::ExcMessage ("In hp::DoFHandler objects, finite elements are only associated " "with active cells. Consequently, you can not ask for the " "active finite element on cells with children.") DEAL::Yes, exception! DEAL::ExcMessage ("You cannot call this function on non-active cells " "of hp::DoFHandler objects unless you provide an explicit " "finite element index because they do not have naturally " "associated finite element spaces associated: degrees " "of freedom are only distributed on active cells for which " "the active_fe_index has been set.") +DEAL::Yes, exception 1! +DEAL::ExcMessage ("In hp::DoFHandler objects, finite elements are only associated " "with active cells. Consequently, you can not ask for the " "active finite element on cells with children.") DEAL::Yes, exception! DEAL::ExcMessage ("You cannot call this function on non-active cells " "of hp::DoFHandler objects unless you provide an explicit " "finite element index because they do not have naturally " "associated finite element spaces associated: degrees " "of freedom are only distributed on active cells for which " "the active_fe_index has been set.") -- 2.39.5