]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add support to write material ids and boundary indicators.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 9 Apr 1998 09:23:06 +0000 (09:23 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 9 Apr 1998 09:23:06 +0000 (09:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@164 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/data_io.h
deal.II/deal.II/source/numerics/data_io.cc

index 5900fe744e857c6c4811273083f0b77fc36ca011..1a31d95efcd82652876e96e318d2d1d4bcfb87e1 100644 (file)
@@ -437,6 +437,54 @@ class DataOut {
                                      * List of data elements.
                                      */
     vector<DataEntry>  data;
+
+
+                                    /**
+                                     * Return the number of faces in the
+                                     * triangulation which have a boundary
+                                     * indicator not equal to zero. Only
+                                     * these faces are explicitely printed
+                                     * in the #write_*# functions;
+                                     * all faces with indicator 255 are
+                                     * interior ones and an indicator with
+                                     * value zero for faces at the boundary
+                                     * are considered default.
+                                     *
+                                     * This function always returns an empty
+                                     * list in one dimension.
+                                     *
+                                     * The reason for this function is the
+                                     * same as for #write_ucd_faces#. See
+                                     * there for more information.
+                                     */
+    unsigned int n_boundary_faces () const;
+
+                                    /**
+                                     * Write the grid information about
+                                     * faces to #out#. Only those faces
+                                     * are printed which are on the boundary
+                                     * and which have a boundary indicator
+                                     * not equal to zero, since the latter
+                                     * is the default for boundary faces.
+                                     *
+                                     * Since cells and faces are continuously
+                                     * numbered, the #starting_index# for
+                                     * the numbering of the faces is passed
+                                     * also.
+                                     *
+                                     * This function unfortunately can not
+                                     * be included in the regular #write_ucd#
+                                     * function, since it needs special
+                                     * treatment for the case #dim==1#, in
+                                     * which case the face iterators are
+                                     * #void*#'s and lack the member functions
+                                     * which are called. We would not actually
+                                     * call these functions, but the compiler
+                                     * would complain anyway when compiling
+                                     * the function for #dim==1#. Bad luck.
+                                     */
+    void write_ucd_faces (ostream &out,
+                         const unsigned int starting_index) const;
 };
 
 
index f56716c4a59896bca08b3fce0fcad78de7f5180d..bd5740031202dba4df693d78a7f6ca450a9008dc 100644 (file)
@@ -231,7 +231,7 @@ void DataOut<dim>::write_ucd (ostream &out) const {
   DoFHandler<dim>::active_cell_iterator cell,
                                        endc = dofs->end();
   unsigned int n_vertex_dofs;
-  
+
                                   // first loop over all cells to
                                   // find out how many degrees of
                                   // freedom there are located on
@@ -275,7 +275,7 @@ void DataOut<dim>::write_ucd (ostream &out) const {
 
                                   // start with ucd data
   out << n_vertex_dofs << ' '
-      << dofs->get_tria().n_active_cells() << ' '
+      << dofs->get_tria().n_active_cells() + n_boundary_faces() << ' '
       << data.size() << ' '
       << 0 << ' '                  // no cell data
       << 0                         // no model data
@@ -309,21 +309,26 @@ void DataOut<dim>::write_ucd (ostream &out) const {
                                   // we do not use cell data)
   if (true)
     {
-      unsigned int c;
-      for (cell=dofs->begin_active(), c=0; cell!=endc; ++cell, ++c)
+      unsigned int index;
+      for (cell=dofs->begin_active(), index=0; cell!=endc; ++cell, ++index)
        {
-         out << c << ' '
-             << 1 << "   ";             // material id (unused)
+         out << index << ' '
+             << static_cast<unsigned int>(cell->material_id())
+             << " ";
          switch (dim) 
            {
-             case 1:  out << "line  "; break;
-             case 2:  out << "quad  "; break;
-             case 3:  out << "hex   "; break;
+             case 1:  out << "line    "; break;
+             case 2:  out << "quad    "; break;
+             case 3:  out << "hex     "; break;
+             default:
+                   Assert (false, ExcNotImplemented());
            };
          for (unsigned int vertex=0; vertex<(1<<dim); ++vertex)
            out << cell->vertex_dof_index(vertex,0) << ' ';
          out << endl;
        };
+
+      write_ucd_faces (out, index);
     };
 
                                   // if data given: write data, else
@@ -354,6 +359,69 @@ void DataOut<dim>::write_ucd (ostream &out) const {
 
 
 
+template <>
+unsigned int DataOut<1>::n_boundary_faces () const {
+  return 0;
+};
+
+
+
+template <int dim>
+unsigned int DataOut<dim>::n_boundary_faces () const {
+  typename DoFHandler<dim>::active_face_iterator face, endf;
+  unsigned long int n_faces = 0;
+
+  for (face=dofs->begin_active_face(), endf=dofs->end_face();
+       face != endf; ++face)
+    if ((face->boundary_indicator() != 0) &&
+       (face->boundary_indicator() != 255))
+      n_faces++;
+
+  return n_faces;
+};
+
+
+
+template <>
+void DataOut<1>::write_ucd_faces (ostream &, const unsigned int) const {
+  return;
+};
+
+
+
+template <int dim>
+void DataOut<dim>::write_ucd_faces (ostream &out,
+                                   const unsigned int starting_index) const {
+  typename DoFHandler<dim>::active_face_iterator face, endf;
+  unsigned int index=starting_index;
+
+  for (face=dofs->begin_active_face(), endf=dofs->end_face();
+       face != endf; ++face)
+    if ((face->boundary_indicator() != 0) &&
+       (face->boundary_indicator() != 255)) 
+      {
+       out << index << "  "
+           << static_cast<unsigned int>(face->boundary_indicator())
+           << "  ";
+       switch (dim) 
+         {
+           case 2: out << "line    ";  break;
+           case 3: out << "quad    ";  break;
+           default:
+                 Assert (false, ExcNotImplemented());
+         };
+       for (unsigned int vertex=0; vertex<(1<<(dim-1)); ++vertex)
+         out << face->vertex_dof_index(vertex,0) << ' ';
+       out << endl;
+
+       ++index;
+      };         
+};
+
+      
+
+
+
 template <int dim>
 void DataOut<dim>::write_gnuplot (ostream &out) const {
   Assert (dofs != 0, ExcNoDoFHandlerSelected());

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.