]> https://gitweb.dealii.org/ - dealii.git/commitdiff
confusing set_all_manifold* errors if empty 2456/head
authorTimo Heister <timo.heister@gmail.com>
Mon, 4 Apr 2016 16:55:50 +0000 (12:55 -0400)
committerTimo Heister <timo.heister@gmail.com>
Mon, 4 Apr 2016 16:55:50 +0000 (12:55 -0400)
The error messages for set_all_manifold_ids* are confusing if the mesh
is empty:

An error occurred in line <10760> of file </ssd/deal-
git/source/grid/tria.cc> in function
    dealii::Triangulation<dim, spacedim>::raw_quad_iterator
dealii::Triangulation<dim, spacedim>::begin_raw_quad(unsigned int) const
[with int dim = 2, int spacedim = 2, dealii::Triangulation<dim,
spacedim>::raw_quad_iterator =
dealii::TriaRawIterator<dealii::CellAccessor<2, 2> >]
The violated condition was:
    level<n_global_levels() || level<levels.size()
The name and call sequence of the exception was:
    ExcInvalidLevel(level)
Additional Information:
The given level 0 is not in the valid range!

Fix that.

source/grid/tria.cc

index 99a3e47e25286cf6af1978fc22f6e676bf24c085..7bd94ee3f8f483e376fdc9ff718dbddc01955a6b 100644 (file)
@@ -9023,6 +9023,9 @@ template <int dim, int spacedim>
 void
 Triangulation<dim, spacedim>::set_all_manifold_ids (const types::manifold_id m_number)
 {
+  Assert(n_cells()>0,
+         ExcMessage("Error: set_all_manifold_ids() can not be called on an empty Triangulation."));
+
   typename Triangulation<dim,spacedim>::active_cell_iterator
   cell=this->begin_active(), endc=this->end();
 
@@ -9035,6 +9038,9 @@ template <int dim, int spacedim>
 void
 Triangulation<dim, spacedim>::set_all_manifold_ids_on_boundary (const types::manifold_id m_number)
 {
+  Assert(n_cells()>0,
+         ExcMessage("Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
+
   typename Triangulation<dim,spacedim>::active_cell_iterator
   cell=this->begin_active(), endc=this->end();
 
@@ -9050,6 +9056,9 @@ void
 Triangulation<dim, spacedim>::set_all_manifold_ids_on_boundary (const types::boundary_id b_id,
     const types::manifold_id m_number)
 {
+  Assert(n_cells()>0,
+         ExcMessage("Error: set_all_manifold_ids_on_boundary() can not be called on an empty Triangulation."));
+
   bool boundary_found = false;
   typename Triangulation<dim,spacedim>::active_cell_iterator
   cell=this->begin_active(), endc=this->end();

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.