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

openmc-dev / openmc / 13461947318

21 Feb 2025 05:24PM UTC coverage: 85.019% (+0.05%) from 84.969%
13461947318

Pull #3140

github

web-flow
Merge ece247ada into 2b788ea6e
Pull Request #3140: Add Versioning Support from `version.txt`

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

1293 existing lines in 43 files now uncovered.

50627 of 59548 relevant lines covered (85.02%)

35584918.67 hits per line

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

94.74
/src/tallies/filter_surface.cpp
1
#include "openmc/tallies/filter_surface.h"
2

3
#include <cassert>
4

5
#include <fmt/core.h>
6

7
#include "openmc/error.h"
8
#include "openmc/surface.h"
9
#include "openmc/xml_interface.h"
10

11
namespace openmc {
12

13
void SurfaceFilter::from_xml(pugi::xml_node node)
139✔
14
{
15
  auto surfaces = get_node_array<int32_t>(node, "bins");
139✔
16

17
  // Convert surface IDs to indices of the global surfaces vector.
18
  for (auto& s : surfaces) {
278✔
19
    auto search = model::surface_map.find(s);
139✔
20
    if (search == model::surface_map.end()) {
139✔
UNCOV
21
      throw std::runtime_error {
×
UNCOV
22
        fmt::format("Could not find surface {} specified on tally filter.", s)};
×
23
    }
24

25
    s = search->second;
139✔
26
  }
27

28
  this->set_surfaces(surfaces);
139✔
29
}
139✔
30

31
void SurfaceFilter::set_surfaces(span<int32_t> surfaces)
139✔
32
{
33
  // Clear existing surfaces
34
  surfaces_.clear();
139✔
35
  surfaces_.reserve(surfaces.size());
139✔
36
  map_.clear();
139✔
37

38
  // Update surfaces and mapping
39
  for (auto& index : surfaces) {
278✔
40
    assert(index >= 0);
115✔
41
    assert(index < model::surfaces.size());
115✔
42
    surfaces_.push_back(index);
139✔
43
    map_[index] = surfaces_.size() - 1;
139✔
44
  }
45

46
  n_bins_ = surfaces_.size();
139✔
47
}
139✔
48

49
void SurfaceFilter::get_all_bins(
7,603,408✔
50
  const Particle& p, TallyEstimator estimator, FilterMatch& match) const
51
{
52
  auto search = map_.find(p.surface_index());
7,603,408✔
53
  if (search != map_.end()) {
7,603,408✔
54
    match.bins_.push_back(search->second);
3,760,108✔
55
    if (p.surface() < 0) {
3,760,108✔
56
      match.weights_.push_back(-1.0);
1,332,544✔
57
    } else {
58
      match.weights_.push_back(1.0);
2,427,564✔
59
    }
60
  }
61
}
7,603,408✔
62

63
void SurfaceFilter::to_statepoint(hid_t filter_group) const
109✔
64
{
65
  Filter::to_statepoint(filter_group);
109✔
66
  vector<int32_t> surface_ids;
109✔
67
  for (auto c : surfaces_)
218✔
68
    surface_ids.push_back(model::surfaces[c]->id_);
109✔
69
  write_dataset(filter_group, "bins", surface_ids);
109✔
70
}
109✔
71

72
std::string SurfaceFilter::text_label(int bin) const
2,533✔
73
{
74
  return fmt::format("Surface {}", model::surfaces[surfaces_[bin]]->id_);
5,066✔
75
}
76

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

© 2025 Coveralls, Inc