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

openmc-dev / openmc / 22282433317

22 Feb 2026 06:05PM UTC coverage: 81.033% (-0.7%) from 81.688%
22282433317

Pull #3817

github

web-flow
Merge 155a36c12 into 83a30f686
Pull Request #3817: Fix MeshFilter.get_pandas_dataframe to handle all mesh types

16085 of 22646 branches covered (71.03%)

Branch coverage included in aggregate %.

23 of 25 new or added lines in 4 files covered. (92.0%)

1149 existing lines in 38 files now uncovered.

55961 of 66264 relevant lines covered (84.45%)

9160039.43 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/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()
655 ✔
38
{
39
  free_memory_geometry();
655 ✔
40
  free_memory_surfaces();
655 ✔
41
  free_memory_material();
655 ✔
42
  free_memory_volume();
655 ✔
43
  free_memory_simulation();
655 ✔
44
  free_memory_photon();
655 ✔
45
  free_memory_settings();
655 ✔
46
  free_memory_thermal();
655 ✔
47
  library_clear();
655 ✔
48
  nuclides_clear();
655 ✔
49
  free_memory_source();
655 ✔
50
  free_memory_mesh();
655 ✔
51
  free_memory_tally();
655 ✔
52
  free_memory_bank();
655 ✔
53
  free_memory_plot();
655 ✔
54
  free_memory_weight_windows();
655 ✔
55
  if (mpi::master) {
655 !
56
    free_memory_cmfd();
655 ✔
57
  }
58
  if (settings::event_based) {
655 !
59
    free_event_queues();
×
60
  }
61
}
655 ✔
62

63
} // namespace openmc
64

65
using namespace openmc;
66

67
int openmc_finalize()
655 ✔
68
{
69
  if (simulation::initialized)
655 !
UNCOV
70
    openmc_simulation_finalize();
×
71

72
  // Clear results
73
  openmc_reset();
655 ✔
74

75
  // Reset timers
76
  reset_timers();
655 ✔
77

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

155
  simulation::keff = 1.0;
655 ✔
156
  simulation::need_depletion_rx = false;
655 ✔
157
  simulation::ssw_current_file = 1;
655 ✔
158
  simulation::total_gen = 0;
655 ✔
159

160
  simulation::entropy_mesh = nullptr;
655 ✔
161
  simulation::ufs_mesh = nullptr;
655 ✔
162

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

173
  // Deallocate arrays
174
  free_memory();
655 ✔
175

176
#ifdef OPENMC_LIBMESH_ENABLED
177
  settings::libmesh_init.reset();
178
#endif
179

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

190
  openmc_finalize_random_ray();
655 ✔
191

192
  return 0;
655 ✔
193
}
194

195
int openmc_reset()
1,289 ✔
196
{
197

198
  model::universe_level_counts.clear();
1,289 ✔
199

200
  for (auto& t : model::tallies) {
5,148 ✔
201
    t->reset();
3,859 ✔
202
  }
203

204
  // Reset global tallies
205
  simulation::n_realizations = 0;
1,289 ✔
206
  simulation::global_tallies.fill(0.0);
1,289 ✔
207

208
  simulation::k_col_abs = 0.0;
1,289 ✔
209
  simulation::k_col_tra = 0.0;
1,289 ✔
210
  simulation::k_abs_tra = 0.0;
1,289 ✔
211
  simulation::k_sum = {0.0, 0.0};
1,289 ✔
212
  simulation::satisfy_triggers = false;
1,289 ✔
213

214
  settings::cmfd_run = false;
1,289 ✔
215

216
  simulation::n_lost_particles = 0;
1,289 ✔
217

218
  return 0;
1,289 ✔
219
}
220

221
int openmc_reset_timers()
20 ✔
222
{
223
  reset_timers();
20 ✔
224
  return 0;
20 ✔
225
}
226

227
int openmc_hard_reset()
17 ✔
228
{
229
  // Reset all tallies and timers
230
  openmc_reset();
17 ✔
231
  reset_timers();
17 ✔
232

233
  // Reset total generations and keff guess
234
  simulation::keff = 1.0;
17 ✔
235
  simulation::total_gen = 0;
17 ✔
236

237
  // Reset the random number generator state
238
  openmc::openmc_set_seed(DEFAULT_SEED);
17 ✔
239
  openmc::openmc_set_stride(DEFAULT_STRIDE);
17 ✔
240
  return 0;
17 ✔
241
}
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