From d8725052d2da7791b015a69fe00e519a1e23d16c Mon Sep 17 00:00:00 2001 From: Wenyu Lei Date: Thu, 14 Jan 2021 01:15:20 +0100 Subject: [PATCH] added a test for compute_point_locations in simplex meshes --- tests/simplex/compute_point_locations_01.cc | 105 ++++++ .../simplex/compute_point_locations_01.output | 332 ++++++++++++++++++ 2 files changed, 437 insertions(+) create mode 100644 tests/simplex/compute_point_locations_01.cc create mode 100644 tests/simplex/compute_point_locations_01.output diff --git a/tests/simplex/compute_point_locations_01.cc b/tests/simplex/compute_point_locations_01.cc new file mode 100644 index 0000000000..66dc56cb39 --- /dev/null +++ b/tests/simplex/compute_point_locations_01.cc @@ -0,0 +1,105 @@ +// Copyright (C) 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. +// +// --------------------------------------------------------------------- + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "../tests.h" + +// Create a simplex mesh in the unit cube. Check points distribute to each cell +// via GridTools::compute_point_locations + +using namespace dealii; + +template +void +test_in_unit_cube(const std::vector> &points) +{ + Triangulation tria; + GridGenerator::subdivided_hyper_cube_with_simplices(tria, 1); + + MappingFE mapping(Simplex::FE_P(1)); + + const auto tria_cache = + std::make_unique>(tria, mapping); + + const auto point_locations = + GridTools::compute_point_locations(*tria_cache, points); + + const auto cells = std::get<0>(point_locations); + const auto qpoints = std::get<1>(point_locations); + const auto indices = std::get<2>(point_locations); + + deallog << "Print out results in " << dim << "D: " << std::endl; + for (unsigned int i = 0; i < cells.size(); ++i) + { + deallog << "At cell " << i << ":" << std::endl; + for (unsigned int j = 0; j < qpoints[i].size(); ++j) + { + deallog << " qpoints " << j << ": " << std::endl; + deallog << " reference position : (" << qpoints[i][j] << ")" + << std::endl; + deallog << " physical position : (" << points[indices[i][j]] + << ")" << std::endl; + deallog << " FE mapping position : (" + << mapping.transform_unit_to_real_cell(cells[i], + qpoints[i][j]) + << ")" << std::endl; + } + } + deallog << std::endl; +} + +int +main() +{ + initlog(); + + { + unsigned int n = 3; + std::vector> test_points((n + 1) * (n + 1)); + unsigned int global_index = 0; + for (unsigned int i = 0; i < n + 1; ++i) + for (unsigned int j = 0; j < n + 1; ++j) + { + test_points[global_index][0] = (1.0 / n) * i; + test_points[global_index][1] = (1.0 / n) * j; + ++global_index; + } + test_in_unit_cube(test_points); + } + + { + unsigned int n = 3; + std::vector> test_points((n + 1) * (n + 1) * (n + 1)); + unsigned int global_index = 0; + for (unsigned int i = 0; i < n + 1; ++i) + for (unsigned int j = 0; j < n + 1; ++j) + for (unsigned int k = 0; k < n + 1; ++k) + { + test_points[global_index][0] = (1.0 / n) * i; + test_points[global_index][1] = (1.0 / n) * j; + test_points[global_index][2] = (1.0 / n) * k; + ++global_index; + } + test_in_unit_cube(test_points); + } +} diff --git a/tests/simplex/compute_point_locations_01.output b/tests/simplex/compute_point_locations_01.output new file mode 100644 index 0000000000..087ff3025f --- /dev/null +++ b/tests/simplex/compute_point_locations_01.output @@ -0,0 +1,332 @@ + +DEAL::Print out results in 2D: +DEAL::At cell 0: +DEAL:: qpoints 0: +DEAL:: reference position : (0.00000 0.00000) +DEAL:: physical position : (0.00000 0.00000) +DEAL:: FE mapping position : (0.00000 0.00000) +DEAL:: qpoints 1: +DEAL:: reference position : (0.00000 0.333333) +DEAL:: physical position : (0.00000 0.333333) +DEAL:: FE mapping position : (0.00000 0.333333) +DEAL:: qpoints 2: +DEAL:: reference position : (0.00000 0.666667) +DEAL:: physical position : (0.00000 0.666667) +DEAL:: FE mapping position : (0.00000 0.666667) +DEAL:: qpoints 3: +DEAL:: reference position : (0.00000 1.00000) +DEAL:: physical position : (0.00000 1.00000) +DEAL:: FE mapping position : (0.00000 1.00000) +DEAL:: qpoints 4: +DEAL:: reference position : (0.333333 0.00000) +DEAL:: physical position : (0.333333 0.00000) +DEAL:: FE mapping position : (0.333333 0.00000) +DEAL:: qpoints 5: +DEAL:: reference position : (0.333333 0.333333) +DEAL:: physical position : (0.333333 0.333333) +DEAL:: FE mapping position : (0.333333 0.333333) +DEAL:: qpoints 6: +DEAL:: reference position : (0.333333 0.666667) +DEAL:: physical position : (0.333333 0.666667) +DEAL:: FE mapping position : (0.333333 0.666667) +DEAL:: qpoints 7: +DEAL:: reference position : (0.666667 0.00000) +DEAL:: physical position : (0.666667 0.00000) +DEAL:: FE mapping position : (0.666667 0.00000) +DEAL:: qpoints 8: +DEAL:: reference position : (0.666667 0.333333) +DEAL:: physical position : (0.666667 0.333333) +DEAL:: FE mapping position : (0.666667 0.333333) +DEAL:: qpoints 9: +DEAL:: reference position : (1.00000 0.00000) +DEAL:: physical position : (1.00000 0.00000) +DEAL:: FE mapping position : (1.00000 0.00000) +DEAL::At cell 1: +DEAL:: qpoints 0: +DEAL:: reference position : (0.666667 0.00000) +DEAL:: physical position : (0.333333 1.00000) +DEAL:: FE mapping position : (0.333333 1.00000) +DEAL:: qpoints 1: +DEAL:: reference position : (0.333333 0.333333) +DEAL:: physical position : (0.666667 0.666667) +DEAL:: FE mapping position : (0.666667 0.666667) +DEAL:: qpoints 2: +DEAL:: reference position : (0.333333 0.00000) +DEAL:: physical position : (0.666667 1.00000) +DEAL:: FE mapping position : (0.666667 1.00000) +DEAL:: qpoints 3: +DEAL:: reference position : (0.00000 0.666667) +DEAL:: physical position : (1.00000 0.333333) +DEAL:: FE mapping position : (1.00000 0.333333) +DEAL:: qpoints 4: +DEAL:: reference position : (0.00000 0.333333) +DEAL:: physical position : (1.00000 0.666667) +DEAL:: FE mapping position : (1.00000 0.666667) +DEAL:: qpoints 5: +DEAL:: reference position : (0.00000 0.00000) +DEAL:: physical position : (1.00000 1.00000) +DEAL:: FE mapping position : (1.00000 1.00000) +DEAL:: +DEAL::Print out results in 3D: +DEAL::At cell 0: +DEAL:: qpoints 0: +DEAL:: reference position : (0.00000 0.00000 0.00000) +DEAL:: physical position : (0.00000 0.00000 0.00000) +DEAL:: FE mapping position : (0.00000 0.00000 0.00000) +DEAL:: qpoints 1: +DEAL:: reference position : (0.00000 0.00000 0.333333) +DEAL:: physical position : (0.00000 0.00000 0.333333) +DEAL:: FE mapping position : (0.00000 0.00000 0.333333) +DEAL:: qpoints 2: +DEAL:: reference position : (0.00000 0.00000 0.666667) +DEAL:: physical position : (0.00000 0.00000 0.666667) +DEAL:: FE mapping position : (0.00000 0.00000 0.666667) +DEAL:: qpoints 3: +DEAL:: reference position : (0.00000 0.00000 1.00000) +DEAL:: physical position : (0.00000 0.00000 1.00000) +DEAL:: FE mapping position : (0.00000 0.00000 1.00000) +DEAL:: qpoints 4: +DEAL:: reference position : (0.00000 0.333333 0.00000) +DEAL:: physical position : (0.00000 0.333333 0.00000) +DEAL:: FE mapping position : (0.00000 0.333333 0.00000) +DEAL:: qpoints 5: +DEAL:: reference position : (0.00000 0.333333 0.333333) +DEAL:: physical position : (0.00000 0.333333 0.333333) +DEAL:: FE mapping position : (0.00000 0.333333 0.333333) +DEAL:: qpoints 6: +DEAL:: reference position : (0.00000 0.333333 0.666667) +DEAL:: physical position : (0.00000 0.333333 0.666667) +DEAL:: FE mapping position : (0.00000 0.333333 0.666667) +DEAL:: qpoints 7: +DEAL:: reference position : (0.00000 0.666667 0.00000) +DEAL:: physical position : (0.00000 0.666667 0.00000) +DEAL:: FE mapping position : (0.00000 0.666667 0.00000) +DEAL:: qpoints 8: +DEAL:: reference position : (0.00000 0.666667 0.333333) +DEAL:: physical position : (0.00000 0.666667 0.333333) +DEAL:: FE mapping position : (0.00000 0.666667 0.333333) +DEAL:: qpoints 9: +DEAL:: reference position : (0.00000 1.00000 0.00000) +DEAL:: physical position : (0.00000 1.00000 0.00000) +DEAL:: FE mapping position : (0.00000 1.00000 0.00000) +DEAL:: qpoints 10: +DEAL:: reference position : (0.333333 0.00000 0.00000) +DEAL:: physical position : (0.333333 0.00000 0.00000) +DEAL:: FE mapping position : (0.333333 0.00000 0.00000) +DEAL:: qpoints 11: +DEAL:: reference position : (0.333333 0.00000 0.333333) +DEAL:: physical position : (0.333333 0.00000 0.333333) +DEAL:: FE mapping position : (0.333333 0.00000 0.333333) +DEAL:: qpoints 12: +DEAL:: reference position : (0.333333 0.00000 0.666667) +DEAL:: physical position : (0.333333 0.00000 0.666667) +DEAL:: FE mapping position : (0.333333 0.00000 0.666667) +DEAL:: qpoints 13: +DEAL:: reference position : (0.333333 0.333333 0.00000) +DEAL:: physical position : (0.333333 0.333333 0.00000) +DEAL:: FE mapping position : (0.333333 0.333333 0.00000) +DEAL:: qpoints 14: +DEAL:: reference position : (0.333333 0.333333 0.333333) +DEAL:: physical position : (0.333333 0.333333 0.333333) +DEAL:: FE mapping position : (0.333333 0.333333 0.333333) +DEAL:: qpoints 15: +DEAL:: reference position : (0.333333 0.666667 0.00000) +DEAL:: physical position : (0.333333 0.666667 0.00000) +DEAL:: FE mapping position : (0.333333 0.666667 0.00000) +DEAL:: qpoints 16: +DEAL:: reference position : (0.666667 0.00000 0.00000) +DEAL:: physical position : (0.666667 0.00000 0.00000) +DEAL:: FE mapping position : (0.666667 0.00000 0.00000) +DEAL:: qpoints 17: +DEAL:: reference position : (0.666667 0.00000 0.333333) +DEAL:: physical position : (0.666667 0.00000 0.333333) +DEAL:: FE mapping position : (0.666667 0.00000 0.333333) +DEAL:: qpoints 18: +DEAL:: reference position : (0.666667 0.333333 0.00000) +DEAL:: physical position : (0.666667 0.333333 0.00000) +DEAL:: FE mapping position : (0.666667 0.333333 0.00000) +DEAL:: qpoints 19: +DEAL:: reference position : (1.00000 0.00000 0.00000) +DEAL:: physical position : (1.00000 0.00000 0.00000) +DEAL:: FE mapping position : (1.00000 0.00000 0.00000) +DEAL::At cell 1: +DEAL:: qpoints 0: +DEAL:: reference position : (0.666667 0.00000 0.333333) +DEAL:: physical position : (0.00000 0.333333 1.00000) +DEAL:: FE mapping position : (0.00000 0.333333 1.00000) +DEAL:: qpoints 1: +DEAL:: reference position : (0.333333 0.00000 0.333333) +DEAL:: physical position : (0.00000 0.666667 0.666667) +DEAL:: FE mapping position : (0.00000 0.666667 0.666667) +DEAL:: qpoints 2: +DEAL:: reference position : (0.333333 0.00000 0.666667) +DEAL:: physical position : (0.00000 0.666667 1.00000) +DEAL:: FE mapping position : (0.00000 0.666667 1.00000) +DEAL:: qpoints 3: +DEAL:: reference position : (0.00000 0.00000 0.333333) +DEAL:: physical position : (0.00000 1.00000 0.333333) +DEAL:: FE mapping position : (0.00000 1.00000 0.333333) +DEAL:: qpoints 4: +DEAL:: reference position : (0.00000 0.00000 0.666667) +DEAL:: physical position : (0.00000 1.00000 0.666667) +DEAL:: FE mapping position : (0.00000 1.00000 0.666667) +DEAL:: qpoints 5: +DEAL:: reference position : (0.00000 0.00000 1.00000) +DEAL:: physical position : (0.00000 1.00000 1.00000) +DEAL:: FE mapping position : (0.00000 1.00000 1.00000) +DEAL:: qpoints 6: +DEAL:: reference position : (0.333333 0.333333 -5.55112e-17) +DEAL:: physical position : (0.333333 0.666667 0.666667) +DEAL:: FE mapping position : (0.333333 0.666667 0.666667) +DEAL:: qpoints 7: +DEAL:: reference position : (0.333333 0.333333 0.333333) +DEAL:: physical position : (0.333333 0.666667 1.00000) +DEAL:: FE mapping position : (0.333333 0.666667 1.00000) +DEAL:: qpoints 8: +DEAL:: reference position : (0.00000 0.333333 0.333333) +DEAL:: physical position : (0.333333 1.00000 0.666667) +DEAL:: FE mapping position : (0.333333 1.00000 0.666667) +DEAL:: qpoints 9: +DEAL:: reference position : (0.00000 0.333333 0.666667) +DEAL:: physical position : (0.333333 1.00000 1.00000) +DEAL:: FE mapping position : (0.333333 1.00000 1.00000) +DEAL:: qpoints 10: +DEAL:: reference position : (0.00000 0.666667 0.333333) +DEAL:: physical position : (0.666667 1.00000 1.00000) +DEAL:: FE mapping position : (0.666667 1.00000 1.00000) +DEAL::At cell 2: +DEAL:: qpoints 0: +DEAL:: reference position : (0.666667 0.333333 0.00000) +DEAL:: physical position : (0.333333 0.00000 1.00000) +DEAL:: FE mapping position : (0.333333 0.00000 1.00000) +DEAL:: qpoints 1: +DEAL:: reference position : (0.666667 0.00000 0.333333) +DEAL:: physical position : (0.333333 0.333333 1.00000) +DEAL:: FE mapping position : (0.333333 0.333333 1.00000) +DEAL:: qpoints 2: +DEAL:: reference position : (0.333333 0.333333 0.00000) +DEAL:: physical position : (0.666667 0.00000 0.666667) +DEAL:: FE mapping position : (0.666667 0.00000 0.666667) +DEAL:: qpoints 3: +DEAL:: reference position : (0.333333 0.666667 0.00000) +DEAL:: physical position : (0.666667 0.00000 1.00000) +DEAL:: FE mapping position : (0.666667 0.00000 1.00000) +DEAL:: qpoints 4: +DEAL:: reference position : (0.333333 -5.55112e-17 0.333333) +DEAL:: physical position : (0.666667 0.333333 0.666667) +DEAL:: FE mapping position : (0.666667 0.333333 0.666667) +DEAL:: qpoints 5: +DEAL:: reference position : (0.333333 0.333333 0.333333) +DEAL:: physical position : (0.666667 0.333333 1.00000) +DEAL:: FE mapping position : (0.666667 0.333333 1.00000) +DEAL:: qpoints 6: +DEAL:: reference position : (0.333333 0.00000 0.666667) +DEAL:: physical position : (0.666667 0.666667 1.00000) +DEAL:: FE mapping position : (0.666667 0.666667 1.00000) +DEAL:: qpoints 7: +DEAL:: reference position : (0.00000 0.333333 0.00000) +DEAL:: physical position : (1.00000 0.00000 0.333333) +DEAL:: FE mapping position : (1.00000 0.00000 0.333333) +DEAL:: qpoints 8: +DEAL:: reference position : (0.00000 0.666667 0.00000) +DEAL:: physical position : (1.00000 0.00000 0.666667) +DEAL:: FE mapping position : (1.00000 0.00000 0.666667) +DEAL:: qpoints 9: +DEAL:: reference position : (0.00000 1.00000 0.00000) +DEAL:: physical position : (1.00000 0.00000 1.00000) +DEAL:: FE mapping position : (1.00000 0.00000 1.00000) +DEAL:: qpoints 10: +DEAL:: reference position : (0.00000 0.333333 0.333333) +DEAL:: physical position : (1.00000 0.333333 0.666667) +DEAL:: FE mapping position : (1.00000 0.333333 0.666667) +DEAL:: qpoints 11: +DEAL:: reference position : (0.00000 0.666667 0.333333) +DEAL:: physical position : (1.00000 0.333333 1.00000) +DEAL:: FE mapping position : (1.00000 0.333333 1.00000) +DEAL:: qpoints 12: +DEAL:: reference position : (0.00000 0.333333 0.666667) +DEAL:: physical position : (1.00000 0.666667 1.00000) +DEAL:: FE mapping position : (1.00000 0.666667 1.00000) +DEAL::At cell 3: +DEAL:: qpoints 0: +DEAL:: reference position : (0.166667 0.500000 0.166667) +DEAL:: physical position : (0.333333 0.333333 0.666667) +DEAL:: FE mapping position : (0.333333 0.333333 0.666667) +DEAL:: qpoints 1: +DEAL:: reference position : (0.500000 0.166667 0.166667) +DEAL:: physical position : (0.333333 0.666667 0.333333) +DEAL:: FE mapping position : (0.333333 0.666667 0.333333) +DEAL:: qpoints 2: +DEAL:: reference position : (0.166667 0.166667 0.166667) +DEAL:: physical position : (0.666667 0.333333 0.333333) +DEAL:: FE mapping position : (0.666667 0.333333 0.333333) +DEAL:: qpoints 3: +DEAL:: reference position : (0.166667 0.166667 0.500000) +DEAL:: physical position : (0.666667 0.666667 0.666667) +DEAL:: FE mapping position : (0.666667 0.666667 0.666667) +DEAL::At cell 4: +DEAL:: qpoints 0: +DEAL:: reference position : (0.00000 0.333333 0.00000) +DEAL:: physical position : (0.333333 1.00000 0.00000) +DEAL:: FE mapping position : (0.333333 1.00000 0.00000) +DEAL:: qpoints 1: +DEAL:: reference position : (0.00000 0.00000 0.333333) +DEAL:: physical position : (0.333333 1.00000 0.333333) +DEAL:: FE mapping position : (0.333333 1.00000 0.333333) +DEAL:: qpoints 2: +DEAL:: reference position : (0.333333 0.333333 0.00000) +DEAL:: physical position : (0.666667 0.666667 0.00000) +DEAL:: FE mapping position : (0.666667 0.666667 0.00000) +DEAL:: qpoints 3: +DEAL:: reference position : (0.333333 -5.55112e-17 0.333333) +DEAL:: physical position : (0.666667 0.666667 0.333333) +DEAL:: FE mapping position : (0.666667 0.666667 0.333333) +DEAL:: qpoints 4: +DEAL:: reference position : (0.00000 0.666667 0.00000) +DEAL:: physical position : (0.666667 1.00000 0.00000) +DEAL:: FE mapping position : (0.666667 1.00000 0.00000) +DEAL:: qpoints 5: +DEAL:: reference position : (0.00000 0.333333 0.333333) +DEAL:: physical position : (0.666667 1.00000 0.333333) +DEAL:: FE mapping position : (0.666667 1.00000 0.333333) +DEAL:: qpoints 6: +DEAL:: reference position : (0.00000 0.00000 0.666667) +DEAL:: physical position : (0.666667 1.00000 0.666667) +DEAL:: FE mapping position : (0.666667 1.00000 0.666667) +DEAL:: qpoints 7: +DEAL:: reference position : (0.666667 0.333333 0.00000) +DEAL:: physical position : (1.00000 0.333333 0.00000) +DEAL:: FE mapping position : (1.00000 0.333333 0.00000) +DEAL:: qpoints 8: +DEAL:: reference position : (0.666667 0.00000 0.333333) +DEAL:: physical position : (1.00000 0.333333 0.333333) +DEAL:: FE mapping position : (1.00000 0.333333 0.333333) +DEAL:: qpoints 9: +DEAL:: reference position : (0.333333 0.666667 0.00000) +DEAL:: physical position : (1.00000 0.666667 0.00000) +DEAL:: FE mapping position : (1.00000 0.666667 0.00000) +DEAL:: qpoints 10: +DEAL:: reference position : (0.333333 0.333333 0.333333) +DEAL:: physical position : (1.00000 0.666667 0.333333) +DEAL:: FE mapping position : (1.00000 0.666667 0.333333) +DEAL:: qpoints 11: +DEAL:: reference position : (0.333333 0.00000 0.666667) +DEAL:: physical position : (1.00000 0.666667 0.666667) +DEAL:: FE mapping position : (1.00000 0.666667 0.666667) +DEAL:: qpoints 12: +DEAL:: reference position : (0.00000 1.00000 0.00000) +DEAL:: physical position : (1.00000 1.00000 0.00000) +DEAL:: FE mapping position : (1.00000 1.00000 0.00000) +DEAL:: qpoints 13: +DEAL:: reference position : (0.00000 0.666667 0.333333) +DEAL:: physical position : (1.00000 1.00000 0.333333) +DEAL:: FE mapping position : (1.00000 1.00000 0.333333) +DEAL:: qpoints 14: +DEAL:: reference position : (0.00000 0.333333 0.666667) +DEAL:: physical position : (1.00000 1.00000 0.666667) +DEAL:: FE mapping position : (1.00000 1.00000 0.666667) +DEAL:: qpoints 15: +DEAL:: reference position : (0.00000 0.00000 1.00000) +DEAL:: physical position : (1.00000 1.00000 1.00000) +DEAL:: FE mapping position : (1.00000 1.00000 1.00000) +DEAL:: -- 2.39.5