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

NREL / SolTrace / 20379221079

19 Dec 2025 06:37PM UTC coverage: 87.815% (-1.9%) from 89.725%
20379221079

push

github

jmaack24
Fix CI failures

0 of 2 new or added lines in 1 file covered. (0.0%)

183 existing lines in 5 files now uncovered.

6104 of 6951 relevant lines covered (87.81%)

7339992.74 hits per line

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

91.3
/coretrace/simulation_data/surface.hpp
1
/**
2
 * @file surface.hpp
3
 * @brief Optical surface geometry definitions
4
 *
5
 * Defines various optical surface types (flat, parabolic, spherical, etc.)
6
 * and their mathematical representations for ray-surface intersection
7
 * calculations. Provides the foundation for ray tracing on different
8
 * geometric surface types used in concentrated solar power systems.
9
 *
10
 * @defgroup surfaces Optical Surfaces
11
 * @{
12
 */
13

14
#ifndef SOLTRACE_SURFACE_H
15
#define SOLTRACE_SURFACE_H
16

17
#include <memory>
18
#include <vector>
19
#include <nlohmann/json.hpp>
20

21
namespace SolTrace::Data {
22

23
enum SurfaceType
24
{
25
    CONE,
26
    CYLINDER,
27
    FLAT,
28
    PARABOLA,
29
    SPHERE,
30

31
    HYPER,
32
    GENERAL_SPENCER_MURTY,
33
    TORUS,
34

35
    SURFACE_UNKNOWN
36
};
37

38
inline const std::map<SurfaceType, std::string> SurfaceTypeMap =
39
{
40
    {SurfaceType::CONE, "CONE"},
41
    {SurfaceType::CYLINDER, "CYLINDER"},
42
    {SurfaceType::FLAT, "FLAT"},
43
    {SurfaceType::PARABOLA, "PARABOLA"},
44
    {SurfaceType::SPHERE, "SPHERE"},
45
    {SurfaceType::HYPER, "HYPER"},
46
    {SurfaceType::GENERAL_SPENCER_MURTY, "GENERAL_SPENCER_MURTY"},
47
    {SurfaceType::TORUS, "TORUS"},
48
    {SurfaceType::SURFACE_UNKNOWN, "SURFACE_UNKNOWN"}
49
};
50

51
struct Surface
52
{
53
public:
54
    SurfaceType my_type;
55

56
    Surface(SurfaceType st) : my_type(st) {}
6,310✔
57
    virtual ~Surface() {}
11,536✔
58

59
    SurfaceType get_type() { return my_type; }
19,020✔
60

61
    virtual void write_json(nlohmann::ordered_json& jnode) const = 0;
62

UNCOV
63
    virtual double z(double x, double y) const { return 0; }
×
64

65
    inline std::string get_type_string() const {
66
        switch (my_type) {
67
        case CONE: return "Cone";
68
        case CYLINDER: return "Cylinder";
69
        case FLAT: return "Flat";
70
        case PARABOLA: return "Parabola";
71
        case SPHERE: return "Sphere";
72
        case HYPER: return "Hyper";
73
        case GENERAL_SPENCER_MURTY: return "General Spencer Murty";
74
        case TORUS: return "Torus";
75
        case SURFACE_UNKNOWN: return "Unknown";
76
        }
77
        return "Unknown";
78
    }
79
};
80

81
struct Cone : public Surface
82
{
83
    // z(x,y) = sqrt(x^2 + y^2) / tan(theta)
84
    // where theta = half_angle
85
    double half_angle;
UNCOV
86
    Cone(double ha) : Surface(SurfaceType::CONE), half_angle(ha) {}
×
87
    Cone(const nlohmann::ordered_json& jnode);
88
    virtual ~Cone() {}
7✔
89
    virtual void write_json(nlohmann::ordered_json& jnode) const override;
90

91
    virtual double z(double x, double y) const override;
92
};
93

94
struct Cylinder : public Surface
95
{
96
    // x^2 + (z - r)^2 = r^2
97
    // where r = radius
98
    double radius;
99
    Cylinder(double r) : Surface(SurfaceType::CYLINDER), radius(r)
43✔
100
    {
101
    }
43✔
102
    Cylinder(const nlohmann::ordered_json& jnode);
103
    virtual ~Cylinder() {}
69✔
104
    virtual void write_json(nlohmann::ordered_json& jnode) const override;
105

106
    virtual double z(double x, double y) const override;
107
};
108

109
struct Flat : public Surface
110
{
111
    Flat() : Surface(SurfaceType::FLAT) {}
2✔
112
    Flat(const nlohmann::ordered_json& jnode) : Surface(SurfaceType::FLAT) {};
6✔
113
    virtual ~Flat() {}
183✔
114
    virtual void write_json(nlohmann::ordered_json& jnode) const override;
115
};
116

117
struct Parabola : public Surface
118
{
119
    // z(x,y) = (cx * x^2 + cy * y^2) / 2
120
    // TODO: Assuming that vertex_x_curv gives cx and
121
    // that vertex_y_curv gives cy
122
    double focal_length_x;
123
    double focal_length_y;
124

125
    Parabola(double focal_x, double focal_y) : Surface(SurfaceType::PARABOLA),
6,478✔
126
                                               focal_length_x(focal_x),
6,478✔
127
                                               focal_length_y(focal_y)
6,478✔
128
    {
129
    }
6,478✔
130
    Parabola(const nlohmann::ordered_json& jnode);
131
    virtual ~Parabola() {}
23,807✔
132
    virtual void write_json(nlohmann::ordered_json& jnode) const override;
133

134
    virtual double z(double x, double y) const override;
135
};
136

137
struct Sphere : public Surface
138
{
139
    // z(x,y) = c(x^2 + y^2) / [1 + sqrt(1 - c^2{x^2 + y^2})]
140
    // where c = 1/R.
141
    // TODO: This form seems to be unnecessarily complicated.
142
    // Could easily just use one of the equations
143
    // z(x,y) = (1 - sqrt(1 - c^2 (x^2 + y^2))) / c
144
    //        = R - sqrt(R^2 - (x^2 + y^2))
145
    // Need to check on this.
146
    double vertex_curv;
147

148
    Sphere(double curv) : Surface(SurfaceType::SPHERE),
25✔
149
                          vertex_curv(curv)
25✔
150
    {
151
    }
25✔
152
    Sphere(const nlohmann::ordered_json& jnode);
153
    virtual ~Sphere() {}
148✔
154
    virtual void write_json(nlohmann::ordered_json& jnode) const override;
155

156
    virtual double z(double x, double y) const override;
157
};
158

159
// TODO: Add other surface types. Documentation has the following:
160
// 1. Hyperboloid/Ellipsoid
161
// 2. Zernike Series
162
// 3. VSHOT data
163
// 4. Finite Element data
164
// 5. General Spencer & Murty Equation
165
// 6. Polynomial Series (rotationally symmetric)
166
// 7. Cubic Spline Interpolation (rotationally symmetric)
167

168
using surface_ptr = std::shared_ptr<Surface>;
169

170
template <typename S, typename... Args>
171
inline auto make_surface(Args &&...args)
23,972✔
172
{
173
    return std::make_shared<S>(std::forward<Args>(args)...);
23,972✔
174
}
175

176
surface_ptr make_surface_from_type(SurfaceType type,
177
                                   const std::vector<double> &args);
178

179
surface_ptr make_surface_from_json(const nlohmann::ordered_json& jnode);
180

181
} // namespace SolTrace::Data
182

183
/**
184
 * @}
185
 */
186

187
#endif
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