Skip to content

Commit

Permalink
reduce photon leakage for edge-immc, still leaks, need more work
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Oct 26, 2022
1 parent 4c8bdae commit f455d1e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mmclab/example/demo_immc_vessel.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function cfg=demo_immc_vessel(cfg)
function [cfg, flux]=demo_immc_vessel(cfg)
% This example shows how to run e-iMMC on a vessel network

%% load vessel data
Expand Down
17 changes: 17 additions & 0 deletions src/mmc_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,23 @@ void tracer_prep(raytracer* tracer, mcconfig* cfg) {
}
}

// build acceleration data structure to speed up first-neighbor immc edge-roi calculation
// loop over each edgeroi, count how many roi in each elem, and write to the first elem as negative integer
if (tracer->mesh->edgeroi) {
for (i = 0; i < ne; i++) {
int count = 0;

for (j = 0; j < 6; j++)
if (tracer->mesh->edgeroi[(i * 6) + j] > 0.f) {
count++;
}

if (count && fabs(tracer->mesh->edgeroi[i * 6]) < EPS) {
tracer->mesh->edgeroi[i * 6] = -count; // number -1 to -6 indicates how many faces have ROIs
}
}
}

// build acceleration data structure to speed up first-neighbor immc face-roi calculation
// loop over each faceroi, count how many roi in each elem, and write to the first elem as negative integer
if (tracer->mesh->faceroi) {
Expand Down
4 changes: 4 additions & 0 deletions src/mmc_raytrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,10 @@ float branchless_badouel_raytet(ray* r, raytracer* tracer, mcconfig* cfg, visito
int* enb, *ee = (int*)(tracer->mesh->elem + eid * tracer->mesh->elemlen);
float mus;

if (cfg->implicit == 1 && r->inroi && tracer->mesh->edgeroi && fabs(tracer->mesh->edgeroi[eid * 6]) < EPS) {
r->inroi = 0;
}

if (cfg->implicit && r->inroi) {
prop = tracer->mesh->med + tracer->mesh->prop;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/mmclab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ extern "C" int mmc_throw_exception(const int id, const char* msg, const char* fi
*/

void mmclab_usage() {
printf("Usage:\n [flux,detphoton]=mmclab(cfg);\n\nPlease run 'help mmclab' for more details.\n");
printf("MMCLAB v2022.10\nUsage:\n [flux,detphoton]=mmclab(cfg);\n\nPlease run 'help mmclab' for more details.\n");
}

/**
Expand Down

0 comments on commit f455d1e

Please sign in to comment.