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

openmc-dev / openmc / 20163164157

12 Dec 2025 10:01AM UTC coverage: 81.832% (-0.04%) from 81.872%
20163164157

Pull #3279

github

web-flow
Merge c32841e75 into bbfa18d72
Pull Request #3279: Hexagonal mesh model

17271 of 24053 branches covered (71.8%)

Branch coverage included in aggregate %.

602 of 876 new or added lines in 9 files covered. (68.72%)

1836 existing lines in 44 files now uncovered.

55648 of 65055 relevant lines covered (85.54%)

42918761.78 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(
112,368,751✔
11
  const Particle& p, TallyEstimator estimator, FilterMatch& match) const
12
{
13
  Position r0 = p.r_last_current();
112,368,751✔
14
  Position r1 = p.r();
112,368,751✔
15
  if (translated_) {
112,368,751!
16
    r0 -= translation();
×
17
    r1 -= translation();
×
18
  }
19

20
  Direction u = p.u();
112,368,751✔
21
  model::meshes[mesh_]->surface_bins_crossed(r0, r1, u, match.bins_);
112,368,751✔
22
  for (auto b : match.bins_)
170,895,285✔
23
    match.weights_.push_back(1.0);
58,526,534✔
24
}
112,368,751✔
25

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

30
  int n_dim = mesh.n_dimension_;
1,400,212✔
31

32
  if (mesh.get_mesh_type() == "hexagonal") {
1,400,212✔
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,396,868✔
38
  }
39
}
40

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

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

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

90
  return out;
1,396,868✔
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)
396✔
158
{
159
  mesh_ = mesh;
396✔
160
  n_bins_ = model::meshes[mesh_]->n_surface_bins();
396✔
161
}
396✔
162

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

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

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

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

185
extern "C" int openmc_meshsurface_filter_set_translation(
11✔
186
  int32_t index, double translation[3])
187
{
188
  return openmc_mesh_filter_set_translation(index, translation);
11✔
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