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

Open-Sn / opensn / 20219489296

12 Dec 2025 06:55PM UTC coverage: 74.333%. Remained the same
20219489296

push

github

web-flow
Merge pull request #859 from wdhawkins/td_source_driver

Adding time-dependent solver and time-dependent sources

367 of 398 new or added lines in 23 files covered. (92.21%)

359 existing lines in 17 files now uncovered.

18610 of 25036 relevant lines covered (74.33%)

68904591.22 hits per line

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

86.02
/python/lib/py_app.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_app.h"
5
#include "python/lib/console.h"
6
#include "python/lib/py_wrappers.h"
7
#include "framework/logging/log.h"
8
#include "framework/utils/utils.h"
9
#include "framework/utils/timer.h"
10
#include "framework/runtime.h"
11
#include "caliper/cali.h"
12
#include "cxxopts/cxxopts.h"
13
#include <string>
14

15
using namespace opensn;
16
namespace py = pybind11;
17

18
namespace opensnpy
19
{
20

21
PyApp::PyApp(const mpi::Communicator& comm)
417✔
22
{
23
  opensn::mpi_comm = comm;
417✔
24

25
  py::module sys = py::module::import("sys");
417✔
26
  py::exec("rank = " + std::to_string(comm.rank()));
1,251✔
27
  py::exec("size = " + std::to_string(comm.size()));
1,251✔
28
  py::exec("opensn_console = True");
834✔
29

30
  console.BindBarrier(comm);
417✔
31

32
  Console::BindModule(WrapYlm);
417✔
33
  Console::BindModule(WrapVector3);
417✔
34
  Console::BindModule(WrapFunctors);
417✔
35

36
  Console::BindModule(WrapQuadraturePointPhiTheta);
417✔
37
  Console::BindModule(WrapQuadrature);
417✔
38
  Console::BindModule(WrapProductQuadrature);
417✔
39
  Console::BindModule(WrapCurvilinearProductQuadrature);
417✔
40
  Console::BindModule(WrapSLDFEsqQuadrature);
417✔
41
  Console::BindModule(WrapLebedevQuadrature);
417✔
42

43
  Console::BindModule(WrapMesh);
417✔
44
  Console::BindModule(WrapMeshGenerator);
417✔
45
  Console::BindModule(WrapGraphPartitioner);
417✔
46

47
  Console::BindModule(WrapLogicalVolume);
417✔
48

49
  Console::BindModule(WrapPointSource);
417✔
50
  Console::BindModule(WrapVolumetricSource);
417✔
51

52
  Console::BindModule(WrapMultiGroupXS);
417✔
53

54
  Console::BindModule(WrapFieldFunction);
417✔
55
  Console::BindModule(WrapFieldFunctionGridBased);
417✔
56
  Console::BindModule(WrapFieldFunctionInterpolation);
417✔
57

58
  Console::BindModule(WrapResEval);
417✔
59

60
  Console::BindModule(WrapProblem);
417✔
61
  Console::BindModule(WrapSolver);
417✔
62
  Console::BindModule(WrapLBS);
417✔
63
  Console::BindModule(WrapSteadyState);
417✔
64
  Console::BindModule(WrapTimeDependent);
417✔
65
  Console::BindModule(WrapNLKEigen);
417✔
66
  Console::BindModule(WrapPIteration);
417✔
67
  Console::BindModule(WrapDiscreteOrdinatesKEigenAcceleration);
834✔
68
}
417✔
69

70
int
71
PyApp::Run(int argc, char** argv)
417✔
72
{
73
  if (opensn::mpi_comm.rank() == 0)
417✔
74
  {
75
    std::cout << opensn::program << " version " << GetVersionStr() << "\n"
405✔
76
              << Timer::GetLocalDateTimeString() << " Running " << opensn::program << " with "
540✔
77
              << opensn::mpi_comm.size() << " processes.\n"
78
              << opensn::program << " number of arguments supplied: " << argc - 1 << "\n"
135✔
79
              << std::endl;
135✔
80
  }
81

82
  if (ProcessArguments(argc, argv))
417✔
83
  {
84
    opensn::Initialize();
417✔
85
    console.InitConsole();
417✔
86
    console.ExecuteFile(opensn::input_path.string());
417✔
87
    opensn::Finalize();
415✔
88

89
    if (opensn::mpi_comm.rank() == 0)
415✔
90
    {
91
      std::cout << "\nElapsed execution time: " << program_timer.GetTimeString() << "\n"
266✔
92
                << Timer::GetLocalDateTimeString() << " " << opensn::program
266✔
93
                << " finished execution." << std::endl;
399✔
94
    }
95
  }
96
  else
97
    return EXIT_FAILURE;
98

99
  cali_mgr.flush();
415✔
100
  return EXIT_SUCCESS;
415✔
101
}
102

103
bool
104
PyApp::ProcessArguments(int argc, char** argv)
417✔
105
{
106
  cxxopts::Options options(LowerCase(opensn::program), "");
834✔
107

108
  try
417✔
109
  {
110
    /* clang-format off */
111
    options.add_options("User")
834✔
112
    ("h,help",                      "Help message")
1,251✔
113
    ("c,suppress-color",            "Suppress color output")
1,251✔
114
    ("v,verbose",                   "Verbosity level (0 to 3). Default is 0.", cxxopts::value<unsigned int>())
1,251✔
115
    ("caliper",                     "Enable Caliper reporting",
1,251✔
116
      cxxopts::value<std::string>()->implicit_value("runtime-report(calc.inclusive=true),max_column_width=80"))
1,251✔
117
    ("i,input",                     "Input file", cxxopts::value<std::string>())
1,251✔
118
    ("p,py",                        "Python expression", cxxopts::value<std::vector<std::string>>());
1,251✔
119
    /* clang-format on */
120

121
    auto result = options.parse(argc, argv);
417✔
122

123
    if (result.count("help"))
417✔
124
    {
UNCOV
125
      if (opensn::mpi_comm.rank() == 0)
×
126
        std::cout << options.help({"User"}) << std::endl;
×
127
      return false;
×
128
    }
129

130
    if (result.count("verbose"))
417✔
131
    {
132
      auto verbosity = result["verbose"].as<unsigned int>();
4✔
133
      opensn::log.SetVerbosity(verbosity);
4✔
134
    }
135

136
    if (result.count("suppress-color"))
417✔
137
      opensn::suppress_color = true;
417✔
138

139
    if (result.count("caliper"))
417✔
140
    {
UNCOV
141
      opensn::use_caliper = true;
×
142
      opensn::cali_config = result["caliper"].as<std::string>();
×
143
    }
144

145
    if (result.count("py"))
417✔
146
    {
147
      for (const auto& pyarg : result["py"].as<std::vector<std::string>>())
834✔
148
        console.GetCommandBuffer().push_back(pyarg);
417✔
149
    }
150

151
    opensn::input_path = result["input"].as<std::string>();
417✔
152
    if (not std::filesystem::exists(input_path) or not std::filesystem::is_regular_file(input_path))
834✔
153
    {
UNCOV
154
      if (opensn::mpi_comm.rank() == 0)
×
155
        std::cerr << "Invalid input file: " << input_path.string() << "\n" << std::endl;
×
156
      return false;
×
157
    }
158
  }
417✔
UNCOV
159
  catch (const std::exception& e)
×
160
  {
UNCOV
161
    if (opensn::mpi_comm.rank() == 0)
×
162
      std::cerr << e.what() << "\n" << options.help({"User"}) << std::endl;
×
163
    return false;
×
164
  }
×
165

166
  return true;
417✔
167
}
417✔
168

169
} // namespace opensnpy
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