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

openmc-dev / openmc / 19851424750

02 Dec 2025 08:02AM UTC coverage: 82.016% (+0.1%) from 81.872%
19851424750

Pull #3413

github

web-flow
Merge 014f116d0 into ef22558f4
Pull Request #3413: More interpolation types in Tabular.

16946 of 23531 branches covered (72.02%)

Branch coverage included in aggregate %.

68 of 107 new or added lines in 3 files covered. (63.55%)

1391 existing lines in 31 files now uncovered.

54939 of 64116 relevant lines covered (85.69%)

42116359.66 hits per line

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

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

62
} // namespace openmc
63

64
using namespace openmc;
65

66
int openmc_finalize()
7,490✔
67
{
68
  if (simulation::initialized)
7,490✔
69
    openmc_simulation_finalize();
3✔
70

71
  // Clear results
72
  openmc_reset();
7,490✔
73

74
  // Reset timers
75
  reset_timers();
7,490✔
76

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

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

158
  simulation::entropy_mesh = nullptr;
7,490✔
159
  simulation::ufs_mesh = nullptr;
7,490✔
160

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

170
  // Deallocate arrays
171
  free_memory();
7,490✔
172

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

177
  // Free all MPI types
178
#ifdef OPENMC_MPI
179
  if (mpi::source_site != MPI_DATATYPE_NULL) {
4,015✔
180
    MPI_Type_free(&mpi::source_site);
3,925✔
181
  }
182
  if (mpi::collision_track_site != MPI_DATATYPE_NULL) {
4,015✔
183
    MPI_Type_free(&mpi::collision_track_site);
3,925✔
184
  }
185
#endif
186

187
  openmc_reset_random_ray();
7,490✔
188

189
  return 0;
7,490✔
190
}
191

192
int openmc_reset()
14,925✔
193
{
194

195
  model::universe_level_counts.clear();
14,925✔
196

197
  for (auto& t : model::tallies) {
68,104✔
198
    t->reset();
53,179✔
199
  }
200

201
  // Reset global tallies
202
  simulation::n_realizations = 0;
14,925✔
203
  xt::view(simulation::global_tallies, xt::all()) = 0.0;
14,925✔
204

205
  simulation::k_col_abs = 0.0;
14,925✔
206
  simulation::k_col_tra = 0.0;
14,925✔
207
  simulation::k_abs_tra = 0.0;
14,925✔
208
  simulation::k_sum = {0.0, 0.0};
14,925✔
209
  simulation::satisfy_triggers = false;
14,925✔
210

211
  settings::cmfd_run = false;
14,925✔
212

213
  simulation::n_lost_particles = 0;
14,925✔
214

215
  return 0;
14,925✔
216
}
217

218
int openmc_reset_timers()
205✔
219
{
220
  reset_timers();
205✔
221
  return 0;
205✔
222
}
223

224
int openmc_hard_reset()
187✔
225
{
226
  // Reset all tallies and timers
227
  openmc_reset();
187✔
228
  reset_timers();
187✔
229

230
  // Reset total generations and keff guess
231
  simulation::keff = 1.0;
187✔
232
  simulation::total_gen = 0;
187✔
233

234
  // Reset the random number generator state
235
  openmc::openmc_set_seed(DEFAULT_SEED);
187✔
236
  openmc::openmc_set_stride(DEFAULT_STRIDE);
187✔
237
  return 0;
187✔
238
}
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