]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added set_all_* functions to tria.
authorLuca Heltai <luca.heltai@sissa.it>
Mon, 12 Jan 2015 13:31:33 +0000 (14:31 +0100)
committerLuca Heltai <luca.heltai@sissa.it>
Mon, 12 Jan 2015 13:31:33 +0000 (14:31 +0100)
doc/news/changes.h
include/deal.II/grid/tria.h
source/grid/tria.cc
tests/manifold/set_all_manifold_ids_01.cc [new file with mode: 0644]
tests/manifold/set_all_manifold_ids_01.output [new file with mode: 0644]
tests/manifold/set_all_manifold_ids_02.cc [new file with mode: 0644]
tests/manifold/set_all_manifold_ids_02.output [new file with mode: 0644]

index ee01cf9ebc06657c7d8402881bfd6adb33c094f7..50a97d6a3258263108b764236b10ab1ee15e053f 100644 (file)
@@ -145,6 +145,15 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li> New: Triangulation::set_all_manifold_ids() and 
+  Triangulation::set_all_manifold_ids_on_boundaries()
+  set all manifold ids on every object or on every 
+  boundary object respectively.
+  <br>
+  (Luca Heltai, 2015/01/12)
+  </li>
+
+
   <li> New: GridTools::copy_boundary_to_manifold_id() and 
   GridTools::copy_material_to_manifold_id() copy
   boundary_ids and material_ids to manifold_ids for 
index 891f9a91646b41fb38952bd9fb71b33f4ed225d9..db4e1ed16481adf526f8e9dd3f191b2b22baf7d1 100644 (file)
@@ -1627,6 +1627,29 @@ public:
    */
   void set_manifold (const types::manifold_id number);
 
+  /**
+   * Set the manifold_id of all of cells and faces to the given
+   * argument.
+   *
+   * @ingroup manifold
+   *
+   * @see
+   * @ref GlossManifoldIndicator "Glossary entry on manifold indicators"
+   */
+  void set_all_manifold_ids (const types::manifold_id &number);
+
+  /**
+   * Set the manifold_id of all of boundary faces to the given
+   * argument.
+   *
+   * @ingroup manifold
+   *
+   * @see
+   * @ref GlossManifoldIndicator "Glossary entry on manifold indicators"
+   */
+  void set_all_manifold_ids_on_boundary (const types::manifold_id &number);
+
+
   /**
    * Return a constant reference to a boundary object used for this
    * triangulation.  Number is the same as in @p set_boundary
index d7ab4f648ab1c48e79657d02486228d9b4e7897e..785a5408b708bc0d3029a798a911b6c7d91a263a 100644 (file)
@@ -8770,6 +8770,30 @@ Triangulation<dim, spacedim>::set_manifold (const types::manifold_id m_number)
   manifold.erase(m_number);
 }
 
+template <int dim, int spacedim>
+void
+Triangulation<dim, spacedim>::set_all_manifold_ids (const types::manifold_id &m_number)
+{
+  typename Triangulation<dim,spacedim>::active_cell_iterator
+  cell=this->begin_active(), endc=this->end();
+
+  for (; cell != endc; ++cell)
+    cell->set_all_manifold_ids(m_number);
+}
+
+
+template <int dim, int spacedim>
+void
+Triangulation<dim, spacedim>::set_all_manifold_ids_on_boundary (const types::manifold_id &m_number)
+{
+  typename Triangulation<dim,spacedim>::active_cell_iterator
+  cell=this->begin_active(), endc=this->end();
+
+  for (; cell != endc; ++cell)
+    for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+      if (cell->face(f)->at_boundary())
+        cell->face(f)->set_all_manifold_ids(m_number);
+}
 
 
 template <int dim, int spacedim>
diff --git a/tests/manifold/set_all_manifold_ids_01.cc b/tests/manifold/set_all_manifold_ids_01.cc
new file mode 100644 (file)
index 0000000..a8a7c85
--- /dev/null
@@ -0,0 +1,77 @@
+//------------------------------------------------------------
+//    Copyright (C) 2015, the deal.II authors
+//
+//    This file is subject to LGPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <fstream>
+#include <base/logstream.h>
+
+
+// all include files you need here
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria_boundary_lib.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/grid_out.h>
+
+template<int dim, int spacedim>
+void print_info(Triangulation<dim,spacedim> &tria) {
+  typename Triangulation<dim,spacedim>::active_cell_iterator cell;
+
+  for (cell = tria.begin_active(); cell != tria.end(); ++cell)
+    {
+      deallog << "cell: " << cell 
+             << ", material_id: " 
+             << (int)cell->material_id()
+             << ", manifold_id: " 
+             << (int)cell->manifold_id() << std::endl;
+
+      for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+         deallog << "face: " << cell->face(f)
+                 << ", boundary_id: " 
+                 << (int)cell->face(f)->boundary_indicator()
+                 << ", manifold_id: " 
+                 << (int)cell->face(f)->manifold_id() << std::endl;
+    }
+}
+
+
+// Helper function
+template <int dim, int spacedim>
+void test()
+{
+  deallog << "Testing dim=" << dim
+          << ", spacedim="<< spacedim << std::endl;
+
+  Triangulation<dim,spacedim> tria;
+  GridGenerator::hyper_cube (tria, 0., 1.);
+
+  deallog << "Original mesh ==============================" << std::endl;
+  print_info(tria);
+  tria.set_all_manifold_ids(1);
+  deallog << "Modified mesh ==============================" << std::endl;
+  print_info(tria);
+}
+
+int main ()
+{
+  initlog(true);
+  
+  test<1,1>();
+  test<1,2>();
+  test<2,2>();
+  test<2,3>();
+  test<3,3>();
+
+  return 0;
+}
+
diff --git a/tests/manifold/set_all_manifold_ids_01.output b/tests/manifold/set_all_manifold_ids_01.output
new file mode 100644 (file)
index 0000000..03d0fdf
--- /dev/null
@@ -0,0 +1,62 @@
+
+DEAL::Testing dim=1, spacedim=1
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 1, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 1, manifold_id: 1
+DEAL::Testing dim=1, spacedim=2
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 1, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 1, manifold_id: 1
+DEAL::Testing dim=2, spacedim=2
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: -1
+DEAL::face: 2, boundary_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 3, boundary_id: 0, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 0, manifold_id: 1
+DEAL::face: 2, boundary_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 3, boundary_id: 0, manifold_id: 1
+DEAL::Testing dim=2, spacedim=3
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: -1
+DEAL::face: 2, boundary_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 3, boundary_id: 0, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 0, manifold_id: 1
+DEAL::face: 2, boundary_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 3, boundary_id: 0, manifold_id: 1
+DEAL::Testing dim=3, spacedim=3
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 2, boundary_id: 0, manifold_id: -1
+DEAL::face: 3, boundary_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 4, boundary_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: -1
+DEAL::face: 5, boundary_id: 0, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: 1
+DEAL::face: 2, boundary_id: 0, manifold_id: 1
+DEAL::face: 3, boundary_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 4, boundary_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 0, manifold_id: 1
+DEAL::face: 5, boundary_id: 0, manifold_id: 1
diff --git a/tests/manifold/set_all_manifold_ids_02.cc b/tests/manifold/set_all_manifold_ids_02.cc
new file mode 100644 (file)
index 0000000..7d0130b
--- /dev/null
@@ -0,0 +1,77 @@
+//------------------------------------------------------------
+//    Copyright (C) 2015, the deal.II authors
+//
+//    This file is subject to LGPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <fstream>
+#include <base/logstream.h>
+
+
+// all include files you need here
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/tria_accessor.h>
+#include <deal.II/grid/tria_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/grid/tria_boundary_lib.h>
+#include <deal.II/grid/grid_tools.h>
+#include <deal.II/grid/grid_out.h>
+
+template<int dim, int spacedim>
+void print_info(Triangulation<dim,spacedim> &tria) {
+  typename Triangulation<dim,spacedim>::active_cell_iterator cell;
+
+  for (cell = tria.begin_active(); cell != tria.end(); ++cell)
+    {
+      deallog << "cell: " << cell 
+             << ", material_id: " 
+             << (int)cell->material_id()
+             << ", manifold_id: " 
+             << (int)cell->manifold_id() << std::endl;
+
+      for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
+         deallog << "face: " << cell->face(f)
+                 << ", boundary_id: " 
+                 << (int)cell->face(f)->boundary_indicator()
+                 << ", manifold_id: " 
+                 << (int)cell->face(f)->manifold_id() << std::endl;
+    }
+}
+
+
+// Helper function
+template <int dim, int spacedim>
+void test()
+{
+  deallog << "Testing dim=" << dim
+          << ", spacedim="<< spacedim << std::endl;
+
+  Triangulation<dim,spacedim> tria;
+  GridGenerator::hyper_cube (tria, 0., 1.);
+
+  deallog << "Original mesh ==============================" << std::endl;
+  print_info(tria);
+  tria.set_all_manifold_ids_on_boundary(1);
+  deallog << "Modified mesh ==============================" << std::endl;
+  print_info(tria);
+}
+
+int main ()
+{
+  initlog(true);
+  
+  test<1,1>();
+  test<1,2>();
+  test<2,2>();
+  test<2,3>();
+  test<3,3>();
+
+  return 0;
+}
+
diff --git a/tests/manifold/set_all_manifold_ids_02.output b/tests/manifold/set_all_manifold_ids_02.output
new file mode 100644 (file)
index 0000000..34d3465
--- /dev/null
@@ -0,0 +1,62 @@
+
+DEAL::Testing dim=1, spacedim=1
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 1, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 1, manifold_id: 1
+DEAL::Testing dim=1, spacedim=2
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 1, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 1, manifold_id: 1
+DEAL::Testing dim=2, spacedim=2
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: -1
+DEAL::face: 2, boundary_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 3, boundary_id: 0, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: 1
+DEAL::face: 2, boundary_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 3, boundary_id: 0, manifold_id: 1
+DEAL::Testing dim=2, spacedim=3
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: -1
+DEAL::face: 2, boundary_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 3, boundary_id: 0, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: 1
+DEAL::face: 2, boundary_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 3, boundary_id: 0, manifold_id: 1
+DEAL::Testing dim=3, spacedim=3
+DEAL::Original mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 2, boundary_id: 0, manifold_id: -1
+DEAL::face: 3, boundary_id: 0, manifold_id: -1
+DEAL::face: 0, boundary_id: 0, manifold_id: -1
+DEAL::face: 4, boundary_id: 0, manifold_id: -1
+DEAL::face: 1, boundary_id: 0, manifold_id: -1
+DEAL::face: 5, boundary_id: 0, manifold_id: -1
+DEAL::Modified mesh ==============================
+DEAL::cell: 0.0, material_id: 0, manifold_id: -1
+DEAL::face: 2, boundary_id: 0, manifold_id: 1
+DEAL::face: 3, boundary_id: 0, manifold_id: 1
+DEAL::face: 0, boundary_id: 0, manifold_id: 1
+DEAL::face: 4, boundary_id: 0, manifold_id: 1
+DEAL::face: 1, boundary_id: 0, manifold_id: 1
+DEAL::face: 5, boundary_id: 0, manifold_id: 1

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.