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

openmc-dev / openmc / 22261613902

21 Feb 2026 06:02PM UTC coverage: 81.808% (+0.05%) from 81.763%
22261613902

Pull #3474

github

web-flow
Merge aea47008a into 139907c95
Pull Request #3474: Support arbitrary symmetry axis for CylindricalIndependent class

17351 of 24448 branches covered (70.97%)

Branch coverage included in aggregate %.

50 of 64 new or added lines in 2 files covered. (78.13%)

2915 existing lines in 63 files now uncovered.

57697 of 67289 relevant lines covered (85.75%)

45481208.67 hits per line

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

97.01
/src/distribution_angle.cpp
1
#include "openmc/distribution_angle.h"
2

3
#include <cmath> // for abs, copysign
4

5
#include "openmc/tensor.h"
6

7
#include "openmc/endf.h"
8
#include "openmc/hdf5_interface.h"
9
#include "openmc/math_functions.h"
10
#include "openmc/random_lcg.h"
11
#include "openmc/search.h"
12
#include "openmc/vector.h" // for vector
13

14
namespace openmc {
15

16
//==============================================================================
17
// AngleDistribution implementation
18
//==============================================================================
19

20
AngleDistribution::AngleDistribution(hid_t group)
2,810,329✔
21
{
22
  // Get incoming energies
23
  read_dataset(group, "energy", energy_);
2,810,329✔
24
  int n_energy = energy_.size();
2,810,329✔
25

26
  // Get outgoing energy distribution data
27
  vector<int> offsets;
2,810,329✔
28
  vector<int> interp;
2,810,329✔
29
  hid_t dset = open_dataset(group, "mu");
2,810,329✔
30
  read_attribute(dset, "offsets", offsets);
2,810,329✔
31
  read_attribute(dset, "interpolation", interp);
2,810,329✔
32
  tensor::Tensor<double> temp;
2,810,329✔
33
  read_dataset(dset, temp);
2,810,329✔
34
  close_dataset(dset);
2,810,329✔
35

36
  for (int i = 0; i < n_energy; ++i) {
27,073,926✔
37
    // Determine number of outgoing energies
38
    int j = offsets[i];
24,263,597✔
39
    int n;
40
    if (i < n_energy - 1) {
24,263,597✔
41
      n = offsets[i + 1] - j;
21,453,268✔
42
    } else {
43
      n = temp.shape(1) - j;
2,810,329✔
44
    }
45

46
    // Create and initialize tabular distribution
47
    tensor::View<double> xs = temp.slice(0, tensor::range(j, j + n));
24,263,597✔
48
    tensor::View<double> ps = temp.slice(1, tensor::range(j, j + n));
24,263,597✔
49
    tensor::View<double> cs = temp.slice(2, tensor::range(j, j + n));
24,263,597✔
50
    vector<double> x {xs.begin(), xs.end()};
24,263,597✔
51
    vector<double> p {ps.begin(), ps.end()};
24,263,597✔
52
    vector<double> c {cs.begin(), cs.end()};
24,263,597✔
53

54
    // To get answers that match ACE data, for now we still use the tabulated
55
    // CDF values that were passed through to the HDF5 library. At a later
56
    // time, we can remove the CDF values from the HDF5 library and
57
    // reconstruct them using the PDF
58
    Tabular* mudist =
59
      new Tabular {x.data(), p.data(), n, int2interp(interp[i]), c.data()};
24,263,597✔
60

61
    distribution_.emplace_back(mudist);
24,263,597✔
62
  }
24,263,597✔
63
}
2,810,329✔
64

65
double AngleDistribution::sample(double E, uint64_t* seed) const
765,042,150✔
66
{
67
  // Find energy bin and calculate interpolation factor
68
  int i;
69
  double r;
70
  get_energy_index(energy_, E, i, r);
765,042,150✔
71

72
  // Sample between the ith and (i+1)th bin
73
  if (r > prn(seed))
765,042,150✔
74
    ++i;
315,394,046✔
75

76
  // Sample i-th distribution
77
  double mu = distribution_[i]->sample(seed).first;
765,042,150✔
78

79
  // Make sure mu is in range [-1,1] and return
80
  if (std::abs(mu) > 1.0)
765,042,150!
UNCOV
81
    mu = std::copysign(1.0, mu);
×
82
  return mu;
765,042,150✔
83
}
84

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