]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Set cell manifold ids when the apply_all_indicators_to_manifold flag is used. 7818/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 16 Mar 2019 00:11:58 +0000 (01:11 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Sat, 16 Mar 2019 10:40:17 +0000 (11:40 +0100)
doc/news/changes/minor/20190316Arndt [new file with mode: 0644]
include/deal.II/grid/grid_in.h
source/grid/grid_in.cc
tests/grid/grid_in_ucd_02.cc [new file with mode: 0644]
tests/grid/grid_in_ucd_02.output [new file with mode: 0644]
tests/grid/grid_in_ucd_02_grids/grid_1.inp [new file with mode: 0644]
tests/grid/grid_in_ucd_02_grids/grid_2.inp [new file with mode: 0644]
tests/grid/grid_in_ucd_02_grids/grid_3.inp [new file with mode: 0644]
tests/hp/step-5.cc

diff --git a/doc/news/changes/minor/20190316Arndt b/doc/news/changes/minor/20190316Arndt
new file mode 100644 (file)
index 0000000..204e05b
--- /dev/null
@@ -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.
+<br>
+(Daniel Arndt, 2019/03/16)
index d646ead8f41f7bc11b24bdfc49d0d222872d077b..73c4be4a3d0d9a594bba107a626b1a6386b123e9 100644 (file)
@@ -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,
index ad18740f2849c4b2bc361fb3328239bdaf6c371b..28f2907258f82c17c5b2af3d5156a55304de433c 100644 (file)
@@ -834,6 +834,9 @@ GridIn<dim, spacedim>::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<types::manifold_id>(material_id);
           cells.back().material_id =
             static_cast<types::material_id>(material_id);
 
diff --git a/tests/grid/grid_in_ucd_02.cc b/tests/grid/grid_in_ucd_02.cc
new file mode 100644 (file)
index 0000000..365849a
--- /dev/null
@@ -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 <deal.II/dofs/dof_handler.h>
+
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/grid_in.h>
+#include <deal.II/grid/grid_out.h>
+#include <deal.II/grid/manifold_lib.h>
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+
+#include <sstream>
+#include <string>
+
+#include "../tests.h"
+
+template <int dim, int spacedim>
+void
+test(const std::string &filename)
+{
+  std::ifstream                tmp_in(filename);
+  Triangulation<dim, spacedim> tria;
+  GridIn<dim, spacedim>        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<dim>::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<dim>::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 (file)
index 0000000..0c23062
--- /dev/null
@@ -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 (file)
index 0000000..f6446ee
--- /dev/null
@@ -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 (file)
index 0000000..41efaf5
--- /dev/null
@@ -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 (file)
index 0000000..5218408
--- /dev/null
@@ -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
+
index 17d2393719a8f9dd12c8d14e9c9114b9af2e9483..af23e503353f1c3399ace5cb62cc58e7e231b69c 100644 (file)
@@ -306,7 +306,7 @@ LaplaceProblem<dim>::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<dim> boundary;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.