From 93aaf304f42cfb52163e7c28373d70d81a5c15ba Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sat, 17 Aug 2013 04:31:24 +0000 Subject: [PATCH] Add testcase for bug #83. git-svn-id: https://svn.dealii.org/trunk@30331 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/hp/solution_transfer_03.cc | 123 ++++++++++++++++++++++ tests/hp/solution_transfer_03/cmp/generic | 33 ++++++ 2 files changed, 156 insertions(+) create mode 100644 tests/hp/solution_transfer_03.cc create mode 100644 tests/hp/solution_transfer_03/cmp/generic diff --git a/tests/hp/solution_transfer_03.cc b/tests/hp/solution_transfer_03.cc new file mode 100644 index 0000000000..82a08810ab --- /dev/null +++ b/tests/hp/solution_transfer_03.cc @@ -0,0 +1,123 @@ +// --------------------------------------------------------------------- +// $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. +// +// --------------------------------------------------------------------- + + + +// SolutionTransfer got into trouble when interpolating between an old and a +// new mesh where some cells are set to use FENothing, see bug #83 +// (https://code.google.com/p/dealii/issues/detail?id=83) +// +// the testcase is really invalid -- it forgot to call +// Triangulation::execute_c_and_r but the error is completely unhelpful + +#include "../tests.h" +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + + + +int main() +{ + std::ofstream logfile("solution_transfer_03/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::DoFHandler<2> dof_handler(triangulation); + hp::FECollection<2> fe_collection; + + + fe_collection.push_back(FE_Q<2>(1)); + fe_collection.push_back(FE_Nothing<2>()); + + + // 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; + + + // Save output + DataOut<2, hp::DoFHandler<2> > data_out; + data_out.attach_dof_handler (dof_handler); + data_out.add_data_vector (solution, "Solution"); + data_out.build_patches(); + data_out.write_vtu (deallog.get_file_stream()); + + + // Assign FE_Q_ to all cells + cell = dof_handler.begin_active(); + for( ; cell != endc; ++cell){ + cell->set_active_fe_index(0); + } + + + // Interpoalte solution + 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); + + + // Save output + DataOut<2, hp::DoFHandler<2> > data_out2; + data_out2.attach_dof_handler (dof_handler); + data_out2.add_data_vector (new_solution, "Solution"); + data_out2.build_patches(); + data_out2.write_vtu(deallog.get_file_stream()); +} + + + diff --git a/tests/hp/solution_transfer_03/cmp/generic b/tests/hp/solution_transfer_03/cmp/generic new file mode 100644 index 0000000000..088afdba56 --- /dev/null +++ b/tests/hp/solution_transfer_03/cmp/generic @@ -0,0 +1,33 @@ + + + + + + + + +AQAAAIABAACAAQAAMwAAAA==eNpjYMAHHtgzkCQP4+MSRwcf7PGbi67vgz1+84h1Dy77Yeo+2FPmHlzmfMAQBwBtNxtp + + + + + +AQAAAEAAAABAAAAAKAAAAA==eNoNwwkSwBAQALB1VIvi/7+VzCQiIlnMVh9fm5/d6fB3edxeCvAAeQ== + + +AQAAABAAAAAQAAAAEwAAAA==eNpjYWBg4ABiHiAWAGIAAVAAKQ== + + +AQAAAAQAAAAEAAAADAAAAA==eNrj5OTkBAAAXgAl + + + + +AQAAAIAAAACAAAAAEAAAAA==eNpjYKAG+GBPLg0AGqcJeQ== + + + + -- 2.39.5