From: bangerth Date: Tue, 21 Jan 2014 06:20:58 +0000 (+0000) Subject: Fix a recently introduced problem with SolutionTransfer. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30ebbe4deac95c5a9118c52c99a33d1cd7dc47f6;p=dealii-svn.git Fix a recently introduced problem with SolutionTransfer. git-svn-id: https://svn.dealii.org/trunk@32269 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/numerics/solution_transfer.cc b/deal.II/source/numerics/solution_transfer.cc index 8a3d59e895..b34bcaec37 100644 --- a/deal.II/source/numerics/solution_transfer.cc +++ b/deal.II/source/numerics/solution_transfer.cc @@ -1,7 +1,7 @@ // --------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1999 - 2013 by the deal.II authors +// Copyright (C) 1999 - 2014 by the deal.II authors // // This file is part of the deal.II library. // @@ -513,8 +513,6 @@ interpolate (const std::vector &all_in, const std::vector > *const valuesptr =pointerstruct->second.dof_values_ptr; - const unsigned int dofs_per_cell=cell->get_fe().dofs_per_cell; - // cell stayed or is // refined if (indexptr) @@ -528,7 +526,6 @@ interpolate (const std::vector &all_in, // cell and prolong it // to its children unsigned int in_size = indexptr->size(); - local_values.reinit(dofs_per_cell, true); for (unsigned int j=0; j &all_in, } else { + const unsigned int dofs_per_cell + = cell->get_fe().dofs_per_cell; + AssertDimension (dofs_per_cell, indexptr->size()); + local_values.reinit (dofs_per_cell); for (unsigned int i=0; iset_dof_values_by_interpolation(local_values, - all_out[j]); + all_out[j], + cell->active_fe_index()); } } } @@ -659,6 +661,8 @@ interpolate (const std::vector &all_in, Assert (!cell->has_children(), ExcInternalError()); Assert (indexptr == 0, ExcInternalError()); + + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; dofs.resize(dofs_per_cell); // get the local // indices diff --git a/tests/hp/solution_transfer_06.cc b/tests/hp/solution_transfer_06.cc new file mode 100644 index 0000000000..6033aa983b --- /dev/null +++ b/tests/hp/solution_transfer_06.cc @@ -0,0 +1,109 @@ +// --------------------------------------------------------------------- +// $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. +// +// --------------------------------------------------------------------- + + + +// SolutionTransfer accessed the active_fe_index of the cell from which to +// interpolate to children, but this active_fe_index is now on an inactive +// cell and may no longer be valid. we need to use the number previously +// stored + +#include "../tests.h" +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + +using namespace dealii; + + +template +void test () +{ + Triangulation triangulation; + GridGenerator::hyper_cube (triangulation); + + hp::FECollection fe_collection; + fe_collection.push_back(FE_Q(1)); + fe_collection.push_back(FE_Q(2)); + + hp::DoFHandler dof_handler(triangulation); + dof_handler.begin_active()->set_active_fe_index(0); + dof_handler.distribute_dofs (fe_collection); + + // Init solution + Vector solution(dof_handler.n_dofs()); + solution = 1.0; + + + // set refine flag for the only cell we have, then do the refinement + SolutionTransfer, hp::DoFHandler > + solution_trans(dof_handler); + dof_handler.begin_active()->set_refine_flag (); + solution_trans.prepare_for_coarsening_and_refinement(solution); + triangulation.execute_coarsening_and_refinement (); + + // now set the active_fe_index flags on the new set of fine level cells, but + // also clear the one from the now inactive cell + dof_handler.begin(0)->set_active_fe_index(1); + for (unsigned int c=0; cn_children(); ++c) + dof_handler.begin(0)->child(c)->set_active_fe_index(1); + + // distribute dofs and transfer solution there + dof_handler.distribute_dofs (fe_collection); + + Vector new_solution(dof_handler.n_dofs()); + solution_trans.interpolate(solution, new_solution); + + // we should now have only 1s in the new_solution vector + for (unsigned int i=0; i (); + test<2> (); + test<3> (); +} diff --git a/tests/hp/solution_transfer_06.output b/tests/hp/solution_transfer_06.output new file mode 100644 index 0000000000..fb71de2867 --- /dev/null +++ b/tests/hp/solution_transfer_06.output @@ -0,0 +1,4 @@ + +DEAL::OK +DEAL::OK +DEAL::OK