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

openmc-dev / openmc / 21489819490

29 Jan 2026 06:21PM UTC coverage: 80.077% (-1.9%) from 81.953%
21489819490

Pull #3757

github

web-flow
Merge d08626053 into f7a734189
Pull Request #3757: Testing point detectors

16004 of 22621 branches covered (70.75%)

Branch coverage included in aggregate %.

94 of 518 new or added lines in 26 files covered. (18.15%)

1021 existing lines in 52 files now uncovered.

53779 of 64524 relevant lines covered (83.35%)

8016833.26 hits per line

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

42.86
/include/openmc/distribution_multi.h
1
#ifndef DISTRIBUTION_MULTI_H
2
#define DISTRIBUTION_MULTI_H
3

4
#include "openmc/memory.h"
5

6
#include "pugixml.hpp"
7

8
#include "openmc/distribution.h"
9
#include "openmc/error.h"
10
#include "openmc/position.h"
11

12
namespace openmc {
13

14
//==============================================================================
15
//! Probability density function for points on the unit sphere. Extensions of
16
//! this type are used to sample angular distributions for starting sources
17
//==============================================================================
18

19
class UnitSphereDistribution {
20
public:
21
  UnitSphereDistribution() {};
620✔
22
  explicit UnitSphereDistribution(Direction u) : u_ref_ {u} {};
×
23
  explicit UnitSphereDistribution(pugi::xml_node node);
24
  virtual ~UnitSphereDistribution() = default;
919✔
25

26
  static unique_ptr<UnitSphereDistribution> create(pugi::xml_node node);
27

28
  //! Sample a direction from the distribution
29
  //! \param seed Pseudorandom number seed pointer
30
  //! \return (sampled Direction, sample weight)
31
  virtual std::pair<Direction, double> sample(uint64_t* seed) const = 0;
32

NEW
33
  virtual double evaluate(Direction u) const
×
34
  {
NEW
35
    fatal_error("evaluate not available for this UnitSphereDistribution type");
×
36
  }
37

38
  Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
39
};
40

41
//==============================================================================
42
//! Explicit distribution of polar and azimuthal angles
43
//==============================================================================
44

45
class PolarAzimuthal : public UnitSphereDistribution {
46
public:
47
  PolarAzimuthal(Direction u, UPtrDist mu, UPtrDist phi);
48
  explicit PolarAzimuthal(pugi::xml_node node);
49

50
  //! Sample a direction from the distribution
51
  //! \param seed Pseudorandom number seed pointer
52
  //! \return (sampled Direction, sample weight)
53
  std::pair<Direction, double> sample(uint64_t* seed) const override;
54

55
  //! Sample a direction and return evaluation of the PDF for biased sampling.
56
  //! Note that bias distributions are intended to return unit-weight samples.
57
  //! \param seed Pseudorandom number seed points
58
  //! \return (sampled Direction, value of the PDF at this Direction)
59
  std::pair<Direction, double> sample_as_bias(uint64_t* seed) const;
60

61
  double evaluate(Direction u) const override;
62

63
  // Observing pointers
64
  Distribution* mu() const { return mu_.get(); }
×
65
  Distribution* phi() const { return phi_.get(); }
×
66

67
private:
68
  //! Common sampling implementation
69
  //! \param seed Pseudorandom number seed pointer
70
  //! \param return_pdf If true, return PDF evaluation; if false, return
71
  //!        importance weight
72
  //! \return (sampled Direction, weight or PDF value)
73
  std::pair<Direction, double> sample_impl(
74
    uint64_t* seed, bool return_pdf) const;
75

76
  Direction v_ref_ {1.0, 0.0, 0.0}; //!< reference direction
77
  Direction w_ref_;
78
  UPtrDist mu_;  //!< Distribution of polar angle
79
  UPtrDist phi_; //!< Distribution of azimuthal angle
80
};
81

82
//==============================================================================
83
//! Uniform distribution on the unit sphere
84
//==============================================================================
85

86
Direction isotropic_direction(uint64_t* seed);
87

88
class Isotropic : public UnitSphereDistribution {
89
public:
90
  Isotropic() {};
620✔
91
  explicit Isotropic(pugi::xml_node node);
92

93
  //! Sample a direction from the distribution
94
  //! \param seed Pseudorandom number seed pointer
95
  //! \return (sampled direction, sample weight)
96
  std::pair<Direction, double> sample(uint64_t* seed) const override;
97

98
  double evaluate(Direction u) const override;
99

100
  // Set or get bias distribution
101
  void set_bias(std::unique_ptr<PolarAzimuthal> bias)
×
102
  {
103
    bias_ = std::move(bias);
×
104
  }
×
105

106
  const PolarAzimuthal* bias() const { return bias_.get(); }
1,768,089✔
107

108
protected:
109
  // Biasing distribution
110
  unique_ptr<PolarAzimuthal> bias_;
111
};
112

113
//==============================================================================
114
//! Monodirectional distribution
115
//==============================================================================
116

117
class Monodirectional : public UnitSphereDistribution {
118
public:
119
  Monodirectional(Direction u) : UnitSphereDistribution {u} {};
120
  explicit Monodirectional(pugi::xml_node node)
276✔
121
    : UnitSphereDistribution {node} {};
276✔
122

123
  //! Sample a direction from the distribution
124
  //! \param seed Pseudorandom number seed pointer
125
  //! \return (sampled direction, sample weight)
126
  std::pair<Direction, double> sample(uint64_t* seed) const override;
127
};
128

129
using UPtrAngle = unique_ptr<UnitSphereDistribution>;
130

131
} // namespace openmc
132

133
#endif // DISTRIBUTION_MULTI_H
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