From 7e5f9c25e5b4d179467f48e32a5c7dafe8834b56 Mon Sep 17 00:00:00 2001 From: Simon Sticko Date: Tue, 10 May 2022 08:10:50 +0200 Subject: [PATCH] Add two asserts in NonMatching::MeshClassifier. --- source/non_matching/mesh_classifier.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/non_matching/mesh_classifier.cc b/source/non_matching/mesh_classifier.cc index 236b14022e..7195ce3b33 100644 --- a/source/non_matching/mesh_classifier.cc +++ b/source/non_matching/mesh_classifier.cc @@ -46,6 +46,16 @@ namespace NonMatching { namespace MeshClassifierImplementation { + DeclExceptionMsg( + ReclassifyNotCalled, + "The Triangulation has not been classified. You need to call the " + "reclassify()-function before using this function."); + + DeclExceptionMsg( + ExcTriangulationMismatch, + "The incoming cell does not belong to the triangulation passed to " + "the constructor."); + /** * Return LocationToLevelSet::inside/outside if all values in incoming * vector are negative/positive, otherwise return @@ -419,6 +429,11 @@ namespace NonMatching MeshClassifier::location_to_level_set( const typename Triangulation::cell_iterator &cell) const { + Assert(cell_locations.size() == triangulation->n_active_cells(), + internal::MeshClassifierImplementation::ReclassifyNotCalled()); + Assert(&cell->get_triangulation() == triangulation, + internal::MeshClassifierImplementation::ExcTriangulationMismatch()); + return cell_locations.at(cell->active_cell_index()); } @@ -431,6 +446,10 @@ namespace NonMatching const unsigned int face_index) const { AssertIndexRange(face_index, GeometryInfo::faces_per_cell); + Assert(face_locations.size() == triangulation->n_raw_faces(), + internal::MeshClassifierImplementation::ReclassifyNotCalled()); + Assert(&cell->get_triangulation() == triangulation, + internal::MeshClassifierImplementation::ExcTriangulationMismatch()); return face_locations.at(cell->face(face_index)->index()); } -- 2.39.5