#define __deal2__data_out_h
-//TODO:[?] DataOut determines whether something is a DoF or cell vector by the size of the vector.
-// This will fail if someone is using DG0 elements,
-// since there the number of elements of both types of vectors is the
-// same, but the ordering will usually differ. Errors cannot be plotted
-// anyway, since they are float vectors.
-
-
#include <base/smartpointer.h>
#include <base/multithread_info.h>
class DataOut_DoFData : public DataOutInterface<patch_dim,patch_space_dim>
{
public:
+ /**
+ * Type describing what the
+ * vector given to
+ * @ref{add_data_vector} is: a
+ * vector that has one entry per
+ * degree of freedom in a
+ * @ref{DoFHandler} object (such
+ * as solution vectors), or one
+ * entry per cell in the
+ * triangulation underlying the
+ * @ref{DoFHandler} object (such
+ * as error per cell data). The
+ * value @p{type_automatic} tells
+ * @ref{add_data_vector} to find
+ * out itself (see the
+ * documentation of
+ * @p{add_data_vector} for the
+ * method used).
+ */
+ enum DataVectorType {
+ type_dof_data, type_cell_data, type_automatic
+ };
+
/**
* Constructor
*/
* the number of active cells on
* the present grid, in which
* case it is assumed to be a
- * cell data vector.
+ * cell data vector. As the
+ * number of degrees of freedom
+ * and of cells is usually not
+ * equal, the function can
+ * determine itself which type of
+ * vector it is given; however,
+ * there is one corner case,
+ * namely if you compute with
+ * piecewise constant elements
+ * and have one scalar quantity,
+ * then there are as many cells
+ * as there are degrees of
+ * freedom, but they may be
+ * ordered differently. In that
+ * case, you can change the last
+ * argument of the function from
+ * its default value
+ * @p{type_automatic} to either
+ * @p{type_dof_data} or @p{type_cell_data},
+ * depending on what the vector
+ * represents. Apart from this
+ * corner case, you can leave the
+ * argument at its default value
+ * and let the function determine
+ * the type of the vector itself.
*
* If it is a vector holding DoF
* data, the names given shall be
* are valid and which are not.
*/
void add_data_vector (const Vector<double> &data,
- const std::vector<std::string> &names);
+ const std::vector<std::string> &names,
+ const DataVectorType type = type_automatic);
/**
* This function is an
* each component to @p{name}
*/
void add_data_vector (const Vector<double> &data,
- const std::string &name);
+ const std::string &name,
+ const DataVectorType type = type_automatic);
/**
* Release the pointers to the
* data vector.
*/
std::vector<std::string> names;
-
- /**
- * Physical unit name of this
- * component.
- */
- std::string units;
};
/**
DataEntry::memory_consumption () const
{
return (sizeof (data) +
- MemoryConsumption::memory_consumption (names) +
- MemoryConsumption::memory_consumption (units));
+ MemoryConsumption::memory_consumption (names));
};
template <int dof_handler_dim, int patch_dim, int patch_space_dim>
void
-DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::add_data_vector (const Vector<double> &vec,
- const std::vector<std::string> &names)
+DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::
+add_data_vector (const Vector<double> &vec,
+ const std::vector<std::string> &names,
+ const DataVectorType type)
{
Assert (dofs != 0, ExcNoDoFHandlerSelected ());
// vectors
Assert ((vec.size() == dofs->get_tria().n_active_cells()) ||
(vec.size() == dofs->n_dofs()),
- ExcInvalidVectorSize(vec.size(), dofs->get_tria().n_active_cells(), dofs->n_dofs()));
+ ExcInvalidVectorSize(vec.size(), dofs->get_tria().n_active_cells(),
+ dofs->n_dofs()));
// either cell data and one name,
// or dof data and n_components names
- if (vec.size() == dofs->get_tria().n_active_cells())
- Assert (names.size() == 1,
- ExcInvalidNumberOfNames (names.size(), 1));
- if (vec.size() == dofs->n_dofs())
- Assert (names.size() == dofs->get_fe().n_components(),
- ExcInvalidNumberOfNames (names.size(), dofs->get_fe().n_components()));
+ DataVectorType actual_type = type;
+ if (type == type_automatic)
+ {
+ if (vec.size() == dofs->get_tria().n_active_cells())
+ actual_type = type_cell_data;
+ else
+ actual_type = type_dof_data;
+ };
+
+ switch (actual_type)
+ {
+ case type_cell_data:
+ Assert (vec.size() == dofs->get_tria().n_active_cells(),
+ ExcInvalidVectorSize (vec.size(),
+ dofs->n_dofs(),
+ dofs->get_tria().n_active_cells()));
+ Assert (names.size() == 1,
+ ExcInvalidNumberOfNames (names.size(), 1));
+ break;
+
+ case type_dof_data:
+ Assert (vec.size() == dofs->n_dofs(),
+ ExcInvalidVectorSize (vec.size(),
+ dofs->n_dofs(),
+ dofs->get_tria().n_active_cells()));
+ Assert (names.size() == dofs->get_fe().n_components(),
+ ExcInvalidNumberOfNames (names.size(), dofs->get_fe().n_components()));
+ break;
+
+ case type_automatic:
+ // this case should have
+ // been handled above...
+ Assert (false, ExcInternalError());
+ };
+
for (unsigned int i=0; i<names.size(); ++i)
Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ExcInvalidCharacter (names[i]));
DataEntry new_entry (&vec, names);
- if (vec.size() == dofs->n_dofs())
+ if (actual_type == type_dof_data)
dof_data.push_back (new_entry);
else
- if (vec.size() == dofs->get_tria().n_active_cells())
- cell_data.push_back (new_entry);
- else
- Assert (false,
- ExcInvalidVectorSize (vec.size(),
- dofs->n_dofs(),
- dofs->get_tria().n_active_cells()));
+ cell_data.push_back (new_entry);
};
template <int dof_handler_dim, int patch_dim, int patch_space_dim>
void
-DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::add_data_vector (const Vector<double> &vec,
- const std::string &name)
+DataOut_DoFData<dof_handler_dim,patch_dim,patch_space_dim>::
+add_data_vector (const Vector<double> &vec,
+ const std::string &name,
+ const DataVectorType type)
{
unsigned int n_components = dofs->get_fe().n_components ();
};
};
- add_data_vector (vec, names);
+ add_data_vector (vec, names, type);
}