From 29e2816249cc7902ef7ffc5c5d87eb1206ef9b49 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Mon, 19 Oct 2015 16:49:30 -0400 Subject: [PATCH] fix voidtime flag, fix mesh entry and exit with retessellated meshes --- mmc/trunk/mmclab/example/demo_compare_mmc_mcx.m | 3 ++- mmc/trunk/mmclab/mmclab.m | 5 ++++- mmc/trunk/src/mmclab.cpp | 2 ++ mmc/trunk/src/tettracing.c | 16 +++++++++------- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/mmc/trunk/mmclab/example/demo_compare_mmc_mcx.m b/mmc/trunk/mmclab/example/demo_compare_mmc_mcx.m index f21031b8..8dc6442e 100644 --- a/mmc/trunk/mmclab/example/demo_compare_mmc_mcx.m +++ b/mmc/trunk/mmclab/example/demo_compare_mmc_mcx.m @@ -57,7 +57,7 @@ if(planarsrc) % when planar src is used, re-tessellate the mesh cfg.srctype='planar'; - cfg.srcpos=[10 10 -1]; + cfg.srcpos=[10 10 -10]; cfg.srcparam1=[40 0 0 0]; cfg.srcparam2=[0 40 0 0]; @@ -73,6 +73,7 @@ cfg.elemprop=cfg.elem(:,5); cfg.elem=cfg.elem(:,1:4); end +cfg=mmclab(cfg,'prep'); %%----------------------------------------------------------------- %% run mmclab diff --git a/mmc/trunk/mmclab/mmclab.m b/mmc/trunk/mmclab/mmclab.m index 1fcbc46e..681a1376 100644 --- a/mmc/trunk/mmclab/mmclab.m +++ b/mmc/trunk/mmclab/mmclab.m @@ -164,7 +164,10 @@ if(~isfield(cfg(i),'elemprop') ||isempty(cfg(i).elemprop) && size(cfg(i).elem,2)>4) cfg(i).elemprop=cfg(i).elem(:,5); end - cfg(i).elem=meshreorient(cfg(i).node,cfg(i).elem(:,1:4)); + if(~isfield(cfg(i),'isreoriented') || cfg(i).isreoriented==0) + cfg(i).elem=meshreorient(cfg(i).node,cfg(i).elem(:,1:4)); + cfg(i).isreoriented=1; + end if(~isfield(cfg(i),'facenb') || isempty(cfg(i).facenb)) cfg(i).facenb=faceneighbors(cfg(i).elem); end diff --git a/mmc/trunk/src/mmclab.cpp b/mmc/trunk/src/mmclab.cpp index e93096d9..786d06a7 100644 --- a/mmc/trunk/src/mmclab.cpp +++ b/mmc/trunk/src/mmclab.cpp @@ -483,6 +483,8 @@ void mmc_set_field(const mxArray *root,const mxArray *item,int idx, mcconfig *cf cfg->nphoton=arraydim[1]; printf("mmc.nphoton=%d;\n",cfg->nphoton); } + }else if(strcmp(name,"isreoriented")==0){ + /*internal flag, don't need to do anything*/ }else{ printf("WARNING: redundant field '%s'\n",name); } diff --git a/mmc/trunk/src/tettracing.c b/mmc/trunk/src/tettracing.c index bab1b584..bc4f4ea7 100644 --- a/mmc/trunk/src/tettracing.c +++ b/mmc/trunk/src/tettracing.c @@ -779,16 +779,18 @@ float onephoton(unsigned int id,raytracer *tracer,tetmesh *mesh,mcconfig *cfg, } if(r.eid==0) break; /*when a photon enters the domain from the background*/ - if((cfg->debuglevel&dlExit) && mesh->med[mesh->type[oldeid-1]].n == cfg->nout && mesh->med[mesh->type[r.eid-1]].n != cfg->nout ){ + if(mesh->type[oldeid-1]==0 && mesh->type[r.eid-1]){ + if(cfg->debuglevel&dlExit) fprintf(cfg->flog,"e %f %f %f %f %f %f %f %d\n",r.p0.x,r.p0.y,r.p0.z, r.vec.x,r.vec.y,r.vec.z,r.weight,r.eid); - if(!cfg->voidtime) - r.photontimer=0.f; - } + if(!cfg->voidtime) + r.photontimer=0.f; + } /*when a photon exits the domain into the background*/ - if((cfg->debuglevel&dlExit) && mesh->med[mesh->type[oldeid-1]].n != cfg->nout && mesh->med[mesh->type[r.eid-1]].n == cfg->nout ){ - fprintf(cfg->flog,"x %f %f %f %f %f %f %f %d\n",r.p0.x,r.p0.y,r.p0.z, - r.vec.x,r.vec.y,r.vec.z,r.weight,r.eid); + if(mesh->type[oldeid-1] && mesh->type[r.eid-1]==0){ + if(cfg->debuglevel&dlExit) + fprintf(cfg->flog,"x %f %f %f %f %f %f %f %d\n",r.p0.x,r.p0.y,r.p0.z, + r.vec.x,r.vec.y,r.vec.z,r.weight,r.eid); if(!cfg->isextdet){ r.eid=0; break;