From: Matthias Maier Date: Sat, 1 Jul 2023 14:44:58 +0000 (-0500) Subject: FESystem: do not abuse Subscriptor* as a fancy void* X-Git-Tag: relicensing~814^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d6668b55a53ca4758d007fafc06ad3a5422ba73;p=dealii.git FESystem: do not abuse Subscriptor* as a fancy void* Instead use dynamic_cast to check for cast compatibility at runtime. Interestengly, we already did in the debug Assert to check that everything is in order. --- diff --git a/source/fe/fe_system.cc b/source/fe/fe_system.cc index 1d2102928c..d7a6627c37 100644 --- a/source/fe/fe_system.cc +++ b/source/fe/fe_system.cc @@ -1431,39 +1431,29 @@ FESystem::compute_fill( // static cast through the common base class: if (face_no == invalid_face_number) { - const Subscriptor *quadrature_base_pointer = &quadrature; - Assert(dynamic_cast *>( - quadrature_base_pointer) != nullptr, - ExcInternalError()); - cell_quadrature = - static_cast *>(quadrature_base_pointer); + dynamic_cast *>(&quadrature); + Assert(cell_quadrature != nullptr, ExcInternalError()); n_q_points = cell_quadrature->size(); } else if (sub_no == invalid_face_number) { - const Subscriptor *quadrature_base_pointer = &quadrature; - Assert(dynamic_cast *>( - quadrature_base_pointer) != nullptr, - ExcInternalError()); - // If we don't have wedges or pyramids then there should only be one // quadrature rule here - face_quadrature = static_cast *>( - quadrature_base_pointer); + face_quadrature = + dynamic_cast *>(&quadrature); + Assert(face_quadrature != nullptr, ExcInternalError()); + n_q_points = (*face_quadrature)[face_quadrature->size() == 1 ? 0 : face_no] .size(); } else { - const Subscriptor *quadrature_base_pointer = &quadrature; - Assert(dynamic_cast *>( - quadrature_base_pointer) != nullptr, - ExcInternalError()); - sub_face_quadrature = - static_cast *>(quadrature_base_pointer); + dynamic_cast *>(&quadrature); + Assert(sub_face_quadrature != nullptr, ExcInternalError()); + n_q_points = sub_face_quadrature->size(); } Assert(n_q_points != numbers::invalid_unsigned_int, ExcInternalError());