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

openmc-dev / openmc / 29079049279

10 Jul 2026 08:12AM UTC coverage: 80.467% (-0.8%) from 81.292%
29079049279

Pull #3951

github

web-flow
Merge b5a65303a into 7c408f6a1
Pull Request #3951: wwinp files: Fix MemoryError in WeightWindowsList.export_to_hdf5 and speed up from_wwinp. Alternative Approach

16741 of 24259 branches covered (69.01%)

Branch coverage included in aggregate %.

70 of 132 new or added lines in 10 files covered. (53.03%)

790 existing lines in 49 files now uncovered.

57487 of 67988 relevant lines covered (84.55%)

28150237.78 hits per line

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

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

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

34
#include "openmc/tensor.h"
35

36
namespace openmc {
37

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

65
} // namespace openmc
66

67
using namespace openmc;
68

69
int openmc_cleanup()
2,100✔
70
{
71
#ifdef OPENMC_LIBMESH_ENABLED
72
  settings::libmesh_init.reset();
73
#endif
74

75
  // Free all MPI types
76
#ifdef OPENMC_MPI
77
  if (mpi::source_site != MPI_DATATYPE_NULL) {
78
    MPI_Type_free(&mpi::source_site);
79
  }
80
  if (mpi::collision_track_site != MPI_DATATYPE_NULL) {
81
    MPI_Type_free(&mpi::collision_track_site);
82
  }
83
#endif
84

85
  openmc_finalize_random_ray();
2,100✔
86

87
  // If MPI is in use and enabled, terminate it
88
#ifdef OPENMC_MPI
89
  MPI_Finalize();
90
#endif
91
  return 0;
2,100✔
92
}
93

94
int openmc_finalize()
2,888✔
95
{
96
  if (simulation::initialized)
2,888!
UNCOV
97
    openmc_simulation_finalize();
×
98

99
  // Clear results
100
  openmc_reset();
2,888✔
101

102
  // Reset timers
103
  reset_timers();
2,888✔
104

105
  // Reset global variables
106
  settings::assume_separate = false;
2,888✔
107
  settings::check_overlaps = false;
2,888✔
108
  settings::collision_track_config = CollisionTrackConfig {};
2,888✔
109
  settings::confidence_intervals = false;
2,888✔
110
  settings::create_fission_neutrons = true;
2,888✔
111
  settings::create_delayed_neutrons = true;
2,888✔
112
  settings::electron_treatment = ElectronTreatment::LED;
2,888✔
113
  settings::delayed_photon_scaling = true;
2,888✔
114
  settings::energy_cutoff = {0.0, 1000.0, 0.0, 0.0};
2,888✔
115
  settings::time_cutoff = {INFTY, INFTY, INFTY, INFTY};
2,888✔
116
  settings::entropy_on = false;
2,888✔
117
  settings::event_based = false;
2,888✔
118
  settings::free_gas_threshold = 400.0;
2,888✔
119
  settings::gen_per_batch = 1;
2,888✔
120
  settings::legendre_to_tabular = true;
2,888✔
121
  settings::legendre_to_tabular_points = -1;
2,888✔
122
  settings::material_cell_offsets = true;
2,888✔
123
  settings::max_lost_particles = 10;
2,888✔
124
  settings::max_order = 0;
2,888✔
125
  settings::max_particles_in_flight = 100000;
2,888✔
126
  settings::max_secondaries = 10000;
2,888✔
127
  settings::max_particle_events = 1'000'000;
2,888✔
128
  settings::max_history_splits = 10'000'000;
2,888✔
129
  settings::max_tracks = 1000;
2,888✔
130
  settings::max_write_lost_particles = -1;
2,888✔
131
  settings::n_log_bins = 8000;
2,888✔
132
  settings::n_inactive = 0;
2,888✔
133
  settings::n_particles = -1;
2,888✔
134
  settings::output_summary = true;
2,888✔
135
  settings::output_tallies = true;
2,888✔
136
  settings::particle_restart_run = false;
2,888✔
137
  settings::path_cross_sections.clear();
2,888✔
138
  settings::path_input.clear();
2,888✔
139
  settings::path_output.clear();
2,888✔
140
  settings::path_particle_restart.clear();
2,888✔
141
  settings::path_sourcepoint.clear();
2,888✔
142
  settings::path_statepoint.clear();
2,888✔
143
  settings::photon_transport = false;
2,888✔
144
  settings::reduce_tallies = true;
2,888✔
145
  settings::rel_max_lost_particles = 1.0e-6;
2,888✔
146
  settings::res_scat_on = false;
2,888✔
147
  settings::res_scat_method = ResScatMethod::rvs;
2,888✔
148
  settings::res_scat_energy_min = 0.01;
2,888✔
149
  settings::res_scat_energy_max = 1000.0;
2,888✔
150
  settings::restart_run = false;
2,888✔
151
  settings::run_CE = true;
2,888✔
152
  settings::run_mode = RunMode::UNSET;
2,888✔
153
  settings::surface_grazing_cutoff = 0.001;
2,888✔
154
  settings::surface_grazing_ratio = 0.5;
2,888✔
155
  settings::solver_type = SolverType::MONTE_CARLO;
2,888✔
156
  settings::source_latest = false;
2,888✔
157
  settings::source_rejection_fraction = 0.05;
2,888✔
158
  settings::source_separate = false;
2,888✔
159
  settings::source_write = true;
2,888✔
160
  settings::ssw_cell_id = C_NONE;
2,888✔
161
  settings::ssw_cell_type = SSWCellType::None;
2,888✔
162
  settings::ssw_max_particles = 0;
2,888✔
163
  settings::ssw_max_files = 1;
2,888✔
164
  settings::survival_biasing = false;
2,888✔
165
  settings::temperature_default = 293.6;
2,888✔
166
  settings::temperature_method = TemperatureMethod::NEAREST;
2,888✔
167
  settings::temperature_multipole = false;
2,888✔
168
  settings::temperature_range = {0.0, 0.0};
2,888✔
169
  settings::temperature_tolerance = 10.0;
2,888✔
170
  settings::properties_file.clear();
2,888✔
171
  settings::trigger_on = false;
2,888✔
172
  settings::trigger_predict = false;
2,888✔
173
  settings::trigger_batch_interval = 1;
2,888✔
174
  settings::uniform_source_sampling = false;
2,888✔
175
  settings::ufs_on = false;
2,888✔
176
  settings::urr_ptables_on = true;
2,888✔
177
  settings::use_decay_photons = false;
2,888✔
178
  settings::use_shared_secondary_bank = false;
2,888✔
179
  settings::verbosity = -1;
2,888✔
180
  settings::weight_cutoff = 0.25;
2,888✔
181
  settings::weight_survive = 1.0;
2,888✔
182
  settings::weight_windows_file.clear();
2,888✔
183
  settings::weight_windows_on = false;
2,888✔
184
  settings::write_all_tracks = false;
2,888✔
185
  settings::write_initial_source = false;
2,888✔
186

187
  simulation::keff = 1.0;
2,888✔
188
  simulation::need_depletion_rx = false;
2,888✔
189
  simulation::ssw_current_file = 1;
2,888✔
190
  simulation::total_gen = 0;
2,888✔
191

192
  simulation::entropy_mesh = nullptr;
2,888✔
193
  simulation::ufs_mesh = nullptr;
2,888✔
194

195
  data::energy_max = {INFTY, INFTY, INFTY, INFTY};
2,888✔
196
  data::energy_min = {0.0, 0.0, 0.0, 0.0};
2,888✔
197
  data::temperature_min = 0.0;
2,888✔
198
  data::temperature_max = INFTY;
2,888✔
199
  data::mg = {};
2,888✔
200
  model::root_universe = -1;
2,888✔
201
  model::plotter_seed = 1;
2,888✔
202
  openmc::openmc_set_seed(DEFAULT_SEED);
2,888✔
203
  openmc::openmc_set_stride(DEFAULT_STRIDE);
2,888✔
204

205
  // Deallocate arrays
206
  free_memory();
2,888✔
207

208
  return 0;
2,888✔
209
}
210

211
int openmc_reset()
5,728✔
212
{
213

214
  model::universe_level_counts.clear();
5,728✔
215

216
  for (auto& t : model::tallies) {
21,932✔
217
    t->reset();
16,204✔
218
  }
219

220
  // Reset global tallies
221
  simulation::n_realizations = 0;
5,728✔
222
  simulation::global_tallies.fill(0.0);
5,728✔
223

224
  simulation::k_col_abs = 0.0;
5,728✔
225
  simulation::k_col_tra = 0.0;
5,728✔
226
  simulation::k_abs_tra = 0.0;
5,728✔
227
  simulation::k_sum = {0.0, 0.0};
5,728✔
228
  simulation::satisfy_triggers = false;
5,728✔
229

230
  settings::cmfd_run = false;
5,728✔
231

232
  simulation::n_lost_particles = 0;
5,728✔
233
  simulation::simulation_tracks_completed = 0;
5,728✔
234

235
  return 0;
5,728✔
236
}
237

238
int openmc_reset_timers()
92✔
239
{
240
  reset_timers();
92✔
241
  return 0;
92✔
242
}
243

244
int openmc_hard_reset()
68✔
245
{
246
  // Reset all tallies and timers
247
  openmc_reset();
68✔
248
  reset_timers();
68✔
249

250
  // Reset total generations and keff guess
251
  simulation::keff = 1.0;
68✔
252
  simulation::total_gen = 0;
68✔
253

254
  // Reset the random number generator state
255
  openmc::openmc_set_seed(DEFAULT_SEED);
68✔
256
  openmc::openmc_set_stride(DEFAULT_STRIDE);
68✔
257
  return 0;
68✔
258
}
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