Definition of the core ray-tracing functions. More...
Go to the source code of this file.
Classes | |
struct | MMC_ray |
Data structure associated with the current photon/ray. More... | |
struct | MMC_visitor |
A structure that accumulates the statistics about the simulation. More... | |
Macros | |
#define | MAX_TRIAL 3 |
#define | FIX_PHOTON 1e-3f |
Typedefs | |
typedef struct MMC_ray | ray |
typedef struct MMC_visitor | visitor |
Functions | |
void | interppos (float3 *w, float3 *p1, float3 *p2, float3 *p3, float3 *pout) |
function to linearly interpolate between 3 3D points (p1,p2,p3) using weight (w) More... | |
void | getinterp (float w1, float w2, float w3, float3 *p1, float3 *p2, float3 *p3, float3 *pout) |
function to linearly interpolate between 3 3D points (p1,p2,p3) using scalar weight (w) More... | |
void | fixphoton (float3 *p, float3 *nodes, int *ee) |
Function to deal with ray-edge/ray-vertex intersections. More... | |
void | onephoton (size_t id, raytracer *tracer, tetmesh *mesh, mcconfig *cfg, RandType *ran, RandType *ran0, visitor *visit) |
The core Monte Carlo function simulating a single photon (!!!Important!!!) More... | |
void | launchphoton (mcconfig *cfg, ray *r, tetmesh *mesh, RandType *ran, RandType *ran0) |
Launch a new photon. More... | |
float | reflectray (mcconfig *cfg, float3 *c0, raytracer *tracer, int *oldeid, int *eid, int faceid, RandType *ran, int inroi) |
Calculate the reflection/transmission of a ray at an interface. More... | |
float | reflectrayroi (mcconfig *cfg, float3 *c0, float3 *ph, raytracer *tracer, int *eid, int *inroi, RandType *ran, int roitype, int roiidx, int refeid) |
Calculate the reflection/transmission of a ray at the ROI surface. More... | |
void | save_scatter_events (ray *r, tetmesh *mesh, mcconfig *cfg, visitor *visit) |
void | albedoweight (ray *r, tetmesh *mesh, mcconfig *cfg, visitor *visit) |
Deal with absorption using MCML-like algorithm (albedo-weight MC) More... | |
void | visitor_init (mcconfig *cfg, visitor *visit) |
void | visitor_clear (visitor *visit) |
void | updateroi (int immctype, ray *r, tetmesh *mesh) |
void | traceroi (ray *r, raytracer *tracer, int roitype, int doinit) |
void | compute_distances_to_edge (ray *r, raytracer *tracer, int *ee, int edgeid, float d2d[2], float3 p2d[2], int *hitstatus) |
void | compute_distances_to_node (ray *r, raytracer *tracer, int *ee, int index, float nr, float3 **center, int *hitstatus) |
float | ray_cylinder_intersect (ray *r, int index, float d2d[2], float3 p2d[2], int hitstatus) |
float | ray_sphere_intersect (ray *r, int index, float3 *center, float nr, int hitstatus) |
float | ray_face_intersect (ray *r, raytracer *tracer, int *ee, int index, int baseid, int eid, int *hitstatus) |
Definition of the core ray-tracing functions.
#define FIX_PHOTON 1e-3f |
offset to the ray to avoid edge/vertex
#define MAX_TRIAL 3 |
number of fixes when a photon hits an edge/vertex
Deal with absorption using MCML-like algorithm (albedo-weight MC)
This function performs MCML-like absorption calculations
[in,out] | r | the current ray |
[in] | mesh | the mesh data structure |
[in,out] | cfg | simulation configuration structure |
[out] | visit | statistics counters of this thread |
Function to deal with ray-edge/ray-vertex intersections.
when a photon is crossing a vertex or edge, (slightly) pull the photon toward the center of the element and try again
[in,out] | p | current photon position |
[in] | nodes | pointer to the 4 nodes of the tet |
[in] | ee | indices of the 4 nodes ee=elem[eid] |
|
inline |
function to linearly interpolate between 3 3D points (p1,p2,p3) using scalar weight (w)
pout=p1*w1+p2*w2+p3*w3
[in] | w1 | weight for p1 |
[in] | w2 | weight for p2 |
[in] | w3 | weight for p3 |
[in] | p1 | 1st point |
[in] | p2 | 2nd point |
[in] | p3 | 3rd point |
[out] | pout | output 3D position |
function to linearly interpolate between 3 3D points (p1,p2,p3) using weight (w)
pout=p1*w1+p2*w2+p3*w3
[in] | w | weight vector |
[in] | p1 | 1st point |
[in] | p2 | 2nd point |
[in] | p3 | 3rd point |
[out] | pout | output 3D position |
Launch a new photon.
This function launch a new photon using one of the dozen supported source forms.
[in,out] | cfg | simulation configuration structure |
[in,out] | r | the current ray |
[in] | mesh | the mesh data structure |
[in,out] | ran | the random number generator states |
[in,out] | ran0 | the additional random number generator states |
void onephoton | ( | size_t | id, |
raytracer * | tracer, | ||
tetmesh * | mesh, | ||
mcconfig * | cfg, | ||
RandType * | ran, | ||
RandType * | ran0, | ||
visitor * | visit | ||
) |
The core Monte Carlo function simulating a single photon (!!!Important!!!)
This is the core Monte Carlo simulation function. It simulates the life-time of a single photon packet, from launching to termination.
[in] | id | the linear index of the current photon, starting from 0. |
[in] | tracer | the ray-tracer aux data structure |
[in] | mesh | the mesh data structure |
[in,out] | ran | the random number generator states |
[in,out] | ran0 | the additional random number generator states |
[in,out] | cfg | simulation configuration structure |
[out] | visit | statistics counters of this thread |
float reflectray | ( | mcconfig * | cfg, |
float3 * | c0, | ||
raytracer * | tracer, | ||
int * | oldeid, | ||
int * | eid, | ||
int | faceid, | ||
RandType * | ran, | ||
int | inroi | ||
) |
Calculate the reflection/transmission of a ray at an interface.
This function handles the reflection and transmission events at an interface where the refractive indices mismatch.
[in,out] | cfg | simulation configuration structure |
[in] | c0 | the current direction vector of the ray |
[in] | tracer | the ray-tracer aux data structure |
[in] | oldeid | the index of the element the photon moves away from |
[in] | eid | the index of the element the photon about to move into |
[in] | faceid | index of the face through which the photon reflects/transmits |
[in,out] | ran | the random number generator states |
float reflectrayroi | ( | mcconfig * | cfg, |
float3 * | c0, | ||
float3 * | ph, | ||
raytracer * | tracer, | ||
int * | eid, | ||
int * | inroi, | ||
RandType * | ran, | ||
int | roitype, | ||
int | roiidx, | ||
int | refeid | ||
) |
Calculate the reflection/transmission of a ray at the ROI surface.
This function handles the reflection and transmission events at the roi surface wall where the refractive indices mismatch.
[in] | c0 | the current direction vector of the ray |
[in] | u | the current direction vector of the edge |
[in] | ph | hitting position at the edgeroi |
[in] | E0 | any point on the edge |
[in] | tracer | the ray-tracer aux data structure |
[in] | eid | the index of the CURRENT element |
[in,out] | ran | the random number generator states |