]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add two asserts in NonMatching::MeshClassifier. 13709/head
authorSimon Sticko <simon@sticko.se>
Tue, 10 May 2022 06:10:50 +0000 (08:10 +0200)
committerSimon Sticko <simon@sticko.se>
Tue, 10 May 2022 06:43:06 +0000 (08:43 +0200)
source/non_matching/mesh_classifier.cc

index 236b14022e93eab35c40274be8de85d28fb2f44b..7195ce3b33698652d18f46846e7ee9bbbeeb9de9 100644 (file)
@@ -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<dim>::location_to_level_set(
     const typename Triangulation<dim>::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<dim>::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());
   }

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.