From 77b6a4250cc4533f9cba2482a482f124a7510653 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 7 Mar 2024 16:11:00 -0600 Subject: [PATCH 1/3] Correcting element bounding boxes and putting an element lookup safeguard in place --- src/moab/mesh_manager.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/moab/mesh_manager.cpp b/src/moab/mesh_manager.cpp index 19be979..3999e53 100644 --- a/src/moab/mesh_manager.cpp +++ b/src/moab/mesh_manager.cpp @@ -186,7 +186,8 @@ MOABMeshManager::get_surface_elements(MeshID surface) const std::vector MOABMeshManager::element_vertices(MeshID element) const { moab::EntityHandle element_handle; - this->moab_interface()->handle_from_id(moab::MBTRI, element, element_handle); + moab::ErrorCode rval = this->moab_interface()->handle_from_id(moab::MBTRI, element, element_handle); + if (rval == moab::MB_ENTITY_NOT_FOUND) fatal_error("Could not find entity with ID in the mesh database {}", element); auto out = this->mb_direct()->get_mb_coords(element_handle); return std::vector(out.begin(), out.end()); } @@ -206,11 +207,7 @@ Direction MOABMeshManager::triangle_normal(MeshID element) const BoundingBox MOABMeshManager::element_bounding_box(MeshID element) const { auto vertices = this->element_vertices(element); - BoundingBox bb; - for (const auto& v : vertices) { - bb.update(v); - } - return bb; + return BoundingBox::from_points(vertices); } BoundingBox From 6c05fa37d6cb73723170be17eb264918bf7c1783 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 7 Mar 2024 16:11:47 -0600 Subject: [PATCH 2/3] Commenting safeguard for now. Performance+testing first --- src/moab/mesh_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/moab/mesh_manager.cpp b/src/moab/mesh_manager.cpp index 3999e53..a22ef71 100644 --- a/src/moab/mesh_manager.cpp +++ b/src/moab/mesh_manager.cpp @@ -186,8 +186,8 @@ MOABMeshManager::get_surface_elements(MeshID surface) const std::vector MOABMeshManager::element_vertices(MeshID element) const { moab::EntityHandle element_handle; - moab::ErrorCode rval = this->moab_interface()->handle_from_id(moab::MBTRI, element, element_handle); - if (rval == moab::MB_ENTITY_NOT_FOUND) fatal_error("Could not find entity with ID in the mesh database {}", element); + this->moab_interface()->handle_from_id(moab::MBTRI, element, element_handle); + // if (rval == moab::MB_ENTITY_NOT_FOUND) fatal_error("Could not find entity with ID in the mesh database {}", element); auto out = this->mb_direct()->get_mb_coords(element_handle); return std::vector(out.begin(), out.end()); } From c473fbe3592cfe92b7ea4a43d6ccbf92a7e27d4c Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Thu, 7 Mar 2024 16:12:22 -0600 Subject: [PATCH 3/3] Addressing particle IDs a little differently --- tools/particle_sim.cpp | 53 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/tools/particle_sim.cpp b/tools/particle_sim.cpp index 57e3985..39976ef 100644 --- a/tools/particle_sim.cpp +++ b/tools/particle_sim.cpp @@ -141,30 +141,31 @@ const int n_particles {100}; const int max_events {1000}; -bool verbose = true; - - for (int i = 0; i < n_particles; i++) { - write_message("Starting particle {}", i); - Particle p(xdg, i, verbose); - p.initialize(); - while (true) { - p.surf_dist(); - // terminate for leakage - if (!p.alive_) break; - p.sample_collision_distance(); - p.advance(); - if (p.surface_intersection_.first < p.collision_distance_) - p.cross_surface(); - else - p.collide(); - if (!p.alive_) break; - - if (p.n_events_ > max_events) { - write_message("Maximum number of events ({}) reached", max_events); - break; - } - } - } - - return 0; +bool verbose = false; + +for (int i = 0; i < n_particles; i++) { + int particle_id = i+1; + write_message("Starting particle {}", particle_id); + Particle p(xdg, particle_id, verbose); + p.initialize(); + while (true) { + p.surf_dist(); + // terminate for leakage + if (!p.alive_) break; + p.sample_collision_distance(); + p.advance(); + if (p.surface_intersection_.first < p.collision_distance_) + p.cross_surface(); + else + p.collide(); + if (!p.alive_) break; + + if (p.n_events_ > max_events) { + write_message("Maximum number of events ({}) reached", max_events); + break; + } + } +} + +return 0; }