Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to ViennaRay 2.1.0 #76

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(
ViennaPS
LANGUAGES CXX
VERSION 2.0.1)
VERSION 2.0.2)

# --------------------------------------------------------------------------------------------------------
# Library switches
Expand Down Expand Up @@ -84,7 +84,7 @@ CPMAddPackage(

CPMFindPackage(
NAME ViennaRay
VERSION 2.0.4
VERSION 2.1.0
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaRay"
EXCLUDE_FROM_ALL ${VIENNAPS_BUILD_PYTHON})

Expand Down
2 changes: 1 addition & 1 deletion include/viennaps/cellSet/csMeanFreePath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ template <class NumericType, int D> class csMeanFreePath {
ray.time = 0.0f;
#endif

ray.tfar = std::numeric_limits<rtcNumericType>::max();
ray.tfar = std::numeric_limits<rayInternal::rtcNumericType>::max();
rayHit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
rayHit.hit.geomID = RTC_INVALID_GEOMETRY_ID;

Expand Down
6 changes: 3 additions & 3 deletions include/viennaps/cellSet/csPointSource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <raySource.hpp>

template <typename NumericType, int D>
class csPointSource : public raySource<NumericType, D> {
class csPointSource : public raySource<csPointSource<NumericType, D>> {
const unsigned mNumPoints;
const csTriple<NumericType> origin;
const csTriple<NumericType> direction;
Expand All @@ -17,7 +17,7 @@ class csPointSource : public raySource<NumericType, D> {
: origin(passedOrigin), direction(passedDirection),
mNumPoints(pNumPoints) {}

void fillRay(RTCRay &ray, const size_t idx, rayRNG &RngState) override final {
void fillRay(RTCRay &ray, const size_t idx, rayRNG &RngState) const {
#ifdef ARCH_X86
reinterpret_cast<__m128 &>(ray) =
_mm_set_ps(1e-4f, (float)origin[2], (float)origin[1], (float)origin[0]);
Expand All @@ -37,5 +37,5 @@ class csPointSource : public raySource<NumericType, D> {
#endif
}

size_t getNumPoints() const override final { return mNumPoints; }
size_t getNumPoints() const { return mNumPoints; }
};
16 changes: 8 additions & 8 deletions include/viennaps/cellSet/csTracing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ template <class T, int D> class csTracing {
csPointSource<T, D>(pointSourceOrigin, pointSourceDirection,
traceSettings, mGeometry.getNumPoints());

csTracingKernel<T, D>(mDevice, mGeometry, boundary, raySource, mParticle,
mNumberOfRaysPerPoint, mNumberOfRaysFixed,
mUseRandomSeeds, mRunNumber++, cellSet,
excludeMaterialId - 1)
csTracingKernel(mDevice, mGeometry, boundary, raySource, mParticle,
mNumberOfRaysPerPoint, mNumberOfRaysFixed,
mUseRandomSeeds, mRunNumber++, cellSet,
excludeMaterialId - 1)
.apply();
} else {
auto raySource = raySourceRandom<T, D>(
boundingBox, mParticle->getSourceDistributionPower(), traceSettings,
mGeometry.getNumPoints(), usePrimaryDirection, orthoBasis);

csTracingKernel<T, D>(mDevice, mGeometry, boundary, raySource, mParticle,
mNumberOfRaysPerPoint, mNumberOfRaysFixed,
mUseRandomSeeds, mRunNumber++, cellSet,
excludeMaterialId - 1)
csTracingKernel(mDevice, mGeometry, boundary, raySource, mParticle,
mNumberOfRaysPerPoint, mNumberOfRaysFixed,
mUseRandomSeeds, mRunNumber++, cellSet,
excludeMaterialId - 1)
.apply();
}

Expand Down
36 changes: 22 additions & 14 deletions include/viennaps/cellSet/csTracingKernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
#include <raySource.hpp>
#include <rayUtil.hpp>

template <typename T, int D> class csTracingKernel {
template <typename SourceType, typename T, int D> class csTracingKernel {
public:
csTracingKernel(RTCDevice &pDevice, rayGeometry<T, D> &pRTCGeometry,
rayBoundary<T, D> &pRTCBoundary, raySource<T, D> &pSource,
rayBoundary<T, D> &pRTCBoundary,
raySource<SourceType> &pSource,
std::unique_ptr<csAbstractParticle<T>> &pParticle,
const size_t pNumOfRayPerPoint, const size_t pNumOfRayFixed,
const bool pUseRandomSeed, const size_t pRunNumber,
Expand Down Expand Up @@ -94,7 +95,8 @@ template <typename T, int D> class csTracingKernel {
bool reflect = false;
bool hitFromBack = false;
do {
rayHit.ray.tfar = std::numeric_limits<rtcNumericType>::max();
rayHit.ray.tfar =
std::numeric_limits<rayInternal::rtcNumericType>::max();
rayHit.hit.instID[0] = RTC_INVALID_GEOMETRY_ID;
rayHit.hit.geomID = RTC_INVALID_GEOMETRY_ID;

Expand All @@ -119,9 +121,12 @@ template <typename T, int D> class csTracingKernel {

// Calculate point of impact
const auto &ray = rayHit.ray;
const rtcNumericType xx = ray.org_x + ray.dir_x * ray.tfar;
const rtcNumericType yy = ray.org_y + ray.dir_y * ray.tfar;
const rtcNumericType zz = ray.org_z + ray.dir_z * ray.tfar;
const rayInternal::rtcNumericType xx =
ray.org_x + ray.dir_x * ray.tfar;
const rayInternal::rtcNumericType yy =
ray.org_y + ray.dir_y * ray.tfar;
const rayInternal::rtcNumericType zz =
ray.org_z + ray.dir_z * ray.tfar;

/* -------- Hit from back -------- */
const auto rayDir = rayTriple<T>{ray.dir_x, ray.dir_y, ray.dir_z};
Expand Down Expand Up @@ -205,19 +210,22 @@ template <typename T, int D> class csTracingKernel {
#ifdef ARCH_X86
reinterpret_cast<__m128 &>(rayHit.ray) =
_mm_set_ps(1e-4f, zz, yy, xx);
reinterpret_cast<__m128 &>(rayHit.ray.dir_x) =
_mm_set_ps(0.0f, (rtcNumericType)fillnDirection.second[2],
(rtcNumericType)fillnDirection.second[1],
(rtcNumericType)fillnDirection.second[0]);
reinterpret_cast<__m128 &>(rayHit.ray.dir_x) = _mm_set_ps(
0.0f, (rayInternal::rtcNumericType)fillnDirection.second[2],
(rayInternal::rtcNumericType)fillnDirection.second[1],
(rayInternal::rtcNumericType)fillnDirection.second[0]);
#else
rayHit.ray.org_x = xx;
rayHit.ray.org_y = yy;
rayHit.ray.org_z = zz;
rayHit.ray.tnear = 1e-4f;

rayHit.ray.dir_x = (rtcNumericType)fillnDirection.second[0];
rayHit.ray.dir_y = (rtcNumericType)fillnDirection.second[1];
rayHit.ray.dir_z = (rtcNumericType)fillnDirection.second[2];
rayHit.ray.dir_x =
(rayInternal::rtcNumericType)fillnDirection.second[0];
rayHit.ray.dir_y =
(rayInternal::rtcNumericType)fillnDirection.second[1];
rayHit.ray.dir_z =
(rayInternal::rtcNumericType)fillnDirection.second[2];
rayHit.ray.time = 0.0f;
#endif
} while (reflect);
Expand Down Expand Up @@ -278,7 +286,7 @@ template <typename T, int D> class csTracingKernel {
RTCDevice &mDevice;
rayGeometry<T, D> &mGeometry;
rayBoundary<T, D> &mBoundary;
raySource<T, D> &mSource;
raySource<SourceType> &mSource;
std::unique_ptr<csAbstractParticle<T>> const mParticle = nullptr;
const long long mNumRays;
const bool mUseRandomSeeds;
Expand Down
2 changes: 1 addition & 1 deletion include/viennaps/geometries/psMakeHole.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ template <class NumericType, int D> class psMakeHole {

NumericType topRadius = holeRadius;
if (taperAngle) {
topRadius += std::tan(taperAngle * rayInternal::PI / 180.) * holeDepth;
topRadius += std::tan(taperAngle * M_PI / 180.) * holeDepth;
}

lsMakeGeometry<NumericType, D>(
Expand Down
2 changes: 1 addition & 1 deletion include/viennaps/geometries/psMakeTrench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ template <class NumericType, int D> class psMakeTrench {
if (taperingAngle) {
auto mesh = psSmartPointer<lsMesh<NumericType>>::New();
const NumericType offset =
std::tan(taperingAngle * rayInternal::PI / 180.) * trenchDepth;
std::tan(taperingAngle * M_PI / 180.) * trenchDepth;
if constexpr (D == 2) {
for (int i = 0; i < 4; i++) {
std::array<NumericType, 3> node = {0., 0., 0.};
Expand Down
10 changes: 4 additions & 6 deletions include/viennaps/models/psPlasmaDamage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class DamageIon : public csParticle<DamageIon<T, D>, T> {
do {
const auto rand1 = uniDist(RNG);
const auto rand2 = uniDist(RNG);
E = std::cos(rayInternal::PI * 2 * rand1) *
std::sqrt(-2. * std::log(rand2)) * deltaIonEnergy +
E = std::cos(M_PI * 2 * rand1) * std::sqrt(-2. * std::log(rand2)) *
deltaIonEnergy +
meanIonEnergy;
} while (E < minEnergy);
}
Expand All @@ -39,8 +39,7 @@ class DamageIon : public csParticle<DamageIon<T, D>, T> {
if (incAngle >= inflectAngle) {
Eref_peak =
Eref_max *
(1 - (1 - A) * std::pow((rayInternal::PI / 2. - incAngle) /
(rayInternal::PI / 2. - inflectAngle),
(1 - (1 - A) * std::pow((M_PI_2 - incAngle) / (M_PI_2 - inflectAngle),
n_r));
} else {
Eref_peak = Eref_max * A * std::pow(incAngle / inflectAngle, n_l);
Expand Down Expand Up @@ -165,8 +164,7 @@ class DamageIon : public csParticle<DamageIon<T, D>, T> {
static constexpr T n_l = 10.;
static constexpr T n_r = 1.;

static constexpr T A =
1. / (1. + (n_l / n_r) * (rayInternal::PI / (2 * inflectAngle) - 1.));
static constexpr T A = 1. / (1. + (n_l / n_r) * (M_PI_2 / inflectAngle - 1.));

T E;

Expand Down
2 changes: 1 addition & 1 deletion include/viennaps/psGDSGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,6 @@ template <class NumericType, int D = 3> class psGDSGeometry {
}

static inline NumericType deg2rad(const NumericType angleDeg) {
return angleDeg * rayInternal::PI / 180.;
return angleDeg * M_PI / 180.;
}
};
1 change: 0 additions & 1 deletion python/pyWrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
#include <psUtils.hpp>
#include <rayParticle.hpp>
#include <rayReflection.hpp>
#include <rayTraceDirection.hpp>
#include <rayUtil.hpp>

// always use double for python export
Expand Down
Loading