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

openmc-dev / openmc / 22670832759

04 Mar 2026 01:11PM UTC coverage: 81.478% (-0.08%) from 81.556%
22670832759

Pull #3847

github

web-flow
Merge 9853f1f4b into 0ab46dfa3
Pull Request #3847: Implementation of forced collision variance reduction scheme

17565 of 25304 branches covered (69.42%)

Branch coverage included in aggregate %.

78 of 87 new or added lines in 5 files covered. (89.66%)

66 existing lines in 10 files now uncovered.

57934 of 67358 relevant lines covered (86.01%)

61109854.28 hits per line

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

83.02
/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,832✔
24
{
25
  mark_as_lost(message.c_str());
5,832✔
26
}
5,823✔
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)
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()
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()
207,074,932✔
52
{
53
  // Create and clear coordinate levels
54
  coord_.resize(model::n_coord_levels);
207,074,932✔
55
  cell_last_.resize(model::n_coord_levels);
207,074,932✔
56
  clear();
207,074,932✔
57
}
207,074,932✔
58

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

65
  for (auto c_i : root_universe->cells_) {
62,473,752✔
66
    auto dist =
46,855,314✔
67
      model::cells.at(c_i)->distance(root_coord.r(), root_coord.u(), 0, this);
46,855,314✔
68
    if (dist.first < boundary().distance()) {
46,855,314✔
69
      boundary().distance() = dist.first;
20,608,280✔
70
      boundary().surface() = dist.second;
20,608,280✔
71
    }
72
  }
73

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

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

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

93
ParticleData::ParticleData()
161,426,968✔
94
{
95
  zero_delayed_bank();
161,426,968✔
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) {
161,426,968✔
101
    flux_derivs_.resize(model::tally_derivs.size());
40,568,986✔
102
    zero_flux_derivs();
40,568,986✔
103
  }
104

105
  // Allocate space for tally filter matches
106
  filter_matches_.resize(model::tally_filters.size());
161,426,968✔
107

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

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

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