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

openmc-dev / openmc / 19074870542

04 Nov 2025 04:02PM UTC coverage: 81.682% (-0.2%) from 81.872%
19074870542

Pull #3279

github

web-flow
Merge 26285d9ac into bd76fc056
Pull Request #3279: Hexagonal mesh model

16965 of 23709 branches covered (71.56%)

Branch coverage included in aggregate %.

560 of 856 new or added lines in 7 files covered. (65.42%)

125 existing lines in 2 files now uncovered.

54731 of 64066 relevant lines covered (85.43%)

42373202.59 hits per line

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

92.54
/src/tallies/filter_meshsurface.cpp
1
#include "openmc/tallies/filter_meshsurface.h"
2

3
#include "openmc/capi.h"
4
#include "openmc/constants.h"
5
#include "openmc/error.h"
6
#include "openmc/mesh.h"
7

8
namespace openmc {
9

10
void MeshSurfaceFilter::get_all_bins(
122,321,006✔
11
  const Particle& p, TallyEstimator estimator, FilterMatch& match) const
12
{
13
  Position r0 = p.r_last_current();
122,321,006✔
14
  Position r1 = p.r();
122,321,006✔
15
  if (translated_) {
122,321,006!
16
    r0 -= translation();
×
17
    r1 -= translation();
×
18
  }
19

20
  Direction u = p.u();
122,321,006✔
21
  model::meshes[mesh_]->surface_bins_crossed(r0, r1, u, match.bins_);
122,321,006✔
22
  for (auto b : match.bins_)
185,305,996✔
23
    match.weights_.push_back(1.0);
62,984,990✔
24
}
122,321,006✔
25

26
std::string MeshSurfaceFilter::text_label(int bin) const
1,401,916✔
27
{
28
  auto& mesh = *model::meshes[mesh_];
1,401,916✔
29

30
  int n_dim = mesh.n_dimension_;
1,401,916✔
31

32
  if (mesh.get_mesh_type() == "hexagonal") {
1,401,916✔
33
    // Hexagonal mesh with 2 x 4 surfaces
34
    return hexbin_label(bin);
3,344✔
35
  } else {
36
    // The regular behavior for a structured mesh with 2 x ndim surfaces
37
    return bin_label(n_dim, bin);
1,398,572✔
38
  }
39
}
40

41
std::string MeshSurfaceFilter::bin_label(int n_dim, int bin) const
1,398,572✔
42
{
43
  // Get flattend mesh index and surface index.
44
  int i_mesh = bin / (4 * n_dim);
1,398,572✔
45
  MeshDir surf_dir = static_cast<MeshDir>(bin % (4 * n_dim));
1,398,572✔
46

47
  // Get mesh index part of label.
48
  std::string out = MeshFilter::text_label(i_mesh);
1,398,572✔
49

50
  // Get surface part of label.
51
  switch (surf_dir) {
1,398,572!
52
  case MeshDir::OUT_LEFT:
116,720✔
53
    out += " Outgoing, x-min";
116,720✔
54
    break;
116,720✔
55
  case MeshDir::IN_LEFT:
116,720✔
56
    out += " Incoming, x-min";
116,720✔
57
    break;
116,720✔
58
  case MeshDir::OUT_RIGHT:
116,720✔
59
    out += " Outgoing, x-max";
116,720✔
60
    break;
116,720✔
61
  case MeshDir::IN_RIGHT:
116,720✔
62
    out += " Incoming, x-max";
116,720✔
63
    break;
116,720✔
64
  case MeshDir::OUT_BACK:
116,665✔
65
    out += " Outgoing, y-min";
116,665✔
66
    break;
116,665✔
67
  case MeshDir::IN_BACK:
116,665✔
68
    out += " Incoming, y-min";
116,665✔
69
    break;
116,665✔
70
  case MeshDir::OUT_FRONT:
116,665✔
71
    out += " Outgoing, y-max";
116,665✔
72
    break;
116,665✔
73
  case MeshDir::IN_FRONT:
116,665✔
74
    out += " Incoming, y-max";
116,665✔
75
    break;
116,665✔
76
  case MeshDir::OUT_BOTTOM:
116,258✔
77
    out += " Outgoing, z-min";
116,258✔
78
    break;
116,258✔
79
  case MeshDir::IN_BOTTOM:
116,258✔
80
    out += " Incoming, z-min";
116,258✔
81
    break;
116,258✔
82
  case MeshDir::OUT_TOP:
116,258✔
83
    out += " Outgoing, z-max";
116,258✔
84
    break;
116,258✔
85
  case MeshDir::IN_TOP:
116,258✔
86
    out += " Incoming, z-max";
116,258✔
87
    break;
116,258✔
88
  }
89

90
  return out;
1,398,572✔
91
}
×
92

93
std::string MeshSurfaceFilter::hexbin_label(int bin) const
3,344✔
94
{
95

96
  // Get flattend mesh index and surface index.
97
  int i_mesh = bin / (4 * 4);
3,344✔
98
  HexMeshDir surf_dir = static_cast<HexMeshDir>(bin % (4 * 4));
3,344✔
99

100
  // Get mesh index part of label.
101
  std::string out = MeshFilter::text_label(i_mesh);
3,344✔
102

103
  switch (surf_dir) {
3,344!
104
  case HexMeshDir::OUT_SE:
209✔
105
    out += " Outgoing, r_max SE";
209✔
106
    break;
209✔
107
  case HexMeshDir::IN_SE:
209✔
108
    out += " Incoming, r_max SE";
209✔
109
    break;
209✔
110
  case HexMeshDir::OUT_NW:
209✔
111
    out += " OUtgoing, r min NW";
209✔
112
    break;
209✔
113
  case HexMeshDir::IN_NW:
209✔
114
    out += " Incoming, r min NW";
209✔
115
    break;
209✔
116
  case HexMeshDir::OUT_E:
209✔
117
    out += " Outgoing, q max E";
209✔
118
    break;
209✔
119
  case HexMeshDir::IN_E:
209✔
120
    out += " Incoming, q max E";
209✔
121
    break;
209✔
122
  case HexMeshDir::OUT_W:
209✔
123
    out += " Outgoing, q min W";
209✔
124
    break;
209✔
125
  case HexMeshDir::IN_W:
209✔
126
    out += " Incoming, q min W";
209✔
127
    break;
209✔
128
  case HexMeshDir::OUT_NE:
209✔
129
    out += " Outgoing, s max NE";
209✔
130
    break;
209✔
131
  case HexMeshDir::IN_NE:
209✔
132
    out += " Incoming, s max NE";
209✔
133
    break;
209✔
134
  case HexMeshDir::OUT_SW:
209✔
135
    out += " Outgoing, s min SW";
209✔
136
    break;
209✔
137
  case HexMeshDir::IN_SW:
209✔
138
    out += " Incoming, s min SW";
209✔
139
    break;
209✔
140
  case HexMeshDir::OUT_BOTTOM:
209✔
141
    out += " Outgoing, z min";
209✔
142
    break;
209✔
143
  case HexMeshDir::IN_BOTTOM:
209✔
144
    out += " Incoming, z min";
209✔
145
    break;
209✔
146
  case HexMeshDir::OUT_TOP:
209✔
147
    out += " Outgoing, z max";
209✔
148
    break;
209✔
149
  case HexMeshDir::IN_TOP:
209✔
150
    out += " Incoming, z max";
209✔
151
    break;
209✔
152
  }
153

154
  return out;
3,344✔
NEW
155
}
×
156

157
void MeshSurfaceFilter::set_mesh(int32_t mesh)
415✔
158
{
159
  mesh_ = mesh;
415✔
160
  n_bins_ = model::meshes[mesh_]->n_surface_bins();
415✔
161
}
415✔
162

163
//==============================================================================
164
// C-API functions
165
//==============================================================================
166

167
extern "C" int openmc_meshsurface_filter_get_mesh(
48✔
168
  int32_t index, int32_t* index_mesh)
169
{
170
  return openmc_mesh_filter_get_mesh(index, index_mesh);
48✔
171
}
172

173
extern "C" int openmc_meshsurface_filter_set_mesh(
228✔
174
  int32_t index, int32_t index_mesh)
175
{
176
  return openmc_mesh_filter_set_mesh(index, index_mesh);
228✔
177
}
178

179
extern "C" int openmc_meshsurface_filter_get_translation(
12✔
180
  int32_t index, double translation[3])
181
{
182
  return openmc_mesh_filter_get_translation(index, translation);
12✔
183
}
184

185
extern "C" int openmc_meshsurface_filter_set_translation(
12✔
186
  int32_t index, double translation[3])
187
{
188
  return openmc_mesh_filter_set_translation(index, translation);
12✔
189
}
190

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