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

openmc-dev / openmc / 21106440915

18 Jan 2026 05:07AM UTC coverage: 80.822% (-1.2%) from 82.044%
21106440915

Pull #3732

github

web-flow
Merge e0d6fcdcf into 5847b0de2
Pull Request #3732: Volume Calculation enhancement including refactoring and real-valued scoring implementation

15996 of 22249 branches covered (71.9%)

Branch coverage included in aggregate %.

229 of 255 new or added lines in 3 files covered. (89.8%)

1115 existing lines in 52 files now uncovered.

53688 of 63970 relevant lines covered (83.93%)

13914511.73 hits per line

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

96.75
/src/finalize.cpp
1
#include "openmc/finalize.h"
2

3
#include "openmc/bank.h"
4
#include "openmc/capi.h"
5
#include "openmc/cmfd_solver.h"
6
#include "openmc/collision_track.h"
7
#include "openmc/constants.h"
8
#include "openmc/cross_sections.h"
9
#include "openmc/dagmc.h"
10
#include "openmc/eigenvalue.h"
11
#include "openmc/event.h"
12
#include "openmc/geometry.h"
13
#include "openmc/geometry_aux.h"
14
#include "openmc/material.h"
15
#include "openmc/mesh.h"
16
#include "openmc/message_passing.h"
17
#include "openmc/nuclide.h"
18
#include "openmc/photon.h"
19
#include "openmc/plot.h"
20
#include "openmc/random_lcg.h"
21
#include "openmc/random_ray/random_ray_simulation.h"
22
#include "openmc/settings.h"
23
#include "openmc/simulation.h"
24
#include "openmc/source.h"
25
#include "openmc/surface.h"
26
#include "openmc/tallies/tally.h"
27
#include "openmc/thermal.h"
28
#include "openmc/timer.h"
29
#include "openmc/volume_calc.h"
30
#include "openmc/weight_windows.h"
31

32
#include "xtensor/xview.hpp"
33

34
namespace openmc {
35

36
void free_memory()
1,252✔
37
{
38
  free_memory_geometry();
1,252✔
39
  free_memory_surfaces();
1,252✔
40
  free_memory_material();
1,252✔
41
  free_memory_volume();
1,252✔
42
  free_memory_simulation();
1,252✔
43
  free_memory_photon();
1,252✔
44
  free_memory_settings();
1,252✔
45
  free_memory_thermal();
1,252✔
46
  library_clear();
1,252✔
47
  nuclides_clear();
1,252✔
48
  free_memory_source();
1,252✔
49
  free_memory_mesh();
1,252✔
50
  free_memory_tally();
1,252✔
51
  free_memory_bank();
1,252✔
52
  free_memory_plot();
1,252✔
53
  free_memory_weight_windows();
1,252✔
54
  if (mpi::master) {
1,252!
55
    free_memory_cmfd();
1,252✔
56
  }
57
  if (settings::event_based) {
1,252!
58
    free_event_queues();
×
59
  }
60
}
1,252✔
61

62
} // namespace openmc
63

64
using namespace openmc;
65

66
int openmc_finalize()
1,252✔
67
{
68
  if (simulation::initialized)
1,252!
UNCOV
69
    openmc_simulation_finalize();
×
70

71
  // Clear results
72
  openmc_reset();
1,252✔
73

74
  // Reset timers
75
  reset_timers();
1,252✔
76

77
  // Reset global variables
78
  settings::assume_separate = false;
1,252✔
79
  settings::check_overlaps = false;
1,252✔
80
  settings::collision_track_config = CollisionTrackConfig {};
1,252✔
81
  settings::confidence_intervals = false;
1,252✔
82
  settings::create_fission_neutrons = true;
1,252✔
83
  settings::create_delayed_neutrons = true;
1,252✔
84
  settings::electron_treatment = ElectronTreatment::LED;
1,252✔
85
  settings::delayed_photon_scaling = true;
1,252✔
86
  settings::energy_cutoff = {0.0, 1000.0, 0.0, 0.0};
1,252✔
87
  settings::time_cutoff = {INFTY, INFTY, INFTY, INFTY};
1,252✔
88
  settings::entropy_on = false;
1,252✔
89
  settings::event_based = false;
1,252✔
90
  settings::free_gas_threshold = 400.0;
1,252✔
91
  settings::gen_per_batch = 1;
1,252✔
92
  settings::legendre_to_tabular = true;
1,252✔
93
  settings::legendre_to_tabular_points = -1;
1,252✔
94
  settings::material_cell_offsets = true;
1,252✔
95
  settings::max_lost_particles = 10;
1,252✔
96
  settings::max_order = 0;
1,252✔
97
  settings::max_particles_in_flight = 100000;
1,252✔
98
  settings::max_secondaries = 10000;
1,252✔
99
  settings::max_particle_events = 1'000'000;
1,252✔
100
  settings::max_history_splits = 10'000'000;
1,252✔
101
  settings::max_tracks = 1000;
1,252✔
102
  settings::max_write_lost_particles = -1;
1,252✔
103
  settings::n_log_bins = 8000;
1,252✔
104
  settings::n_inactive = 0;
1,252✔
105
  settings::n_particles = -1;
1,252✔
106
  settings::output_summary = true;
1,252✔
107
  settings::output_tallies = true;
1,252✔
108
  settings::particle_restart_run = false;
1,252✔
109
  settings::path_cross_sections.clear();
1,252✔
110
  settings::path_input.clear();
1,252✔
111
  settings::path_output.clear();
1,252✔
112
  settings::path_particle_restart.clear();
1,252✔
113
  settings::path_sourcepoint.clear();
1,252✔
114
  settings::path_statepoint.clear();
1,252✔
115
  settings::photon_transport = false;
1,252✔
116
  settings::reduce_tallies = true;
1,252✔
117
  settings::rel_max_lost_particles = 1.0e-6;
1,252✔
118
  settings::res_scat_on = false;
1,252✔
119
  settings::res_scat_method = ResScatMethod::rvs;
1,252✔
120
  settings::res_scat_energy_min = 0.01;
1,252✔
121
  settings::res_scat_energy_max = 1000.0;
1,252✔
122
  settings::restart_run = false;
1,252✔
123
  settings::run_CE = true;
1,252✔
124
  settings::run_mode = RunMode::UNSET;
1,252✔
125
  settings::source_latest = false;
1,252✔
126
  settings::source_rejection_fraction = 0.05;
1,252✔
127
  settings::source_separate = false;
1,252✔
128
  settings::source_write = true;
1,252✔
129
  settings::ssw_cell_id = C_NONE;
1,252✔
130
  settings::ssw_cell_type = SSWCellType::None;
1,252✔
131
  settings::ssw_max_particles = 0;
1,252✔
132
  settings::ssw_max_files = 1;
1,252✔
133
  settings::survival_biasing = false;
1,252✔
134
  settings::temperature_default = 293.6;
1,252✔
135
  settings::temperature_method = TemperatureMethod::NEAREST;
1,252✔
136
  settings::temperature_multipole = false;
1,252✔
137
  settings::temperature_range = {0.0, 0.0};
1,252✔
138
  settings::temperature_tolerance = 10.0;
1,252✔
139
  settings::trigger_on = false;
1,252✔
140
  settings::trigger_predict = false;
1,252✔
141
  settings::trigger_batch_interval = 1;
1,252✔
142
  settings::uniform_source_sampling = false;
1,252✔
143
  settings::ufs_on = false;
1,252✔
144
  settings::urr_ptables_on = true;
1,252✔
145
  settings::verbosity = -1;
1,252✔
146
  settings::weight_cutoff = 0.25;
1,252✔
147
  settings::weight_survive = 1.0;
1,252✔
148
  settings::weight_windows_file.clear();
1,252✔
149
  settings::weight_windows_on = false;
1,252✔
150
  settings::write_all_tracks = false;
1,252✔
151
  settings::write_initial_source = false;
1,252✔
152

153
  simulation::keff = 1.0;
1,252✔
154
  simulation::need_depletion_rx = false;
1,252✔
155
  simulation::ssw_current_file = 1;
1,252✔
156
  simulation::total_gen = 0;
1,252✔
157

158
  simulation::entropy_mesh = nullptr;
1,252✔
159
  simulation::ufs_mesh = nullptr;
1,252✔
160

161
  data::energy_max = {INFTY, INFTY, INFTY, INFTY};
1,252✔
162
  data::energy_min = {0.0, 0.0, 0.0, 0.0};
1,252✔
163
  data::temperature_min = 0.0;
1,252✔
164
  data::temperature_max = INFTY;
1,252✔
165
  model::root_universe = -1;
1,252✔
166
  model::plotter_seed = 1;
1,252✔
167
  openmc::openmc_set_seed(DEFAULT_SEED);
1,252✔
168
  openmc::openmc_set_stride(DEFAULT_STRIDE);
1,252✔
169

170
  // Deallocate arrays
171
  free_memory();
1,252✔
172

173
#ifdef OPENMC_LIBMESH_ENABLED
174
  settings::libmesh_init.reset();
175
#endif
176

177
  // Free all MPI types
178
#ifdef OPENMC_MPI
179
  if (mpi::source_site != MPI_DATATYPE_NULL) {
180
    MPI_Type_free(&mpi::source_site);
181
  }
182
  if (mpi::collision_track_site != MPI_DATATYPE_NULL) {
183
    MPI_Type_free(&mpi::collision_track_site);
184
  }
185
  if (mpi::mpi_volume_results != MPI_DATATYPE_NULL) {
186
    MPI_Type_free(&mpi::mpi_volume_results);
187
  }
188
  if (mpi::mpi_volume_tally != MPI_DATATYPE_NULL) {
189
    MPI_Type_free(&mpi::mpi_volume_tally);
190
  }
191
#endif
192

193
  openmc_reset_random_ray();
1,252✔
194

195
  return 0;
1,252✔
196
}
197

198
int openmc_reset()
2,470✔
199
{
200

201
  model::universe_level_counts.clear();
2,470✔
202

203
  for (auto& t : model::tallies) {
9,850✔
204
    t->reset();
7,380✔
205
  }
206

207
  // Reset global tallies
208
  simulation::n_realizations = 0;
2,470✔
209
  xt::view(simulation::global_tallies, xt::all()) = 0.0;
2,470✔
210

211
  simulation::k_col_abs = 0.0;
2,470✔
212
  simulation::k_col_tra = 0.0;
2,470✔
213
  simulation::k_abs_tra = 0.0;
2,470✔
214
  simulation::k_sum = {0.0, 0.0};
2,470✔
215
  simulation::satisfy_triggers = false;
2,470✔
216

217
  settings::cmfd_run = false;
2,470✔
218

219
  simulation::n_lost_particles = 0;
2,470✔
220

221
  return 0;
2,470✔
222
}
223

224
int openmc_reset_timers()
40✔
225
{
226
  reset_timers();
40✔
227
  return 0;
40✔
228
}
229

230
int openmc_hard_reset()
34✔
231
{
232
  // Reset all tallies and timers
233
  openmc_reset();
34✔
234
  reset_timers();
34✔
235

236
  // Reset total generations and keff guess
237
  simulation::keff = 1.0;
34✔
238
  simulation::total_gen = 0;
34✔
239

240
  // Reset the random number generator state
241
  openmc::openmc_set_seed(DEFAULT_SEED);
34✔
242
  openmc::openmc_set_stride(DEFAULT_STRIDE);
34✔
243
  return 0;
34✔
244
}
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