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

openmc-dev / openmc / 18299973882

07 Oct 2025 02:14AM UTC coverage: 81.92% (-3.3%) from 85.194%
18299973882

push

github

web-flow
Switch to using coveralls github action for reporting (#3594)

16586 of 23090 branches covered (71.83%)

Branch coverage included in aggregate %.

53703 of 62712 relevant lines covered (85.63%)

43428488.21 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());
×
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,344,126,253✔
41
{
42
  cell_ = C_NONE;
1,344,126,253✔
43
  universe_ = C_NONE;
1,344,126,253✔
44
  lattice_ = C_NONE;
1,344,126,253✔
45
  lattice_index_[0] = 0;
1,344,126,253✔
46
  lattice_index_[1] = 0;
1,344,126,253✔
47
  lattice_index_[2] = 0;
1,344,126,253✔
48
  rotated_ = false;
1,344,126,253✔
49
}
1,344,126,253✔
50

51
GeometryState::GeometryState()
197,220,724✔
52
{
53
  // Create and clear coordinate levels
54
  coord_.resize(model::n_coord_levels);
197,220,724✔
55
  cell_last_.resize(model::n_coord_levels);
197,220,724✔
56
  clear();
197,220,724✔
57
}
197,220,724✔
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()
154,430,349✔
94
{
95
  zero_delayed_bank();
154,430,349✔
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) {
154,430,349✔
101
    flux_derivs_.resize(model::tally_derivs.size());
40,062,885✔
102
    zero_flux_derivs();
40,062,885✔
103
  }
104

105
  // Allocate space for tally filter matches
106
  filter_matches_.resize(model::tally_filters.size());
154,430,349✔
107

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

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

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