From 13889d164f4ad7146e5f1d271957632459188a04 Mon Sep 17 00:00:00 2001 From: waqar-ukaea Date: Tue, 3 Jun 2025 10:54:49 +0100 Subject: [PATCH 1/3] Assign void material if no volume property found --- src/mesh_manager_interface.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mesh_manager_interface.cpp b/src/mesh_manager_interface.cpp index a0f461f0..8374b1a7 100644 --- a/src/mesh_manager_interface.cpp +++ b/src/mesh_manager_interface.cpp @@ -71,7 +71,12 @@ MeshManager::surface_has_property(MeshID surface, PropertyType type) const Property MeshManager::get_volume_property(MeshID volume, PropertyType type) const { - return volume_metadata_.at({volume, type}); + try { + return volume_metadata_.at({volume, type}); + } + catch (const std::out_of_range e) { + return VOID_MATERIAL; + } } Property From cd86e7a3856a4d07dc512ecdf30e1750c667a181 Mon Sep 17 00:00:00 2001 From: waqar-ukaea Date: Tue, 3 Jun 2025 10:57:21 +0100 Subject: [PATCH 2/3] Added similar exception handling for get_surface_property() --- src/mesh_manager_interface.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mesh_manager_interface.cpp b/src/mesh_manager_interface.cpp index 8374b1a7..f974b23e 100644 --- a/src/mesh_manager_interface.cpp +++ b/src/mesh_manager_interface.cpp @@ -82,9 +82,14 @@ MeshManager::get_volume_property(MeshID volume, PropertyType type) const Property MeshManager::get_surface_property(MeshID surface, PropertyType type) const { - if (surface_metadata_.count({surface, type}) == 0) - return {PropertyType::BOUNDARY_CONDITION, "transmission"}; - return surface_metadata_.at({surface, type}); + try { + if (surface_metadata_.count({surface, type}) == 0) + return {PropertyType::BOUNDARY_CONDITION, "transmission"}; + return surface_metadata_.at({surface, type}); + } + catch (const std::out_of_range e) { + return VOID_MATERIAL; + } } MeshID MeshManager::next_volume(MeshID current_volume, MeshID surface) const From 1fb5e414ac48b138d86047a41927f7e18bfea7d8 Mon Sep 17 00:00:00 2001 From: waqar-ukaea Date: Mon, 9 Jun 2025 13:37:39 +0100 Subject: [PATCH 3/3] Added a PROPERTY_NOT_FOUND constant --- include/xdg/constants.h | 3 +++ src/mesh_manager_interface.cpp | 20 ++++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/include/xdg/constants.h b/include/xdg/constants.h index b3d97ce5..e6e08354 100644 --- a/include/xdg/constants.h +++ b/include/xdg/constants.h @@ -77,12 +77,15 @@ constexpr int BVH_MAX_DEPTH = 64; // geometric property type (e.g. material assignment or boundary condition) // TODO: separate into VolumeProperty and SurfaceProperty enum class PropertyType { + NOT_FOUND = -2, BOUNDARY_CONDITION = -1, MATERIAL = 0, DENSITY = 1, TEMPERATURE = 2 }; +static const Property PROPERTY_NOT_FOUND {PropertyType::NOT_FOUND, "NOT_FOUND"}; + static const std::map PROP_TYPE_TO_STR = { {PropertyType::BOUNDARY_CONDITION, "BOUNDARY_CONDITION"}, diff --git a/src/mesh_manager_interface.cpp b/src/mesh_manager_interface.cpp index f974b23e..b59b9199 100644 --- a/src/mesh_manager_interface.cpp +++ b/src/mesh_manager_interface.cpp @@ -71,25 +71,17 @@ MeshManager::surface_has_property(MeshID surface, PropertyType type) const Property MeshManager::get_volume_property(MeshID volume, PropertyType type) const { - try { - return volume_metadata_.at({volume, type}); - } - catch (const std::out_of_range e) { - return VOID_MATERIAL; - } + if (surface_metadata_.count({volume, type}) == 0) + return PROPERTY_NOT_FOUND; + return volume_metadata_.at({volume, type}); } Property MeshManager::get_surface_property(MeshID surface, PropertyType type) const { - try { - if (surface_metadata_.count({surface, type}) == 0) - return {PropertyType::BOUNDARY_CONDITION, "transmission"}; - return surface_metadata_.at({surface, type}); - } - catch (const std::out_of_range e) { - return VOID_MATERIAL; - } + if (surface_metadata_.count({surface, type}) == 0) + return {PropertyType::BOUNDARY_CONDITION, "transmission"}; + return surface_metadata_.at({surface, type}); } MeshID MeshManager::next_volume(MeshID current_volume, MeshID surface) const