]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix problem when printing in ucd format: output each vertex's data only once.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 30 Apr 1998 10:20:23 +0000 (10:20 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 30 Apr 1998 10:20:23 +0000 (10:20 +0000)
git-svn-id: https://svn.dealii.org/trunk@226 0785d39b-7218-0410-832d-ea1e28bc413d

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

index c689f85f5b127cdfb6356a51fb621339dadc10d3..745abddca2ecd57937ad19b21f4149f6162c2cd8 100644 (file)
@@ -340,7 +340,7 @@ void DataOut<dim>::write_ucd (ostream &out) const {
                                   // if data given: write data, else
                                   // only write grid
   if (data.size() != 0)
-    {
+    {      
       out << data.size() << "    ";    // number of vectors
       for (unsigned int i=0; i!=data.size(); ++i)
        out << 1 << ' ';               // number of components;
@@ -349,15 +349,28 @@ void DataOut<dim>::write_ucd (ostream &out) const {
       
       for (unsigned int i=0; i<data.size(); ++i)
        out << data[i].name << ',' << data[i].units << endl;
-      
+
+                                      // AVS requires that the dof values
+                                      // be given in exactly the same order
+                                      // as in the vertex section and only
+                                      // once.
+
+                                      // note if a given vertex was
+                                      // already written
+      vector<bool> already_written (dofs->n_dofs(), false);
+                                      // write vertices
       for (cell=dofs->begin_active(); cell!=endc; ++cell)
-       for (unsigned int vertex=0; vertex<(1<<dim); ++vertex)
-         {
-           out << cell->vertex_dof_index(vertex,0) << "   ";
-           for (unsigned int i=0; i!=data.size(); ++i)
-             out << (*data[i].data)(cell->vertex_dof_index(vertex,0)) << ' ';
-           out << endl;
-         };
+       for (unsigned int vertex=0; vertex<(1<<dim); ++vertex) 
+         if (already_written[cell->vertex_dof_index(vertex,0)]==false)
+           {
+             out << cell->vertex_dof_index(vertex,0) // vertex index
+                 << "   "; 
+             for (unsigned int i=0; i!=data.size(); ++i)
+               out << (*data[i].data)(cell->vertex_dof_index(vertex,0)) << ' ';
+             out << endl;
+
+             already_written[cell->vertex_dof_index(vertex,0)] = true;
+           };
     };
                                   // no cell data
                                   // no model data

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.