diff --git a/kratos/containers/geometry_container.h b/kratos/containers/geometry_container.h index 8a72268cc17..cfce8e5e9aa 100644 --- a/kratos/containers/geometry_container.h +++ b/kratos/containers/geometry_container.h @@ -128,11 +128,12 @@ class GeometryContainer return mGeometries.insert(pNewGeometry); } else if (&(*i) == pNewGeometry.get()) { // check if the pointee coincides return i; - } else { // check if the connectivities coincide - // first check for the geometry type + } else { // Check if the connectivities coincide + // First check for the geometry type KRATOS_ERROR_IF_NOT(TGeometryType::HasSameGeometryType(*i, *pNewGeometry)) << "Attempting to add geometry with Id: " << pNewGeometry->Id() << ". A different geometry with the same Id already exists." << std::endl; - // check that the connectivities are the same + // Check that the connectivities are the same // note that we deliberately check the node ids and not the pointer adresses as there might be very rare situations + // (e.g., creating nodes bypassing the model part interface) with same connectivities but different pointer addresses for (IndexType i_node = 0; i_node < i->PointsNumber(); ++i_node) { KRATOS_ERROR_IF((*i)[i_node].Id() != (*pNewGeometry)[i_node].Id()) << "Attempting to add a new geometry with Id: " << pNewGeometry->Id() << ". A same type geometry with same Id but different connectivities already exists." << std::endl;