* 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
#include <fe/fe_values.h>
#include <fe/mapping_q1.h>
-
+#ifdef HAVE_STD_STRINGSTREAM
+# include <sstream>
+#else
+# include <strstream>
+#endif
template <int dim>
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);
}
<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