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

NREL / SolTrace / 18544749821

15 Oct 2025 10:47PM UTC coverage: 89.946% (+45.8%) from 44.166%
18544749821

push

github

web-flow
Restructured backend for SolTrace (#63)

* Initial API for refactored SolTrace

* Updates to various APIs; first pass at element/ray source container implementation

* Use existing matrix-vector code as backend for matrix and vector classes; start implementing APIs

* Created new test on power tower example file with 50000 rays. Changed CMake to use cpp 17.

* Added ground results csv to new folder in google-tests directory

* Removed register prefix from variables in mtrand.h. More errors to come.

* Removed lines in CMakeLists causing linux failure, fixed bug in power tower test

* Created parabola.stinput test and a test using powertower optimization on the powertower sample

* Commented out parabola test for now, added nonexistent branch to CI to see how it runs

* Fixed syntax error

* Changed tests based on PR feedback

* Fixed error in CMakeLists that caused failure on windows

* Removed output messages from st_sim_run_test

* Fixed silly mistake in previous commit

* Added comments and removed unused libraries

* Changed naming conventions of tests

* Added high flux solar furnace test changes, changed parabola test file name

* Fixed typo

* Move refactored data to its own directory; add to refactored classes to build

* Add missed files

* Add unit tests for basic linear algebra and container template

* More tests; Start implementation of composite element

* Add more unit tests on element

* Add missed headers

* Remove target from cmake build command in CI

* Initial virtual element implementation; smoke test for virtual element

* Correct aperture spelling; add tests for virtual elements

* Add some unit tests for simulation data

* Move to static library for simulation data (temporary); update cmake files to get correct mac architecture

* Attempt to fix coverage failure

* Attempt to capture inline functions in code coverage; add a few more explicit tests

* Fix build

* Separate storage of CompositeElement and SingleElement; update te... (continued)

4357 of 4844 new or added lines in 62 files covered. (89.95%)

4357 of 4844 relevant lines covered (89.95%)

8565975.82 hits per line

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

51.16
/coretrace/simulation_runner/native_runner/generate_ray.cpp
1

2
#include "generate_ray.hpp"
3

4
#include "simulation_data_export.hpp"
5

6
namespace SolTrace::NativeRunner {
7

8
void GenerateRay(
7,618,987✔
9
        MTRand &myrng,
10
        double PosSunStage[3],
11
        double Origin[3],
12
        double RLocToRef[3][3],
13
        TSun *Sun,
14
        double PosRayGlobal[3],
15
        double CosRayGlobal[3],
16
        double PosRaySun[3])
17
{
18
        /*{This procedure generates a randomly located ray in the x-y plane of the sun coordinate system in
19
         the z direction of the sun coord. system, checks to see that the ray is within the region of interest
20
         defined by the spatial extent of the elements of Stage as seen from the sun
21
         and ultimately transforms that ray to the global coord. system.   The z-axis of the sun coord. system points
22
         towards the Stage coord. system origin.
23

24
         Input
25
                   - Seed = Seed for random number generator
26
                   - Sun = Sun data record of type TSun
27
                   - Origin = Primary Stage origin
28
                   - RLocToRef = transformation matrix from local to reference frame
29
         Output
30
                   - PosRayGlobal = Position of ray in Global coordinate system
31
                   - CosRayGlobal = Direction cosines of ray in Global coordinate system} */
32

33
        double XRaySun = 0.0, YRaySun = 0.0, ZRaySun = 0.0;
7,618,987✔
34
        double CosRaySun[3] = {0.0, 0.0, 0.0};
7,618,987✔
35
        double PosRayStage[3] = {0.0, 0.0, 0.0};
7,618,987✔
36
        double CosRayStage[3] = {0.0, 0.0, 0.0};
7,618,987✔
37
        int NegPosSign = 0;
7,618,987✔
38
        PosRaySun[0] = 0.;
7,618,987✔
39
        PosRaySun[1] = 0.;
7,618,987✔
40
        PosRaySun[2] = 0.;
7,618,987✔
41

42
        // ZRaySun := 0.0;  //Origin of rays in xy plane of sun coord system.
43
        ZRaySun = -10000.0; // changed 5/1/00.  rays originate from well bebind the sun coordinate system xy
7,618,987✔
44
                                                //  plane which has been translated to primary stage origin.         This value has been reduced signficantly because of numerical issues in tracing rays from sun
45
                                                //  to the closer form solution for a cylinder.  It used to 1e6 and has been reduced to 1e4, which should still be sufficient.   10-26-09 Wendelin
46

47
        //{Generate random rays inside of region of interest or from point source}
48

49
        if (Sun->PointSource) // fixed this on 3-18-13
7,618,987✔
50
        {
NEW
51
                PosRayGlobal[0] = Sun->Origin[0];
×
NEW
52
                PosRayGlobal[1] = Sun->Origin[1];
×
NEW
53
                PosRayGlobal[2] = Sun->Origin[2];
×
54

NEW
55
                if (myrng() <= 0.5)
×
NEW
56
                        NegPosSign = -1;
×
57
                else
NEW
58
                        NegPosSign = 1;
×
59

NEW
60
                CosRayGlobal[0] = NegPosSign * myrng(); // random direction for x part of ray vector
×
61

NEW
62
                if (myrng() <= 0.5)
×
NEW
63
                        NegPosSign = -1;
×
64
                else
NEW
65
                        NegPosSign = 1;
×
66

NEW
67
                CosRayGlobal[1] = NegPosSign * myrng(); // random direction for y part of ray vector
×
68

NEW
69
                if (myrng() <= 0.5)
×
NEW
70
                        NegPosSign = -1;
×
71
                else
NEW
72
                        NegPosSign = 1;
×
73

NEW
74
                CosRayGlobal[2] = NegPosSign * myrng(); // random direction for z part of ray vector
×
75

NEW
76
                double CosRayGMag = sqrt(CosRayGlobal[0] * CosRayGlobal[0] +
×
NEW
77
                                                                 CosRayGlobal[1] * CosRayGlobal[1] +
×
NEW
78
                                                                 CosRayGlobal[2] * CosRayGlobal[2]);
×
79

NEW
80
                CosRayGlobal[0] = CosRayGlobal[0] / CosRayGMag; // obtain unit vector by dividing by magnitude
×
NEW
81
                CosRayGlobal[1] = CosRayGlobal[1] / CosRayGMag;
×
NEW
82
                CosRayGlobal[2] = CosRayGlobal[2] / CosRayGMag;
×
83
        }
84
        else
85
        {
86
                // following changed on 09/26/05 to more efficiently generate rays relative to element center of mass in primary stage
87
                /*{XRaySun := 2.0*MaxRad*ran3(Seed) - MaxRad;  //ran3 produces results independent of platform.
88
                YRaySun := 2.0*MaxRad*ran3(Seed) - MaxRad;
89
                if (XRaySun*XRaySun + YRaySun*YRaySun) > MaxRad*MaxRad then goto GENRAY;
90
                XRaySun := Xcm + XRaySun;  //adjust location of generated rays about element center of mass
91
                YRaySun := Ycm + YRaySun;}*/
92

93
                XRaySun = Sun->MinXSun + (Sun->MaxXSun - Sun->MinXSun) * myrng(); // uses a rectangular region of interest about the primary
7,618,987✔
94
                YRaySun = Sun->MinYSun + (Sun->MaxYSun - Sun->MinYSun) * myrng(); // stage. Added 09/26/05
7,618,987✔
95

96
                // std::cout << "MinXSun: " << Sun->MinXSun
97
                //                   << "\nMaxXSun: " << Sun->MaxXSun
98
                //                   << "\nMinYSun: " << Sun->MinYSun
99
                //                   << "\nMaxYSun: " << Sun->MaxYSun
100
                //                   << "\nXRaySun: " << XRaySun
101
                //                   << "\nYRaySun:" << YRaySun
102
                //                   << "\nR1: " << (XRaySun - Sun->MinXSun) / (Sun->MaxXSun - Sun->MinXSun)
103
                //                   << "\nR2: " << (YRaySun - Sun->MinYSun) / (Sun->MaxYSun - Sun->MinXSun)
104
                //                   << std::endl;
105

106
                //{Offload ray location and direction cosines into sun array}
107
                PosRaySun[0] = XRaySun;
7,618,987✔
108
                PosRaySun[1] = YRaySun;
7,618,987✔
109
                PosRaySun[2] = ZRaySun;
7,618,987✔
110
                CosRaySun[0] = 0.0;
7,618,987✔
111
                CosRaySun[1] = 0.0;
7,618,987✔
112
                CosRaySun[2] = 1.0;
7,618,987✔
113

114
                //{Transform ray locations and dir cosines into Stage system}
115
                TransformToReference(PosRaySun, CosRaySun, PosSunStage, Sun->RLocToRef, PosRayStage, CosRayStage);
7,618,987✔
116

117
                //{Transform ray locations and dir cosines into global system}
118
                TransformToReference(PosRayStage, CosRayStage, Origin, RLocToRef, PosRayGlobal, CosRayGlobal);
7,618,987✔
119
        }
120

121
        return;
15,237,974✔
122
}
123

124
} // namespace SolTrace::NativeRunner
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