• 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
/src/tallies/filter_point.cpp
1
#include "openmc/tallies/filter_point.h"
2
#include "openmc/tallies/tally_scoring.h"
3

4
#include <fmt/core.h>
5

6
#include "openmc/math_functions.h"
7
#include "openmc/simulation.h"
8
#include "openmc/xml_interface.h"
9

10
namespace openmc {
11

NEW
12
void PointFilter::from_xml(pugi::xml_node node)
×
13
{
NEW
14
  auto bins = get_node_array<double>(node, "bins");
×
15

16
  // Convert to vector of detectors
NEW
17
  vector<std::pair<Position, double>> detectors;
×
NEW
18
  size_t n = bins.size() / 4;
×
NEW
19
  for (int i = 0; i < n; ++i) {
×
NEW
20
    Position pos {bins[4 * i], bins[4 * i + 1], bins[4 * i + 2]};
×
NEW
21
    detectors.push_back(std::make_pair(pos, bins[4 * i + 3]));
×
22
  }
NEW
23
  this->set_detectors(detectors);
×
NEW
24
}
×
25

NEW
26
void PointFilter::set_detectors(span<std::pair<Position, double>> detectors)
×
27
{
28
  // Clear existing detectors
NEW
29
  detectors_.clear();
×
NEW
30
  detectors_.reserve(detectors.size());
×
31

32
  // Set detectors and number of bins
NEW
33
  for (auto d : detectors) {
×
NEW
34
    detectors_.push_back(d);
×
35
  }
NEW
36
  n_bins_ = detectors_.size();
×
NEW
37
}
×
38

NEW
39
void PointFilter::reset_indices()
×
40
{
NEW
41
  indices_.clear();
×
NEW
42
  for (auto det : model::active_point_detectors) {
×
NEW
43
    vector<int32_t> temp;
×
NEW
44
    for (auto i = 0; i < detectors_.size(); i++) {
×
NEW
45
      auto [d, r] = detectors_[i];
×
NEW
46
      if (d == det)
×
NEW
47
        temp.push_back(i);
×
48
    }
NEW
49
    indices_.push_back(temp);
×
NEW
50
  }
×
NEW
51
}
×
52

NEW
53
void PointFilter::get_all_bins(
×
54
  const Particle& p, TallyEstimator estimator, FilterMatch& match) const
55
{
NEW
56
  double attenuation = p.wgt() / p.wgt_last();
×
NEW
57
  for (auto i : indices_[simulation::i_det]) {
×
NEW
58
    auto [pos, r] = detectors_[i];
×
NEW
59
    if ((p.r() - pos).norm() < FP_COINCIDENT) {
×
NEW
60
      match.bins_.push_back(i);
×
61
      double weight;
NEW
62
      double distance = (p.r_last() - pos).norm();
×
NEW
63
      if (distance > r) {
×
NEW
64
        weight = attenuation / (distance * distance);
×
65
      } else {
NEW
66
        weight = 3.0 * -exprel(-p.macro_xs().total * r) / (r * r);
×
67
      }
NEW
68
      match.weights_.push_back(weight);
×
69
    }
70
  }
NEW
71
}
×
72

NEW
73
void PointFilter::to_statepoint(hid_t filter_group) const
×
74
{
NEW
75
  Filter::to_statepoint(filter_group);
×
NEW
76
  vector<double> detectors;
×
NEW
77
  for (auto [pos, r] : detectors_) {
×
NEW
78
    detectors.push_back(pos[0]);
×
NEW
79
    detectors.push_back(pos[1]);
×
NEW
80
    detectors.push_back(pos[2]);
×
NEW
81
    detectors.push_back(r);
×
82
  }
NEW
83
  write_dataset(filter_group, "bins", detectors);
×
NEW
84
}
×
85

NEW
86
std::string PointFilter::text_label(int bin) const
×
87
{
NEW
88
  auto [pos, r] = detectors_.at(bin);
×
NEW
89
  return fmt::format("Point: {} {}", pos, r);
×
90
}
91

92
} // namespace openmc
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