]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Triangulation::get_boundary_ids(): don't return duplicates. 17678/head
authorDavid Wells <drwells@email.unc.edu>
Fri, 6 Sep 2024 22:52:00 +0000 (18:52 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 9 Sep 2024 19:17:42 +0000 (15:17 -0400)
In 1d we support, in spacedim == 2 and spacedim == 3, more than two boundary
nodes, so we need to remove duplicates from this vector.

doc/news/changes/minor/20240906Wells [new file with mode: 0644]
source/grid/tria.cc
tests/grid/grid_in_vtk_1d_3d.cc
tests/grid/grid_in_vtk_1d_3d.output

diff --git a/doc/news/changes/minor/20240906Wells b/doc/news/changes/minor/20240906Wells
new file mode 100644 (file)
index 0000000..e80e66b
--- /dev/null
@@ -0,0 +1,4 @@
+Fixed: Triangulation::get_boundary_ids() does not return duplicates when
+`dim == 1` any more.
+<br>
+(David Wells, 2024/09/06)
index 446727d20e862d4237c37e25db9a1aaa9ff83748..a496a30a662dff4c58395459b4eaa6b4afe4f6d3 100644 (file)
@@ -12331,30 +12331,14 @@ DEAL_II_CXX20_REQUIRES((concepts::is_valid_dim_spacedim<dim, spacedim>))
 std::vector<types::boundary_id> Triangulation<dim, spacedim>::get_boundary_ids()
   const
 {
-  // in 1d, we store a map of all used boundary indicators. use it for
-  // our purposes
-  if (dim == 1)
-    {
-      std::vector<types::boundary_id> boundary_ids;
-      for (std::map<unsigned int, types::boundary_id>::const_iterator p =
-             vertex_to_boundary_id_map_1d->begin();
-           p != vertex_to_boundary_id_map_1d->end();
-           ++p)
-        boundary_ids.push_back(p->second);
-
-      return boundary_ids;
-    }
-  else
-    {
-      std::set<types::boundary_id> b_ids;
-      for (auto cell : active_cell_iterators())
-        if (cell->is_locally_owned())
-          for (const unsigned int face : cell->face_indices())
-            if (cell->at_boundary(face))
-              b_ids.insert(cell->face(face)->boundary_id());
-      std::vector<types::boundary_id> boundary_ids(b_ids.begin(), b_ids.end());
-      return boundary_ids;
-    }
+  std::set<types::boundary_id> boundary_ids;
+  for (const auto &cell : active_cell_iterators())
+    if (cell->is_locally_owned())
+      for (const auto &face : cell->face_indices())
+        if (cell->at_boundary(face))
+          boundary_ids.insert(cell->face(face)->boundary_id());
+
+  return {boundary_ids.begin(), boundary_ids.end()};
 }
 
 
index d8eef4a0e104d6bc8ebc60320e5c670a0b633152..cfddaeb55c0f2abdd616097bfa2be4418cba6ad5 100644 (file)
@@ -58,6 +58,9 @@ main()
         }
     }
 
+  for (const auto &boundary_id : triangulation1.get_boundary_ids())
+    deallog << "  boundary_id = " << boundary_id << std::endl;
+
   deallog << "Triangulation 2:\n";
   for (const auto &cell : triangulation2.active_cell_iterators())
     {
@@ -69,6 +72,9 @@ main()
         }
     }
 
+  for (const auto &boundary_id : triangulation1.get_boundary_ids())
+    deallog << "  boundary_id = " << boundary_id << std::endl;
+
   GridGenerator::merge_triangulations(triangulation2,
                                       triangulation1,
                                       triangulation2);
index f1d25018eb6c07b40a4e0245e9404a12a4b844c8..8f505ac215fa9e90bad5aae076eaec847b1857ce 100644 (file)
@@ -12,6 +12,8 @@ DEAL::    vertex: 0.00000 2.01000 -1.00000
 DEAL::  cell=0.3
 DEAL::    vertex: 0.00000 2.01000 0.00000
 DEAL::    vertex: 0.00000 3.01000 0.00000
+DEAL::  boundary_id = 0
+DEAL::  boundary_id = 1
 DEAL::Triangulation 2:
   cell=0.0
 DEAL::    vertex: 0.00000 0.00000 0.00000
@@ -25,6 +27,8 @@ DEAL::    vertex: 0.00000 0.00000 -1.00000
 DEAL::  cell=0.3
 DEAL::    vertex: 0.00000 0.00000 0.00000
 DEAL::    vertex: 0.00000 1.00000 0.00000
+DEAL::  boundary_id = 0
+DEAL::  boundary_id = 1
 0.00000 0.00000 0.00000 0 0
 0.00000 0.00000 1.00000 0 0
 

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.