Skip to content

Commit

Permalink
Add smoothing flux test
Browse files Browse the repository at this point in the history
  • Loading branch information
tobre1 committed Feb 13, 2025
1 parent 8586cd3 commit caf2ec7
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/viennaray/rayTrace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ template <class NumericType, int D> class Trace {
return pGlobalData_;
}

Geometry<NumericType, D> &getGeometry() { return geometry_; }

void setGlobalData(TracingData<NumericType> &data) { pGlobalData_ = &data; }

[[nodiscard]] TraceInfo getRayTraceInfo() { return RTInfo_; }
Expand Down
7 changes: 7 additions & 0 deletions tests/smoothing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project(smoothing LANGUAGES CXX)

add_executable(${PROJECT_NAME} "${PROJECT_NAME}.cpp")
target_link_libraries(${PROJECT_NAME} PRIVATE ViennaRay)

add_dependencies(ViennaRay_Tests ${PROJECT_NAME})
add_test(NAME ${PROJECT_NAME} COMMAND $<TARGET_FILE:${PROJECT_NAME}>)
54 changes: 54 additions & 0 deletions tests/smoothing/smoothing.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <rayTrace.hpp>
#include <vcTestAsserts.hpp>

using namespace viennaray;

int main() {
using NumericType = float;
constexpr int D = 3;
NumericType gridDelta = 1.0;
std::vector<std::array<NumericType, D>> points;
std::vector<std::array<NumericType, D>> normals;

points.push_back({0, 0, 0});
points.push_back({1, 0, 0});
points.push_back({2, 0, 0});

points.push_back({0, 1, 0});
points.push_back({1, 1, 0});
points.push_back({2, 1, 0});

normals.push_back({0, 0, 1});
normals.push_back({0, 0, 1});
normals.push_back({0, 0, 1});

const Vec3D<NumericType> direction = {0, 1, 0};
normals.push_back(Normalize(direction));
normals.push_back(Normalize(direction));
normals.push_back(Normalize(direction));

std::vector<NumericType> flux = {1, 1, 1, 0, 0, 0};

Trace<NumericType, D> trace;
trace.setGeometry(points, normals, gridDelta);

trace.smoothFlux(flux, 1);

auto &geo = trace.getGeometry();

for (unsigned int idx = 0; idx < 3; ++idx) {
// auto neighbors = geo.getNeighborIndicies(idx);
// std::cout << "flux[" << idx << "] = " << flux[idx] << std::endl;
// std::cout << "num neighbors: " << neighbors.size() << std::endl;
VC_TEST_ASSERT_ISCLOSE(flux[idx], 1.0, 1e-6);
}

for (unsigned int idx = 3; idx < 6; ++idx) {
// auto neighbors = geo.getNeighborIndicies(idx);
// std::cout << "flux[" << idx << "] = " << flux[idx] << std::endl;
// std::cout << "num neighbors: " << neighbors.size() << std::endl;
VC_TEST_ASSERT_ISCLOSE(flux[idx], 0.0, 1e-6);
}

return 0;
}

0 comments on commit caf2ec7

Please sign in to comment.