From 7924d82e4fcbdc1bf3e080ccf3d21b827c0bbd76 Mon Sep 17 00:00:00 2001 From: =?utf8?q?B=C3=A4rbel=20Janssen?= Date: Fri, 12 Sep 2014 15:01:23 +0200 Subject: [PATCH] use the fe index also in the case where triangulation was prepared for pure refinement and add test that would fail without the patch and works fine now --- source/numerics/solution_transfer.cc | 3 +- tests/hp/solution_transfer_11.cc | 99 ++++++++++++++++++++++++++++ tests/hp/solution_transfer_11.output | 4 ++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 tests/hp/solution_transfer_11.cc create mode 100644 tests/hp/solution_transfer_11.output diff --git a/source/numerics/solution_transfer.cc b/source/numerics/solution_transfer.cc index f7f38b4c26..a79c72a64a 100644 --- a/source/numerics/solution_transfer.cc +++ b/source/numerics/solution_transfer.cc @@ -94,7 +94,8 @@ void SolutionTransfer::prepare_for_pure_refinement() // out of the data vectors and prolonging // them to the children cell->get_dof_indices(indices_on_cell[i]); - cell_map[std::make_pair(cell->level(),cell->index())].indices_ptr=&indices_on_cell[i]; + cell_map[std::make_pair(cell->level(),cell->index())] + = Pointerstruct(&indices_on_cell[i], cell->active_fe_index()); } prepared_for=pure_refinement; } diff --git a/tests/hp/solution_transfer_11.cc b/tests/hp/solution_transfer_11.cc new file mode 100644 index 0000000000..ad2d81864e --- /dev/null +++ b/tests/hp/solution_transfer_11.cc @@ -0,0 +1,99 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2011 - 2013 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. +// +// --------------------------------------------------------------------- + + +//Test to check if the actual fe_index is used in SolutionTransfer + +#include "../tests.h" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +template +void transfer(std::ostream &out) +{ + Triangulation tria; + GridGenerator::hyper_cube(tria); + tria.refine_global(1); + + hp::FECollection fe; + fe.push_back (FE_Q (1)); + fe.push_back (FE_Q (2)); + + hp::DoFHandler dof_handler(tria); + dof_handler.begin(0)->child(0)->set_active_fe_index(1); + + Vector solution; + + dof_handler.distribute_dofs (fe); + solution.reinit(dof_handler.n_dofs()); + + for (unsigned int i=0; i,hp::DoFHandler > soltrans(dof_handler); + + typename Triangulation::active_cell_iterator cell=tria.begin_active(), + endc=tria.end(); + ++cell; + ++cell; + for (; cell!=endc; ++cell) + cell->set_refine_flag(); + + Vector old_solution=solution; + tria.prepare_coarsening_and_refinement(); + soltrans.prepare_for_pure_refinement(); + tria.execute_coarsening_and_refinement(); + dof_handler.distribute_dofs (fe); + solution.reinit(dof_handler.n_dofs()); + soltrans.refine_interpolate(old_solution, solution); +} + + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + deallog << " 1D solution transfer" << std::endl; + transfer<1>(logfile); + + deallog << " 2D solution transfer" << std::endl; + transfer<2>(logfile); + + deallog << " 3D solution transfer" << std::endl; + transfer<3>(logfile); +} + + + diff --git a/tests/hp/solution_transfer_11.output b/tests/hp/solution_transfer_11.output new file mode 100644 index 0000000000..76a5bc702c --- /dev/null +++ b/tests/hp/solution_transfer_11.output @@ -0,0 +1,4 @@ + +DEAL:: 1D solution transfer +DEAL:: 2D solution transfer +DEAL:: 3D solution transfer -- 2.39.5