diff --git a/include/openmc/ray.h b/include/openmc/ray.h index 1b4ebdb96b..d4eed88685 100644 --- a/include/openmc/ray.h +++ b/include/openmc/ray.h @@ -51,14 +51,26 @@ private: class ParticleRay : public Ray, public Particle { public: + ParticleRay( + Position r, Direction u, ParticleType type_, double time_, double E_) + : Ray(r, u) + { + type() = type_; + time() = time_; + E() = E_; + } + + void on_intersection() override; + // Sets the dist_ variable void update_distance() override; + const double& traversal_distance() const { return traversal_distance_; } + const double& traversal_mfp() const { return traversal_mfp_; } + protected: - // Records how much time passed during travel - double time_distance_ {0.0}; // Records how much mean free paths the ray traveled - double mfp_distance_ {0.0}; + double traversal_mfp_ {0.0}; }; } // namespace openmc diff --git a/src/ray.cpp b/src/ray.cpp index 3287d00198..f0667ff5e1 100644 --- a/src/ray.cpp +++ b/src/ray.cpp @@ -173,11 +173,13 @@ void Ray::update_distance() traversal_distance_ += boundary().distance(); } +void ParticleRay::on_intersection() {} + void ParticleRay::update_distance() { Ray::update_distance(); - time_distance_ += speed() * boundary().distance(); + time() += boundary().distance() / speed(); // Calculate microscopic and macroscopic cross sections if (material() != MATERIAL_VOID) { @@ -205,7 +207,7 @@ void ParticleRay::update_distance() macro_xs().nu_fission = 0.0; } - mfp_distance_ += macro_xs().total * boundary().distance(); + traversal_mfp_ += macro_xs().total * boundary().distance(); } } // namespace openmc