Skip to content
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
38bb800
First commit of port to GLM
nicholasbl Jan 22, 2026
52258c4
Passes tests, but is a bit slow
nicholasbl Jan 23, 2026
b665288
Merge remote-tracking branch 'origin/develop' into dev_updates
nicholasbl Jan 23, 2026
c49c566
Clean up from merge
nicholasbl Jan 23, 2026
41e3ac3
Fix more tests
nicholasbl Jan 24, 2026
d99f085
Performance and bugfix
nicholasbl Jan 24, 2026
2acc79f
Remove old vec files and patch optix
nicholasbl Jan 24, 2026
20ffa4e
Compile fixes for optix
nicholasbl Jan 24, 2026
599c005
More detail for gcc issues
nicholasbl Jan 24, 2026
5f46881
Uninitialized read in gcc
nicholasbl Jan 24, 2026
ef13831
Fix uninit and duration test
nicholasbl Jan 24, 2026
09db2d4
Bump test timing. Another uninit.
nicholasbl Jan 25, 2026
10911e0
Merge remote-tracking branch 'origin/develop' into dev_updates
nicholasbl Feb 8, 2026
6da668a
Update gitignore
nicholasbl Feb 8, 2026
c8dbb15
Multiple fixes to compile and execute
nicholasbl Feb 8, 2026
0edfd62
Fix the helio tests to only run if embree is enabled
nicholasbl Feb 8, 2026
02bb568
Improve embree test
nicholasbl Feb 8, 2026
7cfbb2b
Header fixes GCC
nicholasbl Feb 8, 2026
2bedb97
Timing for coverage
nicholasbl Feb 8, 2026
68cdd49
Wider bands for CI
nicholasbl Feb 8, 2026
fcf8b59
Trying a fix for a weird coverage error
nicholasbl Feb 8, 2026
4ebee8d
Trying one more coverage fix
nicholasbl Feb 9, 2026
ecf2a3f
Another tweak. If this fails, we move to ignore negatives
nicholasbl Feb 9, 2026
10f0cfa
Ignore negatives for the moment
nicholasbl Feb 9, 2026
6ec5c5a
Address review comments
nicholasbl Feb 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
build_type: [Release, Debug]
build_type: [Release, RelWithDebInfo]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: |
# Capture coverage info; ignore mismatches to prevent geninfo line errors
lcov --capture --directory . --output-file coverage.info --ignore-errors unused
lcov --capture --directory . --output-file coverage.info --ignore-errors unused,negative --rc geninfo_unexecuted_blocks=1
# Remove unwanted directories (3rd-party, deps)
lcov --remove coverage.info '*/_deps/*' '*/nlohmann_json-src/*' '/usr/*' --output-file coverage.info --ignore-errors unused

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,7 @@ build*
google-tests/*.stinput
google-tests/*.mon
google-tests/*.csv

**/*.DS_Store
**/strace
**/straced
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.19)

Project(soltrace_ui VERSION 1.0.0)

include(cmake/CPM.cmake)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

Expand Down
24 changes: 24 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.42.1)
set(CPM_HASH_SUM "f3a6dcc6a04ce9e7f51a127307fa4f699fb2bade357a8eb4c5b45df76e1dc6a5")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
2 changes: 1 addition & 1 deletion coretrace/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ else(MSVC)
add_compile_definitions(_DEBUG)
if (NOT APPLE AND ENABLE_COVERAGE)
# SET(CMAKE_CXX_FLAGS "-O0 -coverage -fkeep-inline-functions")
SET(CMAKE_CXX_FLAGS "-O0 --coverage")
SET(CMAKE_CXX_FLAGS "-O0 --coverage -fprofile-update=atomic")
endif()
else()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG" )
Expand Down
33 changes: 21 additions & 12 deletions coretrace/simulation_data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ include_directories(.)
include_directories(cst_templates)
include_directories(solar_position_calculators)

include(FetchContent)
FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG v3.11.3
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(nlohmann_json)
CPMAddPackage(
GITHUB_REPOSITORY "nlohmann/json"
GIT_TAG "v3.11.3"
GIT_SHALLOW TRUE
OPTIONS "JSON_BuildTests OFF"
)

CPMAddPackage(
GITHUB_REPOSITORY "g-truc/glm"
GIT_TAG "1.0.3"
GIT_SHALLOW TRUE
OPTIONS
"GLM_ENABLE_CXX_17 ON"
)

set(SIMDATA_SRC
aperture.cpp
Expand All @@ -26,7 +32,6 @@ set(SIMDATA_SRC
sun.cpp
surface.cpp
utilities.cpp
vector3d.cpp
virtual_element.cpp
cst_templates/arclength.cpp
cst_templates/heliostat.cpp
Expand Down Expand Up @@ -60,8 +65,8 @@ set(SIMDATA_HDRS
stage_element.hpp
sun.hpp
surface.hpp
vector_utility.hpp
utilities.hpp
vector3d.hpp
virtual_element.hpp
cst_templates/arclength.hpp
cst_templates/heliostat.hpp
Expand Down Expand Up @@ -90,8 +95,12 @@ set_target_properties(simdata
PREFIX ""
)

# Link JSON (propagates its include directory)
target_link_libraries(simdata PUBLIC nlohmann_json::nlohmann_json)
# Link dependencies
target_link_libraries(simdata
PUBLIC
nlohmann_json::nlohmann_json
glm::glm
)

if (NOT APPLE AND ENABLE_COVERAGE)
# SET(CMAKE_CXX_FLAGS "-O0 -coverage -fkeep-inline-functions")
Expand Down
62 changes: 28 additions & 34 deletions coretrace/simulation_data/aperture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// #include <iostream>

#include "constants.hpp"
#include "vector_utility.hpp"

namespace SolTrace::Data
{
Expand Down Expand Up @@ -771,62 +772,56 @@ namespace SolTrace::Data

Rectangle::Rectangle(double xlen, double ylen)
: Aperture(ApertureType::RECTANGLE),
x_length(xlen),
y_length(ylen)
m_length(xlen, ylen)
{
// Default to rectangle centered at the origin.
this->x_coord = -0.5 * this->x_length;
this->y_coord = -0.5 * this->y_length;
return;
m_coord = -0.5 * m_length;
update_cached();
}

Rectangle::Rectangle(double xlen, double ylen, double xl, double yl)
: Aperture(ApertureType::RECTANGLE),
x_length(xlen),
y_length(ylen),
x_coord(xl),
y_coord(yl)
m_length(xlen, ylen),
m_coord(xl, yl)
{
update_cached();
}

Rectangle::Rectangle(const nlohmann::ordered_json &jnode)
: Aperture(ApertureType::RECTANGLE)
{
this->x_length = jnode.at("x_length");
this->y_length = jnode.at("y_length");
this->x_coord = jnode.at("x_coord");
this->y_coord = jnode.at("y_coord");
m_length.x = jnode.at("x_length");
m_length.y = jnode.at("y_length");
m_coord.x = jnode.at("x_coord");
m_coord.y = jnode.at("y_coord");
update_cached();
}

double Rectangle::aperture_area() const
{
return this->x_length * this->y_length;
return m_length.x * m_length.y;
}

double Rectangle::diameter_circumscribed_circle() const
{
return sqrt(x_length * x_length + y_length * y_length);
return glm::length(m_length);
}

void Rectangle::bounding_box(double &xmin,
double &xmax,
double &ymin,
double &ymax) const
{
xmin = this->x_coord;
xmax = this->x_coord + this->x_length;
ymin = this->y_coord;
ymax = this->y_coord + this->y_length;
return;
xmin = m_coord.x;
xmax = m_cached_range.x;
ymin = m_coord.y;
ymax = m_cached_range.y;
}

bool Rectangle::is_in(double x, double y) const
{
double xl = this->x_coord;
double yl = this->y_coord;
double xu = xl + this->x_length;
double yu = yl + this->y_length;
return (xl <= x && x <= xu && yl <= y && y <= yu);
return (m_coord.x <= x && x <= m_cached_range.x &&
m_coord.y <= y && y <= m_cached_range.y);
}

aperture_ptr Rectangle::make_copy() const
Expand All @@ -839,10 +834,10 @@ namespace SolTrace::Data
{
ApertureType type = ApertureType::RECTANGLE;
jnode["aperture_type"] = ApertureTypeMap.at(type);
jnode["x_length"] = this->x_length;
jnode["y_length"] = this->y_length;
jnode["x_coord"] = this->x_coord;
jnode["y_coord"] = this->y_coord;
jnode["x_length"] = m_length.x;
jnode["y_length"] = m_length.y;
jnode["x_coord"] = m_coord.x;
jnode["y_coord"] = m_coord.y;
}

std::tuple<std::vector<double>, std::vector<int>>
Expand All @@ -855,10 +850,9 @@ namespace SolTrace::Data
{
for (int j = 0; j <= segments; ++j)
{
const double x = i * x_length / segments + x_coord;
const double y = j * y_length / segments + y_coord;
verts.push_back(x);
verts.push_back(y);
auto p = glm::dvec2(i, j) * m_length / double(segments) + m_coord;
verts.push_back(p.x);
verts.push_back(p.y);
}
}
for (int i = 0; i < segments; ++i)
Expand All @@ -879,7 +873,7 @@ namespace SolTrace::Data
indices.push_back(d);
}
}
return make_pair(verts, indices);
return std::make_pair(verts, indices);
}

bool intri(double x1, double y1,
Expand Down
43 changes: 36 additions & 7 deletions coretrace/simulation_data/aperture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <cmath>
#include <memory>
#include <vector>

#include <glm/vec2.hpp>
#include <nlohmann/json.hpp>

#include "constants.hpp"
Expand Down Expand Up @@ -320,8 +322,6 @@ namespace SolTrace::Data
{
double diameter;

// Circle() : Aperture(CIRCLE), diameter(0.0) {}

/**
* @brief Constructor for circular aperture
* @param d Diameter of the circle
Expand Down Expand Up @@ -519,15 +519,18 @@ namespace SolTrace::Data
triangulation() const override;
};

struct Rectangle : public Aperture
class Rectangle : public Aperture
{
double x_length;
double y_length;
glm::dvec2 m_length;
// NOTE: The point (x_coord, y_coord) gives the location of the
// lower left hand corner of the rectangle in the xy-plane.
double x_coord;
double y_coord;
glm::dvec2 m_coord;

glm::dvec2 m_cached_range;

void update_cached() { m_cached_range = m_coord + m_length; }

public:
/**
* @brief Constructor for centered rectangular aperture
* @param xlen Length in x direction
Expand All @@ -552,6 +555,32 @@ namespace SolTrace::Data

virtual ~Rectangle() {}

double x_length() const { return m_length.x; }
double y_length() const { return m_length.y; }
double x_coord() const { return m_coord.x; }
double y_coord() const { return m_coord.y; }

void set_x_length(double x_length)
{
m_length.x = x_length;
update_cached();
}
void set_y_length(double y_length)
{
m_length.y = y_length;
update_cached();
}
void set_x_coord(double x_coord)
{
m_coord.x = x_coord;
update_cached();
}
void set_y_coord(double y_coord)
{
m_coord.y = y_coord;
update_cached();
}

/**
* @brief Calculate rectangular aperture area
* @return Area of the rectangular aperture
Expand Down
Loading
Loading