Skip to content

Commit

Permalink
fix voidtime flag, fix mesh entry and exit with retessellated meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Oct 19, 2015
1 parent ccdeb40 commit 29e2816
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion mmc/trunk/mmclab/example/demo_compare_mmc_mcx.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand All @@ -73,6 +73,7 @@
cfg.elemprop=cfg.elem(:,5);
cfg.elem=cfg.elem(:,1:4);
end
cfg=mmclab(cfg,'prep');

%%-----------------------------------------------------------------
%% run mmclab
Expand Down
5 changes: 4 additions & 1 deletion mmc/trunk/mmclab/mmclab.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions mmc/trunk/src/mmclab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
16 changes: 9 additions & 7 deletions mmc/trunk/src/tettracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 29e2816

Please sign in to comment.