Skip to content

Commit

Permalink
improve assert message for non matching reference cell types
Browse files Browse the repository at this point in the history
  • Loading branch information
mschreter committed Sep 20, 2023
1 parent 6091815 commit 98cbe90
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
5 changes: 2 additions & 3 deletions include/deal.II/dofs/dof_accessor.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -2636,9 +2636,8 @@ DoFCellAccessor<dimension_, space_dimension_, level_dof_access>::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;
}
Expand Down
40 changes: 40 additions & 0 deletions include/deal.II/grid/reference_cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,46 @@ namespace internal
*/
const ArrayView<const T> vertices_1;
};

class ExcNonMatchingReferenceCellTypes : public dealii::ExceptionBase
{
public:
/**
* Constructor.
*/
ExcNonMatchingReferenceCellTypes(const ReferenceCell &entity_type_0,
const ReferenceCell &entity_type_1)
: entity_type_0(entity_type_0)
, entity_type_1(entity_type_1)
{}

/**
* Destructor.
*/
virtual ~ExcNonMatchingReferenceCellTypes() noexcept override = default;

/**
* Print error message to @p out.
*/
virtual void
print_info(std::ostream &out) const override
{
out << "The reference-cell type of " << entity_type_0.to_string()
<< " does not match with " << entity_type_1.to_string()
<< ". This could happen if one object (e.g. Triangulation) holds "
<< "reference cells from a hexahedral mesh and the other one "
<< "(FiniteElement) from a simplex mesh." << std::endl;
}

/**
* First entity type.
*/
const ReferenceCell &entity_type_0;
/**
* Second entity type.
*/
const ReferenceCell &entity_type_1;
};
} // namespace internal


Expand Down

0 comments on commit 98cbe90

Please sign in to comment.