From dd9bff40a1355cd7dce7d9dd17297ea96ac9ef25 Mon Sep 17 00:00:00 2001 From: rockfool Date: Mon, 16 Sep 2019 12:00:47 -0400 Subject: [PATCH] optimize the switch of white boundary --- src/particle.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/particle.cpp b/src/particle.cpp index 6e87691957..bf107a741c 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -458,15 +458,11 @@ Particle::cross_surface() score_surface_tally(this, model::active_meshsurf_tallies); this->r() = r; } - - Direction u; - if(surf->bc_ == BC_REFLECT) { - // Reflect particle off surface - u = surf->reflect(this->r(), this->u()); - } else if(surf->bc_ == BC_WHITE) { - // Diffuse reflect particle off surface - u = surf->diffuse_reflect(this->r(), this->u()); - } + + Direction u = (surf->bc_ == BC_REFLECT) ? + surf->reflect(this->r(), this->u()) : + surf->diffuse_reflect(this->r(), this->u()); + // Make sure new particle direction is normalized this->u() = u / u.norm();