]> https://gitweb.dealii.org/ - dealii.git/commitdiff
New get_boundary_indicators function.
authorRalf Hartmann <Ralf.Hartmann@dlr.de>
Fri, 30 Sep 2005 16:47:58 +0000 (16:47 +0000)
committerRalf Hartmann <Ralf.Hartmann@dlr.de>
Fri, 30 Sep 2005 16:47:58 +0000 (16:47 +0000)
git-svn-id: https://svn.dealii.org/trunk@11563 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/source/grid/tria.cc

index 4f276a1dfe4ad57c5ccc478fddfc0a0242792a31..18cb07e437f4ce5b3f676e87778fd65daa063d4a 100644 (file)
@@ -1700,6 +1700,23 @@ class Triangulation : public Subscriptor
                                      * @p set_boundary
                                      */
     const Boundary<dim> & get_boundary (const unsigned int number) const;
+
+                                    /**
+                                     * Fill the boundary_indicators
+                                     * vector with all boundary
+                                     * indicators assigned to
+                                     * boundary faces of this
+                                     * Triangulation object. Note,
+                                     * that each boundary indicator
+                                     * is reported only once. The
+                                     * boundary_indicators vector
+                                     * will be resized to match the
+                                     * number of different indicators
+                                     * (which is greater or equal
+                                     * one).
+                                     */
+    void get_boundary_indicators(
+      std::vector<unsigned char> &boundary_indicators) const;
     
                                     /**
                                      *  Copy a triangulation. This
index 39efc3904a1496d15acc55c97676bc97d5a6837c..7b08fd6f6b7ac089936ce1372d4f63d5127b7647 100644 (file)
@@ -121,6 +121,30 @@ Triangulation<dim>::get_boundary (const unsigned int number) const
 }
 
 
+
+template <int dim>
+void
+Triangulation<dim>::get_boundary_indicators (
+  std::vector<unsigned char> &boundary_indicators) const 
+{
+  std::vector<bool> bi_exists(255, false);
+  active_cell_iterator cell=begin_active();
+  for (; cell!=end(); ++cell)
+    for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
+      if (cell->at_boundary(face))
+       bi_exists[cell->face(face)->boundary_indicator()]=true;
+
+  const unsigned int n_bi=
+    std::count(bi_exists.begin(), bi_exists.end(), true);
+
+  boundary_indicators.resize(n_bi);
+  unsigned int bi_counter=0;
+  for (unsigned int i=0; i<bi_exists.size(); ++i)
+    if (bi_exists[i]==true)
+      boundary_indicators[bi_counter++]=i;
+}
+
+
 /*--------- Put the next functions a bit out-or-order to avoid use before
   --------- explicit specialization, which is not allowed.                */
 

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.