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

openmc-dev / openmc / 13894606366

17 Mar 2025 08:15AM UTC coverage: 84.924% (-0.1%) from 85.042%
13894606366

Pull #3305

github

web-flow
Merge 042852a3c into 58f2a2177
Pull Request #3305: New Feature Development: The Implementation of chord length sampling (CLS) method for stochastic media( #3286 )

20 of 161 new or added lines in 8 files covered. (12.42%)

1043 existing lines in 45 files now uncovered.

51567 of 60721 relevant lines covered (84.92%)

36823581.23 hits per line

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

99.31
/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/constants.h"
7
#include "openmc/cross_sections.h"
8
#include "openmc/dagmc.h"
9
#include "openmc/eigenvalue.h"
10
#include "openmc/event.h"
11
#include "openmc/geometry.h"
12
#include "openmc/geometry_aux.h"
13
#include "openmc/material.h"
14
#include "openmc/mesh.h"
15
#include "openmc/message_passing.h"
16
#include "openmc/nuclide.h"
17
#include "openmc/photon.h"
18
#include "openmc/plot.h"
19
#include "openmc/random_lcg.h"
20
#include "openmc/random_ray/random_ray_simulation.h"
21
#include "openmc/settings.h"
22
#include "openmc/simulation.h"
23
#include "openmc/source.h"
24
#include "openmc/stochastic_media.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()
6,478✔
37
{
38
  free_memory_geometry();
6,478✔
39
  free_memory_surfaces();
6,478✔
40
  free_memory_material();
6,478✔
41
  free_memory_stochastic_media();
6,478✔
42
  free_memory_volume();
6,478✔
43
  free_memory_simulation();
6,478✔
44
  free_memory_photon();
6,478✔
45
  free_memory_settings();
6,478✔
46
  free_memory_thermal();
6,478✔
47
  library_clear();
6,478✔
48
  nuclides_clear();
6,478✔
49
  free_memory_source();
6,478✔
50
  free_memory_mesh();
6,478✔
51
  free_memory_tally();
6,478✔
52
  free_memory_bank();
6,478✔
53
  free_memory_plot();
6,478✔
54
  free_memory_weight_windows();
6,478✔
55
  if (mpi::master) {
6,478✔
56
    free_memory_cmfd();
5,533✔
57
  }
58
  if (settings::event_based) {
6,478✔
UNCOV
59
    free_event_queues();
×
60
  }
61
}
6,478✔
62

63
} // namespace openmc
64

65
using namespace openmc;
66

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

72
  // Clear results
73
  openmc_reset();
6,478✔
74

75
  // Reset timers
76
  reset_timers();
6,478✔
77

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

150
  simulation::keff = 1.0;
6,478✔
151
  simulation::need_depletion_rx = false;
6,478✔
152
  simulation::ssw_current_file = 1;
6,478✔
153
  simulation::total_gen = 0;
6,478✔
154

155
  simulation::entropy_mesh = nullptr;
6,478✔
156
  simulation::ufs_mesh = nullptr;
6,478✔
157

158
  data::energy_max = {INFTY, INFTY};
6,478✔
159
  data::energy_min = {0.0, 0.0};
6,478✔
160
  data::temperature_min = 0.0;
6,478✔
161
  data::temperature_max = INFTY;
6,478✔
162
  model::root_universe = -1;
6,478✔
163
  model::plotter_seed = 1;
6,478✔
164
  openmc::openmc_set_seed(DEFAULT_SEED);
6,478✔
165
  openmc::openmc_set_stride(DEFAULT_STRIDE);
6,478✔
166

167
  // Deallocate arrays
168
  free_memory();
6,478✔
169

170
#ifdef LIBMESH
171
  settings::libmesh_init.reset();
1,202✔
172
#endif
173

174
  // Free all MPI types
175
#ifdef OPENMC_MPI
176
  if (mpi::source_site != MPI_DATATYPE_NULL)
3,506✔
177
    MPI_Type_free(&mpi::source_site);
3,422✔
178
#endif
179

180
  openmc_reset_random_ray();
6,478✔
181

182
  return 0;
6,478✔
183
}
184

185
int openmc_reset()
12,942✔
186
{
187

188
  model::universe_cell_counts.clear();
12,942✔
189
  model::universe_level_counts.clear();
12,942✔
190

191
  for (auto& t : model::tallies) {
64,119✔
192
    t->reset();
51,177✔
193
  }
194

195
  // Reset global tallies
196
  simulation::n_realizations = 0;
12,942✔
197
  xt::view(simulation::global_tallies, xt::all()) = 0.0;
12,942✔
198

199
  simulation::k_col_abs = 0.0;
12,942✔
200
  simulation::k_col_tra = 0.0;
12,942✔
201
  simulation::k_abs_tra = 0.0;
12,942✔
202
  simulation::k_sum = {0.0, 0.0};
12,942✔
203
  simulation::satisfy_triggers = false;
12,942✔
204

205
  settings::cmfd_run = false;
12,942✔
206

207
  simulation::n_lost_particles = 0;
12,942✔
208

209
  return 0;
12,942✔
210
}
211

212
int openmc_reset_timers()
176✔
213
{
214
  reset_timers();
176✔
215
  return 0;
176✔
216
}
217

218
int openmc_hard_reset()
187✔
219
{
220
  // Reset all tallies and timers
221
  openmc_reset();
187✔
222
  reset_timers();
187✔
223

224
  // Reset total generations and keff guess
225
  simulation::keff = 1.0;
187✔
226
  simulation::total_gen = 0;
187✔
227

228
  // Reset the random number generator state
229
  openmc::openmc_set_seed(DEFAULT_SEED);
187✔
230
  openmc::openmc_set_stride(DEFAULT_STRIDE);
187✔
231
  return 0;
187✔
232
}
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