From 655da87b9a2da7d0c172221aaeaa9a29b031ce9b Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 13 Jun 2000 11:38:57 +0000 Subject: [PATCH] Improve on the type of exception that is generated when a vector has wrong size. Previously we got the null-information exception -------------------------------------------------------- An error occurred in line <83> of file in function void DataOut_DoFData<2>::add_data_vector(const Vector &, const vector,__malloc_alloc_template<0> >,allocator,__malloc_alloc_template<0> > > > &) The violated condition was: ((vec.size() == dofs->get_tria().n_active_cells()) && (names.size() == 1)) || ((vec.size() == dofs->n_dofs()) && (names.size() == dofs->get_fe().n_components())) The name and call sequence of the exception was: ExcInvalidNumberOfNames (names.size(), dofs->get_fe().n_components()) Additional Information: You have to give one name per component in your data vector. The number you gave was 1, but the number of components is 1 -------------------------------------------------------- which does not shed much light on what the problem is (number of components seems to be ok, not?) Now we get 1-------------------------------------------------------- An error occurred in line <81> of file in function void DataOut_DoFData<2>::add_data_vector(const Vector &, const vector,__malloc_alloc_template<0> >,allocator,__malloc_alloc_template<0> > > > &) The violated condition was: (vec.size() == dofs->get_tria().n_active_cells()) || (vec.size() == dofs->n_dofs()) The name and call sequence of the exception was: ExcInvalidVectorSize(vec.size(), dofs->get_tria().n_active_cells(), dofs->n_dofs()) Additional Information: The vector has size 0 but the DoFHandler objects says there are 2560 degrees of freedom and there are 2641 active cells. -------------------------------------------------------- git-svn-id: https://svn.dealii.org/trunk@3008 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/source/numerics/data_out.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/deal.II/deal.II/source/numerics/data_out.cc b/deal.II/deal.II/source/numerics/data_out.cc index aef1a22890..baeb073f28 100644 --- a/deal.II/deal.II/source/numerics/data_out.cc +++ b/deal.II/deal.II/source/numerics/data_out.cc @@ -73,14 +73,21 @@ void DataOut_DoFData::add_data_vector (const Vector &vec, const vector &names) { Assert (dofs != 0, ExcNoDoFHandlerSelected ()); + + // check for allowed sizes of + // 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())); + // either cell data and one name, // or dof data and n_components names - Assert (((vec.size() == dofs->get_tria().n_active_cells()) && - (names.size() == 1)) - || - ((vec.size() == dofs->n_dofs()) && - (names.size() == dofs->get_fe().n_components())), - ExcInvalidNumberOfNames (names.size(), dofs->get_fe().n_components())); + 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())); for (unsigned int i=0; i