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

Open-Sn / opensn / 25654184358

09 May 2026 03:58AM UTC coverage: 75.687%. Remained the same
25654184358

push

github

web-flow
Merge pull request #1042 from wdhawkins/ang_quadrature_refactor

Refactoring angular quadrature classes.

230 of 278 new or added lines in 27 files covered. (82.73%)

181 existing lines in 12 files now uncovered.

22258 of 29408 relevant lines covered (75.69%)

64739266.89 hits per line

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

50.0
/framework/math/quadratures/angular/triangular_quadrature.h
1
// SPDX-FileCopyrightText: 2026 The OpenSn Authors <https://open-sn.github.io/opensn/>
2
// SPDX-License-Identifier: MIT
3

4
#pragma once
5

6
#include "framework/math/quadratures/angular/angular_quadrature.h"
7
#include <map>
8
#include <vector>
9

10
namespace opensn
11
{
12

13
/// Base class for triangular quadratures.
14
///
15
/// Unlike product quadratures which have a fixed number of azimuthal angles per polar level,
16
/// triangular quadratures have a varying number that decreases as the polar angle moves away
17
/// from the equatorial plane.
18
class TriangularQuadrature : public AngularQuadrature
19
{
20
public:
21
  ~TriangularQuadrature() override = default;
3✔
22

23
  /// Return the abscissae index for the given polar and azimuthal angle indices.
24
  unsigned int GetAngleNum(const unsigned int polar_angle_index,
25
                           const unsigned int azimu_angle_index) const
26
  {
27
    return map_directions_.at(polar_angle_index)[azimu_angle_index];
28
  }
29

30
  /// Return constant reference to map_directions.
31
  const std::map<unsigned int, std::vector<unsigned int>>& GetDirectionMap() const
32
  {
33
    return map_directions_;
34
  }
35

36
  /// Polar angles for each polar level.
37
  const std::vector<double>& GetPolarAngles() const { return polar_ang_; }
38

39
  /// Azimuthal angles for each polar level.
40
  const std::vector<std::vector<double>>& GetAzimuthalAnglesPerPolarLevel() const
41
  {
42
    return azimuthal_per_polar_;
43
  }
44

NEW
45
  unsigned int GetNumPolarAngles() const override { return n_polar_; }
×
46

NEW
47
  unsigned int GetNumAzimuthalAngles() const override { return n_azimuthal_; }
×
48

49
protected:
50
  TriangularQuadrature(unsigned int dimension,
3✔
51
                       unsigned int scattering_order,
52
                       OperatorConstructionMethod method = OperatorConstructionMethod::STANDARD)
53
    : AngularQuadrature(
3✔
54
        AngularQuadratureType::TRIANGULAR_QUADRATURE, dimension, scattering_order, method),
55
      weight_sum_(0.0)
3✔
56
  {
57
  }
3✔
58

59
  /// Sum of all quadrature weights.
60
  double weight_sum_;
61

62
  /// Polar angles for each polar level.
63
  std::vector<double> polar_ang_;
64

65
  /// Azimuthal angles for each polar level.
66
  ///
67
  /// The number of azimuthal angles decreases as the polar angle moves away from the equator,
68
  /// in contrast to product quadratures which have a fixed count at every level.
69
  std::vector<std::vector<double>> azimuthal_per_polar_;
70

71
  /// Linear indices of ordered directions mapped to polar level.
72
  std::map<unsigned int, std::vector<unsigned int>> map_directions_;
73

74
  /// Number of polar angles specified for this triangular quadrature.
75
  unsigned int n_polar_ = 0;
76

77
  /// Maximum number of azimuthal angles specified for this triangular quadrature.
78
  unsigned int n_azimuthal_ = 0;
79
};
80

81
/// Triangular GLC quadrature for 3D XYZ geometry.
82
///
83
/// Similar to GLCProductQuadrature3DXYZ, but with fewer azimuthal angles as the polar angle moves
84
/// away from the equatorial plane. The maximum number of azimuthal angles (at the equator) is
85
/// computed automatically as 2 * Npolar.
86
class GLCTriangularQuadrature3DXYZ : public TriangularQuadrature
87
{
88
public:
89
  /// Construct a 3D XYZ triangular Gauss-Legendre-Chebyshev quadrature.
90
  ///
91
  /// For each polar angle away from the equator there is 1 fewer azimuthal angle per octant.
92
  /// \param Npolar Number of polar angles.
93
  /// \param scattering_order Scattering order for moment calculations.
94
  /// \param verbose Enable verbose output.
95
  /// \param method Harmonic operator construction method used to build the moment operators.
96
  explicit GLCTriangularQuadrature3DXYZ(
97
    unsigned int Npolar,
98
    unsigned int scattering_order,
99
    bool verbose = false,
100
    OperatorConstructionMethod method = OperatorConstructionMethod::STANDARD);
101

UNCOV
102
  std::string GetName() const override { return "3D XYZ Triangular"; }
×
103

104
private:
105
  /// Assemble quadrature points and weights for the varying azimuthal angles per polar level.
106
  void AssembleTriangularCosines(const std::vector<std::vector<double>>& azimuthal_per_polar,
107
                                 const std::vector<double>& polar,
108
                                 const std::vector<std::vector<double>>& wts_per_polar,
109
                                 bool verbose);
110
};
111

112
/// Triangular GLC quadrature for 2D XY geometry.
113
///
114
/// Similar to GLCProductQuadrature2DXY, but with fewer azimuthal angles as the polar angle moves
115
/// away from the equatorial plane. Only upper hemisphere points (z >= 0) are included. The maximum
116
/// number of azimuthal angles is computed automatically as 2 * Npolar.
117
class GLCTriangularQuadrature2DXY : public TriangularQuadrature
118
{
119
public:
120
  /// Construct a 2D XY triangular Gauss-Legendre-Chebyshev quadrature.
121
  ///
122
  /// For each polar angle away from the equator there is 1 fewer azimuthal angle per octant.
123
  /// \param Npolar Number of polar angles.
124
  /// \param scattering_order Scattering order for moment calculations.
125
  /// \param verbose Enable verbose output.
126
  /// \param method Harmonic operator construction method used to build the moment operators.
127
  explicit GLCTriangularQuadrature2DXY(
128
    unsigned int Npolar,
129
    unsigned int scattering_order,
130
    bool verbose = false,
131
    OperatorConstructionMethod method = OperatorConstructionMethod::STANDARD);
132

UNCOV
133
  std::string GetName() const override { return "2D XY Triangular"; }
×
UNCOV
134

×
UNCOV
135
private:
×
UNCOV
136
  /// Assemble quadrature points and weights for the varying azimuthal angles per polar level.
×
137
  void AssembleTriangularCosines(const std::vector<std::vector<double>>& azimuthal_per_polar,
1✔
138
                                 const std::vector<double>& polar,
1✔
139
                                 const std::vector<std::vector<double>>& wts_per_polar,
140
                                 bool verbose);
141
};
142

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