Add spherical surface support to GPU (OptiX) runner for High Flux Solar Furnace - #169
Conversation
- Add SPHERICAL surface type to OptixCSP SurfaceType enum - Add SurfaceSpherical class to OptixCSP Surface.h - Add spherical geometry data structs to GeometryDataST.h for all 6 aperture types - Add HEXAGON_SPHERICAL and other spherical variants to OpticalEntityType enum - Add spherical ray-intersection helpers and kernels to intersection.cu - Update geometry_manager.cpp to handle SPHERICAL surface type - Update CspElement.cpp to convert spherical elements to GPU geometry data - Update pipeline_manager.cpp to register new spherical intersection programs - Map SurfaceType::SPHERE to OptixCSP::SPHERICAL in optix_runner.cpp - Add GPU regression test for High Flux Solar Furnace file
| const float eps = 1e-12f; | ||
| int count = 0; | ||
|
|
||
| if (fabsf(c) < eps) |
There was a problem hiding this comment.
This is a pathological case that should get handled in SimulationData rather than accounted for here.
| const float ta = (-B - sq) * inv2A; | ||
| const float tb = (-B + sq) * inv2A; | ||
|
|
||
| if (ta >= ray_tmin && ta <= ray_tmax) |
There was a problem hiding this comment.
This doesn't filter out hits that are on the top half of the sphere as is done traditionally in SolTrace
|
|
||
| float3 n; | ||
| float ox, oy, oz, dx, dy, dz; | ||
| parabolic_ray_to_local(ray_orig, ray_dir, |
There was a problem hiding this comment.
We should probably rename parabolic_ray_to_local since it is being used in a spherical function.
There was a problem hiding this comment.
Pull request overview
This PR extends the OptiX (GPU) simulation pipeline to support SolTrace spherical (s) surfaces (including spherical variants of the supported aperture types), fixing crashes when running the High Flux Solar Furnace example, and adds/updates unit tests plus input validation in the simulation data model.
Changes:
- Added a SPHERICAL surface type to the OptiX pipeline, including GPU geometry payloads and OptiX intersection programs for spherical apertures.
- Wired spherical surface conversion/mapping through OptiX runner setup, geometry/SBT management, and pipeline kernel registration.
- Added a High Flux Solar Furnace regression test and refactored/expanded OptiX geometry intersection tests; added validation for surface/aperture constructors with accompanying tests.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| google-tests/unit-tests/simulation_runner/optix_runner/high_flux_solar_furnace_test.cpp | New regression tests exercising spherical+hexagon geometry via the GPU runner. |
| google-tests/unit-tests/simulation_runner/optix_runner/geometry_intersection_test.cpp | Refactors common intersection assertions and adds spherical intersection coverage. |
| google-tests/unit-tests/simulation_runner/optix_runner/CMakeLists.txt | Registers the new HFSF unit test in the OptiX test target. |
| google-tests/unit-tests/simulation_runner/native_runner/sphere_calculator_test.cpp | Adjusts tests to set invalid parameters post-construction for constructor validation changes. |
| google-tests/unit-tests/simulation_runner/native_runner/parabola_calculator_test.cpp | Same as above for parabola calculator coverage. |
| google-tests/unit-tests/simulation_runner/native_runner/cylinder_calculator_test.cpp | Same as above for cylinder calculator and rectangle dimension validation. |
| google-tests/unit-tests/simulation_data/surface_test.cpp | Adds validation-focused unit tests for multiple surface types. |
| google-tests/unit-tests/simulation_data/aperture_test.cpp | Adds validation-focused unit tests for multiple aperture types. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/shaders/Soltrace.h | Extends OptiX SBT optical entity type enum with spherical variants. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/shaders/intersection.cu | Implements spherical intersection helper math and 6 spherical intersection programs. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/shaders/GeometryDataST.h | Adds spherical geometry payload structs, enum entries, setters/getters, and union members. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/core/Surface.h | Adds SurfaceSpherical to represent spherical curvature in OptixCSP. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/core/soltrace_type.h | Adds SPHERICAL to OptixCSP SurfaceType. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/core/pipeline_manager.cpp | Registers spherical intersection program names in the kernel map. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/core/geometry_manager.cpp | Assigns spherical SBT offsets for each aperture type during geometry collection. |
| coretrace/simulation_runner/optix_runner/OptixCSP/src/core/CspElement.cpp | Converts spherical elements into the new spherical GPU geometry payloads. |
| coretrace/simulation_runner/optix_runner/optix_runner.cpp | Maps SolTrace Sphere surfaces to OptixCSP SurfaceSpherical during setup. |
| coretrace/simulation_data/surface.hpp | Adds a virtual validate() hook and calls it from surface constructors. |
| coretrace/simulation_data/surface.cpp | Implements surface validation logic for cone/cylinder/parabola/sphere. |
| coretrace/simulation_data/aperture.hpp | Adds a virtual validate() hook and calls it from aperture constructors. |
| coretrace/simulation_data/aperture.cpp | Implements aperture validation logic for multiple aperture types. |
Suppressed comments (2)
google-tests/unit-tests/simulation_runner/optix_runner/high_flux_solar_furnace_test.cpp:123
- Hit counting in the native-vs-OptiX consistency check ignores TRANSMIT events, which can make the ratio comparison fail even when both runners behave consistently for transmissive optics.
RayEvent rev = rec->get_event(j);
if (rev == RayEvent::ABSORB || rev == RayEvent::REFLECT)
++native_total_hits;
}
google-tests/unit-tests/simulation_runner/optix_runner/high_flux_solar_furnace_test.cpp:161
- Hit counting for the OptiX run ignores TRANSMIT events, which can make the GPU-vs-native comparison fail for transmissive optics.
RayEvent rev = rec->get_event(j);
if (rev == RayEvent::ABSORB || rev == RayEvent::REFLECT)
++optix_total_hits;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jmaack24
left a comment
There was a problem hiding this comment.
My concerns were addressed
|
Summary of changes I made after Copilot changes PR SummaryThis PR adds spherical-surface support for the GPU OptiX runner used by the High Flux Solar Furnace workflow, hardens surface/aperture validation, and expands tests around geometry intersection behavior. Why This ChangeThe OptiX path needed end-to-end handling for spherical surfaces and improved guardrails for invalid geometry metadata. This branch also improves test coverage and stabilizes tolerance behavior for intersection-related assertions. What ChangedFeatures
Validation and Robustness
Tests
Scope of FilesPrimary implementation areas:
Primary test areas:
Change Size
Reviewer Notes
|
taylorbrown75
left a comment
There was a problem hiding this comment.
Looks good. Solar furnace example works on gpu.
…ar Furnace (NLR-SolTrace#169) * Initial plan * Add spherical surface support to GPU (OptiX) runner for HFSF file - Add SPHERICAL surface type to OptixCSP SurfaceType enum - Add SurfaceSpherical class to OptixCSP Surface.h - Add spherical geometry data structs to GeometryDataST.h for all 6 aperture types - Add HEXAGON_SPHERICAL and other spherical variants to OpticalEntityType enum - Add spherical ray-intersection helpers and kernels to intersection.cu - Update geometry_manager.cpp to handle SPHERICAL surface type - Update CspElement.cpp to convert spherical elements to GPU geometry data - Update pipeline_manager.cpp to register new spherical intersection programs - Map SurfaceType::SPHERE to OptixCSP::SPHERICAL in optix_runner.cpp - Add GPU regression test for High Flux Solar Furnace file * Remove unused variables in rectangle_spherical intersection shader * Add validation of surface and aperture data fields * Changes to OptixRunner sphere implementation * Add basic spherical intersection tests for optix runner; refactor tests to use common code * Test fixes * Fix test and tighten tolerance; address copilot comments * Relax test tolerance * Move test to relative error test * Return to 10 percent tolerance * Rename parabola_ray_to_local function --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Jonathan Maack <jonathan.maack@nrel.gov>
…ar Furnace (NLR-SolTrace#169) * Initial plan * Add spherical surface support to GPU (OptiX) runner for HFSF file - Add SPHERICAL surface type to OptixCSP SurfaceType enum - Add SurfaceSpherical class to OptixCSP Surface.h - Add spherical geometry data structs to GeometryDataST.h for all 6 aperture types - Add HEXAGON_SPHERICAL and other spherical variants to OpticalEntityType enum - Add spherical ray-intersection helpers and kernels to intersection.cu - Update geometry_manager.cpp to handle SPHERICAL surface type - Update CspElement.cpp to convert spherical elements to GPU geometry data - Update pipeline_manager.cpp to register new spherical intersection programs - Map SurfaceType::SPHERE to OptixCSP::SPHERICAL in optix_runner.cpp - Add GPU regression test for High Flux Solar Furnace file * Remove unused variables in rectangle_spherical intersection shader * Add validation of surface and aperture data fields * Changes to OptixRunner sphere implementation * Add basic spherical intersection tests for optix runner; refactor tests to use common code * Test fixes * Fix test and tighten tolerance; address copilot comments * Relax test tolerance * Move test to relative error test * Return to 10 percent tolerance * Rename parabola_ray_to_local function --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Jonathan Maack <jonathan.maack@nrel.gov>
…ar Furnace (NLR-SolTrace#169) * Initial plan * Add spherical surface support to GPU (OptiX) runner for HFSF file - Add SPHERICAL surface type to OptixCSP SurfaceType enum - Add SurfaceSpherical class to OptixCSP Surface.h - Add spherical geometry data structs to GeometryDataST.h for all 6 aperture types - Add HEXAGON_SPHERICAL and other spherical variants to OpticalEntityType enum - Add spherical ray-intersection helpers and kernels to intersection.cu - Update geometry_manager.cpp to handle SPHERICAL surface type - Update CspElement.cpp to convert spherical elements to GPU geometry data - Update pipeline_manager.cpp to register new spherical intersection programs - Map SurfaceType::SPHERE to OptixCSP::SPHERICAL in optix_runner.cpp - Add GPU regression test for High Flux Solar Furnace file * Remove unused variables in rectangle_spherical intersection shader * Add validation of surface and aperture data fields * Changes to OptixRunner sphere implementation * Add basic spherical intersection tests for optix runner; refactor tests to use common code * Test fixes * Fix test and tighten tolerance; address copilot comments * Relax test tolerance * Move test to relative error test * Return to 10 percent tolerance * Rename parabola_ray_to_local function --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Jonathan Maack <jonathan.maack@nrel.gov>
The GPU (OptiX) runner crashed on the High Flux Solar Furnace example file because the OptixCSP pipeline had no
SPHERICALsurface type — onlyFLAT,PARABOLIC,MESH, andCYLINDER. The HFSF file uses spherical surfaces (s) with hexagonal apertures (h).GPU pipeline additions
soltrace_type.h— AddedSPHERICALtoSurfaceTypeenumSurface.h— AddedSurfaceSphericalclass holding vertex curvaturec = 1/RGeometryDataST.h— Added 6 GPU geometry structs (Rectangle_Spherical,Circle_Spherical,Hexagon_Spherical,Annulus_Spherical,Triangle_Spherical,Quadrilateral_Spherical) with correspondingTypeenum entries (15–20), setters, and union membersSoltrace.h— Added 6*_SPHERICALentries toOpticalEntityType(SBT offsets 13–18);NUM_OPTICAL_ENTITY_TYPESis now 19intersection.cu— Addedspherical_solve()andspherical_world_normal()device helpers plus 6__intersection__*_sphericalkernels:geometry_manager.cpp—SPHERICALbranch added for all 6 aperture SBT offset assignmentsCspElement.cpp—SPHERICALgeometry data conversion for all 6 aperture typespipeline_manager.cpp— 6 newIntersectionKernelMapentries for spherical shader namesoptix_runner.cpp—case SurfaceType::SPHERE:mapsSolTrace::Data::Sphere→OptixCSP::SurfaceSphericalTests
Added
high_flux_solar_furnace_test.cppwith two tests:OptixRunnerCanRun— loads HFSF, runs GPU trace, asserts non-zero ray interactionsOptixRunnerResultsConsistentWithNativeRunner— compares GPU vs. native total hit count within 10% relative tolerance (10 000 rays, fixed seed, no stochastic errors)