From df1a79ab3abd6f126e7000972eea4c1c3779bb42 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 16 Mar 2019 01:11:58 +0100 Subject: [PATCH] Set cell manifold ids when the apply_all_indicators_to_manifold flag is used. --- doc/news/changes/minor/20190316Arndt | 4 ++ include/deal.II/grid/grid_in.h | 3 +- source/grid/grid_in.cc | 3 + tests/grid/grid_in_ucd_02.cc | 77 ++++++++++++++++++++++ tests/grid/grid_in_ucd_02.output | 53 +++++++++++++++ tests/grid/grid_in_ucd_02_grids/grid_1.inp | 4 ++ tests/grid/grid_in_ucd_02_grids/grid_2.inp | 11 ++++ tests/grid/grid_in_ucd_02_grids/grid_3.inp | 29 ++++++++ tests/hp/step-5.cc | 2 +- 9 files changed, 184 insertions(+), 2 deletions(-) create mode 100644 doc/news/changes/minor/20190316Arndt create mode 100644 tests/grid/grid_in_ucd_02.cc create mode 100644 tests/grid/grid_in_ucd_02.output create mode 100644 tests/grid/grid_in_ucd_02_grids/grid_1.inp create mode 100644 tests/grid/grid_in_ucd_02_grids/grid_2.inp create mode 100644 tests/grid/grid_in_ucd_02_grids/grid_3.inp diff --git a/doc/news/changes/minor/20190316Arndt b/doc/news/changes/minor/20190316Arndt new file mode 100644 index 0000000000..204e05b914 --- /dev/null +++ b/doc/news/changes/minor/20190316Arndt @@ -0,0 +1,4 @@ +Improved: The apply_all_indicators_to_manifold flag in GridIn::read_ucd() +lets the indicators be used for cells as manifold id as well. +
+(Daniel Arndt, 2019/03/16) diff --git a/include/deal.II/grid/grid_in.h b/include/deal.II/grid/grid_in.h index d646ead8f4..73c4be4a3d 100644 --- a/include/deal.II/grid/grid_in.h +++ b/include/deal.II/grid/grid_in.h @@ -417,7 +417,8 @@ public: * manifold_id for the same cell. Yet it is possible to use * the flag apply_all_indicators_to_manifolds to decide if * the indicators in the file refer to manifolds (flag set to true) - * or boundaries (flag set to false). + * or boundaries (flag set to false). If the flag is set, the + * indicators are used for cells as manifold id, too. */ void read_ucd(std::istream &in, diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index ad18740f28..28f2907258 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -834,6 +834,9 @@ GridIn::read_ucd(std::istream &in, Assert(material_id < numbers::invalid_material_id, ExcIndexRange(material_id, 0, numbers::invalid_material_id)); + if (apply_all_indicators_to_manifolds) + cells.back().manifold_id = + static_cast(material_id); cells.back().material_id = static_cast(material_id); diff --git a/tests/grid/grid_in_ucd_02.cc b/tests/grid/grid_in_ucd_02.cc new file mode 100644 index 0000000000..365849a14d --- /dev/null +++ b/tests/grid/grid_in_ucd_02.cc @@ -0,0 +1,77 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 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. +// +// --------------------------------------------------------------------- + +// Test that cell manifold ids are also set for the +// "apply_all_indicators_to_manifolds" option in GridIn::read_ucd + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "../tests.h" + +template +void +test(const std::string &filename) +{ + std::ifstream tmp_in(filename); + Triangulation tria; + GridIn gi; + gi.attach_triangulation(tria); + gi.read_ucd(tmp_in, true); + deallog << "Testing dim=" << dim << " spacedim=" << spacedim << std::endl; + for (const auto &cell : tria.active_cell_iterators()) + { + deallog << "cell->manifold_id: " << cell->manifold_id() << std::endl; + if (dim > 1) + for (unsigned int face_no = 0; + face_no < GeometryInfo::faces_per_cell; + ++face_no) + deallog << "cell->face(" << face_no + << ")->manifold_id: " << cell->face(face_no)->manifold_id() + << std::endl; + if (dim > 1) + for (unsigned int line_no = 0; + line_no < GeometryInfo::lines_per_cell; + ++line_no) + deallog << "cell->line(" << line_no + << ")->manifold_id: " << cell->line(line_no)->manifold_id() + << std::endl; + } + deallog << std::endl; +} + +int +main() +{ + initlog(); + deallog.get_file_stream() << std::setprecision(2); + + test<1, 1>(SOURCE_DIR "/grid_in_ucd_02_grids/grid_1.inp"); + test<1, 2>(SOURCE_DIR "/grid_in_ucd_02_grids/grid_1.inp"); + test<1, 3>(SOURCE_DIR "/grid_in_ucd_02_grids/grid_1.inp"); + test<2, 2>(SOURCE_DIR "/grid_in_ucd_02_grids/grid_2.inp"); + test<2, 3>(SOURCE_DIR "/grid_in_ucd_02_grids/grid_2.inp"); + test<3, 3>(SOURCE_DIR "/grid_in_ucd_02_grids/grid_3.inp"); +} diff --git a/tests/grid/grid_in_ucd_02.output b/tests/grid/grid_in_ucd_02.output new file mode 100644 index 0000000000..0c2306278d --- /dev/null +++ b/tests/grid/grid_in_ucd_02.output @@ -0,0 +1,53 @@ + +DEAL::Testing dim=1 spacedim=1 +DEAL::cell->manifold_id: 99 +DEAL:: +DEAL::Testing dim=1 spacedim=2 +DEAL::cell->manifold_id: 99 +DEAL:: +DEAL::Testing dim=1 spacedim=3 +DEAL::cell->manifold_id: 99 +DEAL:: +DEAL::Testing dim=2 spacedim=2 +DEAL::cell->manifold_id: 99 +DEAL::cell->face(0)->manifold_id: 100 +DEAL::cell->face(1)->manifold_id: 100 +DEAL::cell->face(2)->manifold_id: 100 +DEAL::cell->face(3)->manifold_id: 100 +DEAL::cell->line(0)->manifold_id: 100 +DEAL::cell->line(1)->manifold_id: 100 +DEAL::cell->line(2)->manifold_id: 100 +DEAL::cell->line(3)->manifold_id: 100 +DEAL:: +DEAL::Testing dim=2 spacedim=3 +DEAL::cell->manifold_id: 99 +DEAL::cell->face(0)->manifold_id: 100 +DEAL::cell->face(1)->manifold_id: 100 +DEAL::cell->face(2)->manifold_id: 100 +DEAL::cell->face(3)->manifold_id: 100 +DEAL::cell->line(0)->manifold_id: 100 +DEAL::cell->line(1)->manifold_id: 100 +DEAL::cell->line(2)->manifold_id: 100 +DEAL::cell->line(3)->manifold_id: 100 +DEAL:: +DEAL::Testing dim=3 spacedim=3 +DEAL::cell->manifold_id: 99 +DEAL::cell->face(0)->manifold_id: 100 +DEAL::cell->face(1)->manifold_id: 100 +DEAL::cell->face(2)->manifold_id: 100 +DEAL::cell->face(3)->manifold_id: 100 +DEAL::cell->face(4)->manifold_id: 100 +DEAL::cell->face(5)->manifold_id: 100 +DEAL::cell->line(0)->manifold_id: 101 +DEAL::cell->line(1)->manifold_id: 101 +DEAL::cell->line(2)->manifold_id: 101 +DEAL::cell->line(3)->manifold_id: 101 +DEAL::cell->line(4)->manifold_id: 101 +DEAL::cell->line(5)->manifold_id: 101 +DEAL::cell->line(6)->manifold_id: 101 +DEAL::cell->line(7)->manifold_id: 101 +DEAL::cell->line(8)->manifold_id: 101 +DEAL::cell->line(9)->manifold_id: 101 +DEAL::cell->line(10)->manifold_id: 101 +DEAL::cell->line(11)->manifold_id: 101 +DEAL:: diff --git a/tests/grid/grid_in_ucd_02_grids/grid_1.inp b/tests/grid/grid_in_ucd_02_grids/grid_1.inp new file mode 100644 index 0000000000..f6446ee532 --- /dev/null +++ b/tests/grid/grid_in_ucd_02_grids/grid_1.inp @@ -0,0 +1,4 @@ +2 1 0 0 0 +1 0 0 0 +2 1 0 0 +1 99 line 1 2 diff --git a/tests/grid/grid_in_ucd_02_grids/grid_2.inp b/tests/grid/grid_in_ucd_02_grids/grid_2.inp new file mode 100644 index 0000000000..41efaf5f68 --- /dev/null +++ b/tests/grid/grid_in_ucd_02_grids/grid_2.inp @@ -0,0 +1,11 @@ +4 5 0 0 0 +1 0 0 0 +2 1 0 0 +3 0 1 0 +4 1 1 0 +1 99 quad 1 2 4 3 +2 100 line 1 2 +3 100 line 2 4 +4 100 line 4 3 +5 100 line 3 1 + diff --git a/tests/grid/grid_in_ucd_02_grids/grid_3.inp b/tests/grid/grid_in_ucd_02_grids/grid_3.inp new file mode 100644 index 0000000000..5218408f06 --- /dev/null +++ b/tests/grid/grid_in_ucd_02_grids/grid_3.inp @@ -0,0 +1,29 @@ +8 19 0 0 0 +1 0 0 0 +2 1 0 0 +3 0 1 0 +4 1 1 0 +5 0 0 1 +6 1 0 1 +7 0 1 1 +8 1 1 1 +1 99 hex 1 2 6 5 3 4 8 7 +2 100 quad 1 2 4 3 +3 100 quad 5 6 8 7 +4 100 quad 1 2 6 5 +5 100 quad 3 4 8 7 +6 100 quad 1 3 7 5 +7 100 quad 2 4 8 6 +8 101 line 1 2 +9 101 line 2 4 +10 101 line 4 3 +11 101 line 3 1 +12 101 line 5 6 +13 101 line 6 8 +14 101 line 8 7 +15 101 line 7 5 +16 101 line 1 5 +17 101 line 2 6 +18 101 line 3 7 +19 101 line 4 8 + diff --git a/tests/hp/step-5.cc b/tests/hp/step-5.cc index 17d2393719..af23e50335 100644 --- a/tests/hp/step-5.cc +++ b/tests/hp/step-5.cc @@ -306,7 +306,7 @@ LaplaceProblem::run() std::ifstream input_file(SOURCE_DIR "/grids/circle-grid.inp"); Assert(dim == 2, ExcInternalError()); - grid_in.read_ucd(input_file, true); + grid_in.read_ucd(input_file); GridTools::copy_boundary_to_manifold_id(triangulation); static const SphericalManifold boundary; -- 2.39.5