From 58aff881d16540e0aa860c43d34c701b9560478b Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 9 Jan 2014 00:11:48 +0000 Subject: [PATCH] Fix more bugs... git-svn-id: https://svn.dealii.org/trunk@32181 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/fe/fe.cc | 7 +- tests/hp/do_function_hessians_01.cc | 120 ++++++++++++++++++++++++ tests/hp/do_function_hessians_01.output | 2 + 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 tests/hp/do_function_hessians_01.cc create mode 100644 tests/hp/do_function_hessians_01.output diff --git a/deal.II/source/fe/fe.cc b/deal.II/source/fe/fe.cc index f8c0482261..df61dbc73a 100644 --- a/deal.II/source/fe/fe.cc +++ b/deal.II/source/fe/fe.cc @@ -1,7 +1,7 @@ // --------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1998 - 2013 by the deal.II authors +// Copyright (C) 1998 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -1248,6 +1248,11 @@ FiniteElement::compute_2nd ( & update_hessians, ExcInternalError()); + // there is nothing to do if there are no degrees of freedom (e.g., in an + // FE_Nothing) + if (this->dofs_per_cell == 0) + return; + // make sure we have as many entries as there are nonzero components // Assert (data.shape_hessians.size() == // std::accumulate (n_nonzero_components_table.begin(), diff --git a/tests/hp/do_function_hessians_01.cc b/tests/hp/do_function_hessians_01.cc new file mode 100644 index 0000000000..c2022df1a4 --- /dev/null +++ b/tests/hp/do_function_hessians_01.cc @@ -0,0 +1,120 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2011 - 2014 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// testcase by Minh Do-Quang: a case where SolutionTransfer got into trouble +// in a couple of places when using FE_Nothing and FESystem. + +#include "../tests.h" +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +using namespace dealii; + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + Triangulation<2> triangulation; + GridGenerator::hyper_cube (triangulation); + triangulation.refine_global (1); + + + hp::FECollection<2> fe_collection; + + fe_collection.push_back(FESystem<2>(FE_Q<2>(1), 1, FE_Q<2>(1), 1)); + fe_collection.push_back(FESystem<2>(FE_Nothing<2>(), 1, FE_Nothing<2>(), 1)); + + hp::DoFHandler<2> dof_handler(triangulation); + + // Assign FE to cells + hp::DoFHandler<2>::active_cell_iterator cell; + hp::DoFHandler<2>::active_cell_iterator endc = dof_handler.end(); + + + cell = dof_handler.begin_active(); + cell->set_active_fe_index(1); + cell++; + cell->set_active_fe_index(1); + cell++; + cell->set_active_fe_index(0); + cell++; + cell->set_active_fe_index(0); + + + dof_handler.distribute_dofs (fe_collection); + + // Init solution + Vector solution(dof_handler.n_dofs()); + solution = 1.0; + + + SolutionTransfer<2, Vector, hp::DoFHandler<2> > solultion_trans(dof_handler); + solultion_trans.prepare_for_coarsening_and_refinement(solution); + + triangulation.execute_coarsening_and_refinement (); + dof_handler.distribute_dofs (fe_collection); + + Vector new_solution(dof_handler.n_dofs()); + solultion_trans.interpolate(solution, new_solution); + + hp::QCollection<2> q; + q.push_back(QMidpoint<2>()); + q.push_back(QMidpoint<2>()); + hp::FEValues<2> x_fe_values (fe_collection, q, update_hessians); + for (typename hp::DoFHandler<2>::active_cell_iterator cell = dof_handler.begin_active(); + cell != dof_handler.end(); ++cell) + { + x_fe_values.reinit (cell); + std::vector > > + derivatives (q[0].size(), std::vector >(cell->get_fe().n_components())); + + x_fe_values.get_present_fe_values().get_function_hessians (new_solution, + derivatives); + } + + // we are good if we made it to here + deallog << "OK" << std::endl; +} + + + diff --git a/tests/hp/do_function_hessians_01.output b/tests/hp/do_function_hessians_01.output new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/hp/do_function_hessians_01.output @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5