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

openmc-dev / openmc / 14411276588

11 Apr 2025 08:13PM UTC coverage: 85.393% (+0.3%) from 85.044%
14411276588

Pull #3133

github

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

250 of 260 new or added lines in 13 files covered. (96.15%)

147 existing lines in 9 files now uncovered.

52242 of 61178 relevant lines covered (85.39%)

37177303.05 hits per line

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

98.11
/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,001,632✔
14
{
15
  if (settings::ifp_parameter == IFPParameter::BetaEffective ||
1,001,632✔
16
      settings::ifp_parameter == IFPParameter::Both) {
1,001,632✔
17
    return true;
1,001,632✔
18
  }
NEW
19
  return false;
×
20
}
21

22
bool is_generation_time_or_both()
835,212✔
23
{
24
  if (settings::ifp_parameter == IFPParameter::GenerationTime ||
835,212✔
25
      settings::ifp_parameter == IFPParameter::Both) {
835,212✔
26
    return true;
835,212✔
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
  resize_ifp_data(simulation::ifp_source_delayed_group_bank,
16✔
49
    simulation::ifp_source_lifetime_bank, simulation::work_per_rank);
50
  resize_ifp_data(simulation::ifp_fission_delayed_group_bank,
16✔
51
    simulation::ifp_fission_lifetime_bank, 3 * simulation::work_per_rank);
52
}
16✔
53

54
void copy_ifp_data_from_fission_banks(
442,475✔
55
  int i_bank, vector<int>& delayed_groups, vector<double>& lifetimes)
56
{
57
  if (is_beta_effective_or_both()) {
442,475✔
58
    delayed_groups = simulation::ifp_fission_delayed_group_bank[i_bank];
442,475✔
59
  }
60
  if (is_generation_time_or_both()) {
442,475✔
61
    lifetimes = simulation::ifp_fission_lifetime_bank[i_bank];
442,475✔
62
  }
63
}
442,475✔
64

65
#ifdef OPENMC_MPI
66

67
void broadcast_ifp_n_generation(int& n_generation,
200✔
68
  const vector<vector<int>>& delayed_groups,
69
  const vector<vector<double>>& lifetimes)
70
{
71
  if (mpi::rank == 0) {
200✔
72
    if (is_beta_effective_or_both()) {
100✔
73
      n_generation = static_cast<int>(delayed_groups[0].size());
100✔
74
    } else {
75
      n_generation = static_cast<int>(lifetimes[0].size());
76
    }
77
  }
78
  MPI_Bcast(&n_generation, 1, MPI_INT, 0, mpi::intracomm);
200✔
79
}
200✔
80

81
void send_ifp_info(int64_t idx, int64_t n, int n_generation, int neighbor,
95✔
82
  vector<MPI_Request>& requests, const vector<vector<int>>& delayed_groups,
83
  vector<int>& send_delayed_groups, const vector<vector<double>>& lifetimes,
84
  vector<double>& send_lifetimes)
85
{
86
  // Copy data in send buffers
87
  for (int i = idx; i < idx + n; i++) {
1,390✔
88
    if (is_beta_effective_or_both()) {
1,295✔
89
      std::copy(delayed_groups[i].begin(), delayed_groups[i].end(),
1,295✔
90
        send_delayed_groups.begin() + i * n_generation);
2,590✔
91
    }
92
    if (is_generation_time_or_both()) {
1,295✔
93
      std::copy(lifetimes[i].begin(), lifetimes[i].end(),
1,295✔
94
        send_lifetimes.begin() + i * n_generation);
2,590✔
95
    }
96
  }
97
  // Send delayed groups
98
  if (is_beta_effective_or_both()) {
95✔
99
    requests.emplace_back();
95✔
100
    MPI_Isend(&send_delayed_groups[n_generation * idx],
95✔
101
      n_generation * static_cast<int>(n), MPI_INT, neighbor, mpi::rank,
102
      mpi::intracomm, &requests.back());
95✔
103
  }
104
  // Send lifetimes
105
  if (is_generation_time_or_both()) {
95✔
106
    requests.emplace_back();
95✔
107
    MPI_Isend(&send_lifetimes[n_generation * idx],
95✔
108
      n_generation * static_cast<int>(n), MPI_DOUBLE, neighbor, mpi::rank,
109
      mpi::intracomm, &requests.back());
95✔
110
  }
111
}
95✔
112

113
void receive_ifp_data(int64_t idx, int64_t n, int n_generation, int neighbor,
95✔
114
  vector<MPI_Request>& requests, vector<int>& delayed_groups,
115
  vector<double>& lifetimes, vector<DeserializationInfo>& deserialization)
116
{
117
  // Receive delayed groups
118
  if (is_beta_effective_or_both()) {
95✔
119
    requests.emplace_back();
95✔
120
    MPI_Irecv(&delayed_groups[n_generation * idx],
95✔
121
      n_generation * static_cast<int>(n), MPI_INT, neighbor, neighbor,
122
      mpi::intracomm, &requests.back());
95✔
123
  }
124
  // Receive lifetimes
125
  if (is_generation_time_or_both()) {
95✔
126
    requests.emplace_back();
95✔
127
    MPI_Irecv(&lifetimes[n_generation * idx],
95✔
128
      n_generation * static_cast<int>(n), MPI_DOUBLE, neighbor, neighbor,
129
      mpi::intracomm, &requests.back());
95✔
130
  }
131
  // Deserialization info to reconstruct data later
132
  DeserializationInfo info = {idx, n};
95✔
133
  deserialization.push_back(info);
95✔
134
}
95✔
135

136
void copy_partial_ifp_data_to_source_banks(int64_t idx, int n, int64_t i_bank,
200✔
137
  const vector<vector<int>>& delayed_groups,
138
  const vector<vector<double>>& lifetimes)
139
{
140
  if (is_beta_effective_or_both()) {
200✔
141
    std::copy(&delayed_groups[idx], &delayed_groups[idx + n],
200✔
142
      &simulation::ifp_source_delayed_group_bank[i_bank]);
200✔
143
  }
144
  if (is_generation_time_or_both()) {
200✔
145
    std::copy(&lifetimes[idx], &lifetimes[idx + n],
200✔
146
      &simulation::ifp_source_lifetime_bank[i_bank]);
200✔
147
  }
148
}
200✔
149

150
void deserialize_ifp_info(int n_generation,
200✔
151
  const vector<DeserializationInfo>& deserialization,
152
  const vector<int>& delayed_groups, const vector<double>& lifetimes)
153
{
154
  for (auto info : deserialization) {
295✔
155
    int64_t index_local = info.index_local;
95✔
156
    int64_t n = info.n;
95✔
157

158
    for (int i = index_local; i < index_local + n; i++) {
1,390✔
159
      if (is_beta_effective_or_both()) {
1,295✔
160
        vector<int> delayed_groups_received(
161
          delayed_groups.begin() + n_generation * i,
162
          delayed_groups.begin() + n_generation * (i + 1));
1,295✔
163
        simulation::ifp_source_delayed_group_bank[i] = delayed_groups_received;
1,295✔
164
      }
1,295✔
165
      if (is_generation_time_or_both()) {
1,295✔
166
        vector<double> lifetimes_received(lifetimes.begin() + n_generation * i,
167
          lifetimes.begin() + n_generation * (i + 1));
1,295✔
168
        simulation::ifp_source_lifetime_bank[i] = lifetimes_received;
1,295✔
169
      }
1,295✔
170
    }
171
  }
172
}
200✔
173

174
#endif
175

176
void copy_complete_ifp_data_to_source_banks(
120✔
177
  const vector<vector<int>>& delayed_groups,
178
  const vector<vector<double>>& lifetimes)
179
{
180
  if (is_beta_effective_or_both()) {
120✔
181
    std::copy(delayed_groups.data(),
240✔
182
      delayed_groups.data() + settings::n_particles,
120✔
183
      simulation::ifp_source_delayed_group_bank.begin());
184
  }
185
  if (is_generation_time_or_both()) {
120✔
186
    std::copy(lifetimes.data(), lifetimes.data() + settings::n_particles,
120✔
187
      simulation::ifp_source_lifetime_bank.begin());
188
  }
189
}
120✔
190

191
void allocate_temporary_vector_ifp(
320✔
192
  vector<vector<int>>& delayed_groups, vector<vector<double>>& lifetimes)
193
{
194
  if (is_beta_effective_or_both()) {
320✔
195
    delayed_groups.resize(simulation::fission_bank.size());
320✔
196
  }
197
  if (is_generation_time_or_both()) {
320✔
198
    lifetimes.resize(simulation::fission_bank.size());
320✔
199
  }
200
}
320✔
201

202
void copy_ifp_data_to_fission_banks(const vector<int>* const delayed_groups_ptr,
320✔
203
  const vector<double>* lifetimes_ptr)
204
{
205
  if (is_beta_effective_or_both()) {
320✔
206
    std::copy(delayed_groups_ptr,
320✔
207
      delayed_groups_ptr + simulation::fission_bank.size(),
320✔
208
      simulation::ifp_fission_delayed_group_bank.data());
209
  }
210
  if (is_generation_time_or_both()) {
320✔
211
    std::copy(lifetimes_ptr, lifetimes_ptr + simulation::fission_bank.size(),
320✔
212
      simulation::ifp_fission_lifetime_bank.data());
213
  }
214
}
320✔
215

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