From: Magdalena Schreter Date: Wed, 20 Sep 2023 13:03:23 +0000 (+0200) Subject: improve assert message for non matching reference cell types X-Git-Tag: relicensing~482^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16020%2Fhead;p=dealii.git improve assert message for non matching reference cell types --- diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index 43cadc9db3..3c2e04763f 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -2636,9 +2636,8 @@ DoFCellAccessor::get_fe() const const auto &fe = this->dof_handler->get_fe(active_fe_index()); Assert(this->reference_cell() == fe.reference_cell(), - ExcMessage( - "The reference-cell type of the cell does not match the one of the " - "finite element!")); + internal::ExcNonMatchingReferenceCellTypes(this->reference_cell(), + fe.reference_cell())); return fe; } diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index aeea0690de..11bcb633b6 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -2687,6 +2687,25 @@ namespace internal */ const ArrayView vertices_1; }; + + /** + * This exception is raised whenever the types of two reference cell objects + * were assumed to be equal, but were not. + * + * Parameters to the constructor are the first and second reference cells, + * both of type ReferenceCell. + */ + DeclException2( + ExcNonMatchingReferenceCellTypes, + ReferenceCell, + ReferenceCell, + << "The reference-cell type used on this cell (" << arg1.to_string() + << ") does not match the reference-cell type of the finite element " + << "associated with this cell (" << arg2.to_string() << "). " + << "Did you accidentally use simplex elements on hypercube meshes " + << "(or the other way around), or are you using a mixed mesh and " + << "assigned a simplex element to a hypercube cell (or the other " + << "way around) via the active_fe_index?"); } // namespace internal diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index bdbdb228cf..d4ef78f357 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -9560,7 +9560,7 @@ XDMFEntry::get_xdmf_content(const unsigned int indent_level, // We now store the type of cell in the XDMFEntry: (void)reference_cell; Assert(cell_type == reference_cell, - ExcMessage("Incorrect ReferenceCell type passed in.")); + internal::ExcNonMatchingReferenceCellTypes(cell_type, reference_cell)); return get_xdmf_content(indent_level); }