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

openmc-dev / openmc / 9966309227

17 Jul 2024 12:53AM UTC coverage: 84.815% (+0.008%) from 84.807%
9966309227

push

github

web-flow
Linear Source Random Ray (#3072)

Co-authored-by: John Tramm <john.tramm@gmail.com>
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>

336 of 369 new or added lines in 9 files covered. (91.06%)

36 existing lines in 4 files now uncovered.

49336 of 58169 relevant lines covered (84.81%)

32020493.4 hits per line

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

78.19
/src/settings.cpp
1
#include "openmc/settings.h"
2

3
#include <cmath>  // for ceil, pow
4
#include <limits> // for numeric_limits
5
#include <string>
6

7
#include <fmt/core.h>
8
#ifdef _OPENMP
9
#include <omp.h>
10
#endif
11

12
#include "openmc/capi.h"
13
#include "openmc/constants.h"
14
#include "openmc/container_util.h"
15
#include "openmc/distribution.h"
16
#include "openmc/distribution_multi.h"
17
#include "openmc/distribution_spatial.h"
18
#include "openmc/eigenvalue.h"
19
#include "openmc/error.h"
20
#include "openmc/file_utils.h"
21
#include "openmc/mcpl_interface.h"
22
#include "openmc/mesh.h"
23
#include "openmc/message_passing.h"
24
#include "openmc/output.h"
25
#include "openmc/plot.h"
26
#include "openmc/random_lcg.h"
27
#include "openmc/random_ray/random_ray.h"
28
#include "openmc/simulation.h"
29
#include "openmc/source.h"
30
#include "openmc/string_utils.h"
31
#include "openmc/tallies/trigger.h"
32
#include "openmc/volume_calc.h"
33
#include "openmc/weight_windows.h"
34
#include "openmc/xml_interface.h"
35

36
namespace openmc {
37

38
//==============================================================================
39
// Global variables
40
//==============================================================================
41

42
namespace settings {
43

44
// Default values for boolean flags
45
bool assume_separate {false};
46
bool check_overlaps {false};
47
bool cmfd_run {false};
48
bool confidence_intervals {false};
49
bool create_delayed_neutrons {true};
50
bool create_fission_neutrons {true};
51
bool delayed_photon_scaling {true};
52
bool entropy_on {false};
53
bool event_based {false};
54
bool legendre_to_tabular {true};
55
bool material_cell_offsets {true};
56
bool output_summary {true};
57
bool output_tallies {true};
58
bool particle_restart_run {false};
59
bool photon_transport {false};
60
bool reduce_tallies {true};
61
bool res_scat_on {false};
62
bool restart_run {false};
63
bool run_CE {true};
64
bool source_latest {false};
65
bool source_separate {false};
66
bool source_write {true};
67
bool source_mcpl_write {false};
68
bool surf_source_write {false};
69
bool surf_mcpl_write {false};
70
bool surf_source_read {false};
71
bool survival_biasing {false};
72
bool temperature_multipole {false};
73
bool trigger_on {false};
74
bool trigger_predict {false};
75
bool ufs_on {false};
76
bool urr_ptables_on {true};
77
bool weight_windows_on {false};
78
bool weight_window_checkpoint_surface {false};
79
bool weight_window_checkpoint_collision {true};
80
bool write_all_tracks {false};
81
bool write_initial_source {false};
82

83
std::string path_cross_sections;
84
std::string path_input;
85
std::string path_output;
86
std::string path_particle_restart;
87
std::string path_sourcepoint;
88
std::string path_statepoint;
89
const char* path_statepoint_c {path_statepoint.c_str()};
90
std::string weight_windows_file;
91

92
int32_t n_inactive {0};
93
int32_t max_lost_particles {10};
94
double rel_max_lost_particles {1.0e-6};
95
int32_t max_write_lost_particles {-1};
96
int32_t gen_per_batch {1};
97
int64_t n_particles {-1};
98

99
int64_t max_particles_in_flight {100000};
100
int max_particle_events {1000000};
101

102
ElectronTreatment electron_treatment {ElectronTreatment::TTB};
103
array<double, 4> energy_cutoff {0.0, 1000.0, 0.0, 0.0};
104
array<double, 4> time_cutoff {INFTY, INFTY, INFTY, INFTY};
105
int legendre_to_tabular_points {C_NONE};
106
int max_order {0};
107
int n_log_bins {8000};
108
int n_batches;
109
int n_max_batches;
110
int max_history_splits {10'000'000};
111
int max_tracks {1000};
112
ResScatMethod res_scat_method {ResScatMethod::rvs};
113
double res_scat_energy_min {0.01};
114
double res_scat_energy_max {1000.0};
115
vector<std::string> res_scat_nuclides;
116
RunMode run_mode {RunMode::UNSET};
117
SolverType solver_type {SolverType::MONTE_CARLO};
118
std::unordered_set<int> sourcepoint_batch;
119
std::unordered_set<int> statepoint_batch;
120
std::unordered_set<int> source_write_surf_id;
121
int64_t max_surface_particles;
122
int64_t ssw_cell_id {C_NONE};
123
SSWCellType ssw_cell_type {SSWCellType::None};
124
TemperatureMethod temperature_method {TemperatureMethod::NEAREST};
125
double temperature_tolerance {10.0};
126
double temperature_default {293.6};
127
array<double, 2> temperature_range {0.0, 0.0};
128
int trace_batch;
129
int trace_gen;
130
int64_t trace_particle;
131
vector<array<int, 3>> track_identifiers;
132
int trigger_batch_interval {1};
133
int verbosity {7};
134
double weight_cutoff {0.25};
135
double weight_survive {1.0};
136

137
} // namespace settings
138

139
//==============================================================================
140
// Functions
141
//==============================================================================
142

143
void get_run_parameters(pugi::xml_node node_base)
5,980✔
144
{
145
  using namespace settings;
146
  using namespace pugi;
147

148
  // Check number of particles
149
  if (!check_for_node(node_base, "particles")) {
5,980✔
150
    fatal_error("Need to specify number of particles.");
×
151
  }
152

153
  // Get number of particles if it wasn't specified as a command-line argument
154
  if (n_particles == -1) {
5,980✔
155
    n_particles = std::stoll(get_node_value(node_base, "particles"));
5,980✔
156
  }
157

158
  // Get maximum number of in flight particles for event-based mode
159
  if (check_for_node(node_base, "max_particles_in_flight")) {
5,980✔
160
    max_particles_in_flight =
×
161
      std::stoll(get_node_value(node_base, "max_particles_in_flight"));
×
162
  }
163

164
  // Get maximum number of events allowed per particle
165
  if (check_for_node(node_base, "max_particle_events")) {
5,980✔
166
    max_particle_events =
×
167
      std::stoll(get_node_value(node_base, "max_particle_events"));
×
168
  }
169

170
  // Get number of basic batches
171
  if (check_for_node(node_base, "batches")) {
5,980✔
172
    n_batches = std::stoi(get_node_value(node_base, "batches"));
5,980✔
173
  }
174
  if (!trigger_on)
5,980✔
175
    n_max_batches = n_batches;
5,835✔
176

177
  // Get max number of lost particles
178
  if (check_for_node(node_base, "max_lost_particles")) {
5,980✔
179
    max_lost_particles =
17✔
180
      std::stoi(get_node_value(node_base, "max_lost_particles"));
17✔
181
  }
182

183
  // Get relative number of lost particles
184
  if (check_for_node(node_base, "rel_max_lost_particles")) {
5,980✔
185
    rel_max_lost_particles =
×
186
      std::stod(get_node_value(node_base, "rel_max_lost_particles"));
×
187
  }
188

189
  // Get relative number of lost particles
190
  if (check_for_node(node_base, "max_write_lost_particles")) {
5,980✔
191
    max_write_lost_particles =
17✔
192
      std::stoi(get_node_value(node_base, "max_write_lost_particles"));
17✔
193
  }
194

195
  // Get number of inactive batches
196
  if (run_mode == RunMode::EIGENVALUE ||
5,980✔
197
      solver_type == SolverType::RANDOM_RAY) {
1,865✔
198
    if (check_for_node(node_base, "inactive")) {
4,234✔
199
      n_inactive = std::stoi(get_node_value(node_base, "inactive"));
4,104✔
200
    }
201
    if (check_for_node(node_base, "generations_per_batch")) {
4,234✔
202
      gen_per_batch =
17✔
203
        std::stoi(get_node_value(node_base, "generations_per_batch"));
17✔
204
    }
205

206
    // Preallocate space for keff and entropy by generation
207
    int m = settings::n_max_batches * settings::gen_per_batch;
4,234✔
208
    simulation::k_generation.reserve(m);
4,234✔
209
    simulation::entropy.reserve(m);
4,234✔
210

211
    // Get the trigger information for keff
212
    if (check_for_node(node_base, "keff_trigger")) {
4,234✔
213
      xml_node node_keff_trigger = node_base.child("keff_trigger");
114✔
214

215
      if (check_for_node(node_keff_trigger, "type")) {
114✔
216
        auto temp = get_node_value(node_keff_trigger, "type", true, true);
114✔
217
        if (temp == "std_dev") {
114✔
218
          keff_trigger.metric = TriggerMetric::standard_deviation;
114✔
219
        } else if (temp == "variance") {
×
220
          keff_trigger.metric = TriggerMetric::variance;
×
221
        } else if (temp == "rel_err") {
×
222
          keff_trigger.metric = TriggerMetric::relative_error;
×
223
        } else {
224
          fatal_error("Unrecognized keff trigger type " + temp);
×
225
        }
226
      } else {
114✔
227
        fatal_error("Specify keff trigger type in settings XML");
×
228
      }
229

230
      if (check_for_node(node_keff_trigger, "threshold")) {
114✔
231
        keff_trigger.threshold =
114✔
232
          std::stod(get_node_value(node_keff_trigger, "threshold"));
114✔
233
        if (keff_trigger.threshold <= 0) {
114✔
234
          fatal_error("keff trigger threshold must be positive");
×
235
        }
236
      } else {
237
        fatal_error("Specify keff trigger threshold in settings XML");
×
238
      }
239
    }
240
  }
241

242
  // Random ray variables
243
  if (solver_type == SolverType::RANDOM_RAY) {
5,980✔
244
    xml_node random_ray_node = node_base.child("random_ray");
187✔
245
    if (check_for_node(random_ray_node, "distance_active")) {
187✔
246
      RandomRay::distance_active_ =
187✔
247
        std::stod(get_node_value(random_ray_node, "distance_active"));
187✔
248
      if (RandomRay::distance_active_ <= 0.0) {
187✔
249
        fatal_error("Random ray active distance must be greater than 0");
×
250
      }
251
    } else {
252
      fatal_error("Specify random ray active distance in settings XML");
×
253
    }
254
    if (check_for_node(random_ray_node, "distance_inactive")) {
187✔
255
      RandomRay::distance_inactive_ =
187✔
256
        std::stod(get_node_value(random_ray_node, "distance_inactive"));
187✔
257
      if (RandomRay::distance_inactive_ < 0) {
187✔
258
        fatal_error(
×
259
          "Random ray inactive distance must be greater than or equal to 0");
260
      }
261
    } else {
262
      fatal_error("Specify random ray inactive distance in settings XML");
×
263
    }
264
    if (check_for_node(random_ray_node, "source")) {
187✔
265
      xml_node source_node = random_ray_node.child("source");
187✔
266
      // Get point to list of <source> elements and make sure there is at least
267
      // one
268
      RandomRay::ray_source_ = Source::create(source_node);
187✔
269
    } else {
270
      fatal_error("Specify random ray source in settings XML");
×
271
    }
272
    if (check_for_node(random_ray_node, "source_shape")) {
187✔
273
      std::string temp_str =
274
        get_node_value(random_ray_node, "source_shape", true, true);
68✔
275
      if (temp_str == "flat") {
68✔
NEW
276
        RandomRay::source_shape_ = RandomRaySourceShape::FLAT;
×
277
      } else if (temp_str == "linear") {
68✔
278
        RandomRay::source_shape_ = RandomRaySourceShape::LINEAR;
34✔
279
      } else if (temp_str == "linear_xy") {
34✔
280
        RandomRay::source_shape_ = RandomRaySourceShape::LINEAR_XY;
34✔
281
      } else {
NEW
282
        fatal_error("Unrecognized source shape: " + temp_str);
×
283
      }
284
    }
68✔
285
    if (check_for_node(random_ray_node, "volume_normalized_flux_tallies")) {
187✔
286
      FlatSourceDomain::volume_normalized_flux_tallies_ =
170✔
287
        get_node_value_bool(random_ray_node, "volume_normalized_flux_tallies");
170✔
288
    }
289
  }
290
}
5,980✔
291

292
void read_settings_xml()
1,732✔
293
{
294
  using namespace settings;
295
  using namespace pugi;
296
  // Check if settings.xml exists
297
  std::string filename = settings::path_input + "settings.xml";
1,732✔
298
  if (!file_exists(filename)) {
1,732✔
299
    if (run_mode != RunMode::PLOTTING) {
24✔
300
      fatal_error("Could not find any XML input files! In order to run OpenMC, "
×
301
                  "you first need a set of input files; at a minimum, this "
302
                  "includes settings.xml, geometry.xml, and materials.xml or a "
303
                  "single model XML file. Please consult the user's guide at "
304
                  "https://docs.openmc.org for further information.");
305
    } else {
306
      // The settings.xml file is optional if we just want to make a plot.
307
      return;
24✔
308
    }
309
  }
310

311
  // Parse settings.xml file
312
  xml_document doc;
1,708✔
313
  auto result = doc.load_file(filename.c_str());
1,708✔
314
  if (!result) {
1,708✔
315
    fatal_error("Error processing settings.xml file.");
×
316
  }
317

318
  // Get root element
319
  xml_node root = doc.document_element();
1,708✔
320

321
  // Verbosity
322
  if (check_for_node(root, "verbosity")) {
1,708✔
323
    verbosity = std::stoi(get_node_value(root, "verbosity"));
213✔
324
  }
325

326
  // To this point, we haven't displayed any output since we didn't know what
327
  // the verbosity is. Now that we checked for it, show the title if necessary
328
  if (mpi::master) {
1,708✔
329
    if (verbosity >= 2)
1,478✔
330
      title();
1,275✔
331
  }
332

333
  write_message("Reading settings XML file...", 5);
1,708✔
334

335
  read_settings_xml(root);
1,708✔
336
}
1,721✔
337

338
void read_settings_xml(pugi::xml_node root)
6,330✔
339
{
340
  using namespace settings;
341
  using namespace pugi;
342

343
  // Find if a multi-group or continuous-energy simulation is desired
344
  if (check_for_node(root, "energy_mode")) {
6,330✔
345
    std::string temp_str = get_node_value(root, "energy_mode", true, true);
731✔
346
    if (temp_str == "mg" || temp_str == "multi-group") {
731✔
347
      run_CE = false;
731✔
348
    } else if (temp_str == "ce" || temp_str == "continuous-energy") {
×
349
      run_CE = true;
×
350
    }
351
  }
731✔
352

353
  // Check for user meshes and allocate
354
  read_meshes(root);
6,330✔
355

356
  // Look for deprecated cross_sections.xml file in settings.xml
357
  if (check_for_node(root, "cross_sections")) {
6,330✔
358
    warning(
×
359
      "Setting cross_sections in settings.xml has been deprecated."
360
      " The cross_sections are now set in materials.xml and the "
361
      "cross_sections input to materials.xml and the OPENMC_CROSS_SECTIONS"
362
      " environment variable will take precendent over setting "
363
      "cross_sections in settings.xml.");
364
    path_cross_sections = get_node_value(root, "cross_sections");
×
365
  }
366

367
  if (!run_CE) {
6,330✔
368
    // Scattering Treatments
369
    if (check_for_node(root, "max_order")) {
731✔
370
      max_order = std::stoi(get_node_value(root, "max_order"));
17✔
371
    } else {
372
      // Set to default of largest int - 1, which means to use whatever is
373
      // contained in library. This is largest int - 1 because for legendre
374
      // scattering, a value of 1 is added to the order; adding 1 to the largest
375
      // int gets you the largest negative integer, which is not what we want.
376
      max_order = std::numeric_limits<int>::max() - 1;
714✔
377
    }
378
  }
379

380
  // Check for a trigger node and get trigger information
381
  if (check_for_node(root, "trigger")) {
6,330✔
382
    xml_node node_trigger = root.child("trigger");
162✔
383

384
    // Check if trigger(s) are to be turned on
385
    trigger_on = get_node_value_bool(node_trigger, "active");
162✔
386

387
    if (trigger_on) {
162✔
388
      if (check_for_node(node_trigger, "max_batches")) {
145✔
389
        n_max_batches = std::stoi(get_node_value(node_trigger, "max_batches"));
145✔
390
      } else {
391
        fatal_error("<max_batches> must be specified with triggers");
×
392
      }
393

394
      // Get the batch interval to check triggers
395
      if (!check_for_node(node_trigger, "batch_interval")) {
145✔
396
        trigger_predict = true;
17✔
397
      } else {
398
        trigger_batch_interval =
128✔
399
          std::stoi(get_node_value(node_trigger, "batch_interval"));
128✔
400
        if (trigger_batch_interval <= 0) {
128✔
401
          fatal_error("Trigger batch interval must be greater than zero");
×
402
        }
403
      }
404
    }
405
  }
406

407
  // Check run mode if it hasn't been set from the command line
408
  xml_node node_mode;
6,330✔
409
  if (run_mode == RunMode::UNSET) {
6,330✔
410
    if (check_for_node(root, "run_mode")) {
6,014✔
411
      std::string temp_str = get_node_value(root, "run_mode", true, true);
5,946✔
412
      if (temp_str == "eigenvalue") {
5,946✔
413
        run_mode = RunMode::EIGENVALUE;
4,047✔
414
      } else if (temp_str == "fixed source") {
1,899✔
415
        run_mode = RunMode::FIXED_SOURCE;
1,865✔
416
      } else if (temp_str == "plot") {
34✔
417
        run_mode = RunMode::PLOTTING;
×
418
      } else if (temp_str == "particle restart") {
34✔
419
        run_mode = RunMode::PARTICLE;
×
420
      } else if (temp_str == "volume") {
34✔
421
        run_mode = RunMode::VOLUME;
34✔
422
      } else {
423
        fatal_error("Unrecognized run mode: " + temp_str);
×
424
      }
425

426
      // Assume XML specifies <particles>, <batches>, etc. directly
427
      node_mode = root;
5,946✔
428
    } else {
5,946✔
429
      warning("<run_mode> should be specified.");
68✔
430

431
      // Make sure that either eigenvalue or fixed source was specified
432
      node_mode = root.child("eigenvalue");
68✔
433
      if (node_mode) {
68✔
434
        run_mode = RunMode::EIGENVALUE;
68✔
435
      } else {
436
        node_mode = root.child("fixed_source");
×
437
        if (node_mode) {
×
438
          run_mode = RunMode::FIXED_SOURCE;
×
439
        } else {
440
          fatal_error("<eigenvalue> or <fixed_source> not specified.");
×
441
        }
442
      }
443
    }
444
  }
445

446
  // Check solver type
447
  if (check_for_node(root, "random_ray")) {
6,330✔
448
    solver_type = SolverType::RANDOM_RAY;
187✔
449
    if (run_CE)
187✔
450
      fatal_error("multi-group energy mode must be specified in settings XML "
×
451
                  "when using the random ray solver.");
452
  }
453

454
  if (run_mode == RunMode::EIGENVALUE || run_mode == RunMode::FIXED_SOURCE) {
6,330✔
455
    // Read run parameters
456
    get_run_parameters(node_mode);
5,980✔
457

458
    // Check number of active batches, inactive batches, max lost particles and
459
    // particles
460
    if (n_batches <= n_inactive) {
5,980✔
461
      fatal_error("Number of active batches must be greater than zero.");
×
462
    } else if (n_inactive < 0) {
5,980✔
463
      fatal_error("Number of inactive batches must be non-negative.");
×
464
    } else if (n_particles <= 0) {
5,980✔
465
      fatal_error("Number of particles must be greater than zero.");
×
466
    } else if (max_lost_particles <= 0) {
5,980✔
467
      fatal_error("Number of max lost particles must be greater than zero.");
×
468
    } else if (rel_max_lost_particles <= 0.0 || rel_max_lost_particles >= 1.0) {
5,980✔
469
      fatal_error("Relative max lost particles must be between zero and one.");
×
470
    }
471
  }
472

473
  // Copy plotting random number seed if specified
474
  if (check_for_node(root, "plot_seed")) {
6,330✔
475
    auto seed = std::stoll(get_node_value(root, "plot_seed"));
×
476
    model::plotter_seed = seed;
×
477
  }
478

479
  // Copy random number seed if specified
480
  if (check_for_node(root, "seed")) {
6,330✔
481
    auto seed = std::stoll(get_node_value(root, "seed"));
410✔
482
    openmc_set_seed(seed);
410✔
483
  }
484

485
  // Check for electron treatment
486
  if (check_for_node(root, "electron_treatment")) {
6,330✔
487
    auto temp_str = get_node_value(root, "electron_treatment", true, true);
51✔
488
    if (temp_str == "led") {
51✔
489
      electron_treatment = ElectronTreatment::LED;
×
490
    } else if (temp_str == "ttb") {
51✔
491
      electron_treatment = ElectronTreatment::TTB;
51✔
492
    } else {
493
      fatal_error("Unrecognized electron treatment: " + temp_str + ".");
×
494
    }
495
  }
51✔
496

497
  // Check for photon transport
498
  if (check_for_node(root, "photon_transport")) {
6,330✔
499
    photon_transport = get_node_value_bool(root, "photon_transport");
189✔
500

501
    if (!run_CE && photon_transport) {
189✔
502
      fatal_error("Photon transport is not currently supported in "
×
503
                  "multigroup mode");
504
    }
505
  }
506

507
  // Number of bins for logarithmic grid
508
  if (check_for_node(root, "log_grid_bins")) {
6,330✔
509
    n_log_bins = std::stoi(get_node_value(root, "log_grid_bins"));
17✔
510
    if (n_log_bins < 1) {
17✔
511
      fatal_error("Number of bins for logarithmic grid must be greater "
×
512
                  "than zero.");
513
    }
514
  }
515

516
  // Number of OpenMP threads
517
  if (check_for_node(root, "threads")) {
6,330✔
518
    if (mpi::master)
×
519
      warning("The <threads> element has been deprecated. Use "
×
520
              "the OMP_NUM_THREADS environment variable to set the number of "
521
              "threads.");
522
  }
523

524
  // ==========================================================================
525
  // EXTERNAL SOURCE
526

527
  // Get point to list of <source> elements and make sure there is at least one
528
  for (pugi::xml_node node : root.children("source")) {
12,464✔
529
    model::external_sources.push_back(Source::create(node));
6,145✔
530
  }
531

532
  // Check if the user has specified to read surface source
533
  if (check_for_node(root, "surf_source_read")) {
6,319✔
534
    surf_source_read = true;
17✔
535
    // Get surface source read node
536
    xml_node node_ssr = root.child("surf_source_read");
17✔
537

538
    std::string path = "surface_source.h5";
17✔
539
    // Check if the user has specified different file for surface source reading
540
    if (check_for_node(node_ssr, "path")) {
17✔
541
      path = get_node_value(node_ssr, "path", false, true);
17✔
542
    }
543
    model::external_sources.push_back(make_unique<FileSource>(path));
17✔
544
  }
17✔
545

546
  // If no source specified, default to isotropic point source at origin with
547
  // Watt spectrum. No default source is needed in random ray mode.
548
  if (model::external_sources.empty() &&
8,022✔
549
      settings::solver_type != SolverType::RANDOM_RAY) {
1,703✔
550
    double T[] {0.0};
1,635✔
551
    double p[] {1.0};
1,635✔
552
    model::external_sources.push_back(make_unique<IndependentSource>(
1,635✔
553
      UPtrSpace {new SpatialPoint({0.0, 0.0, 0.0})},
3,270✔
554
      UPtrAngle {new Isotropic()}, UPtrDist {new Watt(0.988e6, 2.249e-6)},
3,270✔
555
      UPtrDist {new Discrete(T, p, 1)}));
3,270✔
556
  }
557

558
  // Check if we want to write out source
559
  if (check_for_node(root, "write_initial_source")) {
6,319✔
560
    write_initial_source = get_node_value_bool(root, "write_initial_source");
×
561
  }
562

563
  // Survival biasing
564
  if (check_for_node(root, "survival_biasing")) {
6,319✔
565
    survival_biasing = get_node_value_bool(root, "survival_biasing");
190✔
566
  }
567

568
  // Probability tables
569
  if (check_for_node(root, "ptables")) {
6,319✔
570
    urr_ptables_on = get_node_value_bool(root, "ptables");
17✔
571
  }
572

573
  // Cutoffs
574
  if (check_for_node(root, "cutoff")) {
6,319✔
575
    xml_node node_cutoff = root.child("cutoff");
114✔
576
    if (check_for_node(node_cutoff, "weight")) {
114✔
577
      weight_cutoff = std::stod(get_node_value(node_cutoff, "weight"));
17✔
578
    }
579
    if (check_for_node(node_cutoff, "weight_avg")) {
114✔
580
      weight_survive = std::stod(get_node_value(node_cutoff, "weight_avg"));
17✔
581
    }
582
    if (check_for_node(node_cutoff, "energy_neutron")) {
114✔
583
      energy_cutoff[0] =
34✔
584
        std::stod(get_node_value(node_cutoff, "energy_neutron"));
17✔
585
    } else if (check_for_node(node_cutoff, "energy")) {
97✔
586
      warning("The use of an <energy> cutoff is deprecated and should "
×
587
              "be replaced by <energy_neutron>.");
588
      energy_cutoff[0] = std::stod(get_node_value(node_cutoff, "energy"));
×
589
    }
590
    if (check_for_node(node_cutoff, "energy_photon")) {
114✔
591
      energy_cutoff[1] =
126✔
592
        std::stod(get_node_value(node_cutoff, "energy_photon"));
63✔
593
    }
594
    if (check_for_node(node_cutoff, "energy_electron")) {
114✔
595
      energy_cutoff[2] =
×
596
        std::stof(get_node_value(node_cutoff, "energy_electron"));
×
597
    }
598
    if (check_for_node(node_cutoff, "energy_positron")) {
114✔
599
      energy_cutoff[3] =
×
600
        std::stod(get_node_value(node_cutoff, "energy_positron"));
×
601
    }
602
    if (check_for_node(node_cutoff, "time_neutron")) {
114✔
603
      time_cutoff[0] = std::stod(get_node_value(node_cutoff, "time_neutron"));
17✔
604
    }
605
    if (check_for_node(node_cutoff, "time_photon")) {
114✔
606
      time_cutoff[1] = std::stod(get_node_value(node_cutoff, "time_photon"));
×
607
    }
608
    if (check_for_node(node_cutoff, "time_electron")) {
114✔
609
      time_cutoff[2] = std::stod(get_node_value(node_cutoff, "time_electron"));
×
610
    }
611
    if (check_for_node(node_cutoff, "time_positron")) {
114✔
612
      time_cutoff[3] = std::stod(get_node_value(node_cutoff, "time_positron"));
×
613
    }
614
  }
615

616
  // Particle trace
617
  if (check_for_node(root, "trace")) {
6,319✔
618
    auto temp = get_node_array<int64_t>(root, "trace");
17✔
619
    if (temp.size() != 3) {
17✔
620
      fatal_error("Must provide 3 integers for <trace> that specify the "
×
621
                  "batch, generation, and particle number.");
622
    }
623
    trace_batch = temp.at(0);
17✔
624
    trace_gen = temp.at(1);
17✔
625
    trace_particle = temp.at(2);
17✔
626
  }
17✔
627

628
  // Particle tracks
629
  if (check_for_node(root, "track")) {
6,319✔
630
    // Get values and make sure there are three per particle
631
    auto temp = get_node_array<int>(root, "track");
51✔
632
    if (temp.size() % 3 != 0) {
51✔
633
      fatal_error(
×
634
        "Number of integers specified in 'track' is not "
635
        "divisible by 3.  Please provide 3 integers per particle to be "
636
        "tracked.");
637
    }
638

639
    // Reshape into track_identifiers
640
    int n_tracks = temp.size() / 3;
51✔
641
    for (int i = 0; i < n_tracks; ++i) {
204✔
642
      track_identifiers.push_back(
153✔
643
        {temp[3 * i], temp[3 * i + 1], temp[3 * i + 2]});
153✔
644
    }
645
  }
51✔
646

647
  // Shannon entropy
648
  if (solver_type == SolverType::RANDOM_RAY) {
6,319✔
649
    if (check_for_node(root, "entropy_mesh")) {
187✔
650
      fatal_error("Random ray uses FSRs to compute the Shannon entropy. "
×
651
                  "No user-defined entropy mesh is supported.");
652
    }
653
    entropy_on = true;
187✔
654
  } else if (solver_type == SolverType::MONTE_CARLO) {
6,132✔
655
    if (check_for_node(root, "entropy_mesh")) {
6,132✔
656
      int temp = std::stoi(get_node_value(root, "entropy_mesh"));
515✔
657
      if (model::mesh_map.find(temp) == model::mesh_map.end()) {
515✔
658
        fatal_error(fmt::format(
×
659
          "Mesh {} specified for Shannon entropy does not exist.", temp));
660
      }
661

662
      auto* m = dynamic_cast<RegularMesh*>(
515✔
663
        model::meshes[model::mesh_map.at(temp)].get());
515✔
664
      if (!m)
515✔
665
        fatal_error("Only regular meshes can be used as an entropy mesh");
×
666
      simulation::entropy_mesh = m;
515✔
667

668
      // Turn on Shannon entropy calculation
669
      entropy_on = true;
515✔
670

671
    } else if (check_for_node(root, "entropy")) {
5,617✔
672
      fatal_error(
×
673
        "Specifying a Shannon entropy mesh via the <entropy> element "
674
        "is deprecated. Please create a mesh using <mesh> and then reference "
675
        "it by specifying its ID in an <entropy_mesh> element.");
676
    }
677
  }
678
  // Uniform fission source weighting mesh
679
  if (check_for_node(root, "ufs_mesh")) {
6,319✔
680
    auto temp = std::stoi(get_node_value(root, "ufs_mesh"));
17✔
681
    if (model::mesh_map.find(temp) == model::mesh_map.end()) {
17✔
682
      fatal_error(fmt::format("Mesh {} specified for uniform fission site "
×
683
                              "method does not exist.",
684
        temp));
685
    }
686

687
    auto* m =
688
      dynamic_cast<RegularMesh*>(model::meshes[model::mesh_map.at(temp)].get());
17✔
689
    if (!m)
17✔
690
      fatal_error("Only regular meshes can be used as a UFS mesh");
×
691
    simulation::ufs_mesh = m;
17✔
692

693
    // Turn on uniform fission source weighting
694
    ufs_on = true;
17✔
695

696
  } else if (check_for_node(root, "uniform_fs")) {
6,302✔
697
    fatal_error(
×
698
      "Specifying a UFS mesh via the <uniform_fs> element "
699
      "is deprecated. Please create a mesh using <mesh> and then reference "
700
      "it by specifying its ID in a <ufs_mesh> element.");
701
  }
702

703
  // Check if the user has specified to write state points
704
  if (check_for_node(root, "state_point")) {
6,319✔
705

706
    // Get pointer to state_point node
707
    auto node_sp = root.child("state_point");
204✔
708

709
    // Determine number of batches at which to store state points
710
    if (check_for_node(node_sp, "batches")) {
204✔
711
      // User gave specific batches to write state points
712
      auto temp = get_node_array<int>(node_sp, "batches");
204✔
713
      for (const auto& b : temp) {
629✔
714
        statepoint_batch.insert(b);
425✔
715
      }
716
    } else {
204✔
717
      // If neither were specified, write state point at last batch
718
      statepoint_batch.insert(n_batches);
×
719
    }
720
  } else {
721
    // If no <state_point> tag was present, by default write state point at
722
    // last batch only
723
    statepoint_batch.insert(n_batches);
6,115✔
724
  }
725

726
  // Check if the user has specified to write source points
727
  if (check_for_node(root, "source_point")) {
6,319✔
728
    // Get source_point node
729
    xml_node node_sp = root.child("source_point");
102✔
730

731
    // Determine batches at which to store source points
732
    if (check_for_node(node_sp, "batches")) {
102✔
733
      // User gave specific batches to write source points
734
      auto temp = get_node_array<int>(node_sp, "batches");
51✔
735
      for (const auto& b : temp) {
136✔
736
        sourcepoint_batch.insert(b);
85✔
737
      }
738
    } else {
51✔
739
      // If neither were specified, write source points with state points
740
      sourcepoint_batch = statepoint_batch;
51✔
741
    }
742

743
    // Check if the user has specified to write binary source file
744
    if (check_for_node(node_sp, "separate")) {
102✔
745
      source_separate = get_node_value_bool(node_sp, "separate");
68✔
746
    }
747
    if (check_for_node(node_sp, "write")) {
102✔
748
      source_write = get_node_value_bool(node_sp, "write");
×
749
    }
750
    if (check_for_node(node_sp, "mcpl")) {
102✔
751
      source_mcpl_write = get_node_value_bool(node_sp, "mcpl");
17✔
752

753
      // Make sure MCPL support is enabled
754
      if (source_mcpl_write && !MCPL_ENABLED) {
17✔
755
        fatal_error(
×
756
          "Your build of OpenMC does not support writing MCPL source files.");
757
      }
758
    }
759
    if (check_for_node(node_sp, "overwrite_latest")) {
102✔
760
      source_latest = get_node_value_bool(node_sp, "overwrite_latest");
17✔
761
      source_separate = source_latest;
17✔
762
    }
763
  } else {
764
    // If no <source_point> tag was present, by default we keep source bank in
765
    // statepoint file and write it out at statepoints intervals
766
    source_separate = false;
6,217✔
767
    sourcepoint_batch = statepoint_batch;
6,217✔
768
  }
769

770
  // Check if the user has specified to write surface source
771
  if (check_for_node(root, "surf_source_write")) {
6,319✔
772
    surf_source_write = true;
343✔
773
    // Get surface source write node
774
    xml_node node_ssw = root.child("surf_source_write");
343✔
775

776
    // Determine surface ids at which crossing particles are to be banked.
777
    // If no surfaces are specified, all surfaces in the model will be used
778
    // to bank source points.
779
    if (check_for_node(node_ssw, "surface_ids")) {
343✔
780
      auto temp = get_node_array<int>(node_ssw, "surface_ids");
209✔
781
      for (const auto& b : temp) {
1,065✔
782
        source_write_surf_id.insert(b);
856✔
783
      }
784
    }
209✔
785

786
    // Get maximum number of particles to be banked per surface
787
    if (check_for_node(node_ssw, "max_particles")) {
343✔
788
      max_surface_particles =
333✔
789
        std::stoll(get_node_value(node_ssw, "max_particles"));
333✔
790
    } else {
791
      fatal_error("A maximum number of particles needs to be specified "
10✔
792
                  "using the 'max_particles' parameter to store surface "
793
                  "source points.");
794
    }
795

796
    if (check_for_node(node_ssw, "mcpl")) {
333✔
797
      surf_mcpl_write = get_node_value_bool(node_ssw, "mcpl");
×
798

799
      // Make sure MCPL support is enabled
800
      if (surf_mcpl_write && !MCPL_ENABLED) {
×
801
        fatal_error("Your build of OpenMC does not support writing MCPL "
×
802
                    "surface source files.");
803
      }
804
    }
805
    // Get cell information
806
    if (check_for_node(node_ssw, "cell")) {
333✔
807
      ssw_cell_id = std::stoll(get_node_value(node_ssw, "cell"));
114✔
808
      ssw_cell_type = SSWCellType::Both;
114✔
809
    }
810
    if (check_for_node(node_ssw, "cellfrom")) {
333✔
811
      if (ssw_cell_id != C_NONE) {
99✔
812
        fatal_error(
20✔
813
          "'cell', 'cellfrom' and 'cellto' cannot be used at the same time.");
814
      }
815
      ssw_cell_id = std::stoll(get_node_value(node_ssw, "cellfrom"));
79✔
816
      ssw_cell_type = SSWCellType::From;
79✔
817
    }
818
    if (check_for_node(node_ssw, "cellto")) {
313✔
819
      if (ssw_cell_id != C_NONE) {
78✔
820
        fatal_error(
20✔
821
          "'cell', 'cellfrom' and 'cellto' cannot be used at the same time.");
822
      }
823
      ssw_cell_id = std::stoll(get_node_value(node_ssw, "cellto"));
58✔
824
      ssw_cell_type = SSWCellType::To;
58✔
825
    }
826
  }
827

828
  // If source is not separate and is to be written out in the statepoint file,
829
  // make sure that the sourcepoint batch numbers are contained in the
830
  // statepoint list
831
  if (!source_separate) {
6,269✔
832
    for (const auto& b : sourcepoint_batch) {
12,538✔
833
      if (!contains(statepoint_batch, b)) {
6,354✔
834
        fatal_error(
×
835
          "Sourcepoint batches are not a subset of statepoint batches.");
836
      }
837
    }
838
  }
839

840
  // Check if the user has specified to not reduce tallies at the end of every
841
  // batch
842
  if (check_for_node(root, "no_reduce")) {
6,269✔
843
    reduce_tallies = !get_node_value_bool(root, "no_reduce");
×
844
  }
845

846
  // Check if the user has specified to use confidence intervals for
847
  // uncertainties rather than standard deviations
848
  if (check_for_node(root, "confidence_intervals")) {
6,269✔
849
    confidence_intervals = get_node_value_bool(root, "confidence_intervals");
17✔
850
  }
851

852
  // Check for output options
853
  if (check_for_node(root, "output")) {
6,269✔
854
    // Get pointer to output node
855
    pugi::xml_node node_output = root.child("output");
397✔
856

857
    // Check for summary option
858
    if (check_for_node(node_output, "summary")) {
397✔
859
      output_summary = get_node_value_bool(node_output, "summary");
380✔
860
    }
861

862
    // Check for ASCII tallies output option
863
    if (check_for_node(node_output, "tallies")) {
397✔
864
      output_tallies = get_node_value_bool(node_output, "tallies");
17✔
865
    }
866

867
    // Set output directory if a path has been specified
868
    if (check_for_node(node_output, "path")) {
397✔
869
      path_output = get_node_value(node_output, "path");
×
870
      if (!ends_with(path_output, "/")) {
×
871
        path_output += "/";
×
872
      }
873
    }
874
  }
875

876
  // Resonance scattering parameters
877
  if (check_for_node(root, "resonance_scattering")) {
6,269✔
878
    xml_node node_res_scat = root.child("resonance_scattering");
17✔
879

880
    // See if resonance scattering is enabled
881
    if (check_for_node(node_res_scat, "enable")) {
17✔
882
      res_scat_on = get_node_value_bool(node_res_scat, "enable");
17✔
883
    } else {
884
      res_scat_on = true;
×
885
    }
886

887
    // Determine what method is used
888
    if (check_for_node(node_res_scat, "method")) {
17✔
889
      auto temp = get_node_value(node_res_scat, "method", true, true);
17✔
890
      if (temp == "rvs") {
17✔
891
        res_scat_method = ResScatMethod::rvs;
17✔
892
      } else if (temp == "dbrc") {
×
893
        res_scat_method = ResScatMethod::dbrc;
×
894
      } else {
895
        fatal_error(
×
896
          "Unrecognized resonance elastic scattering method: " + temp + ".");
×
897
      }
898
    }
17✔
899

900
    // Minimum energy for resonance scattering
901
    if (check_for_node(node_res_scat, "energy_min")) {
17✔
902
      res_scat_energy_min =
17✔
903
        std::stod(get_node_value(node_res_scat, "energy_min"));
17✔
904
    }
905
    if (res_scat_energy_min < 0.0) {
17✔
906
      fatal_error("Lower resonance scattering energy bound is negative");
×
907
    }
908

909
    // Maximum energy for resonance scattering
910
    if (check_for_node(node_res_scat, "energy_max")) {
17✔
911
      res_scat_energy_max =
17✔
912
        std::stod(get_node_value(node_res_scat, "energy_max"));
17✔
913
    }
914
    if (res_scat_energy_max < res_scat_energy_min) {
17✔
915
      fatal_error("Upper resonance scattering energy bound is below the "
×
916
                  "lower resonance scattering energy bound.");
917
    }
918

919
    // Get resonance scattering nuclides
920
    if (check_for_node(node_res_scat, "nuclides")) {
17✔
921
      res_scat_nuclides =
922
        get_node_array<std::string>(node_res_scat, "nuclides");
17✔
923
    }
924
  }
925

926
  // Get volume calculations
927
  for (pugi::xml_node node_vol : root.children("volume_calc")) {
6,599✔
928
    model::volume_calcs.emplace_back(node_vol);
330✔
929
  }
930

931
  // Get temperature settings
932
  if (check_for_node(root, "temperature_default")) {
6,269✔
933
    temperature_default =
187✔
934
      std::stod(get_node_value(root, "temperature_default"));
187✔
935
  }
936
  if (check_for_node(root, "temperature_method")) {
6,269✔
937
    auto temp = get_node_value(root, "temperature_method", true, true);
350✔
938
    if (temp == "nearest") {
350✔
939
      temperature_method = TemperatureMethod::NEAREST;
150✔
940
    } else if (temp == "interpolation") {
200✔
941
      temperature_method = TemperatureMethod::INTERPOLATION;
200✔
942
    } else {
943
      fatal_error("Unknown temperature method: " + temp);
×
944
    }
945
  }
350✔
946
  if (check_for_node(root, "temperature_tolerance")) {
6,269✔
947
    temperature_tolerance =
186✔
948
      std::stod(get_node_value(root, "temperature_tolerance"));
186✔
949
  }
950
  if (check_for_node(root, "temperature_multipole")) {
6,269✔
951
    temperature_multipole = get_node_value_bool(root, "temperature_multipole");
34✔
952

953
    // Multipole currently doesn't work with photon transport
954
    if (temperature_multipole && photon_transport) {
34✔
955
      fatal_error("Multipole data cannot currently be used in conjunction with "
×
956
                  "photon transport.");
957
    }
958
  }
959
  if (check_for_node(root, "temperature_range")) {
6,269✔
960
    auto range = get_node_array<double>(root, "temperature_range");
×
961
    temperature_range[0] = range.at(0);
×
962
    temperature_range[1] = range.at(1);
×
963
  }
964

965
  // Check for tabular_legendre options
966
  if (check_for_node(root, "tabular_legendre")) {
6,269✔
967
    // Get pointer to tabular_legendre node
968
    xml_node node_tab_leg = root.child("tabular_legendre");
102✔
969

970
    // Check for enable option
971
    if (check_for_node(node_tab_leg, "enable")) {
102✔
972
      legendre_to_tabular = get_node_value_bool(node_tab_leg, "enable");
102✔
973
    }
974

975
    // Check for the number of points
976
    if (check_for_node(node_tab_leg, "num_points")) {
102✔
977
      legendre_to_tabular_points =
×
978
        std::stoi(get_node_value(node_tab_leg, "num_points"));
×
979
      if (legendre_to_tabular_points <= 1 && !run_CE) {
×
980
        fatal_error(
×
981
          "The 'num_points' subelement/attribute of the "
982
          "<tabular_legendre> element must contain a value greater than 1");
983
      }
984
    }
985
  }
986

987
  // Check whether create delayed neutrons in fission
988
  if (check_for_node(root, "create_delayed_neutrons")) {
6,269✔
989
    create_delayed_neutrons =
×
990
      get_node_value_bool(root, "create_delayed_neutrons");
×
991
  }
992

993
  // Check whether create fission sites
994
  if (run_mode == RunMode::FIXED_SOURCE) {
6,269✔
995
    if (check_for_node(root, "create_fission_neutrons")) {
1,814✔
996
      create_fission_neutrons =
17✔
997
        get_node_value_bool(root, "create_fission_neutrons");
17✔
998
    }
999
  }
1000

1001
  // Check whether to scale fission photon yields
1002
  if (check_for_node(root, "delayed_photon_scaling")) {
6,269✔
1003
    delayed_photon_scaling =
×
1004
      get_node_value_bool(root, "delayed_photon_scaling");
×
1005
  }
1006

1007
  // Check whether to use event-based parallelism
1008
  if (check_for_node(root, "event_based")) {
6,269✔
1009
    event_based = get_node_value_bool(root, "event_based");
×
1010
  }
1011

1012
  // Check whether material cell offsets should be generated
1013
  if (check_for_node(root, "material_cell_offsets")) {
6,269✔
1014
    material_cell_offsets = get_node_value_bool(root, "material_cell_offsets");
×
1015
  }
1016

1017
  // Weight window information
1018
  for (pugi::xml_node node_ww : root.children("weight_windows")) {
6,339✔
1019
    variance_reduction::weight_windows.emplace_back(
70✔
1020
      std::make_unique<WeightWindows>(node_ww));
140✔
1021
  }
1022

1023
  // Enable weight windows by default if one or more are present
1024
  if (variance_reduction::weight_windows.size() > 0)
6,269✔
1025
    settings::weight_windows_on = true;
41✔
1026

1027
  // read weight windows from file
1028
  if (check_for_node(root, "weight_windows_file")) {
6,269✔
1029
    weight_windows_file = get_node_value(root, "weight_windows_file");
×
1030
  }
1031

1032
  // read settings for weight windows value, this will override
1033
  // the automatic setting even if weight windows are present
1034
  if (check_for_node(root, "weight_windows_on")) {
6,269✔
1035
    weight_windows_on = get_node_value_bool(root, "weight_windows_on");
24✔
1036
  }
1037

1038
  if (check_for_node(root, "max_history_splits")) {
6,269✔
1039
    settings::max_history_splits =
233✔
1040
      std::stoi(get_node_value(root, "max_history_splits"));
233✔
1041
  }
1042

1043
  if (check_for_node(root, "max_tracks")) {
6,269✔
1044
    settings::max_tracks = std::stoi(get_node_value(root, "max_tracks"));
51✔
1045
  }
1046

1047
  // Create weight window generator objects
1048
  if (check_for_node(root, "weight_window_generators")) {
6,269✔
1049
    auto wwgs_node = root.child("weight_window_generators");
24✔
1050
    for (pugi::xml_node node_wwg :
24✔
1051
      wwgs_node.children("weight_windows_generator")) {
72✔
1052
      variance_reduction::weight_windows_generators.emplace_back(
24✔
1053
        std::make_unique<WeightWindowsGenerator>(node_wwg));
48✔
1054
    }
1055
    // if any of the weight windows are intended to be generated otf, make sure
1056
    // they're applied
1057
    for (const auto& wwg : variance_reduction::weight_windows_generators) {
24✔
1058
      if (wwg->on_the_fly_) {
24✔
1059
        settings::weight_windows_on = true;
24✔
1060
        break;
24✔
1061
      }
1062
    }
1063
  }
1064

1065
  // Set up weight window checkpoints
1066
  if (check_for_node(root, "weight_window_checkpoints")) {
6,269✔
1067
    xml_node ww_checkpoints = root.child("weight_window_checkpoints");
×
1068
    if (check_for_node(ww_checkpoints, "collision")) {
×
1069
      weight_window_checkpoint_collision =
×
1070
        get_node_value_bool(ww_checkpoints, "collision");
×
1071
    }
1072
    if (check_for_node(ww_checkpoints, "surface")) {
×
1073
      weight_window_checkpoint_surface =
×
1074
        get_node_value_bool(ww_checkpoints, "surface");
×
1075
    }
1076
  }
1077
}
6,269✔
1078

1079
void free_memory_settings()
6,395✔
1080
{
1081
  settings::statepoint_batch.clear();
6,395✔
1082
  settings::sourcepoint_batch.clear();
6,395✔
1083
  settings::source_write_surf_id.clear();
6,395✔
1084
  settings::res_scat_nuclides.clear();
6,395✔
1085
}
6,395✔
1086

1087
//==============================================================================
1088
// C API functions
1089
//==============================================================================
1090

1091
extern "C" int openmc_set_n_batches(
60✔
1092
  int32_t n_batches, bool set_max_batches, bool add_statepoint_batch)
1093
{
1094
  if (settings::n_inactive >= n_batches) {
60✔
1095
    set_errmsg("Number of active batches must be greater than zero.");
12✔
1096
    return OPENMC_E_INVALID_ARGUMENT;
12✔
1097
  }
1098

1099
  if (simulation::current_batch >= n_batches) {
48✔
1100
    set_errmsg("Number of batches must be greater than current batch.");
12✔
1101
    return OPENMC_E_INVALID_ARGUMENT;
12✔
1102
  }
1103

1104
  if (!settings::trigger_on) {
36✔
1105
    // Set n_batches and n_max_batches to same value
1106
    settings::n_batches = n_batches;
12✔
1107
    settings::n_max_batches = n_batches;
12✔
1108
  } else {
1109
    // Set n_batches and n_max_batches based on value of set_max_batches
1110
    if (set_max_batches) {
24✔
1111
      settings::n_max_batches = n_batches;
12✔
1112
    } else {
1113
      settings::n_batches = n_batches;
12✔
1114
    }
1115
  }
1116

1117
  // Update size of k_generation and entropy
1118
  int m = settings::n_max_batches * settings::gen_per_batch;
36✔
1119
  simulation::k_generation.reserve(m);
36✔
1120
  simulation::entropy.reserve(m);
36✔
1121

1122
  // Add value of n_batches to statepoint_batch
1123
  if (add_statepoint_batch &&
60✔
1124
      !(contains(settings::statepoint_batch, n_batches)))
24✔
1125
    settings::statepoint_batch.insert(n_batches);
24✔
1126

1127
  return 0;
36✔
1128
}
1129

1130
extern "C" int openmc_get_n_batches(int* n_batches, bool get_max_batches)
5,010✔
1131
{
1132
  *n_batches = get_max_batches ? settings::n_max_batches : settings::n_batches;
5,010✔
1133

1134
  return 0;
5,010✔
1135
}
1136

1137
} // namespace openmc
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