aboutsummaryrefslogtreecommitdiff
path: root/src/pmt_pcath_response.dat
diff options
context:
space:
mode:
Diffstat (limited to 'src/pmt_pcath_response.dat')
0 files changed, 0 insertions, 0 deletions
57 58 59 60 61 62 63 64 65 66 67 68
#ifndef __MATERIALS_H__
#define __MATERIALS_H__

__device__ float min_wavelength;
__device__ float max_wavelength;
__device__ float wavelength_step;
__device__ unsigned int wavelength_size;

struct Material
{
	float *refractive_index;
	float *absorption_length;
	float *scattering_length;
};

struct Surface
{
	float *detect;
	float *absorb;
	float *reflect_diffuse;
	float *reflect_specular;
};

__device__ Material materials[20];
__device__ Surface surfaces[20];

__device__ float interp_property(const float &x, const float *fp)
{
	if (x < min_wavelength)
		return fp[0];

	if (x > max_wavelength)
		return fp[wavelength_size-1];

	int jl = (x-min_wavelength)/wavelength_step;

	return fp[jl] + (x-(min_wavelength + jl*wavelength_step))*(fp[jl+1]-fp[jl])/wavelength_step;
}

extern "C"
{

__global__ void set_wavelength_range(float _min_wavelength, float _max_wavelength, float _wavelength_step, unsigned int _wavelength_size)
{
	min_wavelength = _min_wavelength;
	max_wavelength = _max_wavelength;
	wavelength_step = _wavelength_step;
	wavelength_size = _wavelength_size;
}

__global__ void set_material(int material_index, float *refractive_index, float *absorption_length, float *scattering_length)
{
	materials[material_index].refractive_index = refractive_index;
	materials[material_index].absorption_length = absorption_length;
	materials[material_index].scattering_length = scattering_length;
}

__global__ void set_surface(int surface_index, float *detect, float *absorb, float *reflect_diffuse, float *reflect_specular)
{
	surfaces[surface_index].detect = detect;
	surfaces[surface_index].absorb = absorb;
	surfaces[surface_index].reflect_diffuse = reflect_diffuse;
	surfaces[surface_index].reflect_specular = reflect_specular;
}

} // extern "c"

#endif