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

openmc-dev / openmc / 12776996362

14 Jan 2025 09:49PM UTC coverage: 84.938% (+0.2%) from 84.729%
12776996362

Pull #3133

github

web-flow
Merge 0495246d9 into 549cc0973
Pull Request #3133: Kinetics parameters using Iterated Fission Probability

318 of 330 new or added lines in 10 files covered. (96.36%)

1658 existing lines in 66 files now uncovered.

50402 of 59340 relevant lines covered (84.94%)

33987813.96 hits per line

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

83.33
/include/openmc/distribution_spatial.h
1
#ifndef OPENMC_DISTRIBUTION_SPATIAL_H
2
#define OPENMC_DISTRIBUTION_SPATIAL_H
3

4
#include "pugixml.hpp"
5

6
#include "openmc/distribution.h"
7
#include "openmc/mesh.h"
8
#include "openmc/position.h"
9

10
namespace openmc {
11

12
//==============================================================================
13
//! Probability density function for points in Euclidean space
14
//==============================================================================
15

16
class SpatialDistribution {
17
public:
18
  virtual ~SpatialDistribution() = default;
46,127✔
UNCOV
19

×
20
  //! Sample a position from the distribution
46,127✔
21
  virtual Position sample(uint64_t* seed) const = 0;
22

23
  static unique_ptr<SpatialDistribution> create(pugi::xml_node node);
24
};
25

26
//==============================================================================
27
//! Distribution of points specified by independent distributions in x,y,z
28
//==============================================================================
29

30
class CartesianIndependent : public SpatialDistribution {
31
public:
32
  explicit CartesianIndependent(pugi::xml_node node);
33

34
  //! Sample a position from the distribution
35
  //! \param seed Pseudorandom number seed pointer
36
  //! \return Sampled position
37
  Position sample(uint64_t* seed) const override;
38

39
  // Observer pointers
40
  Distribution* x() const { return x_.get(); }
41
  Distribution* y() const { return y_.get(); }
42
  Distribution* z() const { return z_.get(); }
43

44
private:
45
  UPtrDist x_; //!< Distribution of x coordinates
46
  UPtrDist y_; //!< Distribution of y coordinates
47
  UPtrDist z_; //!< Distribution of z coordinates
48
};
49

50
//==============================================================================
51
//! Distribution of points specified by cylindrical coordinates r,phi,z
52
//==============================================================================
53

54
class CylindricalIndependent : public SpatialDistribution {
55
public:
56
  explicit CylindricalIndependent(pugi::xml_node node);
57

58
  //! Sample a position from the distribution
59
  //! \param seed Pseudorandom number seed pointer
60
  //! \return Sampled position
61
  Position sample(uint64_t* seed) const override;
62

63
  Distribution* r() const { return r_.get(); }
64
  Distribution* phi() const { return phi_.get(); }
65
  Distribution* z() const { return z_.get(); }
66
  Position origin() const { return origin_; }
67

68
private:
69
  UPtrDist r_;      //!< Distribution of r coordinates
70
  UPtrDist phi_;    //!< Distribution of phi coordinates
71
  UPtrDist z_;      //!< Distribution of z coordinates
72
  Position origin_; //!< Cartesian coordinates of the cylinder center
73
};
74

75
//==============================================================================
76
//! Distribution of points specified by spherical coordinates r,cos_theta,phi
77
//==============================================================================
78

79
class SphericalIndependent : public SpatialDistribution {
80
public:
81
  explicit SphericalIndependent(pugi::xml_node node);
82

83
  //! Sample a position from the distribution
84
  //! \param seed Pseudorandom number seed pointer
85
  //! \return Sampled position
86
  Position sample(uint64_t* seed) const override;
87

88
  Distribution* r() const { return r_.get(); }
89
  Distribution* cos_theta() const { return cos_theta_.get(); }
90
  Distribution* phi() const { return phi_.get(); }
91
  Position origin() const { return origin_; }
92

93
private:
94
  UPtrDist r_;         //!< Distribution of r coordinates
95
  UPtrDist cos_theta_; //!< Distribution of cos_theta coordinates
96
  UPtrDist phi_;       //!< Distribution of phi coordinates
97
  Position origin_;    //!< Cartesian coordinates of the sphere center
98
};
99

100
//==============================================================================
101
//! Distribution of points within a mesh
102
//==============================================================================
103

104
class MeshSpatial : public SpatialDistribution {
105
public:
106
  explicit MeshSpatial(pugi::xml_node node);
107
  explicit MeshSpatial(int32_t mesh_id, gsl::span<const double> strengths);
108

109
  //! Sample a position from the distribution
110
  //! \param seed Pseudorandom number seed pointer
111
  //! \return Sampled position
112
  Position sample(uint64_t* seed) const override;
113

114
  //! Sample the mesh for an element and position within that element
115
  //! \param seed Pseudorandom number seed pointer
116
  //! \return Sampled element index and position within that element
117
  std::pair<int32_t, Position> sample_mesh(uint64_t* seed) const;
118

119
  //! Sample a mesh element
120
  //! \param seed Pseudorandom number seed pointer
121
  //! \return Sampled element index
122
  int32_t sample_element_index(uint64_t* seed) const;
123

124
  //! For unstructured meshes, ensure that elements are all linear tetrahedra
125
  void check_element_types() const;
126

127
  // Accessors
128
  const Mesh* mesh() const { return model::meshes.at(mesh_idx_).get(); }
129
  int32_t n_sources() const { return this->mesh()->n_bins(); }
130

2,273,675✔
131
  double total_strength() { return this->elem_idx_dist_.integral(); }
7✔
132

133
private:
134
  int32_t mesh_idx_ {C_NONE};
135
  DiscreteIndex elem_idx_dist_; //!< Distribution of
136
                                //!< mesh element indices
137
};
138

139
//==============================================================================
140
//! Distribution of points
141
//==============================================================================
142

143
class PointCloud : public SpatialDistribution {
144
public:
145
  explicit PointCloud(pugi::xml_node node);
146
  explicit PointCloud(
147
    std::vector<Position> point_cloud, gsl::span<const double> strengths);
148

149
  //! Sample a position from the distribution
150
  //! \param seed Pseudorandom number seed pointer
151
  //! \return Sampled position
152
  Position sample(uint64_t* seed) const override;
153

154
private:
155
  std::vector<Position> point_cloud_;
156
  DiscreteIndex point_idx_dist_; //!< Distribution of Position indices
157
};
158

159
//==============================================================================
160
//! Uniform distribution of points over a box
161
//==============================================================================
162

163
class SpatialBox : public SpatialDistribution {
164
public:
165
  explicit SpatialBox(pugi::xml_node node, bool fission = false);
166

167
  //! Sample a position from the distribution
168
  //! \param seed Pseudorandom number seed pointer
169
  //! \return Sampled position
170
  Position sample(uint64_t* seed) const override;
171

172
  // Properties
173
  bool only_fissionable() const { return only_fissionable_; }
2,578✔
174
  Position lower_left() const { return lower_left_; }
175
  Position upper_right() const { return upper_right_; }
176

177
private:
178
  Position lower_left_;           //!< Lower-left coordinates of box
179
  Position upper_right_;          //!< Upper-right coordinates of box
180
  bool only_fissionable_ {false}; //!< Only accept sites in fissionable region?
181
};
182

183
//==============================================================================
184
//! Distribution at a single point
185
//==============================================================================
186

187
class SpatialPoint : public SpatialDistribution {
188
public:
189
  SpatialPoint() : r_ {} {};
190
  SpatialPoint(Position r) : r_ {r} {};
191
  explicit SpatialPoint(pugi::xml_node node);
192

193
  //! Sample a position from the distribution
194
  //! \param seed Pseudorandom number seed pointer
195
  //! \return Sampled position
196
  Position sample(uint64_t* seed) const override;
197

198
  Position r() const { return r_; }
199

200
private:
201
  Position r_; //!< Single position at which sites are generated
202
};
203

204
using UPtrSpace = unique_ptr<SpatialDistribution>;
205

206
} // namespace openmc
207

208
#endif // OPENMC_DISTRIBUTION_SPATIAL_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

© 2025 Coveralls, Inc