Core unit for mash-based photon transport using ray tracing algorithms. More...
Macros | |
#define | F32N(a) ((a) & 0x80000000) |
#define | F32P(a) ((a) ^ 0x80000000) |
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... | |
float | plucker_raytet (ray *r, raytracer *tracer, mcconfig *cfg, visitor *visit) |
Plucker-coordinate based ray-tracer to advance photon by one step. More... | |
float | havel_raytet (ray *r, raytracer *tracer, mcconfig *cfg, visitor *visit) |
float | badouel_raytet (ray *r, raytracer *tracer, mcconfig *cfg, visitor *visit) |
float | branchless_badouel_raytet (ray *r, raytracer *tracer, mcconfig *cfg, visitor *visit) |
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... | |
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... | |
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... | |
void | launchphoton (mcconfig *cfg, ray *r, tetmesh *mesh, RandType *ran, RandType *ran0) |
Launch a new photon. More... | |
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) |
Variables | |
const int | e2n [6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}} |
const int | fc [4][3] = {{0, 4, 2}, {3, 5, 4}, {2, 5, 1}, {1, 3, 0}} |
Tetrahedron face edge indices. More... | |
const int | nc [4][3] = {{3, 0, 1}, {3, 1, 2}, {2, 0, 3}, {1, 0, 2}} |
Tetrahedron faces, in clock-wise orders, represented using local node indices. More... | |
const int | out [4][3] |
Tetrahedron faces, in counter-clock-wise orders, represented using local node indices. More... | |
const int | facemap [4] |
The local index of the node with an opposite face to the i-th face defined in nc[][]. More... | |
const int | ifacemap [4] |
Inverse mapping between the local index of the node and the corresponding opposite face in nc[]'s order. More... | |
const int | faceorder [5] |
Index mapping from the i-th face-neighbors (facenb) to the face defined in nc[][]. More... | |
const int | ifaceorder [4] |
Index mapping from the i-th face defined in nc[][] to the face-neighbor (facenb) face orders. More... | |
const char | maskmap [16] = {4, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3} |
A mapping from SSE4 mask output to the face index. | |
Core unit for mash-based photon transport using ray tracing algorithms.
#define F32N | ( | a | ) | ((a) & 0x80000000) |
< Macro to enable SSE4 based ray-tracers Macro to test if a floating point is negative
#define F32P | ( | a | ) | ((a) ^ 0x80000000) |
Macro to test if a floating point is positive
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 |
Havel, Badouel and Branch-less Badouel-based SSE4 ray-tracer require to compile with SSE4 only. Give an error if not compiled with SSE.
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 |
Plucker-coordinate based ray-tracer to advance photon by one step.
this function uses Plucker-coordinate based ray-triangle intersection tests to advance photon by one step, see Fang2010.
[in,out] | r | the current ray |
[in] | tracer | the ray-tracer aux data structure |
[in] | 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 |
const int e2n[6][2] = {{0, 1}, {0, 2}, {0, 3}, {1, 2}, {1, 3}, {2, 3}} |
from edge index to node index
const int facemap[4] |
The local index of the node with an opposite face to the i-th face defined in nc[][].
nc[i] <-> node[facemap[i]] the 1st face of this tet, i.e. nc[0]={3,0,1}, is opposite to the 3rd node the 2nd face of this tet, i.e. nc[1]={3,1,2}, is opposite to the 1st node etc.
const int faceorder[5] |
Index mapping from the i-th face-neighbors (facenb) to the face defined in nc[][].
facenb[i] <-> nc[faceorder[i]] the 1st tet neighbor shares the 2nd face of this tet, i.e. nc[1]={3,1,2} the 2nd tet neighbor shares the 4th face of this tet, i.e. nc[3]={1,0,2} etc.
const int fc[4][3] = {{0, 4, 2}, {3, 5, 4}, {2, 5, 1}, {1, 3, 0}} |
Tetrahedron face edge indices.
fc[4] points to the 4 facets of a tetrahedron, with each triangular face made of 3 directed edges. The numbers [0-5] are the local indices of the edge, defined by 0:[0->1], 1:[0->2], 2: [0->3], 3:[1->2], 4:[1->3], 5:[2->3] where the pair in [] are the local nodes forming the edge
const int ifacemap[4] |
Inverse mapping between the local index of the node and the corresponding opposite face in nc[]'s order.
nc[ifacemap[i]] <-> node[i] the 1st node of this tet is in opposite to the 2nd face, i.e. nc[1]={3,1,2} the 2nd node of this tet is in opposite to the 3rd face, i.e. nc[1]={2,0,3} etc.
const int ifaceorder[4] |
Index mapping from the i-th face defined in nc[][] to the face-neighbor (facenb) face orders.
nc[ifaceorder[i]] <-> facenb[i] nc[0], made of nodes {3,0,1}, is the face connecting to the 4th neighbor (facenb[3]), nc[1], made of nodes {3,1,2}, is the face connecting to the 1st neighbor (facenb[0]), etc.
const int nc[4][3] = {{3, 0, 1}, {3, 1, 2}, {2, 0, 3}, {1, 0, 2}} |
Tetrahedron faces, in clock-wise orders, represented using local node indices.
node-connectivity, i.e. nc[4] points to the 4 facets of a tetrahedron, with each triangular face made of 3 nodes. The numbers [0-4] are the local node indices (starting from 0). The order of the nodes are in clock-wise orders.
const int out[4][3] |
Tetrahedron faces, in counter-clock-wise orders, represented using local node indices.
out is like nc[] but with counter-clock-wise orientation. this makes the normal vec of each face pointing outwards.defined in mmc_mesh.c, node orders for each face, in counter-clock-wise orders
node-connectivity, i.e. nc[4] points to the 4 facets of a tetrahedron, with each triangular face made of 3 nodes. The numbers [0-4] are the local node indices (starting from 0). The order of the nodes are in counter-clock-wise orders.