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

openmc-dev / openmc / 14840340664

05 May 2025 03:38PM UTC coverage: 85.195% (-0.009%) from 85.204%
14840340664

Pull #3392

github

web-flow
Merge 5bc1ec35f into 1e7d8324e
Pull Request #3392: Map Compton subshell data to atomic relaxation data

14 of 14 new or added lines in 2 files covered. (100.0%)

330 existing lines in 19 files now uncovered.

52194 of 61264 relevant lines covered (85.2%)

37398320.1 hits per line

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

93.75
/include/openmc/boundary_condition.h
1
#ifndef OPENMC_BOUNDARY_CONDITION_H
2
#define OPENMC_BOUNDARY_CONDITION_H
3

4
#include "openmc/hdf5_interface.h"
5
#include "openmc/particle.h"
6
#include "openmc/position.h"
7
#include <fmt/core.h>
8

9
namespace openmc {
10

11
// Forward declare some types used in function arguments.
12
class Particle;
13
class RandomRay;
14
class Surface;
15

16
//==============================================================================
17
//! A class that tells particles what to do after they strike an outer boundary.
18
//==============================================================================
19

20
class BoundaryCondition {
21
public:
22
  virtual ~BoundaryCondition() = default;
23,530,496✔
UNCOV
23

×
24
  //! Perform tracking operations for a particle that strikes the boundary.
23,530,496✔
25
  //! \param p The particle that struck the boundary.  This class is not meant
26
  //!   to directly modify anything about the particle, but it will do so
27
  //!   indirectly by calling the particle's appropriate cross_*_bc function.
28
  //! \param surf The specific surface on the boundary the particle struck.
29
  virtual void handle_particle(Particle& p, const Surface& surf) const = 0;
30

31
  //! Modify the incident particle's weight according to the boundary's albedo.
32
  //! \param p The particle that struck the boundary.  This function calculates
33
  //!   the reduction in the incident particle's weight as it interacts
34
  //!   with a boundary. The lost weight is tallied before the remaining weight
35
  //!   is reassigned to the incident particle. Implementations of the
36
  //!   handle_particle function typically call this method in its body.
37
  //! \param surf The specific surface on the boundary the particle struck.
38
  void handle_albedo(Particle& p, const Surface& surf) const
39
  {
40
    if (!has_albedo())
616,943,492✔
41
      return;
42
    double initial_wgt = p.wgt();
616,943,492✔
43
    // Treat the lost weight fraction as leakage, similar to VacuumBC.
615,916,136✔
44
    // This ensures the lost weight is tallied properly.
1,027,356✔
45
    p.wgt() *= (1.0 - albedo_);
46
    p.cross_vacuum_bc(surf);
47
    p.wgt() = initial_wgt * albedo_;
1,027,356✔
48
  };
1,027,356✔
49

1,027,356✔
50
  //! Return a string classification of this BC.
51
  virtual std::string type() const = 0;
52

53
  //! Write albedo data of this BC to hdf5.
54
  void to_hdf5(hid_t surf_group) const
55
  {
56
    if (has_albedo()) {
57
      write_string(surf_group, "albedo", fmt::format("{}", albedo_), false);
58
    }
59
  };
60

61
  //! Set albedo of this BC.
62
  void set_albedo(double albedo) { albedo_ = albedo; }
63

64
  //! Return if this BC has an albedo.
65
  bool has_albedo() const { return (albedo_ > 0.0); }
66

67
private:
616,960,349✔
68
  double albedo_ = -1.0;
69
};
70

71
//==============================================================================
72
//! A BC that kills particles, indicating they left the problem.
73
//==============================================================================
74

75
class VacuumBC : public BoundaryCondition {
76
public:
77
  void handle_particle(Particle& p, const Surface& surf) const override;
78

79
  std::string type() const override { return "vacuum"; }
80
};
81

81,429✔
82
//==============================================================================
83
//! A BC that returns particles via specular reflection.
84
//==============================================================================
85

86
class ReflectiveBC : public BoundaryCondition {
87
public:
88
  void handle_particle(Particle& p, const Surface& surf) const override;
89

90
  std::string type() const override { return "reflective"; }
91
};
92

236,526✔
93
//==============================================================================
94
//! A BC that returns particles via diffuse reflection.
95
//==============================================================================
96

97
class WhiteBC : public BoundaryCondition {
98
public:
99
  void handle_particle(Particle& p, const Surface& surf) const override;
100

101
  std::string type() const override { return "white"; }
102
};
103

66✔
104
//==============================================================================
105
//! A BC that moves particles to another part of the problem.
106
//==============================================================================
107

108
class PeriodicBC : public BoundaryCondition {
109
public:
110
  PeriodicBC(int i_surf, int j_surf) : i_surf_(i_surf), j_surf_(j_surf) {};
111

112
  std::string type() const override { return "periodic"; }
232✔
113

114
protected:
11,612✔
115
  int i_surf_;
116
  int j_surf_;
117
};
118

119
//==============================================================================
120
//! A BC that moves particles to another part of the problem without rotation.
121
//==============================================================================
122

123
class TranslationalPeriodicBC : public PeriodicBC {
124
public:
125
  TranslationalPeriodicBC(int i_surf, int j_surf);
126

127
  void handle_particle(Particle& p, const Surface& surf) const override;
128

129
protected:
130
  //! Vector along which incident particles will be moved
131
  Position translation_;
132
};
133

134
//==============================================================================
135
//! A BC that rotates particles about a global axis.
136
//
137
//! Currently only rotations about the z-axis are supported.
138
//==============================================================================
139

140
class RotationalPeriodicBC : public PeriodicBC {
141
public:
142
  RotationalPeriodicBC(int i_surf, int j_surf);
143

144
  void handle_particle(Particle& p, const Surface& surf) const override;
145

146
protected:
147
  //! Angle about the axis by which particle coordinates will be rotated
148
  double angle_;
149
};
150

151
} // namespace openmc
152
#endif // OPENMC_BOUNDARY_CONDITION_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