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

Open-Sn / opensn / 18300593117

06 Oct 2025 10:47PM UTC coverage: 74.862% (-0.2%) from 75.031%
18300593117

push

github

web-flow
Merge pull request #759 from wdhawkins/performance

Sweep performance optimizations

294 of 302 new or added lines in 15 files covered. (97.35%)

334 existing lines in 80 files now uncovered.

17788 of 23761 relevant lines covered (74.86%)

61852783.95 hits per line

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

85.71
/python/lib/logvol.cc
1
// SPDX-FileCopyrightText: 2025 The OpenSn Authors <https://open-sn.github.io/opensn/>
2
// SPDX-License-Identifier: MIT
3

4
#include "python/lib/py_wrappers.h"
5
#include "framework/mesh/logical_volume/logical_volume.h"
6
#include "framework/mesh/logical_volume/boolean_logical_volume.h"
7
#include "framework/mesh/logical_volume/rcc_logical_volume.h"
8
#include "framework/mesh/logical_volume/rpp_logical_volume.h"
9
#include "framework/mesh/logical_volume/sphere_logical_volume.h"
10
#include "framework/mesh/logical_volume/surface_mesh_logical_volume.h"
11
#include <memory>
12

13
namespace opensn
14
{
15

16
// Wrap logical volume
17
void
18
WrapLogicalVolume(py::module& logvol)
416✔
19
{
20
  // clang-format off
21
  // generic logical volume
22
  auto logical_volume = py::class_<LogicalVolume, std::shared_ptr<LogicalVolume>>(
23
    logvol,
24
    "LogicalVolume",
25
    R"(
26
    Generic logical volume.
27

28
    Wrapper of :cpp:class:`opensn::LogicalVolume`.
29
    )"
30
  );
416✔
31
  logical_volume.def(
416✔
32
    "Inside",
33
    &LogicalVolume::Inside,
416✔
34
    "Check if a point is inside or outside the logical volume.",
35
    py::arg("point")
416✔
36
  );
37

38
  // boolean logical volume
39
  auto boolean_logical_volume = py::class_<BooleanLogicalVolume,
40
                                           std::shared_ptr<BooleanLogicalVolume>, LogicalVolume>(
41
    logvol,
42
    "BooleanLogicalVolume",
43
    R"(
44
    Boolean logical volume.
45

46
    Wrapper of :cpp:class:`opensn::BooleanLogicalVolume`.
47
    )"
48
  );
416✔
49
  boolean_logical_volume.def(
416✔
50
    py::init(
416✔
UNCOV
51
      [](py::kwargs& params)
×
52
      {
53
        return BooleanLogicalVolume::Create(kwargs_to_param_block(params));
1✔
54
      }
55
    ),
56
    R"(
57
    Construct a boolean logical volume from a list of combinatorial logics. Each combinatorial logic
58
    are represented by a Python dictionary with two keys:
59

60
     - ``op`` maps to a boolean. True means included and False means excluded.
61
     - ``lv`` maps to a :py:class:`pyopensn.logvol.LogicalVolume`.
62

63
    Parameters
64
    ----------
65
    parts: List[Dict]
66
        List of dictionary of combinatorial logics.
67

68
    Examples
69
    --------
70
    >>> blv = BooleanLogicalVolume(
71
    ...     parts=[{ "op": True, "lv": volume1 }, { "op": False, "lv": volume2 }]
72
    ... )
73
    )"
74
  );
75

76
  // RCC logical volume
77
  auto rcc_logical_volume = py::class_<RCCLogicalVolume, std::shared_ptr<RCCLogicalVolume>,
78
                                       LogicalVolume>(
79
    logvol,
80
    "RCCLogicalVolume",
81
    R"(
82
    Right circular cylinder logical volume.
83

84
    Wrapper of :cpp:class:`opensn::RCCLogicalVolume`.
85
    )"
86
  );
416✔
87
  rcc_logical_volume.def(
416✔
88
    py::init(
416✔
UNCOV
89
      [](py::kwargs& params)
×
90
      {
91
        return RCCLogicalVolume::Create(kwargs_to_param_block(params));
35✔
92
      }
93
    ),
94
    R"(
95
    Construct an RCC logical volume.
96

97
    Parameters
98
    ----------
99
    r: float, default=1.0
100
        Radius of the sphere.
101
    x0: float, default=0.0
102
        X-coordinate of the volume base.
103
    y0: float, default=0.0
104
        Y-coordinate of the volume base.
105
    z0: float, default=0.0
106
        Z-coordinate of the volume base.
107
    vx: float, default=0.0
108
        X-component of the volume extrusion vector.
109
    vy: float, default=0.0
110
        Y-component of the volume extrusion vector.
111
    vz: float, default=1.0
112
        Z-component of the volume extrusion vector.
113
    )"
114
  );
115

116
  // RPP logical volume
117
  auto rpp_logical_volume = py::class_<RPPLogicalVolume, std::shared_ptr<RPPLogicalVolume>,
118
                                       LogicalVolume>(
119
    logvol,
120
    "RPPLogicalVolume",
121
    R"(
122
    Rectangular parallel piped logical volume.
123

124
    Wrapper of :cpp:class:`opensn::RPPLogicalVolume`.
125
    )"
126
  );
416✔
127
  rpp_logical_volume.def(
416✔
128
    py::init(
416✔
UNCOV
129
      [](py::kwargs& params)
×
130
      {
131
        return RPPLogicalVolume::Create(kwargs_to_param_block(params));
386✔
132
      }
133
    ),
134
    R"(
135
    Construct an RPP logical volume.
136

137
    Parameters
138
    ----------
139
    xmin: float, default=0.0
140
        X-min of the volume.
141
    xmax: float, default=1.0
142
        X-max of the volume.
143
    ymin: float, default=0.0
144
        Y-min of the volume.
145
    ymax: float, default=1.0
146
        Y-max of the volume.
147
    zmin: float, default=0.0
148
        Z-min of the volume.
149
    zmax: float, default=1.0
150
        Z-max of the volume.
151
    infx: bool, default=False
152
        Flag, when true, will ignore xmin and xmax.
153
    infy: bool, default=False
154
        Flag, when true, will ignore ymin and ymax.
155
    infz: bool, default=False
156
        Flag, when true, will ignore zmin and zmax.
157
    )"
158
  );
159

160
  // spherical logical volume
161
  auto spherical_logical_volume = py::class_<SphereLogicalVolume,
162
                                             std::shared_ptr<SphereLogicalVolume>, LogicalVolume>(
163
    logvol,
164
    "SphereLogicalVolume",
165
    R"(
166
    Spherical logical volume.
167

168
    Wrapper of :cpp:class:`opensn::SphereLogicalVolume`.
169
    )"
170
  );
416✔
171
  spherical_logical_volume.def(
416✔
172
    py::init(
416✔
UNCOV
173
      [](py::kwargs& params)
×
174
      {
175
        return SphereLogicalVolume::Create(kwargs_to_param_block(params));
2✔
176
      }
177
    ),
178
    R"(
179
    Construct a spherical logical volume.
180

181
    Parameters
182
    ----------
183
    r: float, default=1.0
184
        Radius of the sphere.
185
    x: float, default=0.0
186
        X-location of the volume.
187
    y: float, default=0.0
188
        Y-location of the volume.
189
    z: float, default=0.0
190
        Z-location of the volume.
191
    )"
192
  );
193

194
  // surface mesh logical volume
195
  auto surface_mesh_logical_volume = py::class_<SurfaceMeshLogicalVolume,
196
                                                std::shared_ptr<SurfaceMeshLogicalVolume>,
197
                                                LogicalVolume>(
198
    logvol,
199
    "SurfaceMeshLogicalVolume",
200
    R"(
201
    Surface mesh logical volume.
202

203
    Wrapper of :cpp:class:`opensn::SurfaceMeshLogicalVolume`.
204
    )"
205
  );
416✔
206
  surface_mesh_logical_volume.def(
416✔
207
    py::init(
416✔
UNCOV
208
      [](py::kwargs& params)
×
209
      {
210
        return SurfaceMeshLogicalVolume::Create(kwargs_to_param_block(params));
1✔
211
      }
212
    ),
213
    R"(
214
    Construct a surface mesh logical volume.
215

216
    Parameters
217
    ----------
218
    surface_mesh: pyopensn.mesh.SurfaceMesh
219
        Associated surface mesh.
220
    )"
221
  );
222
  // clang-format on
223
}
416✔
224

225
// Wrap the logical volume components of OpenSn
226
void
227
py_logvol(py::module& pyopensn)
62✔
228
{
229
  py::module logvol = pyopensn.def_submodule("logvol", "Logical volume module.");
62✔
230
  WrapLogicalVolume(logvol);
62✔
231
}
62✔
232

233
} // namespace opensn
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