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

openmc-dev / openmc / 18538152141

15 Oct 2025 06:02PM UTC coverage: 81.97% (-3.2%) from 85.194%
18538152141

Pull #3417

github

web-flow
Merge 4604e1321 into e9077b137
Pull Request #3417: Addition of a collision tracking feature

16794 of 23357 branches covered (71.9%)

Branch coverage included in aggregate %.

480 of 522 new or added lines in 13 files covered. (91.95%)

457 existing lines in 53 files now uncovered.

54128 of 63165 relevant lines covered (85.69%)

42776927.64 hits per line

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

92.0
/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());
×
UNCOV
31
}
×
32

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

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

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

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

65
  for (auto c_i : root_universe->cells_) {
62,466,360✔
66
    auto dist =
67
      model::cells.at(c_i)->distance(root_coord.r(), root_coord.u(), 0, this);
46,849,770✔
68
    if (dist.first < boundary().distance()) {
46,849,770✔
69
      boundary().distance() = dist.first;
20,604,452✔
70
      boundary().surface() = dist.second;
20,604,452✔
71
    }
72
  }
73

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

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

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

93
ParticleData::ParticleData()
153,014,212✔
94
{
95
  zero_delayed_bank();
153,014,212✔
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) {
153,014,212✔
101
    flux_derivs_.resize(model::tally_derivs.size());
38,648,370✔
102
    zero_flux_derivs();
38,648,370✔
103
  }
104

105
  // Allocate space for tally filter matches
106
  filter_matches_.resize(model::tally_filters.size());
153,014,212✔
107

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

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

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

© 2025 Coveralls, Inc