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

openmc-dev / openmc / 24653638292

20 Apr 2026 07:18AM UTC coverage: 81.355% (-0.7%) from 82.058%
24653638292

Pull #2693

github

web-flow
Merge 16d110298 into 36e70d8ef
Pull Request #2693: Add reactivity control to coupled transport-depletion analyses

17627 of 25465 branches covered (69.22%)

Branch coverage included in aggregate %.

77 of 88 new or added lines in 6 files covered. (87.5%)

4024 existing lines in 108 files now uncovered.

58221 of 67766 relevant lines covered (85.91%)

47082727.64 hits per line

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

98.8
/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/mgxs_interface.h"
18
#include "openmc/nuclide.h"
19
#include "openmc/photon.h"
20
#include "openmc/plot.h"
21
#include "openmc/random_lcg.h"
22
#include "openmc/random_ray/random_ray_simulation.h"
23
#include "openmc/settings.h"
24
#include "openmc/simulation.h"
25
#include "openmc/source.h"
26
#include "openmc/surface.h"
27
#include "openmc/tallies/tally.h"
28
#include "openmc/thermal.h"
29
#include "openmc/timer.h"
30
#include "openmc/volume_calc.h"
31
#include "openmc/weight_windows.h"
32

33
#include "openmc/tensor.h"
34

35
namespace openmc {
36

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

63
} // namespace openmc
64

65
using namespace openmc;
66

67
int openmc_finalize()
8,375 ✔
68
{
69
  if (simulation::initialized)
8,375 ✔
70
    openmc_simulation_finalize();
3 ✔
71

72
  // Clear results
73
  openmc_reset();
8,375 ✔
74

75
  // Reset timers
76
  reset_timers();
8,375 ✔
77

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

158
  simulation::keff = 1.0;
8,375 ✔
159
  simulation::need_depletion_rx = false;
8,375 ✔
160
  simulation::ssw_current_file = 1;
8,375 ✔
161
  simulation::total_gen = 0;
8,375 ✔
162

163
  simulation::entropy_mesh = nullptr;
8,375 ✔
164
  simulation::ufs_mesh = nullptr;
8,375 ✔
165

166
  data::energy_max = {INFTY, INFTY, INFTY, INFTY};
8,375 ✔
167
  data::energy_min = {0.0, 0.0, 0.0, 0.0};
8,375 ✔
168
  data::temperature_min = 0.0;
8,375 ✔
169
  data::temperature_max = INFTY;
8,375 ✔
170
  data::mg = {};
8,375 ✔
171
  model::root_universe = -1;
8,375 ✔
172
  model::plotter_seed = 1;
8,375 ✔
173
  openmc::openmc_set_seed(DEFAULT_SEED);
8,375 ✔
174
  openmc::openmc_set_stride(DEFAULT_STRIDE);
8,375 ✔
175

176
  // Deallocate arrays
177
  free_memory();
8,375 ✔
178

179
#ifdef OPENMC_LIBMESH_ENABLED
180
  settings::libmesh_init.reset();
1,593 ✔
181
#endif
182

183
  // Free all MPI types
184
#ifdef OPENMC_MPI
185
  if (mpi::source_site != MPI_DATATYPE_NULL) {
3,689 ✔
186
    MPI_Type_free(&mpi::source_site);
3,610 ✔
187
  }
188
  if (mpi::collision_track_site != MPI_DATATYPE_NULL) {
3,689 ✔
189
    MPI_Type_free(&mpi::collision_track_site);
3,610 ✔
190
  }
191
#endif
192

193
  openmc_finalize_random_ray();
8,375 ✔
194

195
  return 0;
8,375 ✔
196
}
197

198
int openmc_reset()
16,744 ✔
199
{
200

201
  model::universe_level_counts.clear();
16,744 ✔
202

203
  for (auto& t : model::tallies) {
70,916 ✔
204
    t->reset();
54,172 ✔
205
  }
206

207
  // Reset global tallies
208
  simulation::n_realizations = 0;
16,744 ✔
209
  simulation::global_tallies.fill(0.0);
16,744 ✔
210

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

217
  settings::cmfd_run = false;
16,744 ✔
218

219
  simulation::n_lost_particles = 0;
16,744 ✔
220

221
  return 0;
16,744 ✔
222
}
223

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

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

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

240
  // Reset the random number generator state
241
  openmc::openmc_set_seed(DEFAULT_SEED);
187 ✔
242
  openmc::openmc_set_stride(DEFAULT_STRIDE);
187 ✔
243
  return 0;
187 ✔
244
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc