From: Daniel Arndt Date: Wed, 2 Jun 2021 15:56:17 +0000 (-0400) Subject: Remove DataOut::first_cell() and DataOut::next_cell() X-Git-Tag: v9.4.0-rc1~1285^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F12382%2Fhead;p=dealii.git Remove DataOut::first_cell() and DataOut::next_cell() --- diff --git a/doc/news/changes/incompatibilities/20210602DanielArndt-1 b/doc/news/changes/incompatibilities/20210602DanielArndt-1 new file mode 100644 index 0000000000..b6999e2d91 --- /dev/null +++ b/doc/news/changes/incompatibilities/20210602DanielArndt-1 @@ -0,0 +1,4 @@ +Removed: The deprecated member functions DataOut::first_cell() and DataOut::next_cell() +have been removed. +
+(Daniel Arndt, 2021/06/02) diff --git a/include/deal.II/numerics/data_out.h b/include/deal.II/numerics/data_out.h index cdd7a14717..39c20cd0ff 100644 --- a/include/deal.II/numerics/data_out.h +++ b/include/deal.II/numerics/data_out.h @@ -118,16 +118,16 @@ namespace internal * small to be seen individually) or because you only want to see a certain * region of the domain (for example only in the fluid part of the domain in * step-46), or for some other reason. - * - * For this, internally build_patches() does not generate the sequence of - * cells to be converted into patches itself, but relies on the two function - * that we'll call first_cell() and next_cell(). By default, they return the - * first active cell, and the next active cell, respectively. But this can - * be changed using the set_cell_selection() function that allows you to - * replace this behavior. What set_cell_selection() wants to know is how - * you want to pick out the first cell on which output should be generated, - * and how given one cell on which output is generated you want to pick the - * next cell. + + * For this, internally build_patches() does not generate the sequence of cells + * to be converted into patches itself, but relies on the two private + * std::function objects first_cell_function() and next_cell_function(). By + * default, they return the first active cell, and the next active cell, + * respectively. But this can be changed using the set_cell_selection() function + * that allows you to replace this behavior. What set_cell_selection() wants to + * know is how you want to pick out the first cell on which output should be + * generated, and how given one cell on which output is generated you want to + * pick the next cell. * * This may, * for example, include only cells that are in parts of a domain (e.g., if you @@ -416,35 +416,6 @@ public: const std::pair get_cell_selection() const; - /** - * Return the first cell which we want output for. The default - * implementation returns the first active cell, but you might want to - * return other cells in a derived class. - * - * @deprecated Use the set_cell_selection() function instead. - */ - DEAL_II_DEPRECATED - virtual cell_iterator - first_cell(); - - /** - * Return the next cell after @p cell which we want output for. If there - * are no more cells, any implementation of this function should return - * dof_handler->end(). - * - * The default implementation returns the next active cell, but you might - * want to return other cells in a derived class. Note that the default - * implementation assumes that the given @p cell is active, which is - * guaranteed as long as first_cell() is also used from the default - * implementation. Overloading only one of the two functions might not be a - * good idea. - * - * @deprecated Use the set_cell_selection() function instead. - */ - DEAL_II_DEPRECATED - virtual cell_iterator - next_cell(const cell_iterator &cell); - private: /** * A function object that is used to select what the first cell is going to @@ -463,28 +434,6 @@ private: const cell_iterator &)> next_cell_function; - /** - * Return the first cell produced by the first_cell()/next_cell() function - * pair that is locally owned. If this object operates on a non-distributed - * triangulation, the result equals what first_cell() returns. - * - * @deprecated Use the set_cell_selection() function instead. - */ - DEAL_II_DEPRECATED - virtual cell_iterator - first_locally_owned_cell(); - - /** - * Return the next cell produced by the next_cell() function that is locally - * owned. If this object operates on a non-distributed triangulation, the - * result equals what first_cell() returns. - * - * @deprecated Use the set_cell_selection() function instead. - */ - DEAL_II_DEPRECATED - virtual cell_iterator - next_locally_owned_cell(const cell_iterator &cell); - /** * Build one patch. This function is called in a WorkStream context. * diff --git a/source/numerics/data_out.cc b/source/numerics/data_out.cc index 2507c7d819..11bb33f408 100644 --- a/source/numerics/data_out.cc +++ b/source/numerics/data_out.cc @@ -68,16 +68,25 @@ namespace internal template DataOut::DataOut() { - // For the moment, just call the existing virtual functions. This - // preserves backward compatibility. When these deprecated functions are - // removed, we'll just inline their functionality into the lambda - // functions created here. set_cell_selection( [this](const Triangulation &) { - return this->first_locally_owned_cell(); + typename Triangulation::active_cell_iterator cell = + this->triangulation->begin_active(); + + // skip cells if the current one has no children (is active) and is a + // ghost or artificial cell + while ((cell != this->triangulation->end()) && !cell->is_locally_owned()) + ++cell; + return cell; }, - [this](const Triangulation &, const cell_iterator &cell) { - return this->next_locally_owned_cell(cell); + [this](const Triangulation &, + const cell_iterator &old_cell) { + typename Triangulation::active_cell_iterator cell = + old_cell; + ++cell; + while ((cell != this->triangulation->end()) && !cell->is_locally_owned()) + ++cell; + return cell; }); } @@ -1333,60 +1342,6 @@ DataOut::get_cell_selection() const -template -typename DataOut::cell_iterator -DataOut::first_cell() -{ - return this->triangulation->begin_active(); -} - - - -template -typename DataOut::cell_iterator -DataOut::next_cell( - const typename DataOut::cell_iterator &cell) -{ - // convert the iterator to an active_iterator and advance this to the next - // active cell - typename Triangulation::active_cell_iterator active_cell = - cell; - ++active_cell; - return active_cell; -} - - - -template -typename DataOut::cell_iterator -DataOut::first_locally_owned_cell() -{ - typename DataOut::cell_iterator cell = first_cell(); - - // skip cells if the current one has no children (is active) and is a ghost - // or artificial cell - while ((cell != this->triangulation->end()) && cell->is_active() && - !cell->is_locally_owned()) - cell = next_cell(cell); - - return cell; -} - - - -template -typename DataOut::cell_iterator -DataOut::next_locally_owned_cell( - const typename DataOut::cell_iterator &old_cell) -{ - typename DataOut::cell_iterator cell = next_cell(old_cell); - while ((cell != this->triangulation->end()) && cell->is_active() && - !cell->is_locally_owned()) - cell = next_cell(cell); - return cell; -} - - // explicit instantiations #include "data_out.inst" diff --git a/tests/data_out/data_out_08.cc b/tests/data_out/data_out_08.cc deleted file mode 100644 index eec6a3ef53..0000000000 --- a/tests/data_out/data_out_08.cc +++ /dev/null @@ -1,145 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2003 - 2020 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.md at -// the top level directory of deal.II. -// -// --------------------------------------------------------------------- - - -// This test documents two unrelated bugs in DataOut when used with a Filter (by -// deriving from DataOut): -// 1. The patch index computation in data_out.cc is wrong and causes an SIGV (or -// an Assert after adding that): -/* -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, DoFHandlerType = -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() -*/ -// 2. DataOut used begin_active() instead of first_cell() in two places which -// caused a wrong patch to be generated when the first active cell is not picked -// by the filter. - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -#include - -#include "../tests.h" - - -template -class FilteredDataOut : public DataOut -{ -public: - FilteredDataOut(const unsigned int subdomain_id) - : subdomain_id(subdomain_id) - {} - - virtual typename DataOut::cell_iterator - first_cell() - { - auto 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->set_subdomain_id(1); - - FE_DGQ fe(0); - DoFHandler dof_handler(tria); - dof_handler.distribute_dofs(fe); - - // we pick only subdomain==0 which will - // skip the first of the four cells - FilteredDataOut data_out(0); - data_out.attach_dof_handler(dof_handler); - - data_out.add_data_vector(cell_data, - "cell_data", - DataOut::type_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) -{ - initlog(); - deallog << std::setprecision(2); - - check<2>(); - - return 0; -} diff --git a/tests/data_out/data_out_08.output b/tests/data_out/data_out_08.output deleted file mode 100644 index bd4f3f7361..0000000000 --- a/tests/data_out/data_out_08.output +++ /dev/null @@ -1,38 +0,0 @@ - -2 2 -[deal.II intermediate format graphics data] -[written by deal.II x.y.z] -[Version: 3] -1 -cell_data -3 -[deal.II intermediate Patch<2,2>] -0.50 0.0 1.0 0.0 1.0 0.50 0.50 0.50 -4294967295 4294967295 4294967295 2 -0 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 2 4294967295 4294967295 -1 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 -1 4294967295 0 4294967295 -2 1 -0 -1 4 -3.0 3.0 3.0 3.0 - - -0 - -DEAL::OK diff --git a/tests/mpi/p4est_2d_constraintmatrix_04.cc b/tests/mpi/p4est_2d_constraintmatrix_04.cc index 63db8eac75..e9c99c3b66 100644 --- a/tests/mpi/p4est_2d_constraintmatrix_04.cc +++ b/tests/mpi/p4est_2d_constraintmatrix_04.cc @@ -56,44 +56,6 @@ const double T1 = 2.0; -template -class FilteredDataOut : public DataOut -{ -public: - FilteredDataOut(const unsigned int subdomain_id) - : subdomain_id(subdomain_id) - {} - - virtual typename DataOut::cell_iterator - first_cell() - { - auto cell = this->triangulation->begin_active(); - while ((cell != this->triangulation->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->triangulation->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 class TemperatureInitialValues : public Function { @@ -287,7 +249,32 @@ test() std::vector solution_names(1, "T"); - FilteredDataOut data_out(tr.locally_owned_subdomain()); + DataOut data_out; + data_out.set_cell_selection( + [](const Triangulation &t) { + auto cell = t.begin_active(); + while ((cell != t.end()) && + (cell->subdomain_id() != t.locally_owned_subdomain())) + ++cell; + + return cell; + }, + + [](const Triangulation & t, + const typename Triangulation::cell_iterator &old_cell) -> + typename Triangulation::cell_iterator { + if (old_cell != t.end()) + { + const IteratorFilters::SubdomainEqualTo predicate( + t.locally_owned_subdomain()); + + return ++( + FilteredIterator::active_cell_iterator>( + predicate, old_cell)); + } + else + return old_cell; + }); data_out.attach_dof_handler(dofh); data_out.add_data_vector(x_rel, solution_names); diff --git a/tests/mpi/p4est_3d_constraintmatrix_03.cc b/tests/mpi/p4est_3d_constraintmatrix_03.cc index 2ad23eddef..e715ff158a 100644 --- a/tests/mpi/p4est_3d_constraintmatrix_03.cc +++ b/tests/mpi/p4est_3d_constraintmatrix_03.cc @@ -56,44 +56,6 @@ const double T1 = 2.0; -template -class FilteredDataOut : public DataOut -{ -public: - FilteredDataOut(const unsigned int subdomain_id) - : subdomain_id(subdomain_id) - {} - - virtual typename DataOut::cell_iterator - first_cell() - { - auto cell = this->triangulation->begin_active(); - while ((cell != this->triangulation->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->triangulation->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 class TemperatureInitialValues : public Function { @@ -287,7 +249,32 @@ test() std::vector solution_names(1, "T"); - FilteredDataOut data_out(tr.locally_owned_subdomain()); + DataOut data_out; + data_out.set_cell_selection( + [](const Triangulation &t) { + auto cell = t.begin_active(); + while ((cell != t.end()) && + (cell->subdomain_id() != t.locally_owned_subdomain())) + ++cell; + + return cell; + }, + + [](const Triangulation & t, + const typename Triangulation::cell_iterator &old_cell) -> + typename Triangulation::cell_iterator { + if (old_cell != t.end()) + { + const IteratorFilters::SubdomainEqualTo predicate( + t.locally_owned_subdomain()); + + return ++( + FilteredIterator::active_cell_iterator>( + predicate, old_cell)); + } + else + return old_cell; + }); data_out.attach_dof_handler(dofh); data_out.add_data_vector(x_rel, solution_names);