Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- implement DataOut::get_cell_selection - add tests to check using set_cell_selection with non-active tests Basis for of #9100
- Loading branch information
Showing
7 changed files
with
843 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2006 - 2016 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 sequential DataOut::set_cell_selection for multilevel cells | ||
|
||
#include <deal.II/dofs/dof_handler.h> | ||
|
||
#include <deal.II/grid/grid_generator.h> | ||
#include <deal.II/grid/tria.h> | ||
#include <deal.II/grid/tria_accessor.h> | ||
#include <deal.II/grid/tria_iterator.h> | ||
|
||
#include <deal.II/numerics/data_out.h> | ||
|
||
#include "../tests.h" | ||
|
||
using namespace dealii; | ||
|
||
template <int dim> | ||
void | ||
print(DataOut<dim> &data_out, const Triangulation<dim> &tria) | ||
{ | ||
auto &p = data_out.get_cell_selection(); | ||
|
||
for (auto cell = p.first(tria); cell.state() == IteratorState::valid; | ||
cell = p.second(tria, cell)) | ||
{ | ||
deallog << " cell lvl=" << cell->level() << " active=" << cell->active() | ||
<< " id=" << cell->id().to_string() << std::endl; | ||
} | ||
} | ||
|
||
template <int dim> | ||
void | ||
do_test() | ||
{ | ||
Triangulation<dim> triangulation( | ||
Triangulation<dim>::limit_level_difference_at_vertices); | ||
GridGenerator::hyper_cube(triangulation); | ||
triangulation.refine_global(1); | ||
triangulation.begin_active()->set_refine_flag(); | ||
triangulation.execute_coarsening_and_refinement(); | ||
|
||
deallog << "dim= " << dim << " cells=" << triangulation.n_cells() | ||
<< std::endl; | ||
|
||
DataOut<dim> data_out; | ||
data_out.attach_triangulation(triangulation); | ||
deallog << "* default:" << std::endl; | ||
print(data_out, triangulation); | ||
|
||
deallog << "* all cells:" << std::endl; | ||
data_out.set_cell_selection( | ||
[](const typename Triangulation<dim>::cell_iterator &cell) { | ||
return true; | ||
}); | ||
print(data_out, triangulation); | ||
|
||
deallog << "* all cells with level <=1:" << std::endl; | ||
data_out.set_cell_selection( | ||
[](const typename Triangulation<dim>::cell_iterator &cell) { | ||
return (cell->level() <= 1); | ||
}); | ||
print(data_out, triangulation); | ||
|
||
for (unsigned int level = 0; level < triangulation.n_levels(); ++level) | ||
{ | ||
deallog << "* LevelEqualTo " << level << std::endl; | ||
DataOut<dim> data_out; | ||
data_out.attach_triangulation(triangulation); | ||
|
||
data_out.set_cell_selection(IteratorFilters::LevelEqualTo(level)); | ||
print(data_out, triangulation); | ||
} | ||
} | ||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1); | ||
mpi_initlog(); | ||
|
||
do_test<2>(); | ||
do_test<3>(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
|
||
DEAL::dim= 2 cells=9 | ||
DEAL::* default: | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL:: cell lvl=2 active=1 id=0_2:00 | ||
DEAL:: cell lvl=2 active=1 id=0_2:01 | ||
DEAL:: cell lvl=2 active=1 id=0_2:02 | ||
DEAL:: cell lvl=2 active=1 id=0_2:03 | ||
DEAL::* all cells: | ||
DEAL:: cell lvl=0 active=0 id=0_0: | ||
DEAL:: cell lvl=1 active=0 id=0_1:0 | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL:: cell lvl=2 active=1 id=0_2:00 | ||
DEAL:: cell lvl=2 active=1 id=0_2:01 | ||
DEAL:: cell lvl=2 active=1 id=0_2:02 | ||
DEAL:: cell lvl=2 active=1 id=0_2:03 | ||
DEAL::* all cells with level <=1: | ||
DEAL:: cell lvl=0 active=0 id=0_0: | ||
DEAL:: cell lvl=1 active=0 id=0_1:0 | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL::* LevelEqualTo 0 | ||
DEAL:: cell lvl=0 active=0 id=0_0: | ||
DEAL::* LevelEqualTo 1 | ||
DEAL:: cell lvl=1 active=0 id=0_1:0 | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL::* LevelEqualTo 2 | ||
DEAL:: cell lvl=2 active=1 id=0_2:00 | ||
DEAL:: cell lvl=2 active=1 id=0_2:01 | ||
DEAL:: cell lvl=2 active=1 id=0_2:02 | ||
DEAL:: cell lvl=2 active=1 id=0_2:03 | ||
DEAL::dim= 3 cells=17 | ||
DEAL::* default: | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL:: cell lvl=1 active=1 id=0_1:4 | ||
DEAL:: cell lvl=1 active=1 id=0_1:5 | ||
DEAL:: cell lvl=1 active=1 id=0_1:6 | ||
DEAL:: cell lvl=1 active=1 id=0_1:7 | ||
DEAL:: cell lvl=2 active=1 id=0_2:00 | ||
DEAL:: cell lvl=2 active=1 id=0_2:01 | ||
DEAL:: cell lvl=2 active=1 id=0_2:02 | ||
DEAL:: cell lvl=2 active=1 id=0_2:03 | ||
DEAL:: cell lvl=2 active=1 id=0_2:04 | ||
DEAL:: cell lvl=2 active=1 id=0_2:05 | ||
DEAL:: cell lvl=2 active=1 id=0_2:06 | ||
DEAL:: cell lvl=2 active=1 id=0_2:07 | ||
DEAL::* all cells: | ||
DEAL:: cell lvl=0 active=0 id=0_0: | ||
DEAL:: cell lvl=1 active=0 id=0_1:0 | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL:: cell lvl=1 active=1 id=0_1:4 | ||
DEAL:: cell lvl=1 active=1 id=0_1:5 | ||
DEAL:: cell lvl=1 active=1 id=0_1:6 | ||
DEAL:: cell lvl=1 active=1 id=0_1:7 | ||
DEAL:: cell lvl=2 active=1 id=0_2:00 | ||
DEAL:: cell lvl=2 active=1 id=0_2:01 | ||
DEAL:: cell lvl=2 active=1 id=0_2:02 | ||
DEAL:: cell lvl=2 active=1 id=0_2:03 | ||
DEAL:: cell lvl=2 active=1 id=0_2:04 | ||
DEAL:: cell lvl=2 active=1 id=0_2:05 | ||
DEAL:: cell lvl=2 active=1 id=0_2:06 | ||
DEAL:: cell lvl=2 active=1 id=0_2:07 | ||
DEAL::* all cells with level <=1: | ||
DEAL:: cell lvl=0 active=0 id=0_0: | ||
DEAL:: cell lvl=1 active=0 id=0_1:0 | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL:: cell lvl=1 active=1 id=0_1:4 | ||
DEAL:: cell lvl=1 active=1 id=0_1:5 | ||
DEAL:: cell lvl=1 active=1 id=0_1:6 | ||
DEAL:: cell lvl=1 active=1 id=0_1:7 | ||
DEAL::* LevelEqualTo 0 | ||
DEAL:: cell lvl=0 active=0 id=0_0: | ||
DEAL::* LevelEqualTo 1 | ||
DEAL:: cell lvl=1 active=0 id=0_1:0 | ||
DEAL:: cell lvl=1 active=1 id=0_1:1 | ||
DEAL:: cell lvl=1 active=1 id=0_1:2 | ||
DEAL:: cell lvl=1 active=1 id=0_1:3 | ||
DEAL:: cell lvl=1 active=1 id=0_1:4 | ||
DEAL:: cell lvl=1 active=1 id=0_1:5 | ||
DEAL:: cell lvl=1 active=1 id=0_1:6 | ||
DEAL:: cell lvl=1 active=1 id=0_1:7 | ||
DEAL::* LevelEqualTo 2 | ||
DEAL:: cell lvl=2 active=1 id=0_2:00 | ||
DEAL:: cell lvl=2 active=1 id=0_2:01 | ||
DEAL:: cell lvl=2 active=1 id=0_2:02 | ||
DEAL:: cell lvl=2 active=1 id=0_2:03 | ||
DEAL:: cell lvl=2 active=1 id=0_2:04 | ||
DEAL:: cell lvl=2 active=1 id=0_2:05 | ||
DEAL:: cell lvl=2 active=1 id=0_2:06 | ||
DEAL:: cell lvl=2 active=1 id=0_2:07 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// --------------------------------------------------------------------- | ||
// | ||
// Copyright (C) 2006 - 2016 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 parallel DataOut::set_cell_selection for multilevel cells | ||
|
||
#include <deal.II/distributed/tria.h> | ||
|
||
#include <deal.II/dofs/dof_handler.h> | ||
|
||
#include <deal.II/grid/grid_generator.h> | ||
#include <deal.II/grid/tria_accessor.h> | ||
#include <deal.II/grid/tria_iterator.h> | ||
|
||
#include <deal.II/numerics/data_out.h> | ||
|
||
#include "../tests.h" | ||
|
||
using namespace dealii; | ||
|
||
template <int dim> | ||
void | ||
print(DataOut<dim> &data_out, const Triangulation<dim> &tria) | ||
{ | ||
auto &p = data_out.get_cell_selection(); | ||
|
||
for (auto cell = p.first(tria); cell.state() == IteratorState::valid; | ||
cell = p.second(tria, cell)) | ||
{ | ||
deallog << " cell lvl=" << cell->level() << " active=" << cell->active() | ||
<< " owner=" << static_cast<int>(cell->level_subdomain_id()) | ||
<< " id=" << cell->id().to_string() << std::endl; | ||
} | ||
} | ||
|
||
template <int dim> | ||
void | ||
do_test() | ||
{ | ||
parallel::distributed::Triangulation<dim> triangulation( | ||
MPI_COMM_WORLD, | ||
dealii::Triangulation<dim>::none, | ||
parallel::distributed::Triangulation<dim>::construct_multigrid_hierarchy); | ||
|
||
GridGenerator::hyper_cube(triangulation); | ||
triangulation.refine_global(1); | ||
triangulation.begin_active()->set_refine_flag(); | ||
triangulation.execute_coarsening_and_refinement(); | ||
|
||
deallog << "dim= " << dim << " cells=" << triangulation.n_cells() | ||
<< std::endl; | ||
|
||
DataOut<dim> data_out; | ||
data_out.attach_triangulation(triangulation); | ||
|
||
deallog << "* default:" << std::endl; | ||
print(data_out, triangulation); | ||
|
||
deallog << "* all cells:" << std::endl; | ||
data_out.set_cell_selection( | ||
[](const typename Triangulation<dim>::cell_iterator &cell) { | ||
return true; | ||
}); | ||
print(data_out, triangulation); | ||
|
||
deallog << "* LocallyOwnedLevelCell:" << std::endl; | ||
data_out.set_cell_selection(IteratorFilters::LocallyOwnedLevelCell()); | ||
print(data_out, triangulation); | ||
|
||
for (unsigned int level = 0; level < triangulation.n_global_levels(); ++level) | ||
{ | ||
DataOut<dim> data_out; | ||
data_out.attach_triangulation(triangulation); | ||
|
||
deallog << "* LevelEqualTo " << level << std::endl; | ||
data_out.set_cell_selection(IteratorFilters::LevelEqualTo(level)); | ||
print(data_out, triangulation); | ||
|
||
deallog << "* owned on level " << level << std::endl; | ||
data_out.set_cell_selection( | ||
[level](const typename Triangulation<dim>::cell_iterator &cell) { | ||
return (cell->level() == level && cell->is_locally_owned_on_level()); | ||
}); | ||
print(data_out, triangulation); | ||
} | ||
} | ||
|
||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
Utilities::MPI::MPI_InitFinalize mpi(argc, argv, 1); | ||
MPILogInitAll log; | ||
|
||
do_test<2>(); | ||
do_test<3>(); | ||
return 0; | ||
} |
Oops, something went wrong.