Skip to content

Commit 8c24c1c

Browse files
vitmogpaulromano
andauthored
Modify the plotter ray tracing for its utilization in estimators (#3816)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent 83a30f6 commit 8c24c1c

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

include/openmc/plot.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,12 @@ class SolidRayTracePlot : public RayTracePlot {
502502
class Ray : public GeometryState {
503503

504504
public:
505+
// Initialize from location and direction
505506
Ray(Position r, Direction u) { init_from_r_u(r, u); }
506507

508+
// Initialize from known geometry state
509+
Ray(const GeometryState& p) : GeometryState(p) {}
510+
507511
// Called at every surface intersection within the model
508512
virtual void on_intersection() = 0;
509513

src/plot.cpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,9 +1667,25 @@ void Ray::trace()
16671667
// After phase one is done, we can starting tracing from cell to cell within
16681668
// the model. This step can use neighbor lists to accelerate the ray tracing.
16691669

1670-
// Attempt to initialize the particle. We may have to enter a loop to move
1671-
// it up to the edge of the model.
1672-
bool inside_cell = exhaustive_find_cell(*this, settings::verbosity >= 10);
1670+
bool inside_cell;
1671+
// Check for location if the particle is already known
1672+
if (lowest_coord().cell() == C_NONE) {
1673+
// The geometry position of the particle is either unknown or outside of the
1674+
// edge of the model.
1675+
if (lowest_coord().universe() == C_NONE) {
1676+
// Attempt to initialize the particle. We may have to
1677+
// enter a loop to move it up to the edge of the model.
1678+
inside_cell = exhaustive_find_cell(*this, settings::verbosity >= 10);
1679+
} else {
1680+
// It has been already calculated that the current position is outside of
1681+
// the edge of the model.
1682+
inside_cell = false;
1683+
}
1684+
} else {
1685+
// Availability of the cell means that the particle is located inside the
1686+
// edge.
1687+
inside_cell = true;
1688+
}
16731689

16741690
// Advance to the boundary of the model
16751691
while (!inside_cell) {
@@ -1750,6 +1766,11 @@ void Ray::trace()
17501766
coord(lev).r() += boundary().distance() * coord(lev).u();
17511767
}
17521768
surface() = boundary().surface();
1769+
// Initialize last cells from the current cell, because the cell() variable
1770+
// does not contain the data for the case of a single-segment ray
1771+
for (int j = 0; j < n_coord(); ++j) {
1772+
cell_last(j) = coord(j).cell();
1773+
}
17531774
n_coord_last() = n_coord();
17541775
n_coord() = boundary().coord_level();
17551776
if (boundary().lattice_translation()[0] != 0 ||

0 commit comments

Comments
 (0)