Skip to content

Commit 8872c30

Browse files
committed
debug test reflection
1 parent 2558274 commit 8872c30

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

pytissueoptics/rayscattering/opencl/src/propagation.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ void roulette(float weightThreshold, __global Photon *photons, __global uint *se
6464
}
6565

6666
void reflect(FresnelIntersection *fresnelIntersection, __global Photon *photons, uint photonID){
67+
printf("Initial direction: %f, %f, %f\n", photons[photonID].direction.x, photons[photonID].direction.y, photons[photonID].direction.z);
6768
rotateAround(&photons[photonID].direction, &fresnelIntersection->incidencePlane, fresnelIntersection->angleDeflection);
69+
printf("Reflected direction: %f, %f, %f\n", photons[photonID].direction.x, photons[photonID].direction.y, photons[photonID].direction.z);
6870
}
6971

7072
void refract(FresnelIntersection *fresnelIntersection, __global Photon *photons, uint photonID){
@@ -104,6 +106,11 @@ float reflectOrRefract(Intersection *intersection, __global Photon *photons, __c
104106
FresnelIntersection fresnelIntersection = computeFresnelIntersection(photons[photonID].direction, intersection,
105107
materials, surfaces, seeds, gid);
106108

109+
printf("FresnelIntersection.angleDeflection: %f\n", fresnelIntersection.angleDeflection);
110+
printf("FresnelIntersection.isReflected: %d\n", fresnelIntersection.isReflected);
111+
printf("FresnelIntersection.nextMaterialID: %d\n", fresnelIntersection.nextMaterialID);
112+
printf("Intersection.isSmooth: %d\n", intersection->isSmooth);
113+
107114
if (fresnelIntersection.isReflected) {
108115
if (intersection->isSmooth) {
109116
// Prevent reflection from crossing the raw surface.

pytissueoptics/rayscattering/opencl/src/vectorOperators.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ void rotateAroundAxisGlobal(__global float3 *mainVector, __global float3 *axisVe
4343
}
4444

4545
void rotateAround(__global float3 *mainVector, float3 *axisVector, float theta){
46+
printf("rotateAround: %f, %f, %f\n", axisVector->x, axisVector->y, axisVector->z);
47+
printf("rotateAround mainVector: %f, %f, %f\n", mainVector->x, mainVector->y, mainVector->z);
48+
printf("rotateAround theta: %f\n", theta);
4649
// normalizeVectorLocal(axisVector);
4750
float sint = sin(theta);
4851
float cost = cos(theta);

pytissueoptics/rayscattering/tests/opencl/src/testCLPhoton.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ def setUp(self):
4747
sourcePath = os.path.join(OPENCL_SOURCE_DIR, "propagation.c")
4848
self.program = CLProgram(sourcePath)
4949

50-
def tearDown(self):
51-
self.program.release()
52-
5350
def testWhenMoveBy_shouldMovePhotonByTheGivenDistanceTowardsItsDirection(self):
5451
photonResult = self._photonFunc("moveBy", 10)
5552
self.assertEqual(self.INITIAL_POSITION + self.INITIAL_DIRECTION * 10, photonResult.position)
@@ -420,6 +417,7 @@ def _photonFunc(self, funcName: str, *args) -> PhotonResult:
420417
materialID=0, solidID=self.INITIAL_SOLID_ID, weight=self.INITIAL_WEIGHT)
421418
npArgs = [np.float32(arg) if isinstance(arg, (float, int)) else arg for arg in args]
422419
npArgs = [cl.cltypes.make_float3(*arg.array) if isinstance(arg, Vector) else arg for arg in npArgs]
420+
print("npArgs:", npArgs)
423421
self.program.launchKernel(kernelName=funcName + "Kernel", N=1,
424422
arguments=npArgs + [photonBuffer, np.int32(0)])
425423
photonResult = self._getPhotonResult(photonBuffer)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ setenv =
88
PTO_N_WORK_UNITS = 128
99
PTO_MAX_MEMORY_MB = 1024
1010
commands =
11-
python -m unittest pytissueoptics/rayscattering/tests/opencl/src/testCLPhoton.py -v
11+
python -m unittest -v pytissueoptics/rayscattering/tests/opencl/src/testCLPhoton.py -k testWhenReflectOrRefractWithReflectingIntersection_shouldReflectPhoton

0 commit comments

Comments
 (0)