• 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

37.97
/framework/math/unknown_manager/unknown_manager.cc
1
// SPDX-FileCopyrightText: 2024 The OpenSn Authors <https://open-sn.github.io/opensn/>
2
// SPDX-License-Identifier: MIT
3

4
#include "framework/math/unknown_manager/unknown_manager.h"
5
#include "framework/logging/log.h"
6
#include "framework/runtime.h"
7

8
namespace opensn
9
{
10

11
unsigned int
12
UnknownManager::AddUnknown(UnknownType unk_type, unsigned int dimension)
124,841✔
13
{
14
  int last_unknown_end = -1;
124,841✔
15
  if (not unknowns.empty())
124,841✔
16
    last_unknown_end = unknowns.back().GetMapEnd();
50,986✔
17

18
  unsigned int new_unknown_index = unknowns.size();
124,841✔
19

20
  if (unk_type == UnknownType::SCALAR)
124,841✔
21
  {
22
    unknowns.emplace_back(UnknownType::SCALAR, 1, last_unknown_end + 1);
73,138✔
23
    unknowns.back().name = "Unknown_" + std::to_string(unknowns.size() - 1);
73,138✔
24
  }
25
  else if (unk_type == UnknownType::VECTOR_2)
51,703✔
26
  {
27
    unknowns.emplace_back(UnknownType::VECTOR_2, 2, last_unknown_end + 1);
×
28
    unknowns.back().name = "Unknown_" + std::to_string(unknowns.size() - 1);
×
29
  }
30
  else if (unk_type == UnknownType::VECTOR_3)
51,703✔
31
  {
32
    unknowns.emplace_back(UnknownType::VECTOR_3, 3, last_unknown_end + 1);
×
33
    unknowns.back().name = "Unknown_" + std::to_string(unknowns.size() - 1);
×
34
  }
35
  else if (unk_type == UnknownType::VECTOR_N)
51,703✔
36
  {
37
    if (dimension == 0)
51,703✔
38
    {
39
      std::ostringstream oss;
×
40
      oss << "UnknownManager: When adding unknown of type VECTOR_N, dimension cannot be 0";
×
41
      throw std::runtime_error(oss.str());
×
42
    }
×
43

44
    unknowns.emplace_back(UnknownType::VECTOR_N, dimension, last_unknown_end + 1);
51,703✔
45
    unknowns.back().name = "Unknown_" + std::to_string(unknowns.size() - 1);
51,703✔
46
  }
47
  else
48
    throw std::runtime_error(
49
      "UnknownManager: Invalid call to AddUnknown. Unknown type not supported.");
×
50

51
  return new_unknown_index;
124,841✔
52
}
53

54
unsigned int
55
UnknownManager::MapUnknown(int unknown_id, unsigned int component) const
1,835,369,174✔
56
{
57
  if (unknown_id < 0 or unknown_id >= unknowns.size())
1,835,369,174✔
58
  {
59
    std::ostringstream oss;
×
60
    oss << "UnknownManager: Call to MapUnknown failed (id = " << unknown_id << ")";
×
61
    throw std::runtime_error(oss.str());
×
62
  }
×
63
  return unknowns[unknown_id].GetMap(component);
1,835,369,174✔
64
}
65

66
unsigned int
67
UnknownManager::GetTotalUnknownStructureSize() const
1,835,550,565✔
68
{
69
  if (unknowns.empty())
1,835,550,565✔
UNCOV
70
    return 0;
×
71

72
  return unknowns.back().GetMapEnd() + 1;
1,835,550,565✔
73
}
74

75
void
76
UnknownManager::SetUnknownNumOffBlockConnections(int unknown_id, int num_conn)
×
77
{
78
  if (unknown_id < 0 or unknown_id >= unknowns.size())
×
79
  {
80
    std::ostringstream oss;
×
81
    oss << "UnknownManager: Call to SetUnknownNumOffBlockConnections failed (id = " << unknown_id
×
82
        << ")";
×
83
    throw std::runtime_error(oss.str());
×
84
  }
×
85

86
  for (auto& val : unknowns[unknown_id].num_off_block_connections)
×
87
    val = num_conn;
×
88
}
×
89

90
void
91
UnknownManager::SetUnknownComponentNumOffBlockConnections(int unknown_id,
×
92
                                                          unsigned int component,
93
                                                          int num_conn)
94
{
95
  if (unknown_id < 0 or unknown_id >= unknowns.size())
×
96
  {
97
    std::ostringstream oss;
×
98
    oss << "UnknownManager: Call to SetUnknownComponentNumOffBlockConnections failed "
99
        << "(id = " << unknown_id << ")";
×
100
    throw std::runtime_error(oss.str());
×
101
  }
×
102

103
  if (component < 0 or component >= unknowns[unknown_id].num_components)
×
104
  {
105
    std::ostringstream oss;
×
106
    oss << "UnknownManager: Call to SetUnknownComponentNumOffBlockConnections failed "
107
        << "(component id = " << component << ")";
×
108
    throw std::runtime_error(oss.str());
×
109
  }
×
110

111
  unknowns[unknown_id].num_off_block_connections[component] = num_conn;
×
112
}
×
113

114
void
115
UnknownManager::SetUnknownName(int unknown_id, const std::string& unk_name)
72,775✔
116
{
117
  if (unknown_id < 0 or unknown_id >= unknowns.size())
72,775✔
118
  {
119
    std::ostringstream oss;
×
120
    oss << "UnknownManager: Call to SetUnknownName failed (id = " << unknown_id << ")";
×
121
    throw std::runtime_error(oss.str());
×
122
  }
×
123

124
  unknowns[unknown_id].name = unk_name;
72,775✔
125
}
72,775✔
126

127
void
128
UnknownManager::SetUnknownComponentName(int unknown_id,
72,908✔
129
                                        unsigned int component,
130
                                        const std::string& component_name)
131
{
132
  if (unknown_id < 0 or unknown_id >= unknowns.size())
72,908✔
133
  {
134
    std::ostringstream oss;
×
135
    oss << "UnknownManager: Call to SetUnknownComponentName failed (id = " << unknown_id << ")";
×
136
    throw std::runtime_error(oss.str());
×
137
  }
×
138

139
  if (component < 0 or component >= unknowns[unknown_id].num_components)
72,908✔
140
  {
141
    std::ostringstream oss;
×
142
    oss << "UnknownManager: Call to SetUnknownComponentName failed "
143
        << "(component id = " << component << ")";
×
144
    throw std::runtime_error(oss.str());
×
145
  }
×
146

147
  unknowns[unknown_id].component_names[component] = component_name;
72,908✔
148
}
72,908✔
149

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