From 5954dde3d8957268213a92f3bba3cdc1ed502d2e Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Thu, 14 Sep 2017 20:00:36 +0200 Subject: [PATCH] Test on order of construction, and signals. --- source/grid/tria_info_cache.cc | 2 + tests/grid/tria_info_cache_02.cc | 70 ++++++++++++++++++++++++++++ tests/grid/tria_info_cache_02.output | 23 +++++++++ 3 files changed, 95 insertions(+) create mode 100644 tests/grid/tria_info_cache_02.cc create mode 100644 tests/grid/tria_info_cache_02.output diff --git a/source/grid/tria_info_cache.cc b/source/grid/tria_info_cache.cc index 8a150a861a..e9c89139f0 100644 --- a/source/grid/tria_info_cache.cc +++ b/source/grid/tria_info_cache.cc @@ -55,7 +55,9 @@ void TriangulationInfoCache::update(bool topology_is_unchanged) { vertex_to_cells.clear(); vertex_to_cell_centers.clear(); +#ifdef DEAL_II_WITH_NANOFLANN vertex_kdtree.set_points(tria->get_vertices()); +#endif return; } diff --git a/tests/grid/tria_info_cache_02.cc b/tests/grid/tria_info_cache_02.cc new file mode 100644 index 0000000000..4280b6c8e3 --- /dev/null +++ b/tests/grid/tria_info_cache_02.cc @@ -0,0 +1,70 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2001 - 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. +// +// --------------------------------------------------------------------- + +// Validate tria_info_cache. Different construction order. Check signal. + +#include "../tests.h" +#include +#include +#include + + +template +void test () +{ + deallog << "dim = " << dim + << ", spacedim = " << spacedim << std::endl; + + Triangulation tria; + TriangulationInfoCache cache(tria, cache_vertex_to_cell_map); + + GridGenerator::hyper_cube(tria); + + { + auto m = cache.get_vertex_to_cell_map(); + + unsigned int i=0; + for (auto &v : m) + { + for (auto &c : v) + deallog << "Vertex " << i << ", cell " << c << std::endl; + ++i; + } + } + deallog << "After one refinement. " << std::endl; + + tria.refine_global(1); + { + auto m = cache.get_vertex_to_cell_map(); + + unsigned int i=0; + for (auto &v : m) + { + for (auto &c : v) + deallog << "Vertex " << i << ", cell " << c << std::endl; + ++i; + } + } +} + + +int main () +{ + initlog(); + + test<2,2> (); + + return 0; +} diff --git a/tests/grid/tria_info_cache_02.output b/tests/grid/tria_info_cache_02.output new file mode 100644 index 0000000000..f5e83bd97f --- /dev/null +++ b/tests/grid/tria_info_cache_02.output @@ -0,0 +1,23 @@ + +DEAL::dim = 2, spacedim = 2 +DEAL::Vertex 0, cell 0.0 +DEAL::Vertex 1, cell 0.0 +DEAL::Vertex 2, cell 0.0 +DEAL::Vertex 3, cell 0.0 +DEAL::After one refinement. +DEAL::Vertex 0, cell 1.0 +DEAL::Vertex 1, cell 1.1 +DEAL::Vertex 2, cell 1.2 +DEAL::Vertex 3, cell 1.3 +DEAL::Vertex 4, cell 1.0 +DEAL::Vertex 4, cell 1.1 +DEAL::Vertex 5, cell 1.0 +DEAL::Vertex 5, cell 1.2 +DEAL::Vertex 6, cell 1.1 +DEAL::Vertex 6, cell 1.3 +DEAL::Vertex 7, cell 1.2 +DEAL::Vertex 7, cell 1.3 +DEAL::Vertex 8, cell 1.0 +DEAL::Vertex 8, cell 1.1 +DEAL::Vertex 8, cell 1.2 +DEAL::Vertex 8, cell 1.3 -- 2.39.5