std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >
get_vector_data_ranges () const;
+ /**
+ * Validate that the names of the datasets returned by get_dataset_names() and
+ * get_vector_data_ranges() are valid. This currently consists of checking
+ * that names are not used more than once. If an invalid state is encountered,
+ * an Assert() will be triggered in debug mode.
+ */
+ void validate_dataset_names () const;
+
+
/**
* The default number of subdivisions for patches. This is filled by
* parse_parameters() and should be obeyed by build_patches() in derived
}
+template <int dim, int spacedim>
+void
+DataOutInterface<dim,spacedim>::
+validate_dataset_names () const
+{
+#ifdef DEBUG
+ {
+ // Check that names for datasets are only used once. This is somewhat
+ // complicated, because vector ranges might have a name or not.
+ std::set<std::string> all_names;
+
+ const std::vector<std_cxx11::tuple<unsigned int, unsigned int, std::string> >
+ ranges = this->get_vector_data_ranges();
+ const std::vector<std::string> data_names = this->get_dataset_names();
+ const unsigned int n_data_sets = data_names.size();
+ std::vector<bool> data_set_written (n_data_sets, false);
+
+ for (unsigned int n_th_vector=0; n_th_vector<ranges.size(); ++n_th_vector)
+ {
+ const std::string &name = std_cxx11::get<2>(ranges[n_th_vector]);
+ if (name != "")
+ {
+ Assert(all_names.find(name) == all_names.end(),
+ ExcMessage("Error: names of fields in DataOut need to be unique, "
+ "but '" + name + "' is used more than once."));
+ all_names.insert(name);
+ for (unsigned int i=std_cxx11::get<0>(ranges[n_th_vector]);
+ i<=std_cxx11::get<1>(ranges[n_th_vector]);
+ ++i)
+ data_set_written[i] = true;
+ }
+ }
+
+ for (unsigned int data_set=0; data_set<n_data_sets; ++data_set)
+ if (data_set_written[data_set] == false)
+ {
+ const std::string &name = data_names[data_set];
+ Assert(all_names.find(name) == all_names.end(),
+ ExcMessage("Error: names of fields in DataOut need to be unique, "
+ "but '" + name + "' is used more than once."));
+ all_names.insert(name);
+ }
+ }
+#endif
+}
+
// ---------------------------------------------- DataOutReader ----------
Assert (n_subdivisions >= 1,
Exceptions::DataOut::ExcInvalidNumberOfSubdivisions(n_subdivisions));
+ this->validate_dataset_names();
+
// First count the cells we want to create patches of. Also fill the object
// that maps the cell indices to the patch numbers, as this will be needed
// for generation of neighborship information.
Assert (this->triangulation != 0,
Exceptions::DataOut::ExcNoTriangulationSelected());
+ this->validate_dataset_names();
+
unsigned int n_datasets = this->cell_data.size();
for (unsigned int i=0; i<this->dof_data.size(); ++i)
n_datasets += this->dof_data[i]->n_output_variables;
Assert (n_subdivisions >= 1,
Exceptions::DataOut::ExcInvalidNumberOfSubdivisions(n_subdivisions));
+ this->validate_dataset_names();
+
unsigned int n_datasets=this->cell_data.size();
for (unsigned int i=0; i<this->dof_data.size(); ++i)
n_datasets+= this->dof_data[i]->n_output_variables;