From b12f241703c699991368d41e757c328a49b08a63 Mon Sep 17 00:00:00 2001 From: Oliver Sutton Date: Fri, 17 Nov 2017 17:02:19 +0000 Subject: [PATCH] Add a test to ensure that refine_and_coarsen_fixed_number behaves as expected when either top_fraction or bottom_fraction are set to 1.0. --- tests/grid/refine_and_coarsen_fixed_number.cc | 61 +++++++++++++++++++ .../refine_and_coarsen_fixed_number.output | 4 ++ 2 files changed, 65 insertions(+) create mode 100644 tests/grid/refine_and_coarsen_fixed_number.cc create mode 100644 tests/grid/refine_and_coarsen_fixed_number.output diff --git a/tests/grid/refine_and_coarsen_fixed_number.cc b/tests/grid/refine_and_coarsen_fixed_number.cc new file mode 100644 index 0000000000..563d63c7d2 --- /dev/null +++ b/tests/grid/refine_and_coarsen_fixed_number.cc @@ -0,0 +1,61 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 2017 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. +// +// --------------------------------------------------------------------- + +// This test ensures that all cells get refined (resp. coarsened) when +// the value 1.0 is passed as top_fraction (resp. bottom_fraction) to +// the function GridRefinement::refine_and_coarsen_fixed_number. + +#include "../tests.h" +#include +#include +#include +#include + +using namespace dealii; + +int main(int argc, const char *argv[]) +{ + initlog(); + + Triangulation<2> tria; + GridGenerator::hyper_cube (tria); + tria.refine_global(4); + + Vector indicator(tria.n_active_cells()); + for (int i = 0; i != indicator.size(); ++i) + { + indicator[i] = i; + } + + deallog << "n_active_cells: " << tria.n_active_cells() << std::endl; + + GridRefinement::refine_and_coarsen_fixed_number(tria, indicator, 1.0, 0.0); + tria.execute_coarsening_and_refinement(); + + deallog << "n_active_cells: " << tria.n_active_cells() << std::endl; + + indicator.reinit(tria.n_active_cells()); + for (int i = 0; i != indicator.size(); ++i) + { + indicator[i] = i; + } + + GridRefinement::refine_and_coarsen_fixed_number(tria, indicator, 0.0, 1.0); + tria.execute_coarsening_and_refinement(); + + deallog << "n_active_cells: " << tria.n_active_cells() << std::endl; + + return 0; +} diff --git a/tests/grid/refine_and_coarsen_fixed_number.output b/tests/grid/refine_and_coarsen_fixed_number.output new file mode 100644 index 0000000000..94c18282d7 --- /dev/null +++ b/tests/grid/refine_and_coarsen_fixed_number.output @@ -0,0 +1,4 @@ + +DEAL::n_active_cells: 256 +DEAL::n_active_cells: 1024 +DEAL::n_active_cells: 256 -- 2.39.5