]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
bug fix: renumber vertices in GridOut::write_dx() to match implicit vertex numbering...
authorleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Jan 2007 16:03:06 +0000 (16:03 +0000)
committerleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 10 Jan 2007 16:03:06 +0000 (16:03 +0000)
git-svn-id: https://svn.dealii.org/trunk@14293 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/grid/grid_out.cc

index e680ac11a979ff6b04155e1ed50c504a4b5f4ccc..91c18d21a17e2fff62962f54f4b6e061ccdd128e 100644 (file)
@@ -57,6 +57,20 @@ void GridOut::write_dx (const Triangulation<dim> &tria,
   
   const unsigned int n_vertices = tria.n_used_vertices();
 
+                                  // vertices are implicitly numbered from 0 to
+                                  // n_vertices-1. we have to renumber the
+                                  // vertices, because otherwise we would end
+                                  // up with wrong results, if there are unused
+                                  // vertices
+  std::vector<unsigned int> renumber(vertices.size());
+                                  // fill this vector with new vertex numbers
+                                  // ranging from 0 to n_vertices-1
+  unsigned int new_number=0;
+  for (unsigned int i=0; i<vertices.size(); ++i)
+    if (vertex_used[i])
+      renumber[i]=new_number++;
+  Assert(new_number==n_vertices, ExcInternalError());
+
   typename Triangulation<dim>::active_cell_iterator       cell;
   const typename Triangulation<dim>::active_cell_iterator endc=tria.end();
 
@@ -92,7 +106,7 @@ void GridOut::write_dx (const Triangulation<dim> &tria,
       for (cell = tria.begin_active(); cell != endc; ++cell)
        {
          for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_cell; ++v)
-           out << '\t' << cell->vertex_index(GeometryInfo<dim>::dx_to_deal[v]);
+           out << '\t' << renumber[cell->vertex_index(GeometryInfo<dim>::dx_to_deal[v])];
          out << '\n';
        }
       out << "attribute \"element type\" string \"";
@@ -153,7 +167,7 @@ void GridOut::write_dx (const Triangulation<dim> &tria,
              typename Triangulation<dim>::face_iterator face = cell->face(f);
              
              for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
-               out << '\t' << face->vertex_index(GeometryInfo<dim-1>::dx_to_deal[v]);
+               out << '\t' << renumber[face->vertex_index(GeometryInfo<dim-1>::dx_to_deal[v])];
              out << '\n';
            }
        }

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.