From: Arezou Ghesmati Date: Wed, 2 Dec 2015 16:40:28 +0000 (-0600) Subject: Add tests. X-Git-Tag: v8.4.0-rc2~40^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0c75f6d675fc02fe03c4b4c1d9df467208de962;p=dealii.git Add tests. --- diff --git a/tests/grid/build_triangulation_from_patch_01.cc b/tests/grid/build_triangulation_from_patch_01.cc new file mode 100644 index 0000000000..c4f242ee2d --- /dev/null +++ b/tests/grid/build_triangulation_from_patch_01.cc @@ -0,0 +1,92 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 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 GridTools::build_triangulation_from_patch () + + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + Triangulation triangulation (Triangulation::limit_level_difference_at_vertices); + + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global (1); + + + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + { + std::vector::active_cell_iterator> patch_cells + = GridTools::get_patch_around_cell > (cell); + + Triangulation local_triangulation(Triangulation::limit_level_difference_at_vertices); + std::map::active_cell_iterator , + typename Triangulation::active_cell_iterator> patch_to_global_tria_map; + + GridTools::build_triangulation_from_patch > + (patch_cells,local_triangulation,patch_to_global_tria_map); + + deallog << "patch_cells " << cell << ": "; + for (unsigned int i=0; i::active_cell_iterator + tria_cell = local_triangulation.begin_active(); + tria_cell != local_triangulation.end(); ++tria_cell) + deallog << tria_cell << ' '; + deallog << std::endl; + + } + +} + + +int main() +{ + initlog(); + deallog.threshold_double(1.e-10); + + deallog.push("1d"); + test<1>(); + deallog.pop(); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/grid/build_triangulation_from_patch_01.output b/tests/grid/build_triangulation_from_patch_01.output new file mode 100644 index 0000000000..8007ca3938 --- /dev/null +++ b/tests/grid/build_triangulation_from_patch_01.output @@ -0,0 +1,29 @@ + +DEAL:1d::patch_cells 1.0: 1.0 1.1 +DEAL:1d::local_triangulation 1.0: 0.0 0.1 +DEAL:1d::patch_cells 1.1: 1.1 1.0 +DEAL:1d::local_triangulation 1.1: 0.0 0.1 +DEAL:2d::patch_cells 1.0: 1.0 1.1 1.2 +DEAL:2d::local_triangulation 1.0: 0.0 0.1 0.2 +DEAL:2d::patch_cells 1.1: 1.1 1.0 1.3 +DEAL:2d::local_triangulation 1.1: 0.0 0.1 0.2 +DEAL:2d::patch_cells 1.2: 1.2 1.3 1.0 +DEAL:2d::local_triangulation 1.2: 0.0 0.1 0.2 +DEAL:2d::patch_cells 1.3: 1.3 1.2 1.1 +DEAL:2d::local_triangulation 1.3: 0.0 0.1 0.2 +DEAL:3d::patch_cells 1.0: 1.0 1.1 1.2 1.4 +DEAL:3d::local_triangulation 1.0: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.1: 1.1 1.0 1.3 1.5 +DEAL:3d::local_triangulation 1.1: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.2: 1.2 1.3 1.0 1.6 +DEAL:3d::local_triangulation 1.2: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.3: 1.3 1.2 1.1 1.7 +DEAL:3d::local_triangulation 1.3: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.4: 1.4 1.5 1.6 1.0 +DEAL:3d::local_triangulation 1.4: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.5: 1.5 1.4 1.7 1.1 +DEAL:3d::local_triangulation 1.5: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.6: 1.6 1.7 1.4 1.2 +DEAL:3d::local_triangulation 1.6: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.7: 1.7 1.6 1.5 1.3 +DEAL:3d::local_triangulation 1.7: 0.0 0.1 0.2 0.3 diff --git a/tests/grid/build_triangulation_from_patch_02.cc b/tests/grid/build_triangulation_from_patch_02.cc new file mode 100644 index 0000000000..5d967fe362 --- /dev/null +++ b/tests/grid/build_triangulation_from_patch_02.cc @@ -0,0 +1,94 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 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 GridTools::build_triangulation_from_patch () + + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + +template +void test() +{ + Triangulation triangulation (Triangulation::limit_level_difference_at_vertices); + + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global (1); + triangulation.begin_active()->set_refine_flag(); + triangulation.execute_coarsening_and_refinement(); + + + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + { + std::vector::active_cell_iterator> patch_cells + = GridTools::get_patch_around_cell > (cell); + + Triangulation local_triangulation(Triangulation::limit_level_difference_at_vertices); + std::map::active_cell_iterator , typename Triangulation::active_cell_iterator> patch_to_global_tria_map; + + GridTools::build_triangulation_from_patch > + (patch_cells,local_triangulation,patch_to_global_tria_map); + + deallog << "patch_cells " << cell << ": "; + for (unsigned int i=0; i::active_cell_iterator + tria_cell = local_triangulation.begin_active(); + tria_cell != local_triangulation.end(); ++tria_cell) + deallog << tria_cell << ' '; + deallog << std::endl; + + } + + +} + + +int main() +{ + initlog(); + deallog.threshold_double(1.e-10); + + deallog.push("1d"); + test<1>(); + deallog.pop(); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/grid/build_triangulation_from_patch_02.output b/tests/grid/build_triangulation_from_patch_02.output new file mode 100644 index 0000000000..c60ddac6e4 --- /dev/null +++ b/tests/grid/build_triangulation_from_patch_02.output @@ -0,0 +1,51 @@ + +DEAL:1d::patch_cells 1.1: 1.1 2.1 +DEAL:1d::local_triangulation 1.1: 0.1 1.0 1.1 +DEAL:1d::patch_cells 2.0: 2.0 2.1 +DEAL:1d::local_triangulation 2.0: 0.0 0.1 +DEAL:1d::patch_cells 2.1: 2.1 2.0 1.1 +DEAL:1d::local_triangulation 2.1: 0.1 1.0 1.1 +DEAL:2d::patch_cells 1.1: 1.1 2.1 2.3 1.3 +DEAL:2d::local_triangulation 1.1: 0.1 0.2 1.0 1.1 1.2 1.3 +DEAL:2d::patch_cells 1.2: 1.2 1.3 2.2 2.3 +DEAL:2d::local_triangulation 1.2: 0.1 0.2 1.0 1.1 1.2 1.3 +DEAL:2d::patch_cells 1.3: 1.3 1.2 1.1 +DEAL:2d::local_triangulation 1.3: 0.0 0.1 0.2 +DEAL:2d::patch_cells 2.0: 2.0 2.1 2.2 +DEAL:2d::local_triangulation 2.0: 0.0 0.1 0.2 +DEAL:2d::patch_cells 2.1: 2.1 2.0 1.1 2.3 +DEAL:2d::local_triangulation 2.1: 0.1 1.0 1.1 1.2 1.3 +DEAL:2d::patch_cells 2.2: 2.2 2.3 2.0 1.2 +DEAL:2d::local_triangulation 2.2: 0.1 1.0 1.1 1.2 1.3 +DEAL:2d::patch_cells 2.3: 2.3 2.2 1.1 2.1 1.2 +DEAL:2d::local_triangulation 2.3: 0.1 0.2 1.0 1.1 1.2 1.3 +DEAL:3d::patch_cells 1.1: 1.1 2.1 2.3 2.5 2.7 1.3 1.5 +DEAL:3d::local_triangulation 1.1: 0.1 0.2 0.3 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 1.2: 1.2 1.3 2.2 2.6 2.3 2.7 1.6 +DEAL:3d::local_triangulation 1.2: 0.1 0.2 0.3 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 1.3: 1.3 1.2 1.1 1.7 +DEAL:3d::local_triangulation 1.3: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.4: 1.4 1.5 1.6 2.4 2.5 2.6 2.7 +DEAL:3d::local_triangulation 1.4: 0.1 0.2 0.3 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 1.5: 1.5 1.4 1.7 1.1 +DEAL:3d::local_triangulation 1.5: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.6: 1.6 1.7 1.4 1.2 +DEAL:3d::local_triangulation 1.6: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 1.7: 1.7 1.6 1.5 1.3 +DEAL:3d::local_triangulation 1.7: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 2.0: 2.0 2.1 2.2 2.4 +DEAL:3d::local_triangulation 2.0: 0.0 0.1 0.2 0.3 +DEAL:3d::patch_cells 2.1: 2.1 2.0 1.1 2.3 2.5 +DEAL:3d::local_triangulation 2.1: 0.1 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 2.2: 2.2 2.3 2.0 1.2 2.6 +DEAL:3d::local_triangulation 2.2: 0.1 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 2.3: 2.3 2.2 1.1 2.1 1.2 2.7 +DEAL:3d::local_triangulation 2.3: 0.1 0.2 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 2.4: 2.4 2.5 2.6 2.0 1.4 +DEAL:3d::local_triangulation 2.4: 0.1 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 2.5: 2.5 2.4 1.1 2.7 2.1 1.4 +DEAL:3d::local_triangulation 2.5: 0.1 0.2 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 2.6: 2.6 2.7 2.4 1.2 2.2 1.4 +DEAL:3d::local_triangulation 2.6: 0.1 0.2 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 +DEAL:3d::patch_cells 2.7: 2.7 2.6 1.1 2.5 1.2 2.3 1.4 +DEAL:3d::local_triangulation 2.7: 0.1 0.2 0.3 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 diff --git a/tests/grid/get_cells_at_coarsest_common_level_01.cc b/tests/grid/get_cells_at_coarsest_common_level_01.cc new file mode 100644 index 0000000000..011b012141 --- /dev/null +++ b/tests/grid/get_cells_at_coarsest_common_level_01.cc @@ -0,0 +1,118 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 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 GridTools::get_cells_at_coarsest_common_level() + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +void test() +{ + Triangulation triangulation (Triangulation::limit_level_difference_at_vertices); + + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global (2); + + const unsigned int n_refinements[] = { 0, 4, 3, 2 }; + for (unsigned int i=0; i flags (triangulation.n_active_cells(), false); + for (unsigned int k=0; k::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + if (flags[index]) + cell->set_refine_flag(); + AssertThrow (index == triangulation.n_active_cells(), ExcInternalError()); + + // flag all other cells for coarsening + // (this should ensure that at least + // some of them will actually be + // coarsened) + index=0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + if (!flags[index]) + cell->set_coarsen_flag(); + + triangulation.execute_coarsening_and_refinement (); + } + + // now extract patches and print every fifth of them + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + { + std::vector::active_cell_iterator> patch_cells + = GridTools::get_patch_around_cell > (cell); + + std::vector::cell_iterator> coarse_cells + = GridTools::get_cells_at_coarsest_common_level > (patch_cells); + + if (index % 5 == 0) + { + deallog << "coarse_ cells " << cell << ": "; + for (unsigned int i=0; i(); + deallog.pop(); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/grid/get_cells_at_coarsest_common_level_01.output b/tests/grid/get_cells_at_coarsest_common_level_01.output new file mode 100644 index 0000000000..d513485c7a --- /dev/null +++ b/tests/grid/get_cells_at_coarsest_common_level_01.output @@ -0,0 +1,131 @@ + +DEAL:1d::coarse_ cells 2.3: 2.2 2.3 +DEAL:1d::coarse_ cells 4.2: 4.1 4.2 4.3 +DEAL:1d::coarse_ cells 5.1: 4.1 4.2 +DEAL:2d::coarse_ cells 2.1: 2.0 2.1 2.3 2.4 +DEAL:2d::coarse_ cells 3.2: 2.0 2.2 +DEAL:2d::coarse_ cells 3.7: 3.5 3.6 3.7 3.10 3.25 +DEAL:2d::coarse_ cells 3.12: 2.2 2.8 +DEAL:2d::coarse_ cells 3.20: 3.13 3.20 3.21 3.22 3.38 +DEAL:2d::coarse_ cells 3.27: 3.18 3.25 3.26 3.27 3.29 +DEAL:2d::coarse_ cells 3.35: 3.33 3.34 3.35 +DEAL:2d::coarse_ cells 3.40: 2.1 2.4 +DEAL:2d::coarse_ cells 3.45: 3.15 3.44 3.45 3.47 3.48 +DEAL:2d::coarse_ cells 3.50: 3.47 3.48 3.50 3.51 +DEAL:2d::coarse_ cells 4.3: 4.1 4.2 4.3 4.6 4.25 +DEAL:2d::coarse_ cells 4.10: 3.14 3.44 +DEAL:2d::coarse_ cells 4.15: 3.24 3.25 3.26 +DEAL:2d::coarse_ cells 4.20: 3.26 3.28 3.49 +DEAL:2d::coarse_ cells 4.25: 4.3 4.24 4.25 4.27 4.28 +DEAL:2d::coarse_ cells 4.30: 3.32 3.33 3.35 +DEAL:2d::coarse_ cells 5.3: 4.6 4.7 4.28 +DEAL:3d::coarse_ cells 2.11: 2.9 2.10 2.11 2.15 2.25 +DEAL:3d::coarse_ cells 2.45: 2.41 2.44 2.45 2.47 +DEAL:3d::coarse_ cells 2.60: 2.46 2.53 2.56 2.60 2.61 2.62 +DEAL:3d::coarse_ cells 3.2: 3.0 3.2 3.3 3.6 3.104 +DEAL:3d::coarse_ cells 3.10: 3.8 3.10 3.11 3.14 3.102 3.123 3.136 +DEAL:3d::coarse_ cells 3.16: 3.16 3.17 3.18 3.20 3.145 +DEAL:3d::coarse_ cells 3.22: 2.8 2.9 2.11 2.13 +DEAL:3d::coarse_ cells 3.27: 3.23 3.25 3.26 3.27 3.31 3.177 +DEAL:3d::coarse_ cells 3.37: 3.33 3.36 3.37 3.39 3.159 3.228 3.241 +DEAL:3d::coarse_ cells 3.42: 3.40 3.42 3.43 3.46 3.195 +DEAL:3d::coarse_ cells 3.49: 3.48 3.49 3.51 3.53 3.179 3.229 +DEAL:3d::coarse_ cells 3.55: 3.51 3.53 3.54 3.55 3.261 3.379 +DEAL:3d::coarse_ cells 3.61: 2.33 2.35 2.39 2.42 +DEAL:3d::coarse_ cells 3.68: 3.64 3.68 3.69 3.70 3.293 +DEAL:3d::coarse_ cells 3.73: 3.72 3.73 3.75 3.77 3.285 3.291 3.296 +DEAL:3d::coarse_ cells 3.79: 3.75 3.77 3.78 3.79 3.302 3.349 +DEAL:3d::coarse_ cells 3.84: 3.62 3.80 3.84 3.85 3.86 3.341 3.352 +DEAL:3d::coarse_ cells 3.89: 2.22 2.48 2.50 2.51 +DEAL:3d::coarse_ cells 3.95: 2.50 2.51 2.54 +DEAL:3d::coarse_ cells 3.100: 3.5 3.8 3.96 3.100 3.101 3.102 +DEAL:3d::coarse_ cells 3.105: 3.3 3.104 3.105 3.107 3.109 3.112 +DEAL:3d::coarse_ cells 3.110: 2.2 2.6 2.16 +DEAL:3d::coarse_ cells 3.115: 3.113 3.114 3.115 3.119 3.154 3.185 +DEAL:3d::coarse_ cells 3.120: 3.4 3.120 3.121 3.122 3.124 +DEAL:3d::coarse_ cells 3.125: 3.12 3.121 3.124 3.125 3.127 3.265 +DEAL:3d::coarse_ cells 3.130: 3.110 3.128 3.130 3.131 3.134 3.200 +DEAL:3d::coarse_ cells 3.135: 3.131 3.133 3.134 3.135 3.142 3.205 3.283 +DEAL:3d::coarse_ cells 3.140: 3.14 3.56 3.133 3.136 3.140 3.141 3.142 +DEAL:3d::coarse_ cells 3.145: 3.16 3.144 3.145 3.147 3.149 +DEAL:3d::coarse_ cells 3.150: 3.103 3.146 3.148 3.150 3.151 3.156 3.162 +DEAL:3d::coarse_ cells 3.155: 2.10 2.11 2.24 +DEAL:3d::coarse_ cells 3.160: 3.9 3.148 3.160 3.161 3.162 3.164 +DEAL:3d::coarse_ cells 3.165: 3.28 3.161 3.164 3.165 3.167 3.305 +DEAL:3d::coarse_ cells 3.170: 3.139 3.158 3.168 3.170 3.171 3.174 3.240 +DEAL:3d::coarse_ cells 3.175: 2.14 2.15 2.28 2.42 +DEAL:3d::coarse_ cells 3.180: 3.30 3.173 3.176 3.180 3.181 3.182 3.320 +DEAL:3d::coarse_ cells 3.185: 3.32 3.115 3.184 3.185 3.187 3.189 +DEAL:3d::coarse_ cells 3.190: 2.16 2.17 2.19 2.21 +DEAL:3d::coarse_ cells 3.195: 3.42 3.193 3.194 3.195 3.199 +DEAL:3d::coarse_ cells 3.200: 2.6 2.16 2.20 +DEAL:3d::coarse_ cells 3.205: 3.135 3.201 3.204 3.205 3.207 3.212 3.337 +DEAL:3d::coarse_ cells 3.210: 3.190 3.203 3.208 3.210 3.211 3.214 3.216 +DEAL:3d::coarse_ cells 3.215: 3.83 3.211 3.213 3.214 3.215 3.221 3.246 +DEAL:3d::coarse_ cells 3.220: 2.21 2.22 2.23 2.51 +DEAL:3d::coarse_ cells 3.225: 2.11 2.25 +DEAL:3d::coarse_ cells 3.230: 3.39 3.50 3.226 3.228 3.230 3.231 3.236 +DEAL:3d::coarse_ cells 3.235: 3.233 3.234 3.235 3.239 +DEAL:3d::coarse_ cells 3.240: 3.36 3.170 3.209 3.240 3.241 3.242 3.244 +DEAL:3d::coarse_ cells 3.245: 3.52 3.175 3.241 3.244 3.245 3.247 3.369 +DEAL:3d::coarse_ cells 3.250: 3.46 3.219 3.248 3.250 3.251 3.254 +DEAL:3d::coarse_ cells 3.255: 3.251 3.253 3.254 3.255 3.262 3.387 +DEAL:3d::coarse_ cells 3.260: 3.54 3.253 3.256 3.260 3.261 3.262 3.392 +DEAL:3d::coarse_ cells 3.265: 3.125 3.264 3.265 3.267 3.269 3.272 +DEAL:3d::coarse_ cells 3.270: 3.266 3.268 3.270 3.271 3.284 3.290 +DEAL:3d::coarse_ cells 3.275: 3.15 3.57 3.273 3.274 3.275 3.279 3.306 +DEAL:3d::coarse_ cells 3.280: 3.132 3.266 3.280 3.281 3.282 3.284 +DEAL:3d::coarse_ cells 3.285: 3.60 3.73 3.271 3.281 3.284 3.285 3.287 +DEAL:3d::coarse_ cells 3.290: 3.72 3.270 3.288 3.290 3.291 3.294 +DEAL:3d::coarse_ cells 3.295: 3.70 3.77 3.291 3.293 3.294 3.295 +DEAL:3d::coarse_ cells 3.300: 3.70 3.77 3.296 3.300 3.301 3.302 +DEAL:3d::coarse_ cells 3.305: 3.165 3.304 3.305 3.307 3.309 3.312 +DEAL:3d::coarse_ cells 3.310: 2.33 2.40 2.42 2.44 +DEAL:3d::coarse_ cells 3.315: 3.31 3.313 3.314 3.315 3.319 3.321 +DEAL:3d::coarse_ cells 3.320: 2.15 2.41 2.42 2.43 +DEAL:3d::coarse_ cells 3.325: 2.41 2.43 2.47 +DEAL:3d::coarse_ cells 3.330: 2.37 2.40 2.44 2.46 +DEAL:3d::coarse_ cells 3.335: 2.44 2.45 2.46 +DEAL:3d::coarse_ cells 3.340: 3.286 3.336 3.340 3.341 3.342 3.344 +DEAL:3d::coarse_ cells 3.345: 3.75 3.341 3.344 3.345 3.347 3.349 3.352 +DEAL:3d::coarse_ cells 3.350: 3.346 3.348 3.350 3.351 3.364 +DEAL:3d::coarse_ cells 3.355: 2.49 2.53 2.55 2.60 +DEAL:3d::coarse_ cells 3.360: 3.92 3.346 3.360 3.361 3.362 3.364 +DEAL:3d::coarse_ cells 3.365: 2.52 2.54 2.55 +DEAL:3d::coarse_ cells 3.370: 3.83 3.246 3.368 3.370 3.371 3.374 3.384 +DEAL:3d::coarse_ cells 3.375: 2.56 2.57 2.58 2.60 +DEAL:3d::coarse_ cells 3.380: 2.43 2.56 2.57 2.61 +DEAL:3d::coarse_ cells 3.385: 3.253 3.371 3.384 3.385 3.387 3.389 3.392 +DEAL:3d::coarse_ cells 3.390: 2.51 2.58 2.62 +DEAL:3d::coarse_ cells 3.395: 3.263 3.393 3.394 3.395 3.399 +DEAL:3d::coarse_ cells 3.400: 2.55 2.58 2.60 2.62 +DEAL:3d::coarse_ cells 3.405: 2.60 2.62 2.63 +DEAL:3d::coarse_ cells 4.2: 3.0 3.4 3.6 +DEAL:3d::coarse_ cells 4.7: 3.4 3.5 3.6 3.120 +DEAL:3d::coarse_ cells 4.12: 3.4 3.6 3.122 +DEAL:3d::coarse_ cells 4.17: 3.8 3.9 3.100 +DEAL:3d::coarse_ cells 4.22: 3.8 3.10 3.12 3.121 +DEAL:3d::coarse_ cells 4.27: 3.9 3.13 3.15 3.164 +DEAL:3d::coarse_ cells 4.32: 3.16 3.20 3.149 +DEAL:3d::coarse_ cells 4.37: 3.20 3.21 3.24 +DEAL:3d::coarse_ cells 4.42: 3.25 3.28 3.29 3.31 +DEAL:3d::coarse_ cells 4.47: 3.29 3.31 3.313 +DEAL:3d::coarse_ cells 4.52: 3.29 3.30 3.31 3.315 +DEAL:3d::coarse_ cells 4.57: 3.32 3.33 3.154 +DEAL:3d::coarse_ cells 4.62: 3.32 3.34 3.36 3.185 +DEAL:3d::coarse_ cells 4.67: 3.35 3.41 3.226 +DEAL:3d::coarse_ cells 4.72: 3.32 3.36 3.158 3.189 +DEAL:3d::coarse_ cells 4.77: 3.36 3.37 3.158 3.240 +DEAL:3d::coarse_ cells 4.82: 3.42 3.43 +DEAL:3d::coarse_ cells 4.87: 3.43 3.47 3.234 +DEAL:3d::coarse_ cells 4.92: 3.44 3.46 3.199 3.250 +DEAL:3d::coarse_ cells 4.97: 3.50 3.52 3.54 3.55 +DEAL:3d::coarse_ cells 4.102: 3.54 3.247 3.260 3.378 +DEAL:3d::coarse_ cells 4.107: 3.58 3.59 3.80 3.142 +DEAL:3d::coarse_ cells 4.112: 3.58 3.60 3.62 3.287 +DEAL:3d::coarse_ cells 4.117: 3.60 3.62 3.63 3.298 +DEAL:3d::coarse_ cells 4.122: 3.64 3.66 3.276 3.289 +DEAL:3d::coarse_ cells 4.127: 3.64 3.65 3.66 3.68 +DEAL:3d::coarse_ cells 4.132: 3.73 3.74 3.75 3.79 +DEAL:3d::coarse_ cells 4.137: 3.90 3.92 3.94 3.95 +DEAL:3d::coarse_ cells 4.142: 3.94 3.362 diff --git a/tests/grid/get_cells_at_coarsest_common_level_02.cc b/tests/grid/get_cells_at_coarsest_common_level_02.cc new file mode 100644 index 0000000000..c08bb0c87e --- /dev/null +++ b/tests/grid/get_cells_at_coarsest_common_level_02.cc @@ -0,0 +1,95 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 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 GridTools::get_cells_at_coarsest_common_level() + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +void test() +{ + Triangulation triangulation (Triangulation::limit_level_difference_at_vertices); + + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global (2); + + + // now extract patches and print every fifth of them + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + { + std::vector::active_cell_iterator> patch_cells + = GridTools::get_patch_around_cell > (cell); + + std::vector::cell_iterator> coarse_cells + = GridTools::get_cells_at_coarsest_common_level > (patch_cells); + + // in uniform refinemenet(without any hanging nodes), we expect the size of vector of patch_cells for each cell be + // equal to the vector of coarse_cells around that cell + Assert(patch_cells.size()==coarse_cells.size(), ExcInternalError()); + + // we sort both vectors to ensure that we are comparing the correct cells to each other + std::sort(patch_cells.begin(), patch_cells.end()); + std::sort(coarse_cells.begin(), coarse_cells.end()); + + for (unsigned int i=0; i(); + deallog.pop(); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/grid/get_cells_at_coarsest_common_level_02.output b/tests/grid/get_cells_at_coarsest_common_level_02.output new file mode 100644 index 0000000000..76472fc2b7 --- /dev/null +++ b/tests/grid/get_cells_at_coarsest_common_level_02.output @@ -0,0 +1,88 @@ + +DEAL:1d::coarse_ cells 2.0: 2.0 2.1 +DEAL:1d::coarse_ cells 2.1: 2.0 2.1 2.2 +DEAL:1d::coarse_ cells 2.2: 2.1 2.2 2.3 +DEAL:1d::coarse_ cells 2.3: 2.2 2.3 +DEAL:1d::OKay +DEAL:2d::coarse_ cells 2.0: 2.0 2.1 2.2 +DEAL:2d::coarse_ cells 2.1: 2.0 2.1 2.3 2.4 +DEAL:2d::coarse_ cells 2.2: 2.0 2.2 2.3 2.8 +DEAL:2d::coarse_ cells 2.3: 2.1 2.2 2.3 2.6 2.9 +DEAL:2d::coarse_ cells 2.4: 2.1 2.4 2.5 2.6 +DEAL:2d::coarse_ cells 2.5: 2.4 2.5 2.7 +DEAL:2d::coarse_ cells 2.6: 2.3 2.4 2.6 2.7 2.12 +DEAL:2d::coarse_ cells 2.7: 2.5 2.6 2.7 2.13 +DEAL:2d::coarse_ cells 2.8: 2.2 2.8 2.9 2.10 +DEAL:2d::coarse_ cells 2.9: 2.3 2.8 2.9 2.11 2.12 +DEAL:2d::coarse_ cells 2.10: 2.8 2.10 2.11 +DEAL:2d::coarse_ cells 2.11: 2.9 2.10 2.11 2.14 +DEAL:2d::coarse_ cells 2.12: 2.6 2.9 2.12 2.13 2.14 +DEAL:2d::coarse_ cells 2.13: 2.7 2.12 2.13 2.15 +DEAL:2d::coarse_ cells 2.14: 2.11 2.12 2.14 2.15 +DEAL:2d::coarse_ cells 2.15: 2.13 2.14 2.15 +DEAL:2d::OKay +DEAL:3d::coarse_ cells 2.0: 2.0 2.1 2.2 2.4 +DEAL:3d::coarse_ cells 2.1: 2.0 2.1 2.3 2.5 2.8 +DEAL:3d::coarse_ cells 2.2: 2.0 2.2 2.3 2.6 2.16 +DEAL:3d::coarse_ cells 2.3: 2.1 2.2 2.3 2.7 2.10 2.17 +DEAL:3d::coarse_ cells 2.4: 2.0 2.4 2.5 2.6 2.32 +DEAL:3d::coarse_ cells 2.5: 2.1 2.4 2.5 2.7 2.12 2.33 +DEAL:3d::coarse_ cells 2.6: 2.2 2.4 2.6 2.7 2.20 2.34 +DEAL:3d::coarse_ cells 2.7: 2.3 2.5 2.6 2.7 2.14 2.21 2.35 +DEAL:3d::coarse_ cells 2.8: 2.1 2.8 2.9 2.10 2.12 +DEAL:3d::coarse_ cells 2.9: 2.8 2.9 2.11 2.13 +DEAL:3d::coarse_ cells 2.10: 2.3 2.8 2.10 2.11 2.14 2.24 +DEAL:3d::coarse_ cells 2.11: 2.9 2.10 2.11 2.15 2.25 +DEAL:3d::coarse_ cells 2.12: 2.5 2.8 2.12 2.13 2.14 2.40 +DEAL:3d::coarse_ cells 2.13: 2.9 2.12 2.13 2.15 2.41 +DEAL:3d::coarse_ cells 2.14: 2.7 2.10 2.12 2.14 2.15 2.28 2.42 +DEAL:3d::coarse_ cells 2.15: 2.11 2.13 2.14 2.15 2.29 2.43 +DEAL:3d::coarse_ cells 2.16: 2.2 2.16 2.17 2.18 2.20 +DEAL:3d::coarse_ cells 2.17: 2.3 2.16 2.17 2.19 2.21 2.24 +DEAL:3d::coarse_ cells 2.18: 2.16 2.18 2.19 2.22 +DEAL:3d::coarse_ cells 2.19: 2.17 2.18 2.19 2.23 2.26 +DEAL:3d::coarse_ cells 2.20: 2.6 2.16 2.20 2.21 2.22 2.48 +DEAL:3d::coarse_ cells 2.21: 2.7 2.17 2.20 2.21 2.23 2.28 2.49 +DEAL:3d::coarse_ cells 2.22: 2.18 2.20 2.22 2.23 2.50 +DEAL:3d::coarse_ cells 2.23: 2.19 2.21 2.22 2.23 2.30 2.51 +DEAL:3d::coarse_ cells 2.24: 2.10 2.17 2.24 2.25 2.26 2.28 +DEAL:3d::coarse_ cells 2.25: 2.11 2.24 2.25 2.27 2.29 +DEAL:3d::coarse_ cells 2.26: 2.19 2.24 2.26 2.27 2.30 +DEAL:3d::coarse_ cells 2.27: 2.25 2.26 2.27 2.31 +DEAL:3d::coarse_ cells 2.28: 2.14 2.21 2.24 2.28 2.29 2.30 2.56 +DEAL:3d::coarse_ cells 2.29: 2.15 2.25 2.28 2.29 2.31 2.57 +DEAL:3d::coarse_ cells 2.30: 2.23 2.26 2.28 2.30 2.31 2.58 +DEAL:3d::coarse_ cells 2.31: 2.27 2.29 2.30 2.31 2.59 +DEAL:3d::coarse_ cells 2.32: 2.4 2.32 2.33 2.34 2.36 +DEAL:3d::coarse_ cells 2.33: 2.5 2.32 2.33 2.35 2.37 2.40 +DEAL:3d::coarse_ cells 2.34: 2.6 2.32 2.34 2.35 2.38 2.48 +DEAL:3d::coarse_ cells 2.35: 2.7 2.33 2.34 2.35 2.39 2.42 2.49 +DEAL:3d::coarse_ cells 2.36: 2.32 2.36 2.37 2.38 +DEAL:3d::coarse_ cells 2.37: 2.33 2.36 2.37 2.39 2.44 +DEAL:3d::coarse_ cells 2.38: 2.34 2.36 2.38 2.39 2.52 +DEAL:3d::coarse_ cells 2.39: 2.35 2.37 2.38 2.39 2.46 2.53 +DEAL:3d::coarse_ cells 2.40: 2.12 2.33 2.40 2.41 2.42 2.44 +DEAL:3d::coarse_ cells 2.41: 2.13 2.40 2.41 2.43 2.45 +DEAL:3d::coarse_ cells 2.42: 2.14 2.35 2.40 2.42 2.43 2.46 2.56 +DEAL:3d::coarse_ cells 2.43: 2.15 2.41 2.42 2.43 2.47 2.57 +DEAL:3d::coarse_ cells 2.44: 2.37 2.40 2.44 2.45 2.46 +DEAL:3d::coarse_ cells 2.45: 2.41 2.44 2.45 2.47 +DEAL:3d::coarse_ cells 2.46: 2.39 2.42 2.44 2.46 2.47 2.60 +DEAL:3d::coarse_ cells 2.47: 2.43 2.45 2.46 2.47 2.61 +DEAL:3d::coarse_ cells 2.48: 2.20 2.34 2.48 2.49 2.50 2.52 +DEAL:3d::coarse_ cells 2.49: 2.21 2.35 2.48 2.49 2.51 2.53 2.56 +DEAL:3d::coarse_ cells 2.50: 2.22 2.48 2.50 2.51 2.54 +DEAL:3d::coarse_ cells 2.51: 2.23 2.49 2.50 2.51 2.55 2.58 +DEAL:3d::coarse_ cells 2.52: 2.38 2.48 2.52 2.53 2.54 +DEAL:3d::coarse_ cells 2.53: 2.39 2.49 2.52 2.53 2.55 2.60 +DEAL:3d::coarse_ cells 2.54: 2.50 2.52 2.54 2.55 +DEAL:3d::coarse_ cells 2.55: 2.51 2.53 2.54 2.55 2.62 +DEAL:3d::coarse_ cells 2.56: 2.28 2.42 2.49 2.56 2.57 2.58 2.60 +DEAL:3d::coarse_ cells 2.57: 2.29 2.43 2.56 2.57 2.59 2.61 +DEAL:3d::coarse_ cells 2.58: 2.30 2.51 2.56 2.58 2.59 2.62 +DEAL:3d::coarse_ cells 2.59: 2.31 2.57 2.58 2.59 2.63 +DEAL:3d::coarse_ cells 2.60: 2.46 2.53 2.56 2.60 2.61 2.62 +DEAL:3d::coarse_ cells 2.61: 2.47 2.57 2.60 2.61 2.63 +DEAL:3d::coarse_ cells 2.62: 2.55 2.58 2.60 2.62 2.63 +DEAL:3d::coarse_ cells 2.63: 2.59 2.61 2.62 2.63 +DEAL:3d::OKay diff --git a/tests/grid/get_cells_at_coarsest_common_level_03.cc b/tests/grid/get_cells_at_coarsest_common_level_03.cc new file mode 100644 index 0000000000..84a48ee831 --- /dev/null +++ b/tests/grid/get_cells_at_coarsest_common_level_03.cc @@ -0,0 +1,87 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 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 GridTools::get_cells_at_coarsest_common_level() + + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +void test() +{ + Triangulation triangulation (Triangulation::limit_level_difference_at_vertices); + + GridGenerator::hyper_cube(triangulation); + triangulation.refine_global (1); + // Adaptive refinement ... refine the first cell + triangulation.begin_active()->set_refine_flag(); + triangulation.execute_coarsening_and_refinement(); + + // now extract patches and print every fifth of them + unsigned int index = 0; + for (typename Triangulation::active_cell_iterator + cell = triangulation.begin_active(); + cell != triangulation.end(); ++cell, ++index) + { + std::vector::active_cell_iterator> patch_cells + = GridTools::get_patch_around_cell > (cell); + + std::vector::cell_iterator> coarse_cells + = GridTools::get_cells_at_coarsest_common_level > (patch_cells); + + deallog << "coarse_ cells " << cell << ": "; + for (unsigned int i=0; i(); + deallog.pop(); + + deallog.push("2d"); + test<2>(); + deallog.pop(); + + deallog.push("3d"); + test<3>(); + deallog.pop(); +} diff --git a/tests/grid/get_cells_at_coarsest_common_level_03.output b/tests/grid/get_cells_at_coarsest_common_level_03.output new file mode 100644 index 0000000000..3a205c9fb2 --- /dev/null +++ b/tests/grid/get_cells_at_coarsest_common_level_03.output @@ -0,0 +1,26 @@ + +DEAL:1d::coarse_ cells 1.1: 1.0 1.1 +DEAL:1d::coarse_ cells 2.0: 2.0 2.1 +DEAL:1d::coarse_ cells 2.1: 1.0 1.1 +DEAL:2d::coarse_ cells 1.1: 1.0 1.1 1.3 +DEAL:2d::coarse_ cells 1.2: 1.0 1.2 1.3 +DEAL:2d::coarse_ cells 1.3: 1.1 1.2 1.3 +DEAL:2d::coarse_ cells 2.0: 2.0 2.1 2.2 +DEAL:2d::coarse_ cells 2.1: 1.0 1.1 +DEAL:2d::coarse_ cells 2.2: 1.0 1.2 +DEAL:2d::coarse_ cells 2.3: 1.0 1.1 1.2 +DEAL:3d::coarse_ cells 1.1: 1.0 1.1 1.3 1.5 +DEAL:3d::coarse_ cells 1.2: 1.0 1.2 1.3 1.6 +DEAL:3d::coarse_ cells 1.3: 1.1 1.2 1.3 1.7 +DEAL:3d::coarse_ cells 1.4: 1.0 1.4 1.5 1.6 +DEAL:3d::coarse_ cells 1.5: 1.1 1.4 1.5 1.7 +DEAL:3d::coarse_ cells 1.6: 1.2 1.4 1.6 1.7 +DEAL:3d::coarse_ cells 1.7: 1.3 1.5 1.6 1.7 +DEAL:3d::coarse_ cells 2.0: 2.0 2.1 2.2 2.4 +DEAL:3d::coarse_ cells 2.1: 1.0 1.1 +DEAL:3d::coarse_ cells 2.2: 1.0 1.2 +DEAL:3d::coarse_ cells 2.3: 1.0 1.1 1.2 +DEAL:3d::coarse_ cells 2.4: 1.0 1.4 +DEAL:3d::coarse_ cells 2.5: 1.0 1.1 1.4 +DEAL:3d::coarse_ cells 2.6: 1.0 1.2 1.4 +DEAL:3d::coarse_ cells 2.7: 1.0 1.1 1.2 1.4