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

openmc-dev / openmc / 25472760865

07 May 2026 02:32AM UTC coverage: 80.952% (-0.4%) from 81.374%
25472760865

Pull #3757

github

web-flow
Merge 4928ac803 into e542b2f03
Pull Request #3757: Testing point detectors

17726 of 25786 branches covered (68.74%)

Branch coverage included in aggregate %.

44 of 386 new or added lines in 25 files covered. (11.4%)

81 existing lines in 3 files now uncovered.

58569 of 68461 relevant lines covered (85.55%)

47138839.61 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::get_all_bins(
×
40
  const Particle& p, TallyEstimator estimator, FilterMatch& match) const
41
{
NEW
42
  double attenuation = p.wgt() / p.wgt_last();
×
NEW
43
  int i = 0;
×
NEW
44
  for (auto [pos, r] : detectors_) {
×
NEW
45
    if ((p.r() - pos).norm() < FP_COINCIDENT) {
×
NEW
46
      match.bins_.push_back(i);
×
NEW
47
      double weight;
×
NEW
48
      double distance = (p.r_last() - pos).norm();
×
NEW
49
      if (distance > r) {
×
NEW
50
        weight = attenuation / (distance * distance);
×
51
      } else {
NEW
52
        weight = 3.0 * exprel(-p.macro_xs().total * r) / (r * r);
×
53
      }
NEW
54
      match.weights_.push_back(weight);
×
55
    }
NEW
56
    ++i;
×
57
  }
NEW
58
}
×
59

NEW
60
void PointFilter::to_statepoint(hid_t filter_group) const
×
61
{
NEW
62
  Filter::to_statepoint(filter_group);
×
NEW
63
  vector<double> detectors;
×
NEW
64
  for (auto [pos, r] : detectors_) {
×
NEW
65
    detectors.push_back(pos[0]);
×
NEW
66
    detectors.push_back(pos[1]);
×
NEW
67
    detectors.push_back(pos[2]);
×
NEW
68
    detectors.push_back(r);
×
69
  }
NEW
70
  write_dataset(filter_group, "bins", detectors);
×
NEW
71
}
×
72

NEW
73
std::string PointFilter::text_label(int bin) const
×
74
{
NEW
75
  auto [pos, r] = detectors_.at(bin);
×
NEW
76
  return fmt::format("Point: {} {}", pos, r);
×
77
}
78

79
} // 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