• 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

0.0
/include/openmc/event.h
1
#ifndef OPENMC_EVENT_H
2
#define OPENMC_EVENT_H
3

4
//! \file event.h
5
//! \brief Event-based data structures and methods
6

7
#include "openmc/particle.h"
8
#include "openmc/shared_array.h"
9

10
namespace openmc {
11

12
//==============================================================================
13
// Structs
14
//==============================================================================
15

16
// In the event-based model, instead of moving or sorting the particles
17
// themselves based on which event they need, a queue is used to store the
18
// index (and other useful info) for each event type.
19
// The EventQueueItem struct holds the relevant information about a particle
20
// needed for sorting the queue. For very high particle counts, a sorted queue
21
// has the potential to result in greatly improved cache efficiency. However,
22
// sorting will introduce some overhead due to the sorting process itself, and
23
// may not result in any benefits if not enough particles are present for them
24
// to achieve consistent locality improvements.
25
struct EventQueueItem {
26
  int64_t idx;       //!< particle index in event-based particle buffer
27
  ParticleType type; //!< particle type
28
  int64_t material;  //!< material that particle is in
29
  double E;          //!< particle energy
30

31
  // Constructors
32
  EventQueueItem() = default;
UNCOV
33
  EventQueueItem(const Particle& p, int64_t buffer_idx)
×
UNCOV
34
    : idx(buffer_idx), type(p.type()), material(p.material()), E(p.E())
×
UNCOV
35
  {}
×
36

37
  // Compare by particle type, then by material type (4.5% fuel/7.0%
38
  // fuel/cladding/etc), then by energy.
39
  // TODO: Currently in OpenMC, the material ID corresponds not only to a
40
  // general type, but also specific isotopic densities. Ideally we would like
41
  // to be able to just sort by general material type, regardless of densities.
42
  // A more general material type ID may be added in the future, in which case
43
  // we can update the material field of this struct to contain the more general
44
  // id.
45
  bool operator<(const EventQueueItem& rhs) const
46
  {
47
    return std::tie(type, material, E) <
48
           std::tie(rhs.type, rhs.material, rhs.E);
49
  }
50
};
51

52
//==============================================================================
53
// Global variable declarations
54
//==============================================================================
55

56
namespace simulation {
57

58
// Event queues. These use the special SharedArray type, rather than a normal
59
// vector, as they will be shared between threads and may be appended to at the
60
// same time. To facilitate this, the SharedArray thread_safe_append() method
61
// is provided which controls the append operations using atomics.
62
extern SharedArray<EventQueueItem> calculate_fuel_xs_queue;
63
extern SharedArray<EventQueueItem> calculate_nonfuel_xs_queue;
64
extern SharedArray<EventQueueItem> advance_particle_queue;
65
extern SharedArray<EventQueueItem> surface_crossing_queue;
66
extern SharedArray<EventQueueItem> collision_queue;
67

68
// Particle buffer
69
extern vector<Particle> particles;
70

71
} // namespace simulation
72

73
//==============================================================================
74
// Functions
75
//==============================================================================
76

77
//! Allocate space for the event queues and particle buffer
78
//
79
//! \param n_particles The number of particles in the particle buffer
80
void init_event_queues(int64_t n_particles);
81

82
//! Free the event queues and particle buffer
83
void free_event_queues(void);
84

85
//! Enqueue a particle based on if it is in fuel or a non-fuel material
86
//
87
//! \param buffer_idx The particle's actual index in the particle buffer
88
void dispatch_xs_event(int64_t buffer_idx);
89

90
//! Execute the initialization event for all particles
91
//
92
//! \param n_particles The number of particles in the particle buffer
93
//! \param source_offset The offset index in the source bank to use
94
void process_init_events(int64_t n_particles, int64_t source_offset);
95

96
//! Execute the calculate XS event for all particles in this event's buffer
97
//
98
//! \param queue A reference to the desired XS lookup queue
99
void process_calculate_xs_events(SharedArray<EventQueueItem>& queue);
100

101
//! Execute the advance particle event for all particles in this event's buffer
102
void process_advance_particle_events();
103

104
//! Execute the surface crossing event for all particles in this event's buffer
105
void process_surface_crossing_events();
106

107
//! Execute the collision event for all particles in this event's buffer
108
void process_collision_events();
109

110
//! Execute the death event for all particles
111
//
112
//! \param n_particles The number of particles in the particle buffer
113
void process_death_events(int64_t n_particles);
114

115
} // namespace openmc
116

117
#endif // OPENMC_EVENT_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