Skip to content

Add spherical surface support to GPU (OptiX) runner for High Flux Solar Furnace - #169

Merged
qualand merged 12 commits into
developfrom
copilot/support-high-flux-solar-furnace
Aug 11, 2026
Merged

Add spherical surface support to GPU (OptiX) runner for High Flux Solar Furnace#169
qualand merged 12 commits into
developfrom
copilot/support-high-flux-solar-furnace

Conversation

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

The GPU (OptiX) runner crashed on the High Flux Solar Furnace example file because the OptixCSP pipeline had no SPHERICAL surface type — only FLAT, PARABOLIC, MESH, and CYLINDER. The HFSF file uses spherical surfaces (s) with hexagonal apertures (h).

GPU pipeline additions

  • soltrace_type.h — Added SPHERICAL to SurfaceType enum
  • Surface.h — Added SurfaceSpherical class holding vertex curvature c = 1/R
  • GeometryDataST.h — Added 6 GPU geometry structs (Rectangle_Spherical, Circle_Spherical, Hexagon_Spherical, Annulus_Spherical, Triangle_Spherical, Quadrilateral_Spherical) with corresponding Type enum entries (15–20), setters, and union members
  • Soltrace.h — Added 6 *_SPHERICAL entries to OpticalEntityType (SBT offsets 13–18); NUM_OPTICAL_ENTITY_TYPES is now 19
  • intersection.cu — Added spherical_solve() and spherical_world_normal() device helpers plus 6 __intersection__*_spherical kernels:
// Sphere x²+y²+(z-R)²=R² with R=1/c, substituting P=O+t*D:
// A·t² + B·t + C = 0
//   A = dx²+dy²+dz²
//   B = 2·(ox·dx + oy·dy + (oz−R)·dz)
//   C = ox²+oy² + oz·(oz−2R)
// Normal at hit (lx, ly): N = normalize(−c·lx, −c·ly, √(1−c²·(lx²+ly²)))
  • geometry_manager.cppSPHERICAL branch added for all 6 aperture SBT offset assignments
  • CspElement.cppSPHERICAL geometry data conversion for all 6 aperture types
  • pipeline_manager.cpp — 6 new IntersectionKernelMap entries for spherical shader names
  • optix_runner.cppcase SurfaceType::SPHERE: maps SolTrace::Data::SphereOptixCSP::SurfaceSpherical

Tests

Added high_flux_solar_furnace_test.cpp with two tests:

  • OptixRunnerCanRun — loads HFSF, runs GPU trace, asserts non-zero ray interactions
  • OptixRunnerResultsConsistentWithNativeRunner — compares GPU vs. native total hit count within 10% relative tolerance (10 000 rays, fixed seed, no stochastic errors)

Copilot AI added 2 commits July 30, 2026 16:30
- 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
Copilot AI changed the title [WIP] Add GPU runner support for High Flux Solar Furnace Add spherical surface support to GPU (OptiX) runner for High Flux Solar Furnace Jul 30, 2026
Copilot AI requested a review from qualand July 30, 2026 16:36
const float eps = 1e-12f;
int count = 0;

if (fabsf(c) < eps)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably rename parabolic_ray_to_local since it is being used in a spherical function.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread google-tests/unit-tests/simulation_data/aperture_test.cpp Outdated
Comment thread coretrace/simulation_runner/optix_runner/optix_runner.cpp
@jmaack24
jmaack24 marked this pull request as ready for review August 4, 2026 19:42
@jmaack24
jmaack24 self-requested a review August 4, 2026 19:42

@jmaack24 jmaack24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My concerns were addressed

@jmaack24

jmaack24 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Summary of changes I made after Copilot changes

PR Summary

This 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 Change

The 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 Changed

Features

  • Added spherical surface support in the OptiX runner pipeline.
  • Extended geometry/surface data plumbing from simulation data into OptiX-side structures.
  • Updated shader intersection logic to correctly handle spherical cases.

Validation and Robustness

  • Added validation for required surface and aperture fields.
  • Removed unused shader variables and made cleanup/refactor adjustments related to spherical/rectangular intersection paths.
  • Final naming cleanup for parabola local-ray transform helper.

Tests

  • Added basic spherical intersection tests for the OptiX runner.
  • Added High Flux Solar Furnace OptiX-focused tests in:
    • google-tests/unit-tests/simulation_runner/optix_runner/high_flux_solar_furnace_test.cpp
  • Refactored shared intersection test code and updated tolerance strategy (including relative-error checks), settling on 10% tolerance where appropriate.
  • Added/updated simulation-data tests for surface/aperture behavior.

Scope of Files

Primary implementation areas:

  • coretrace/simulation_runner/optix_runner/OptixCSP/src/shaders/intersection.cu
  • coretrace/simulation_runner/optix_runner/OptixCSP/src/shaders/GeometryDataST.h
  • coretrace/simulation_runner/optix_runner/OptixCSP/src/core/CspElement.cpp
  • coretrace/simulation_data/surface.cpp
  • coretrace/simulation_data/aperture.cpp

Primary test areas:

  • google-tests/unit-tests/simulation_runner/optix_runner/geometry_intersection_test.cpp
  • google-tests/unit-tests/simulation_runner/optix_runner/high_flux_solar_furnace_test.cpp
  • google-tests/unit-tests/simulation_data/surface_test.cpp
  • google-tests/unit-tests/simulation_data/aperture_test.cpp

Change Size

  • 21 files changed
  • 1475 insertions
  • 1009 deletions

Reviewer Notes

  • Most of the complexity/risk is in GPU-side intersection math and data layout compatibility between host/device structures.
  • Test tolerance changes were iterated to reduce brittleness while preserving meaningful signal for regression detection.
  • Branch is clean and synchronized with remote at the time of summary generation.

@taylorbrown75 taylorbrown75 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Solar furnace example works on gpu.

@qualand
qualand merged commit 3ee681c into develop Aug 11, 2026
12 checks passed
@qualand
qualand deleted the copilot/support-high-flux-solar-furnace branch August 11, 2026 16:46
nickmedwards pushed a commit to nickmedwards/SolTrace that referenced this pull request Aug 12, 2026
…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>
nickmedwards pushed a commit to nickmedwards/SolTrace that referenced this pull request Aug 12, 2026
…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>
nickmedwards pushed a commit to nickmedwards/SolTrace that referenced this pull request Aug 13, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High Flux Solar Furnace not supported by GPU runner

5 participants