Skip to content

Commit

Permalink
Merge pull request #21 from pshriwise/bbox-fix
Browse files Browse the repository at this point in the history
Bounding box fix
  • Loading branch information
pshriwise authored Mar 7, 2024
2 parents dc740a5 + c473fbe commit e736319
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
7 changes: 2 additions & 5 deletions src/moab/mesh_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ std::vector<Vertex> MOABMeshManager::element_vertices(MeshID element) const
{
moab::EntityHandle element_handle;
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<Vertex>(out.begin(), out.end());
}
Expand All @@ -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
Expand Down
53 changes: 27 additions & 26 deletions tools/particle_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit e736319

Please sign in to comment.