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

openmc-dev / openmc / 14390624619

10 Apr 2025 09:26PM UTC coverage: 85.179% (+0.1%) from 85.044%
14390624619

Pull #3133

github

web-flow
Merge e7fbf3b55 into cdc254ccf
Pull Request #3133: Kinetics parameters using Iterated Fission Probability

320 of 333 new or added lines in 12 files covered. (96.1%)

106 existing lines in 18 files now uncovered.

51990 of 61036 relevant lines covered (85.18%)

36926450.13 hits per line

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

98.5
/src/ifp.cpp
1
#include "openmc/ifp.h"
2

3
#include "openmc/bank.h"
4
#include "openmc/message_passing.h"
5
#include "openmc/particle.h"
6
#include "openmc/particle_data.h"
7
#include "openmc/settings.h"
8
#include "openmc/simulation.h"
9
#include "openmc/vector.h"
10

11
namespace openmc {
12

13
bool is_beta_effective_or_both()
1,223,541✔
14
{
15
  if (settings::ifp_parameter == IFPParameter::BetaEffective ||
1,223,541✔
16
      settings::ifp_parameter == IFPParameter::Both) {
1,223,541✔
17
    return true;
1,223,541✔
18
  }
NEW
19
  return false;
×
20
}
21

22
bool is_generation_time_or_both()
1,057,121✔
23
{
24
  if (settings::ifp_parameter == IFPParameter::GenerationTime ||
1,057,121✔
25
      settings::ifp_parameter == IFPParameter::Both) {
1,057,121✔
26
    return true;
1,057,121✔
27
  }
NEW
28
  return false;
×
29
}
30

31
void ifp(const Particle& p, const SourceSite& site, int64_t idx)
221,925✔
32
{
33
  if (is_beta_effective_or_both()) {
221,925✔
34
    const auto& delayed_groups =
35
      simulation::ifp_source_delayed_group_bank[p.current_work() - 1];
221,925✔
36
    simulation::ifp_fission_delayed_group_bank[idx] =
221,925✔
37
      _ifp(site.delayed_group, delayed_groups);
443,850✔
38
  }
39
  if (is_generation_time_or_both()) {
221,925✔
40
    const auto& lifetimes =
41
      simulation::ifp_source_lifetime_bank[p.current_work() - 1];
221,925✔
42
    simulation::ifp_fission_lifetime_bank[idx] = _ifp(p.lifetime(), lifetimes);
221,925✔
43
  }
44
}
221,925✔
45

46
void resize_simulation_ifp_banks()
16✔
47
{
48
  if (is_beta_effective_or_both()) {
16✔
49
    simulation::ifp_source_delayed_group_bank.resize(simulation::work_per_rank);
16✔
50
    simulation::ifp_fission_delayed_group_bank.resize(
16✔
51
      3 * simulation::work_per_rank);
16✔
52
  }
53
  if (is_generation_time_or_both()) {
16✔
54
    simulation::ifp_source_lifetime_bank.resize(simulation::work_per_rank);
16✔
55
    simulation::ifp_fission_lifetime_bank.resize(3 * simulation::work_per_rank);
16✔
56
  }
57
}
16✔
58

59
void initialize_ifp_pointers(int64_t i_bank,
221,925✔
60
  const vector<int>*& delayed_groups_ptr, const vector<double>*& lifetimes_ptr)
61
{
62
  if (is_beta_effective_or_both()) {
221,925✔
63
    delayed_groups_ptr = &simulation::ifp_fission_delayed_group_bank[i_bank];
221,925✔
64
  }
65
  if (is_generation_time_or_both()) {
221,925✔
66
    lifetimes_ptr = &simulation::ifp_fission_lifetime_bank[i_bank];
221,925✔
67
  }
68
}
221,925✔
69

70
void add_ifp_data(int64_t idx, vector<vector<int>>& delayed_groups,
220,077✔
71
  const vector<int>* const& delayed_groups_ptr,
72
  vector<vector<double>>& lifetimes, const vector<double>* const& lifetimes_ptr)
73
{
74
  if (is_beta_effective_or_both()) {
220,077✔
75
    delayed_groups[idx] = *delayed_groups_ptr;
220,077✔
76
  }
77
  if (is_generation_time_or_both()) {
220,077✔
78
    lifetimes[idx] = *lifetimes_ptr;
220,077✔
79
  }
80
}
220,077✔
81

82
void retrieve_ifp_data_from_fission_banks(int64_t idx, int i_bank,
473✔
83
  vector<vector<int>>& delayed_groups, vector<vector<double>>& lifetimes)
84
{
85
  if (is_beta_effective_or_both()) {
473✔
86
    delayed_groups[idx] = simulation::ifp_fission_delayed_group_bank[i_bank];
473✔
87
  }
88
  if (is_generation_time_or_both()) {
473✔
89
    lifetimes[idx] = simulation::ifp_fission_lifetime_bank[i_bank];
473✔
90
  }
91
}
473✔
92

93
#ifdef OPENMC_MPI
94

95
void broadcast_ifp_n_generation(int& n_generation,
200✔
96
  const vector<vector<int>>& delayed_groups,
97
  const vector<vector<double>>& lifetimes)
98
{
99
  if (mpi::rank == 0) {
200✔
100
    if (is_beta_effective_or_both()) {
100✔
101
      n_generation = static_cast<int>(delayed_groups[0].size());
100✔
102
    } else {
103
      n_generation = static_cast<int>(lifetimes[0].size());
104
    }
105
  }
106
  MPI_Bcast(&n_generation, 1, MPI_INT, 0, mpi::intracomm);
200✔
107
}
200✔
108

109
void send_ifp_info(int64_t idx, int64_t n, int n_generation, int neighbor,
95✔
110
  vector<MPI_Request>& requests, const vector<vector<int>>& delayed_groups,
111
  vector<int>& send_delayed_groups, const vector<vector<double>>& lifetimes,
112
  vector<double>& send_lifetimes)
113
{
114
  // Copy data in send buffers
115
  for (int i = idx; i < idx + n; i++) {
1,390✔
116
    if (is_beta_effective_or_both()) {
1,295✔
117
      std::copy(delayed_groups[i].begin(), delayed_groups[i].end(),
1,295✔
118
        send_delayed_groups.begin() + i * n_generation);
2,590✔
119
    }
120
    if (is_generation_time_or_both()) {
1,295✔
121
      std::copy(lifetimes[i].begin(), lifetimes[i].end(),
1,295✔
122
        send_lifetimes.begin() + i * n_generation);
2,590✔
123
    }
124
  }
125
  // Send delayed groups
126
  if (is_beta_effective_or_both()) {
95✔
127
    requests.emplace_back();
95✔
128
    MPI_Isend(&send_delayed_groups[n_generation * idx],
95✔
129
      n_generation * static_cast<int>(n), MPI_INT, neighbor, mpi::rank,
130
      mpi::intracomm, &requests.back());
95✔
131
  }
132
  // Send lifetimes
133
  if (is_generation_time_or_both()) {
95✔
134
    requests.emplace_back();
95✔
135
    MPI_Isend(&send_lifetimes[n_generation * idx],
95✔
136
      n_generation * static_cast<int>(n), MPI_DOUBLE, neighbor, mpi::rank,
137
      mpi::intracomm, &requests.back());
95✔
138
  }
139
}
95✔
140

141
void receive_ifp_data(int64_t idx, int64_t n, int n_generation, int neighbor,
95✔
142
  vector<MPI_Request>& requests, vector<int>& delayed_groups,
143
  vector<double>& lifetimes, vector<DeserializationInfo>& deserialization)
144
{
145
  // Receive delayed groups
146
  if (is_beta_effective_or_both()) {
95✔
147
    requests.emplace_back();
95✔
148
    MPI_Irecv(&delayed_groups[n_generation * idx],
95✔
149
      n_generation * static_cast<int>(n), MPI_INT, neighbor, neighbor,
150
      mpi::intracomm, &requests.back());
95✔
151
  }
152
  // Receive lifetimes
153
  if (is_generation_time_or_both()) {
95✔
154
    requests.emplace_back();
95✔
155
    MPI_Irecv(&lifetimes[n_generation * idx],
95✔
156
      n_generation * static_cast<int>(n), MPI_DOUBLE, neighbor, neighbor,
157
      mpi::intracomm, &requests.back());
95✔
158
  }
159
  // Deserialization info to reconstruct data later
160
  DeserializationInfo info = {idx, n};
95✔
161
  deserialization.push_back(info);
95✔
162
}
95✔
163

164
void copy_partial_ifp_data_to_source_banks(int64_t idx, int n, int64_t i_bank,
200✔
165
  const vector<vector<int>>& delayed_groups,
166
  const vector<vector<double>>& lifetimes)
167
{
168
  if (is_beta_effective_or_both()) {
200✔
169
    std::copy(&delayed_groups[idx], &delayed_groups[idx + n],
200✔
170
      &simulation::ifp_source_delayed_group_bank[i_bank]);
200✔
171
  }
172
  if (is_generation_time_or_both()) {
200✔
173
    std::copy(&lifetimes[idx], &lifetimes[idx + n],
200✔
174
      &simulation::ifp_source_lifetime_bank[i_bank]);
200✔
175
  }
176
}
200✔
177

178
void deserialize_ifp_info(int n_generation,
200✔
179
  const vector<DeserializationInfo>& deserialization,
180
  const vector<int>& delayed_groups, const vector<double>& lifetimes)
181
{
182
  for (auto info : deserialization) {
295✔
183
    int64_t index_local = info.index_local;
95✔
184
    int64_t n = info.n;
95✔
185

186
    for (int i = index_local; i < index_local + n; i++) {
1,390✔
187
      if (is_beta_effective_or_both()) {
1,295✔
188
        vector<int> delayed_groups_received(
189
          delayed_groups.begin() + n_generation * i,
190
          delayed_groups.begin() + n_generation * (i + 1));
1,295✔
191
        simulation::ifp_source_delayed_group_bank[i] = delayed_groups_received;
1,295✔
192
      }
1,295✔
193
      if (is_generation_time_or_both()) {
1,295✔
194
        vector<double> lifetimes_received(lifetimes.begin() + n_generation * i,
195
          lifetimes.begin() + n_generation * (i + 1));
1,295✔
196
        simulation::ifp_source_lifetime_bank[i] = lifetimes_received;
1,295✔
197
      }
1,295✔
198
    }
199
  }
200
}
200✔
201

202
#endif
203

204
void copy_complete_ifp_data_to_source_banks(
120✔
205
  const vector<vector<int>>& delayed_groups,
206
  const vector<vector<double>>& lifetimes)
207
{
208
  if (is_beta_effective_or_both()) {
120✔
209
    std::copy(delayed_groups.data(),
240✔
210
      delayed_groups.data() + settings::n_particles,
120✔
211
      simulation::ifp_source_delayed_group_bank.begin());
212
  }
213
  if (is_generation_time_or_both()) {
120✔
214
    std::copy(lifetimes.data(), lifetimes.data() + settings::n_particles,
120✔
215
      simulation::ifp_source_lifetime_bank.begin());
216
  }
217
}
120✔
218

219
void allocate_temporary_vector_ifp(vector<vector<int>>& delayed_groups,
320✔
220
  vector<int>*& delayed_groups_ptr, vector<vector<double>>& lifetimes,
221
  vector<double>*& lifetimes_ptr)
222
{
223
  if (is_beta_effective_or_both()) {
320✔
224
    delayed_groups.resize(simulation::fission_bank.size());
320✔
225
    delayed_groups_ptr = delayed_groups.data();
320✔
226
  }
227
  if (is_generation_time_or_both()) {
320✔
228
    lifetimes.resize(simulation::fission_bank.size());
320✔
229
    lifetimes_ptr = lifetimes.data();
320✔
230
  }
231
}
320✔
232

233
void sort_ifp_data_from_fission_banks(int64_t i_bank, int64_t idx,
221,925✔
234
  vector<int>*& delayed_groups_ptr, vector<double>*& lifetimes_ptr)
235
{
236
  if (is_beta_effective_or_both()) {
221,925✔
237
    const auto& delayed_groups =
238
      simulation::ifp_fission_delayed_group_bank[i_bank];
221,925✔
239
    delayed_groups_ptr[idx] = delayed_groups;
221,925✔
240
  }
241
  if (is_generation_time_or_both()) {
221,925✔
242
    const auto& lifetimes = simulation::ifp_fission_lifetime_bank[i_bank];
221,925✔
243
    lifetimes_ptr[idx] = lifetimes;
221,925✔
244
  }
245
}
221,925✔
246

247
void copy_ifp_data_to_fission_banks(
320✔
248
  vector<int>* const& delayed_groups_ptr, vector<double>* const& lifetimes_ptr)
249
{
250
  if (is_beta_effective_or_both()) {
320✔
251
    std::copy(delayed_groups_ptr,
320✔
252
      delayed_groups_ptr + simulation::fission_bank.size(),
320✔
253
      simulation::ifp_fission_delayed_group_bank.data());
254
  }
255
  if (is_generation_time_or_both()) {
320✔
256
    std::copy(lifetimes_ptr, lifetimes_ptr + simulation::fission_bank.size(),
320✔
257
      simulation::ifp_fission_lifetime_bank.data());
258
  }
259
}
320✔
260

261
} // 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