]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Handle the case that a vector-valued element is given to add_data_vector, but
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 29 Jul 2005 20:40:23 +0000 (20:40 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 29 Jul 2005 20:40:23 +0000 (20:40 +0000)
only a single name.

git-svn-id: https://svn.dealii.org/trunk@11218 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/data_out_stack.h
deal.II/deal.II/source/numerics/data_out_stack.cc
deal.II/doc/news/changes.html

index 62500f5d889afed94d2b6acbbe87007f1a5e790a..df9ba68e196578f7986917179ec80bd1e68636e2 100644 (file)
@@ -191,6 +191,14 @@ class DataOutStack : public DataOutInterface<dim+1>
                                      * and therefore only one name needs to
                                      * be given.
                                      *
+                                     * If @p vec is a vector with
+                                     * multiple components this
+                                     * function will generate
+                                     * distinct names for all
+                                     * components by appending an
+                                     * underscore and the number of
+                                     * each component to @p name
+                                     * 
                                      * The data vector must have been
                                      * registered using the @p declare_data_vector
                                      * function before actually using it the
index 75915ed45ca3e8c9e714a705d6f989b73a4d3afb..8cd39eff8dbfc643faee531c8fa306f14786390e 100644 (file)
 #include <fe/fe_values.h>
 #include <fe/mapping_q1.h>
 
-
+#ifdef HAVE_STD_STRINGSTREAM
+#  include <sstream>
+#else
+#  include <strstream>
+#endif
 
 
 template <int dim>
@@ -128,8 +132,37 @@ template <typename number>
 void DataOutStack<dim>::add_data_vector (const Vector<number> &vec,
                                         const std::string    &name)
 {
+  const unsigned int n_components = dof_handler->get_fe().n_components ();
+
   std::vector<std::string> names;
-  names.push_back (name);
+                                  // if only one component or vector
+                                  // is cell vector: we only need one
+                                  // name
+  if ((n_components == 1) ||
+      (vec.size() == dof_handler->get_tria().n_active_cells()))
+    {
+      names.resize (1, name);
+    }
+  else
+                                    // otherwise append _i to the
+                                    // given name
+    {
+      names.resize (n_components);
+      for (unsigned int i=0; i<n_components; ++i)
+       {
+#ifdef HAVE_STD_STRINGSTREAM
+         std::ostringstream namebuf;
+#else
+         std::ostrstream namebuf;
+#endif
+         namebuf << '_' << i;
+#ifndef HAVE_STD_STRINGSTREAM
+         namebuf << std::ends;
+#endif
+         names[i] = name + namebuf.str();
+       }
+    }
+
   add_data_vector (vec, names);
 }
 
index ba4299bc81db2b428d896a511a8ff8c2318b5865..5abb9cbbe5758a84a3a02b694856f223aac9e5b0 100644 (file)
@@ -583,6 +583,16 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p>
+       New: The <code class="member">DataOutStack::add_data_vector</code>
+       function now also allows to give only a single name even if the data is
+       vector-valued. It then makes up names for the individual components by
+       adding numbers to the name, just like the <code
+       class="class">DataOut</code> class already does for a long time.
+       <br> 
+       (WB, 2005/07/29)
+       </p>
+
   <li> <p>
        New: The <code class="class">DataOutStack</code> class can now also be
        used to stack two-dimensional time or parameter dependent data into a 3d

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.