• 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

64.71
/python/lib/response.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 "modules/linear_boltzmann_solvers/response_evaluator/response_evaluator.h"
6
#include <memory>
7

8
namespace opensn
9
{
10

11
// Wrap response evaluator
12
void
13
WrapResEval(py::module& response)
416✔
14
{
15
  // clang-format off
16
  // response evaluator
17
  auto res_eval = py::class_<ResponseEvaluator, std::shared_ptr<ResponseEvaluator>>(
18
    response,
19
    "ResponseEvaluator",
20
    R"(
21
    Response evaluator by folding sources against adjoint solutions.
22

23
    Wrapper of :cpp:class:`opensn::ResponseEvaluator`.
24

25
    The workflow for this utility is constructed to minimize the file reading necessary for
26
    evaluations. To begin, one should add all adjoint solutions that are desired for response
27
    computations into the buffer. Then, one should define the different forward source
28
    configurations of interest. With this, the user can now iterate over the source
29
    configurations and convolve them against all available adjoint solutions in the buffer.
30
    )"
31
  );
416✔
32
  res_eval.def(
416✔
33
    py::init(
416✔
UNCOV
34
      [](py::kwargs& params)
×
35
      {
36
        return ResponseEvaluator::Create(kwargs_to_param_block(params));
28✔
37
      }
38
    ),
39
    R"(
40
    Construct a response evaluator object.
41

42
    Parameters
43
    ----------
44
    lbs_problem: pyopensn.solver.Solver
45
        A handle to an existing LBS problem.
46
    options: Dict
47
        The specification of adjoint buffers and forward to use.
48
    )"
49
  );
50
  res_eval.def(
416✔
51
    "EvaluateResponse",
52
    &ResponseEvaluator::EvaluateResponse,
416✔
53
    R"(
54
    Evaluate a response using the specified adjoint buffer with the currently defined sources in
55
    the solver.
56

57
    Parameters
58
    ----------
59
    buffer_name: str
60
        Adjoint buffer name
61
    )",
62
    py::arg("buffer_name")
416✔
63
  );
64
  res_eval.def(
416✔
65
    "SetOptions",
UNCOV
66
    [](ResponseEvaluator& self, py::kwargs& params)
×
67
    {
68
      InputParameters input = ResponseEvaluator::GetOptionsBlock();
28✔
69
      input.AssignParameters(kwargs_to_param_block(params));
28✔
70
      self.SetOptions(input);
28✔
71
    },
28✔
72
    R"(
73
    Set options for the response evaluator for adding adjoint buffers and defining forward sources.
74

75
    Parameters
76
    ----------
77
    buffers: List[Dict], default=[]
78
        A list of dictionaries containing adjoint buffer specifications.
79
    clear_sources: bool, default=False
80
        A flag to clear existing sources.
81
    sources: List[Dict], default=[]
82
        A list of dictionaries containing source specification information.
83
    )"
84
    );
85
  res_eval.def(
416✔
86
    "ClearForwardSources",
87
    &ResponseEvaluator::ClearForwardSources,
416✔
88
    "Clear the existing forward sources from the response evaluator."
89
  );
90
  res_eval.def(
416✔
91
    "SetBufferOptions",
UNCOV
92
    [](ResponseEvaluator& self, py::kwargs& params)
×
93
    {
94
      InputParameters input = ResponseEvaluator::GetBufferOptionsBlock();
×
95
      input.AssignParameters(kwargs_to_param_block(params));
×
96
      self.SetBufferOptions(input);
×
97
    },
×
98
    R"(
99
    Add adjoint buffers from the options block to the response evaluator.
100
    )"
101
  );
102
  res_eval.def(
416✔
103
    "SetSourceOptions",
UNCOV
104
    [](ResponseEvaluator& self, py::kwargs& params)
×
105
    {
106
      InputParameters input = ResponseEvaluator::GetSourceOptionsBlock();
×
107
      input.AssignParameters(kwargs_to_param_block(params));
×
108
      self.SetSourceOptions(input);
×
109
    },
×
110
    R"(
111
    Add forward sources from the options block to the response evaluator.
112
    )"
113
  );
114
  // clang-format on
115
}
416✔
116

117
// Wrap the response components of OpenSn
118
void
119
py_response(py::module& pyopensn)
62✔
120
{
121
  py::module response = pyopensn.def_submodule("response", "Response module.");
62✔
122
  WrapResEval(response);
62✔
123
}
62✔
124

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