• 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

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

4
#include "framework/graphs/linear_graph_partitioner.h"
5
#include "framework/utils/utils.h"
6
#include "framework/object_factory.h"
7
#include "framework/runtime.h"
8
#include "framework/logging/log.h"
9
#include <cmath>
10

11
namespace opensn
12
{
13

14
OpenSnRegisterObjectInNamespace(mesh, LinearGraphPartitioner);
15

16
InputParameters
17
LinearGraphPartitioner::GetInputParameters()
×
18
{
19
  InputParameters params = GraphPartitioner::GetInputParameters();
×
20

21
  params.SetGeneralDescription(
×
22
    "Basic linear partitioning. This type of partitioner works basically only for testing. "
23
    "Orthogonal meshes can produce decent partitioning but for unstructured grids it can be pretty "
24
    "bad. It partitions cells based on their linear index \"global_id\" instead of actually "
25
    "working with the graph.");
26

27
  params.AddOptionalParameter("all_to_rank",
×
28
                              -1,
29
                              "If non-zero will restrict all cells to this rank, "
30
                              "essentially transforming this partitioner into a "
31
                              "single-rank partitioner.");
32

33
  return params;
×
34
}
×
35

36
std::shared_ptr<LinearGraphPartitioner>
37
LinearGraphPartitioner::Create(const ParameterBlock& params)
×
38
{
39
  auto& factory = opensn::ObjectFactory::GetInstance();
×
40
  return factory.Create<LinearGraphPartitioner>("mesh::LinearGraphPartitioner", params);
×
41
}
42

43
LinearGraphPartitioner::LinearGraphPartitioner(const InputParameters& params)
×
44
  : GraphPartitioner(params), all_to_rank_(params.GetParamValue<int>("all_to_rank"))
×
45
{
46
}
×
47

48
std::vector<int>
49
LinearGraphPartitioner::Partition(const std::vector<std::vector<uint64_t>>& graph,
×
50
                                  const std::vector<Vector3>& /* centroids */,
51
                                  const int number_of_parts)
52
{
53
  log.Log0Verbose1() << "Partitioning with LinearGraphPartitioner";
×
54

55
  const std::vector<SubSetInfo> sub_sets = MakeSubSets(graph.size(), number_of_parts);
×
56

57
  std::vector<int> pids(graph.size(), 0);
×
58

59
  if (all_to_rank_ < 0)
×
60
  {
UNCOV
61
    size_t n = 0;
×
62
    for (int k = 0; k < number_of_parts; ++k)
×
63
      for (size_t m = 0; m < sub_sets[k].ss_size; ++m)
×
64
        pids[n++] = k;
×
65
  }
66
  else
67
    pids.assign(graph.size(), all_to_rank_);
×
68

69
  log.Log0Verbose1() << "Done partitioning with LinearGraphPartitioner";
×
70
  return pids;
×
71
}
×
72

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