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

openmc-dev / openmc / 16190841638

10 Jul 2025 09:03AM UTC coverage: 84.887% (-0.4%) from 85.251%
16190841638

Pull #3279

github

web-flow
Merge 5f15cb8bb into d700d395d
Pull Request #3279: Hexagonal mesh model

564 of 801 new or added lines in 6 files covered. (70.41%)

116 existing lines in 16 files now uncovered.

53118 of 62575 relevant lines covered (84.89%)

37709984.48 hits per line

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

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

20
  Direction u = p.u();
141,928,816✔
21
  model::meshes[mesh_]->surface_bins_crossed(r0, r1, u, match.bins_);
141,928,816✔
22
  for (auto b : match.bins_)
214,203,302✔
23
    match.weights_.push_back(1.0);
72,274,486✔
24
}
141,928,816✔
25

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

30
  int n_dim = mesh.n_dimension_;
1,530,912✔
31

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

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

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

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

90
  return out;
1,527,264✔
91
}
×
92

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

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

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

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

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

157
void MeshSurfaceFilter::set_mesh(int32_t mesh)
457✔
158
{
159
  mesh_ = mesh;
457✔
160
  n_bins_ = model::meshes[mesh_]->n_surface_bins();
457✔
161
}
457✔
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(
258✔
174
  int32_t index, int32_t index_mesh)
175
{
176
  return openmc_mesh_filter_set_mesh(index, index_mesh);
258✔
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