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

openmc-dev / openmc / 23367229037

20 Mar 2026 11:54PM UTC coverage: 81.453% (-0.1%) from 81.58%
23367229037

Pull #3877

github

web-flow
Merge 7af343511 into 3ce6cbfdd
Pull Request #3877: Add VTKHDF output support for all structured mesh types (#3620)

17595 of 25365 branches covered (69.37%)

Branch coverage included in aggregate %.

128 of 133 new or added lines in 1 file covered. (96.24%)

372 existing lines in 15 files now uncovered.

58192 of 67679 relevant lines covered (85.98%)

44598959.65 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() {};
44,279✔
UNCOV
22
  explicit UnitSphereDistribution(Direction u) : u_ref_ {u} {};
×
23
  explicit UnitSphereDistribution(pugi::xml_node node);
24
  virtual ~UnitSphereDistribution() = default;
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

33
  //! Evaluate the probability density for a given direction
34
  //! \param[in] u Direction on the unit sphere
35
  //! \return Probability density at the given direction
UNCOV
36
  virtual double evaluate(Direction u) const
×
37
  {
UNCOV
38
    fatal_error("evaluate not available for this UnitSphereDistribution type");
×
39
  }
40

41
  Direction u_ref_ {0.0, 0.0, 1.0}; //!< reference direction
42
};
43

44
//==============================================================================
45
//! Explicit distribution of polar and azimuthal angles
46
//==============================================================================
47

48
class PolarAzimuthal : public UnitSphereDistribution {
49
public:
50
  PolarAzimuthal(Direction u, UPtrDist mu, UPtrDist phi);
51
  explicit PolarAzimuthal(pugi::xml_node node);
52

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

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

64
  //! Evaluate the probability density for a given direction
65
  //! \param[in] u Direction on the unit sphere
66
  //! \return Probability density at the given direction
67
  double evaluate(Direction u) const override;
68

69
  // Observing pointers
UNCOV
70
  Distribution* mu() const { return mu_.get(); }
×
UNCOV
71
  Distribution* phi() const { return phi_.get(); }
×
72

73
private:
74
  //! Common sampling implementation
75
  //! \param seed Pseudorandom number seed pointer
76
  //! \param return_pdf If true, return PDF evaluation; if false, return
77
  //!        importance weight
78
  //! \return (sampled Direction, weight or PDF value)
79
  std::pair<Direction, double> sample_impl(
80
    uint64_t* seed, bool return_pdf) const;
81

82
  Direction v_ref_ {1.0, 0.0, 0.0}; //!< reference direction
83
  Direction w_ref_;
84
  UPtrDist mu_;  //!< Distribution of polar angle
85
  UPtrDist phi_; //!< Distribution of azimuthal angle
86
};
87

88
//==============================================================================
89
//! Uniform distribution on the unit sphere
90
//==============================================================================
91

92
Direction isotropic_direction(uint64_t* seed);
93

94
class Isotropic : public UnitSphereDistribution {
95
public:
96
  Isotropic() {};
88,558✔
97
  explicit Isotropic(pugi::xml_node node);
98

99
  //! Sample a direction from the distribution
100
  //! \param seed Pseudorandom number seed pointer
101
  //! \return (sampled direction, sample weight)
102
  std::pair<Direction, double> sample(uint64_t* seed) const override;
103

104
  //! Evaluate the probability density for a given direction
105
  //! \param[in] u Direction on the unit sphere
106
  //! \return Probability density at the given direction
107
  double evaluate(Direction u) const override;
108

109
  // Set or get bias distribution
UNCOV
110
  void set_bias(std::unique_ptr<PolarAzimuthal> bias)
×
111
  {
UNCOV
112
    bias_ = std::move(bias);
×
113
  }
114

115
  const PolarAzimuthal* bias() const { return bias_.get(); }
21,575,336!
116

117
protected:
118
  // Biasing distribution
119
  unique_ptr<PolarAzimuthal> bias_;
120
};
121

122
//==============================================================================
123
//! Monodirectional distribution
124
//==============================================================================
125

126
class Monodirectional : public UnitSphereDistribution {
127
public:
128
  Monodirectional(Direction u) : UnitSphereDistribution {u} {};
129
  explicit Monodirectional(pugi::xml_node node)
3,116✔
130
    : UnitSphereDistribution {node} {};
3,116✔
131

132
  //! Sample a direction from the distribution
133
  //! \param seed Pseudorandom number seed pointer
134
  //! \return (sampled direction, sample weight)
135
  std::pair<Direction, double> sample(uint64_t* seed) const override;
136
};
137

138
using UPtrAngle = unique_ptr<UnitSphereDistribution>;
139

140
} // namespace openmc
141

142
#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