From 6a41c0c0035bd3eceb78e062b1e9218acba3bac9 Mon Sep 17 00:00:00 2001 From: heister Date: Wed, 16 Oct 2013 18:40:35 +0000 Subject: [PATCH] add failing test git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31266 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/bits/data_out_08.cc | 138 ++++++++++++++++++++++++++++++++++ tests/bits/data_out_08.output | 47 ++++++++++++ 2 files changed, 185 insertions(+) create mode 100644 tests/bits/data_out_08.cc create mode 100644 tests/bits/data_out_08.output diff --git a/tests/bits/data_out_08.cc b/tests/bits/data_out_08.cc new file mode 100644 index 0000000000..4457b91a83 --- /dev/null +++ b/tests/bits/data_out_08.cc @@ -0,0 +1,138 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2003 - 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. +// +// --------------------------------------------------------------------- + + + +// Bug: filtered DataOut is not picking the correct cells +// This is due to wrong index computation in data_out.cc. +/* +466: -------------------------------------------------------- +466: An error occurred in line <306> of file in function +466: void dealii::DataOut::build_one_patch(const std::pair::cell_iterator, unsigned int>*, dealii::internal::DataOut::ParallelData&, dealii::DataOutBase::Patch&, dealii::DataOut::CurvedCellRegion, std::vector >&) [with int dim = 2, DH = dealii::DoFHandler<2>, typename dealii::DataOut_DoFData::cell_iterator = dealii::TriaIterator >] +466: The violated condition was: +466: cell_and_index->second < patches.size() +466: The name and call sequence of the exception was: +466: ExcInternalError() +*/ + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +std::string output_file_name = "output"; + +template + class FilteredDataOut : public DataOut + { + public: + FilteredDataOut (const unsigned int subdomain_id) + : + subdomain_id (subdomain_id) + {} + + virtual typename DataOut::cell_iterator + first_cell () + { + typename DataOut::active_cell_iterator + cell = this->dofs->begin_active(); + while ((cell != this->dofs->end()) && + (cell->subdomain_id() != subdomain_id)) + ++cell; + + return cell; + } + + virtual typename DataOut::cell_iterator + next_cell (const typename DataOut::cell_iterator &old_cell) + { + if (old_cell != this->dofs->end()) + { + const IteratorFilters::SubdomainEqualTo + predicate(subdomain_id); + + return + ++(FilteredIterator + ::active_cell_iterator> + (predicate,old_cell)); + } + else + return old_cell; + } + + private: + const unsigned int subdomain_id; + }; + + +template +void +check () +{ + Triangulation tria; + GridGenerator::hyper_cube(tria, 0., 1.); + tria.refine_global (1); + + Vector cell_data(4); + for (unsigned int i=0;i<4;++i) + cell_data(i)=i*1.0; + + // this should skip the first cell + typename Triangulation::active_cell_iterator it = tria.begin_active(); + //++it; + it->set_subdomain_id(1); + + FE_DGQ fe(0); + DoFHandler dof_handler (tria); + dof_handler.distribute_dofs (fe); + + // DataOut data_out; + + // we pick only subdomain==0 which will + // skip the first of four cells + FilteredDataOut data_out(0); + data_out.attach_dof_handler (dof_handler); + + data_out.add_data_vector (cell_data, "cell_data"); + data_out.build_patches (); + + data_out.write_deal_II_intermediate (deallog.get_file_stream()); + + deallog << "OK" << std::endl; +} + +int +main(int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv); + std::ofstream logfile(output_file_name.c_str()); + deallog << std::setprecision (2); + logfile << std::setprecision (2); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check<2>(); + + return 0; +} diff --git a/tests/bits/data_out_08.output b/tests/bits/data_out_08.output new file mode 100644 index 0000000000..39fa1b48fe --- /dev/null +++ b/tests/bits/data_out_08.output @@ -0,0 +1,47 @@ + +2 2 +[deal.II intermediate format graphics data] +[written by deal.II x.y.z] +[Version: 3] +1 +cell_data +4 +[deal.II intermediate Patch<2,2>] +0.0 0.0 0.50 0.0 0.50 0.50 0.0 0.50 +4294967295 1 4294967295 2 +0 1 +0 +1 4 +0.0 0.0 0.0 0.0 + + +[deal.II intermediate Patch<2,2>] +0.50 0.0 1.0 0.0 1.0 0.50 0.50 0.50 +0 4294967295 4294967295 3 +1 1 +0 +1 4 +1.0 1.0 1.0 1.0 + + +[deal.II intermediate Patch<2,2>] +0.0 0.50 0.50 0.50 0.50 1.0 0.0 1.0 +4294967295 3 0 4294967295 +2 1 +0 +1 4 +2.0 2.0 2.0 2.0 + + +[deal.II intermediate Patch<2,2>] +0.50 0.50 1.0 0.50 1.0 1.0 0.50 1.0 +2 4294967295 1 4294967295 +3 1 +0 +1 4 +3.0 3.0 3.0 3.0 + + +0 + +DEAL::OK -- 2.39.5