• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 25341025017

04 May 2026 08:11PM UTC coverage: 81.374%. Remained the same
25341025017

Pull #3923

github

web-flow
Merge 69ec75275 into 368ea069c
Pull Request #3923: Increase numerical robustness of cylindrical and spherical distance to boundary checks

17717 of 25568 branches covered (69.29%)

Branch coverage included in aggregate %.

11 of 12 new or added lines in 1 file covered. (91.67%)

45 existing lines in 6 files now uncovered.

58518 of 68117 relevant lines covered (85.91%)

50817959.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.79
/src/particle_data.cpp
1
#include "openmc/particle_data.h"
2

3
#include <sstream>
4

5
#include "openmc/cell.h"
6
#include "openmc/error.h"
7
#include "openmc/geometry.h"
8
#include "openmc/material.h"
9
#include "openmc/nuclide.h"
10
#include "openmc/photon.h"
11
#include "openmc/settings.h"
12
#include "openmc/tallies/derivative.h"
13
#include "openmc/tallies/filter.h"
14
#include "openmc/tallies/tally.h"
15

16
namespace openmc {
17

18
void GeometryState::mark_as_lost(const char* message)
×
19
{
20
  fatal_error(message);
×
21
}
22

23
void GeometryState::mark_as_lost(const std::string& message)
5,799✔
24
{
25
  mark_as_lost(message.c_str());
5,799✔
26
}
5,790✔
27

28
void GeometryState::mark_as_lost(const std::stringstream& message)
×
29
{
30
  mark_as_lost(message.str());
×
31
}
×
32

33
void LocalCoord::rotate(const vector<double>& rotation)
66,594,253✔
34
{
35
  r_ = r_.rotate(rotation);
66,594,253✔
36
  u_ = u_.rotate(rotation);
66,594,253✔
37
  rotated_ = true;
66,594,253✔
38
}
66,594,253✔
39

40
void LocalCoord::reset()
2,147,483,647✔
41
{
42
  cell_ = C_NONE;
2,147,483,647✔
43
  universe_ = C_NONE;
2,147,483,647✔
44
  lattice_ = C_NONE;
2,147,483,647✔
45
  lattice_index_[0] = 0;
2,147,483,647✔
46
  lattice_index_[1] = 0;
2,147,483,647✔
47
  lattice_index_[2] = 0;
2,147,483,647✔
48
  rotated_ = false;
2,147,483,647✔
49
}
2,147,483,647✔
50

51
GeometryState::GeometryState()
568,873,330✔
52
{
53
  // Create and clear coordinate levels
54
  coord_.resize(model::n_coord_levels);
568,873,330✔
55
  cell_last_.resize(model::n_coord_levels);
568,873,330✔
56
  clear();
568,873,330✔
57
}
568,873,330✔
58

59
void GeometryState::advance_to_boundary_from_void()
15,618,757✔
60
{
61
  auto root_coord = this->coord(0);
15,618,757✔
62
  const auto& root_universe = model::universes[model::root_universe];
15,618,757✔
63
  boundary().reset();
15,618,757✔
64

65
  for (auto c_i : root_universe->cells_) {
62,475,028✔
66
    auto dist =
46,856,271✔
67
      model::cells.at(c_i)->distance(root_coord.r(), root_coord.u(), 0, this);
46,856,271✔
68
    if (dist.first < boundary().distance()) {
46,856,271✔
69
      boundary().distance() = dist.first;
20,609,006✔
70
      boundary().surface() = dist.second;
20,609,006✔
71
    }
72
  }
73

74
  // if no intersection or near-infinite intersection, reset
75
  // boundary information
76
  if (boundary().distance() > 1e300) {
15,618,757✔
77
    boundary().distance() = INFTY;
1,971,156✔
78
    boundary().surface() = SURFACE_NONE;
1,971,156✔
79
    return;
1,971,156✔
80
  }
81

82
  // move the particle up to (and just past) the boundary
83
  move_distance(boundary().distance() + TINY_BIT);
13,647,601✔
84
}
85

86
void GeometryState::move_distance(double length)
2,147,483,647✔
87
{
UNCOV
88
  for (int j = 0; j < n_coord(); ++j) {
✔
89
    coord(j).r() += length * coord(j).u();
2,147,483,647✔
90
  }
91
}
2,147,483,647✔
92

93
ParticleData::ParticleData()
346,439,590✔
94
{
95
  zero_delayed_bank();
346,439,590✔
96

97
  // Every particle starts with no accumulated flux derivative.  Note that in
98
  // event mode, we construct the particle once up front, so have to run this
99
  // even if the current batch is inactive.
100
  if (!model::active_tallies.empty() || settings::event_based) {
346,439,590✔
101
    flux_derivs_.resize(model::tally_derivs.size());
47,571,694✔
102
    zero_flux_derivs();
47,571,694✔
103
  }
104

105
  // Allocate space for tally filter matches
106
  filter_matches_.resize(model::tally_filters.size());
346,439,590✔
107

108
  // Create microscopic cross section caches
109
  neutron_xs_.resize(data::nuclides.size());
346,439,590✔
110
  photon_xs_.resize(data::elements.size());
346,439,590✔
111

112
  // Creates the pulse-height storage for the particle
113
  if (!model::pulse_height_cells.empty()) {
346,439,590✔
114
    pht_storage_.resize(model::pulse_height_cells.size(), 0.0);
5,100✔
115
  }
116
}
346,439,590✔
117

118
TrackState ParticleData::get_track_state() const
16,554✔
119
{
120
  TrackState state;
16,554!
121
  state.r = this->r();
16,554!
122
  state.u = this->u();
16,554!
123
  state.E = this->E();
16,554✔
124
  state.time = this->time();
16,554✔
125
  state.wgt = this->wgt();
16,554!
126
  state.cell_id = model::cells[this->lowest_coord().cell()]->id_;
16,554!
127
  state.cell_instance = this->cell_instance();
16,554✔
128
  if (this->material() != MATERIAL_VOID) {
16,554!
129
    state.material_id = model::materials[material()]->id_;
16,554✔
130
  }
131
  return state;
16,554✔
132
}
133

134
} // namespace openmc
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc